Archived

This topic is now archived and is closed to further replies.

1400 connected then 900 using TCP/IP

This topic is 5649 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I figured out how to get past the 64 socket limit with Winsock by redefining a single variable. Win2K Pro has no qualms with having it set to 32768. However, I''m running into a problem where after successfully connecting more than 1400 clients all sending messages a bunch are dropped by the server. To get that many connected I use a small app that connects 100 times (using my client class) and run it a bunch of times. Each instance sends off a message from each connection every second. When one of the connections gets kicked the whole program exits so fewer may actually be getting kicked by the server. Is there any logical reason for this happening? Watching the output window, the server starts stalling when it comes to processing messages with that many connections. Is it just too much for the server to handle (e.g. I need to make message processing more efficient)? Or is it a Winsock thing? Ben IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting ]

Share this post


Link to post
Share on other sites
I reckon 900 connections is a hell of a lot for any one machine to handle, but I've not done much other than 10 client one server networking.

Edit - you may want to check the memory usage per program. If you're allocating send or receive buffers, then the memory usage could get massive.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions


[edited by - siaspete on June 23, 2002 6:47:45 AM]

Share this post


Link to post
Share on other sites
Is the TCP or UDP? You might be filling up your receive buffers and UDP will start dropping packets when that happens (though TCP won''t)

There''s theoretically no limit on the number of connections you can process (at least, no hard-coded limit, it''s a matter of system resources and such)

Also, changing that #define thing is not a good idea, since it''s not very portable. If you''re planning on doing that, consider using a more efficient (though also non-portable) mechanism, like I/O completion ports.


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
It's TCP.

I checked memory usage. At 1400 connections it was 4.5MB. After a few minutes it had kicked out all but 800.

I'll probably just write a simple lobby that hands out IPs and ports of open servers. That would allow for a simple seamless way to limit max connections without crippling the real server.

Fortunatly there's a lot more work to do before having to worry about that.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting ]


[edited by - KalvinB on June 23, 2002 7:28:04 AM]

Share this post


Link to post
Share on other sites
Well, what about CPU load? If you''re using select() (which I assume you are if you need to change a #define), this might be the reason - it doesn''t scale too well. I don''t know how WinSock implements the fd_set, but that could be a bottleneck.

cu,
Prefect

Return to the Shadows

Share this post


Link to post
Share on other sites
The server takes as much CPU power as it can get. select() is probably the bottleneck. I made a couple changes so that it keeps accepting connections until there are no more pending and then reads messages until the que is cleared. That helped remedy disconnects but the server stalled and crashed when I got above 1400 connections.

I/O Completion ports sound like the way to go but I''ve yet to find a tutorial on implementing them with TCP/IP.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting ]

Share this post


Link to post
Share on other sites
Why don''t you use UDP instead. It''s a pain in the @ss I know but it''s around specifically for these kind of problems. Read a book or an article on point-to-point data layer transfer (NOT ppp) and apply the exact same algorithm in a peer-to-peer manner with UDP.

TCP are slow and a hassle for routers to send. I wouldn''t be surprised if some home internet provider routers are limiting the number of simultaneous TCP connections on a single host.

Share this post


Link to post
Share on other sites
quote:
Original post by Coincoin
TCP are slow and a hassle for routers to send. I wouldn''t be surprised if some home internet provider routers are limiting the number of simultaneous TCP connections on a single host.


Eh, routers work with IP packets, so they don''t know anything about UDP or TCP. Sometimes they use the protocol field to give priority to various packet types (and to block others) but that''s it.


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
Yup .. moving to UDP wont really help you here (especially if the data needs to arrive.. cuz then u just end up doing some method of insuring the data arrives which.. oh IS TCP )

anyway.. more to the point, I have just been doing a TCP IOCP class my self :-) so if you have any questions then send em my way -=lukejedikt@hotmail.com=- also do a search on this forum for IOCP ;-) I may even give out my source code if your interested in the hope that you could help me improve it in any way (thinking of making it open source). Its all bundled into a neat class too so you dont have to worry about things like thread handling etc :-)

~wrathgame
ps. im off for 1 week today on holiday so ill reply to any email after that

Share this post


Link to post
Share on other sites
I''m not using UDP because I would have to reinvent the TCP/IP wheel which would waste a significant portion of my time. My project doesn''t require fast packets but it requires they all arrive in tact and in order.

I don''t use Open Source code. I only take "Use it how you like but be nice enough to share any improvements" source. All the source I release is released without an official license.

"I wouldn''t be surprised if some home internet provider routers are limiting the number of simultaneous TCP connections on a single host."

Routers don''t hold or determine connections. All they do is direct traffic. The only determining factor of the maximum number of connections is the server computer.

I''ll keep looking into IOCP. The more I think about it though, the more it makes sense to just limit the max connections to around 1000 and run a lobby. The server could handle 10,000 connections I''m sure but the amount of game logic that would need to be processed would bring the CPU to a halt. It''s entirely possible to run multiple instances of the server on the same computer.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | DevZone | Gang Wars | The Wall | Hosting ]

Share this post


Link to post
Share on other sites
quote:
Original post by KalvinB
I'll keep looking into IOCP. The more I think about it though, the more it makes sense to just limit the max connections to around 1000 and run a lobby. The server could handle 10,000 connections I'm sure but the amount of game logic that would need to be processed would bring the CPU to a halt. It's entirely possible to run multiple instances of the server on the same computer.



Still, even with "only" 1000 connections, your select would be taking a pretty big slice of the CPU. You'd be surpised at the speed improvement, even with small numbers of users, that I/O CPs can give you. Plus it means you're nice and scaleable if you ever decide to get a dual CPU machine

Edit: By the way, there used to be a really good I/O Completion Port sample in the Platform SDK (it was actually a POP3 server) but it's not in the newest one (which I've got). I think we got a few older sdks at work, so I'll have a look for it when I go there, but if you can get your hands on an older Platform SDK (like one from last year or so), have a look in the "\Samples\netds\WinSock" folder for a POP3 sample. It's really good - better than the iocp sample I don't know why they got rid of it...


codeka.com - Just click it.

[edited by - Dean Harding on June 24, 2002 9:50:50 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by KalvinB
That''d be good to have. If the older examples are not readily available on-line anywhere I''d like to get them posted at my site.



I''m not going in to work until Thursday, so if I find it, I''ll mail it to you then. I don''t know why it''s not in the latest SDK, I mean, it''s not out of date or anything...


codeka.com - Just click it.

Share this post


Link to post
Share on other sites
with 1000 connections things like connection timeouts can occer. i assume the test client is on a different pc, and not running on the server, if not there could be your problem. if your going over the net, it could be your isp delibratly block packets due to the flurry of (100s of) connections being made (ids software may think its a DOS attack or portscan). try increasing the time between connections. also check your code, make sure your handling everything correctly. its quite possible your client is mishandling connections.

try threading connections (ie maybe 64 per thread). this allows better multitasking.

win2kpro may be block packets as well due to the flurry of connects (all from the same ip). the output window will be delayed due to cpu overhead generated actually processing requests. thus it only seems to stall, but its the flurry of printfs (or whatever output log function is called) that stalls the server. make sure it only prints a few line per second, or writes to a file. the console can be slow to update at times.

also, most routers ussually have some simple packet filtering, thus can be set to limit tcp syn packets or other things based on the packet. you can do this using linux as a router, and i am sure most "firewalls/routers in a box" designed to share connections at home handle this. which probably means an isp would be using software similar to this as well to help ensure smooth sailing for their network.

Share this post


Link to post
Share on other sites