缩放python龙卷风应用程序的正确方法 [英] The proper way to scale python tornado application
问题描述
我正在寻找某种方法来将龙卷风应用程序的一个实例扩展为许多实例.我有5台服务器,并希望在应用程序的每个4个实例上运行.我不知道如何解决的主要问题-是以正确的方式在实例之间进行通信.我看到了实现它的以下方法:
I am searching for some way to scale one instance of tornado application to many. I have 5 servers and want to run at each 4 instances of application. The main issue I don't know how to resolve - is to make communication between instances in right way. I see next approaches to make it:
- 使用memcached共享数据.我认为这种方法不好,因为使用memcached会将大量流量发送到服务器.因此,将来可能会出现与交通相关的问题.
- 在每个实例之间打开套接字.对我而言,维持这种沟通方式将太困难了.
- 使用 ZeroMQ 之类的工具.我不熟悉这项技术.是否可以成为在服务器之间扩展应用程序的方法?
- Use memcached for sharing data. I don't think this approach is good, because much traffic would go to server with memcached. Therefore in the future there can be trafic-related issues.
- Open sockets between each instance. As for me it will be too hard to maintain such way of communication.
- Use tools like ZeroMQ. I am not familiar with this technology. Is it can be the way to scale application between servers?
推荐答案
我实际上正在寻找类似的东西,而我的想法是这样的.使用Python多重处理模块( http://docs.python.org/library/multiprocessing.html),以这种方式将各个服务器上的进程链接在一起.然后,将memcached服务器用于会话特定的数据. (SessionID,IP信息,用于将会话绑定到特定用户以及他们正在使用的活动线程的信息)其余的是从数据库实例驱动的数据.
I'm actually looking at something similar and the thought I have come up with is this. Use the Python Multiprocessing module ( http://docs.python.org/library/multiprocessing.html ) to link the processes together in that way on the individual servers. Then use a memcached server for session specific data. (SessionIDs, IP information, information used to tie the session to a specific user and to the thread of activity they are using) The rest being data driven from a DB instance.
这篇关于缩放python龙卷风应用程序的正确方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!