1百万用户..我无法扩展! [英] 1 Million users.. I can't Scale!!

查看:44
本文介绍了1百万用户..我无法扩展!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我的情况如下:


1)我开发了一项为移动服务生成内容的服务。

2)内容通过短信网关发送(目前我们只发送

短信)。

3)我有一个百万用户(和攀登)。

4)用户需要在生成
后至少5秒钟获取数据。 (不考虑我的代码外部的任何瓶颈)。

5)生成内容需要1秒。


我正在考虑转移到无堆栈的python所以我可以利用

延续,这样我就可以打开大量的连接到

网关并同时将消息输出给每个用户。(我是m

考虑每个用户1个连接)。


因此我的问题是:

1)我应该切换到无堆栈的python或者我应该通过mutlithreading应用程序进行实验



2)你能给我什么样的建筑建议?

3)有没有人遇到过以前这样的情况?你是怎么处理的?

呢?

4)最后,也许最有争议的是:python是正确的语言

为此?我真的不想切换到Lisp,Icon或Erlang。


我真的需要帮助,因为我的应用程序目前无法扩展。一些

用户最终会在30秒后获得他们的数据(最佳情况)

以及内容生成后最多5分钟。这只是

不可接受。如果我的

创业公司要在市场上生存,那么订户应该得到更好的服务。

Hi guys,
My situation is as follows:

1)I''ve developed a service that generates content for a mobile service.
2)The content is sent through an SMS gateway (currently we only send
text messages).
3)I''ve got a million users (and climbing).
4)The users need to get the data a minimum of 5 seconds after it''s
generated. (not considering any bottlenecks external to my code).
5)Generating the content takes 1 second.

I''m considering moving to stackless python so that I can make use of
continuations so that I can open a massive number of connections to the
gateway and pump the messages out to each user simultaneously.(I''m
thinking of 1 connection per user).

My questions therefore are:
1)Should I switch to stackless python or should I carry out experiments
with mutlithreading the application?
2)What architectural suggestions can you give me?
3)Has anyone encountered such a situation before? How did you deal with
it?
4)Lastly, and probably most controversial: Is python the right language
for this? I really don''t want to switch to Lisp, Icon or Erlang as yet.

I really need help because my application currently can''t scale. Some
user''s end up getting their data 30 seconds after generation(best case)
and up to 5 minutes after content generation. This is simply
unacceptable. The subscribers deserve much better service if my
startup is to survive in the market.

推荐答案

如果你有那么多用户,我不知道Python是否真的适合这么大规模的应用程序。也许它更适合用b / b
以编译语言执行CPU密集型任务,这样你就可以最大化
proformance,然后可能使用UNIX风格的套接字来如果需要,发送/执行

指令到Python界面。

对不起,我真的没什么帮助

-Wes

If you have that many users, I don''t know if Python really is suited
well for such a large scale application. Perhaps it''d be better suited
to do CPU intensive tasks it in a compiled language so you can max out
proformance and then possibly use a UNIX-style socket to send/execute
instructions to the Python interface, if necessary.
Sorry I really couldn''t be of much help
-Wes


我想我会独立查看系统的每个部分以确保

我找到真实的瓶颈。 (它可能是Python,也可能不是)。


在你当前的系统下,你的python程序是否仍然试图在5秒后发送

消息? 30秒,300秒? (或者已经将

消息发送到SMS并且他们正在排队等候?)


如果你的python程序仍在流出消息什么是花时间?
花时间?在总体水平上,您的机器是否受CPU限制?如果

在生成内容后你在程序中的每一步都超时,

一直在哪里(消息组装,通过
$ b发送) $ b网络,等待回复)?


只需通过一些背后的计算,每个100万字节的100万条消息100MB。这是一堆数据在2-3秒内推送到网络上,特别是在小块中。 (这是可能的,但是我会看到这个。)bb网关可以处理那种流量

(传入和传出)?


多线程可能会有所帮助,如果你的python程序花费了所有的时间等待网络(很可能)。如果你受CPU限制并且没有在网络上等待,那么多线程可能就不是答案。

I guess I''d look at each part of the system independently to be sure
I''m finding the real bottleneck. (It may be Python, it may not).

Under your current system, is your python program still trying to send
messages after 5 seconds? 30 seconds, 300 seconds? (Or have the
messages been delivered to SMS and they''re waiting in queue there?)

If your python program is still streaming out the messages, what is it
spending time on? At a gross level, is your machine CPU-bound? If
you time out each step in your program after the content is generated,
where is all the time going (message assembly, sending over the
network, waiting for a response)?

Just by some back-of-the-envelope calculations, 1 million messages at
100 bytes each is 100Mb. That''s a bunch of data to push over a network
in 2-3 seconds, especially in small chunks. (It''s possible, but I''d
look at that.) Can the SMS gateway handle that kind of traffic
(incoming and outgoing)?

Multi-threading may help if your python program is spending all it''s
time waiting for the network (quite possible). If you''re CPU-bound and
not waiting on network, then multi-threading probably isn''t the answer.


Chris Curvey写道:
Chris Curvey wrote:
如果你的python程序花费了所有的时间等待网络(很可能),多线程可能会有所帮助。如果你受CPU限制并且没有在网络上等待,那么多线程可能不是答案。
Multi-threading may help if your python program is spending all it''s
time waiting for the network (quite possible). If you''re CPU-bound and
not waiting on network, then multi-threading probably isn''t the answer.




除非你在一台多CPU /多核机器。

(但请注意Python的GIL)


--Irmen



Unless you are on a multi cpu/ multi core machine.
(but mind Python''s GIL)

--Irmen


这篇关于1百万用户..我无法扩展!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆