1

I'm running a stress test on a websocket server to measure how many clients it can serve simultaneously and on what depends that number.

The server implementation I'm using is pywebsocket, the extension for apache server. Apparently, this creates a new thread for every new client.

The problem is I can only go up to 378 clients, always the same number (and pretty low), and for the next one I receive the following trace:

[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**

I really don't know where this limit might come from, it seems to low to be the number of maximum threads for the process, which I just set to unlimited, or the maximum number of processes for the user, also now set to unlimited.

I also checked the apache2 configuration files and this is what I have in apache2.conf, should be enough:

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>

The server is an Amazon EC2 t1.micro instance with ubuntu.

What else can be causing this limit?

Silvia
  • 269
  • 2
  • 5
  • 17

1 Answers1

0

Try reducing ulimit -s to a much lower value than unlimited/default for whatever piece of code will create many threads, and make sure /proc/sys/kernel/threads-max is not lower then six figures.

covener
  • 17,402
  • 2
  • 31
  • 45