multithreading - TCP/IP - Solving the C10K with the thread per client approach -


after reading famous c10k article , searching on web how things have evolved since written, know if possible today's standard server handle >10000 concurrent connections using a thread per connection (possibly of pool of threads avoid creation/killing process).


some details may affect approach problem:

  1. input, intermediate processing , output.
  2. length of each connection.
  3. technical specifications of server (cores, processors, ram, etc...)
  4. combining system alternative techniques aio, polling, green threads, etc...

obviously i'm not expert in matter, remarks or advices highly appreciated :)

absolutely. standard server can handle more 10k concurrent connections using model one thread per connection. have build such application, , 5 years ago, running more 50k concurrent connections per process on standard linux server. nowadays, should possible run same application more 250k concurrent connections on current hardware.

there few things keep in mind:

  • reuse threads using thread pool. there no need kill threads if not used, because resource usage should optimized peak loads.
  • stack size: default each linux thread reserves 8 mb stack. sums 80 gb 10k threads. should set default stack size value between 64k , 512k, isn't problem, because applications don't require deeper call stacks.
  • if connections short-lived, optimize new connections creating several sockets on same endpoint option so_reuseport.
  • increase user limits: open files (default 1.024), max user processes
  • increase system limits, e.g. /proc/sys/kernel/pid_max (default 32k), /proc/sys/kernel/threads-max, , /proc/sys/vm/max_map_count (default 65k).

the application mentioned above designed handle 2k concurrent connections. however, growth in use, didn't have make significant changes code in order scale 50k connections.


Comments