From: "Jesús Gabriel y Galán" Date: 2010-04-07T02:52:24+09:00 Subject: Maximum number of sockets Hi, I am trying to test how many concurrent connections a certain web server (nginx) can support in our machines, so I tried to make a little ruby script to just open sockets connecting to that machine. I first increased the fd limit of both the server and the client to 100000 and 50000 respectively, and then did this: require 'socket' include Socket::Constants sockets = [] 1086.times do |i| print "#{i}," socket = Socket.new(AF_INET, SOCK_STREAM, 0) sockaddr = Socket.pack_sockaddr_in(80, 'localhost') socket.connect(sockaddr) sockets << socket end print "All sockets connected (#{sockets.size})" gets I'm testing first in my own machine both the client and the server (hence the 'localhost', which shall be replaced by the server IP when this is ready). I started doing 50000 sockets and I faced a problem: nginx_client.rb:10: [BUG] Segmentation fault ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] (surrounded by all the printed #{i}s) Testing different numbers, it seems that 1085 works fine, while 1086 crashes. Anybody has any idea why this could be? Am I doing something wrong in the socket code? Also, I couldn't find a good description of the sockaddr stuff or the pack_sockaddr_in method: can the result of pack_sockaddr_in be reused with different sockets? I'm using the Ubuntu ruby 1.8.7: Linux jesus-laptop 2.6.27-14-generic #1 SMP Tue Aug 18 16:25:45 UTC 2009 i686 GNU/Linux ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux] Thanks, Jesus.