How far epoll can push concurrent socket connection » A programmer's site
How far epoll can push concurrent socket connection
I wrote an online dictionary in pure C in Spring festival.
The dictionary data(about
8.2M, filedbdata) is compressed and loaded into memory usingmmap, an index is build on top of it for fast lookup usingbinary search. The RES is about9Mwhen concurrent connection is not high, say, blow 1k.I handcrafted the web server in pure C with epoll. It serves static file and word lookup request. The performance is amazing,
57.3k req/s, when 1600k socket connections are keptTest Machine
Server and test app are run on the same computer.
Mem: 16GCPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHzOS: GUN/Linux Debian 3.1.0-1-amd64Several config for Linux:
# set up virtual network interface, # test client bind to these IP, then connect for i in `seq 21 87`; do sudo ifconfig eth0:$i 192.168.1.$i up ; done # more ports for testing sudo sysctl -w net.ipv4.ip_local_port_range="1025 65535" # tcp read buffer, min, default, maximum sudo sysctl -w net.ipv4.tcp_rmem="4096 4096 16777216" # tcp write buffer, min, default, maximum sudo sysctl -w net.ipv4.tcp_wmem="4096 4096 16777216" echo 9999999 | sudo tee /proc/sys/fs/nr_open echo 9999999 | sudo tee /proc/sys/fs/file-max # edit /etc/security/limits.conf, add line # * - nofile 9999999Command to show status
cat /proc/net/sockstat