4 ms·
So this Go server is slower than a single threaded, blocking TCP server in Ruby. And the memory? Almost the same: require "socket" s = TCPServer.new 'localhost
by luikore 13y ago
So this Go server is slower than a single threaded, blocking TCP server in Ruby. And the memory? Almost the same:
require "socket"
s = TCPServer.new 'localhost', 1201
loop do
c = s.accept
if c.read(4)
c << 'Pong'
end
c.close
end
- dlsspy 13y agoIt's not obvious to me what that does. Does that only service one of the 100 clients or one of their 10,000 pings each? Or both?
- luikore 13y agoIt's one at a time. But, since the server only performs a one-shot task without the "hang on and wait 30 seconds"-like long connections, and, the default socket backlog of TcpServer is > 100, so every client gets served within the delay of (0~99)*6ms. In short, every round is fully served, and the concurrency level is 100.
- jaekwon 13y agohmm, i tried running that against the go client but the client wouldn't connect. dial tcp 127.0.0.1:1201: connection refused i changed 'localhost' to '127.0.0.1' and now I see a whole lot of dial tcp 127.0.0.1:1201: connection reset by peer some connections were successful though.
- luikore 13y agoThe first one may be your localhost not mapped to 127.0.0.1 ? The second one may be a problem of backlog size. On my system (ruby 2.1.0dev (2013-08-06) [x86_64-darwin12.4.0]) it's 128 and there's no reset. But you can manual change it with s.listen(1000)