NIO - maximum socket connections

How can you tell the maximum number of TCP/IP connections a single process and/or machine can maintain?

The answer is probably OS dependent, so I’d be curious about any info on Mac OS X, Linux and Windows XP.

Basically I’m trying to understand for planning purposes how many clients a single server could support at the same time.

My game server is written in NIO and clients poll it every so often for updates (the nature of the game doesn’t require instantaneous response). However, for an upcoming game I would like to see if a constant connection would work - in which case the question of how many simultaneous connections can be supported is important.

Any insight would be appreciated - especially real world experience. How do games like everquest work? Are there X servers per N players?

Thanks

-Doug

Most MMOG’s run as many clients as they can per server, where the limiting bottleneck is CPU power and RAM. This worked out at around 2000 clients per server back in the early days of EQ, whereas now it’s around 3500 clients per server.

But you have to bear in mind that almost none are using a backend that’s even half as good as it could be.

Webservers are known to be able to handle tens of thousands of simultaneous connections if you’re design and coding is good enough. The c10k page (google for it) was started many years ago on the basis “there’s no technical problem why servers shouldn’t be hadnling 10k clients at once these days…so let’s do it” (or something to that effect).

You could do worse than to read my gem “Thousands of clients per server” in Game Programming Gems 4, which pretty much covers everything you can do on a single server (i.e. without clustering). I was only allowed to write a max of 15 pages, but IMHO I did pretty well within that limit ;D. Of course, if that’s your only reason for buying the book, then it’s a very expensive 15 pages (the full book is about 500-600 pages). Also note that the source code on the CD is not much good - but if you do get the book and want the source, you can mail me and I’ll endeavour to fix up the lot of it and get the improved decent version out to you (and it’s all in java using NIO, of course).

PS I’m keen to get 30k or 40k clients on a NIO server, and I think I can, but I haven’t got enough equipment to test it, unless each client was trivial (e.g. a web browser or similar).

i got that book just for that chapter. dude i never new!
worth every 15pages…

Yes, it’s a great Gem, among many. Well worth the price. I’d be interested in seeing the fixed up source :slight_smile:

The only limit should be the number of file descriptors allowed per process. Some OSs might have the default set fairly low (Most new versions of Linux are set to 1024), however this value can be easily changed.

[quote]Yes, it’s a great Gem, among many. Well worth the price. I’d be interested in seeing the fixed up source :slight_smile:
[/quote]
Thanks for the kind comments, guys :).

re: improved source, I suggest you email me (address given in the book) as soon as JGF v3 appears - I should have free time around then to sort out a major update (apart from a few improvements, there’s some lines of code that are dependent upon bugs in particular versions of JDK 1.4.x, and those now need to be removed).

The other reason (apart from time) why I’d like to wait for a bit now is that 1.5 could be out by then, and so I could test the code on 1.5 and possibly removed some more workaround code…

Mac OS X defaults to 256 file descriptors per process. If you make an application bundle for your app you can use a shell script to run ulimit and then run the JavaApplicationStub to work around it.

Thanks for the information. Any chance I can pay you directly for the relevant article so I don’t have to buy the whole book. I could send you the payment via paypal. How about $10?

-Doug

[quote]Thanks for the information. Any chance I can pay you directly for the relevant article so I don’t have to buy the whole book. I could send you the payment via paypal. How about $10?

-Doug
[/quote]
Chuckle. It was done on standard terms: I don’t own the copyright. So, I don’t get to even consider such things :(. FYI I get less than one dollar for each book sold, and that’s assuming it wasn’t sold at a discount (amazon etc do hefty discounts) - so $10 via paypal would have been a good deal!