浙江省高等学校教师教育理论培训

微信搜索“毛凌志岗前心得”小程序

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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, file dbdata) is compressed and loaded into memory using mmap, an index is build on top of it for fast lookup using binary search. The RES is about 9M when 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 kept

Test Machine

Server and test app are run on the same computer.

  • Mem: 16G
  • CPU: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
  • OS : GUN/Linux Debian 3.1.0-1-amd64

Several 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 9999999

Command to show status

cat /proc/net/sockstat
posted on 2013-01-26 18:20  lexus  阅读(258)  评论(0编辑  收藏  举报