• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
To thread or not to thread...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

To thread or not to thread...


  • Subject: To thread or not to thread...
  • From: Chilton Webb <email@hidden>
  • Date: Tue, 28 May 2002 10:09:39 -0500

I have a game server that ultimately needs to be able to support up to 3,000 simultaneous players.

Response times need to be fast, but a lag of 1 - 3 seconds won't be too disturbing to players (it's eh, quasi-real-time/fast turn-based). Being that one packet message could trigger a 3 second animation, time isn't as crucial here as it would be for say, a Quake server.

The amount of data being passed to any one client during this span of time is at a minimum, 4 bytes long, and maximum of about 128. The average is somewhere around 10 bytes. I need to send this about once per second, though again, timing is not critical there.

I'm running this currently on a Blue & White G3 300, running MacOSX 10.1.4. The 'real' server is a dual 500Mhz G4 (512Mb RAM, shared T3 net connection). For the ten test players I have now, this is far more than enough. In fact, 'top' reports that the server is using less than 3% of system resources with all ten players, and the process manager looks like everything is at idle. It uses about 2% when the game server has no active connections, and we're just fiddling around with the interface.

The core logic for the game server is easily 120k of tightly rolled C. I'm keeping as much of the game as possible cached, and I only hit the hard drive to write out game data (256k tops per write) and player stats (32k tops per write).

Currently it is not threaded, but I probably could add threads to the socket portion of it, as that part is fairly modularized away from the core of the game.

What I'm wondering is, what's the best way to construct the TCP portion so that it will scale to the 3k users? Can this be done on one machine, or do I need to run multiple servers in tandem? When this goes 'live', I'll be moving it to the dual G4 500 machine, or possibly even a new dual G4 of some sort.

So should I spawn multiple threads, or keep it all in one giant blocking socket? I wrote the interface in Cocoa, which was quite nice, so using the various Cocoa networking frameworks is not out of the question, either. I'm mainly concerned with stability and the ability to get this up and running asap.

Suggestions/comments/criticisms welcome.

Thanks,
-Chilton Webb
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: Distinguishing between ppp and ethernet
  • Next by Date: Re: Distinguishing between ppp and ethernet
  • Previous by thread: Re(4): PPPoE on X
  • Next by thread: tools, autoreleasepools and EXC_BAD_ACCESS
  • Index(es):
    • Date
    • Thread