2013-08-22 71 views
1

我正在websocket服务器上运行压力测试,以测量它可以同时服务多少个客户端以及依赖于该数量的服务。websocket - 最大客户端数量

我使用的服务器实现是pywebsocket,它是apache服务器的扩展。显然,这为每个新客户创建一个新线程。

的问题是,我只能上去378客户,总是相同的数量(和相当低),并为下一个我收到以下跟踪:

[2013-08-22 07:47:09,454] [ERROR] __main__.WebSocketServer: Exception in processing request from: ('::ffff:10.36.154.147', 41509, 0, 0) 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock 
    self.process_request(request, client_address) 
    File "/usr/lib/python2.7/SocketServer.py", line 594, in process_request 
    t.start() 
    File "/usr/lib/python2.7/threading.py", line 495, in start 
    _start_new_thread(self.__bootstrap,()) 
**error: can't start new thread** 

我真不”不知道这个限制可能来自哪里,它似乎低于进程的最大线程数,我将其设置为无限制,或者用户的最大进程数目,现在也设置为无限制。

我还检查apache2的配置文件,这是我在apache2.conf,应该足够:

MaxKeepAliveRequests 0 
KeepAliveTimeout 5 


<IfModule mpm_prefork_module> 
    StartServers   50 
    ServerLimit  2000 
    MinSpareServers  50 
    MaxSpareServers  2000 
    MaxClients   2000 
    MaxRequestsPerChild 2000 
</IfModule> 

<IfModule mpm_worker_module> 
    StartServers   50 
    ServerLimit  2000 
    MinSpareThreads  50 
    MaxSpareThreads  2000 
    ThreadLimit   0 
    ThreadsPerChild  2000 
    MaxClients   2000 
    MaxRequestsPerChild 2000 
</IfModule> 

<IfModule mpm_event_module> 
    StartServers   50 
    ServerLimit  2000 
    MinSpareThreads  50 
    MaxSpareThreads  2000 
    ThreadLimit   0 
    ThreadsPerChild  2000 
    MaxClients   2000 
    MaxRequestsPerChild 2000 
</IfModule> 

服务器是一个Amazon EC2 t1.micro实例与Ubuntu。

还有什么可以导致此限制?

回答

0

尝试将ulimit -s降低到比无限/默认值低得多的值,无论任何代码将创建多个线程,并确保/ proc/sys/kernel/threads-max不低于六位数字。