2

I'm trying to establish many(the more - the merrier) socket connections on Windows 2003 server.
I make several server sockets and connect to them from current computer (1 server socket serves 1 client). I also make 1 server socket which serves many connections from another local computer.
When I make 4000 server sockets and 4000 connections to them, plus 4000 client connections to one server socket - everything works fine.
When I try the same thing with 5000 (5000 server sockets and 5000 connections to them) and start connecting clients remote, 1779th client and all the following (1780th, 1781th...) throw exception that connection has been reset or refused.

I have 8Gb RAM, MaxUserPort in registery set to 65534 and it didn't help. I've also tried to set MaxFreeTcbs to 12000 (not sure if it's necessary). Where else could be the problem?

Natalia
  • 21
  • 4
  • What I/O model are you using? IOCP? Completion routines? By 5,000 server sockets, do you mean 5,000 calls to `listen`? Or do you mean 5,000 accepts? (And are you 100% sure the client isn't the limiting factor?) – David Schwartz May 02 '12 at 09:51
  • 32 bit or 64 bit? 32 bit is limited. 8gb ram is quite low for a server allocating 10 thousand buffers for tcp conncetions, potentialy.Your threading model may suck out the rest of the memory, depending how you program it (completion ports a necessity). – TomTom May 02 '12 at 10:03
  • I use IOCP. 5000 server sockets = 5000 listen. 32 bit. no, it's not client. I guess it's memory issue, but not sure. If I try to do the same with 6000, I can't even create so many server sockets. But task manager shows low memory usage... – Natalia May 02 '12 at 10:31
  • What goes wrong when you try to create 6,000 server sockets? What function fails (`socket`? `bind`? `listen`?) And what error do you get? Also, is there some specific reason you are using so many listening sockets? – David Schwartz May 02 '12 at 11:09
  • The error is "no buffer space available". Fails listen. Yes, I do need so many server sockets because it's an interface, which I should provide to foreign application. – Natalia May 02 '12 at 11:12
  • Triple-check your `MaxUserPort` registry entry. (Make sure it's spelled right. Make sure it's 65534 *decimal*. Make sure it's a DWORD.) – David Schwartz May 02 '12 at 11:18
  • Yes, everything is that way. It seems like it's non-paged pool memory problem, which size is fixed. So I can't do anything with it, can I? – Natalia May 02 '12 at 11:36
  • You can minimize your non-paged pool consumption. Use only one listening socket. Post the smallest IOCP buffers you can get away with. Defragment the IOCP buffers so they comprise as few pages as possible. (If you use 2KB IOCB buffers, you can pack them 4 to a page. Be careful as the OVERLAPPED structure counts!) – David Schwartz May 02 '12 at 12:25

0 Answers0