🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Optimizing my multithreaded Server....

Started by
3 comments, last by Darrell 23 years, 10 months ago
Hi All, I''m debating on how to approach this but here''s the details... I''m optimizing my server code, namely handling the player connections. My idea is to expand the 1 thread that I have handling player connections and expand it so that it''s configurable, i.e. based on server load so I can spawn more threads to handle player connections. My idea is to create a pool of threads, say 5 at first. All are suspended until the login thread dumps incoming player connections on a queue, and wakes one/more of them up. I then want to distributed the load so that each thread handles an approx. even amount of players. This is my approach: Login thread accepts connection. Login thread dumps the connection into the Connection Pool thread''s queue. The Connection Pool examines all the Connection threads (threads solely handling player connections. This will actually be 2 threads per pool (1 incoming/1 outgoing) and attaches the connection to the least weighted pool. (Thread with least # of players on it) This way I can play around with the # of pools, and pool sizes to determin an optimal load. If all my pools are full, I just add more pools (spawn some threads) and obviously cap it at a certain player amount (which can be done in the login server thread.) My question to all of you is: Does this sound right? I know NT/linux/Solaris handle threads quite differently and my server will most likely benefit by runnning on Solaris, but how much multithreading is too much? I''d like to here some experience on this before I actually start coding this and end up with useless code. Any suggestions? Thanks in advance, Darrell. Early engine for the server.
Advertisement
take a look at collision ports as well. They are scalable and can handle thousands of simultaneous connections.

-BacksideSnap-
Collision ports? I am unfamiliar with that term? Is it a company name/software library name or hardware?





LOL, my mind was one something else when I was typing. I meant completion ports. Sorry about that.

-BacksideSnap-
Ah ok,

I'd like to use them but:

My server will target unix flavours as well, namely Solaris.
Solaris provides a superior threading model in my opinion so I think my server would run best on that platform.

For those of you who don't know Solaris is available free for non commercial use. Visit www.sun.com for more details.

I want to keep my server as portable as possible, so this means POSIX aio for now.

I have a fair bit of experience in writing multithreaded applications, however this is my first stab at a server designed for a game. Servers that require a constant connection to clients vs. ones that build up/transmit/tear down connections are quite different in design.

So I guess I'm basically I'm implmenting a portable version of "Completion ports". Depending how I do, I'm all for open sourcing that part of the code.

I already have the server running on Linux/Solaris and Win98/NT.
Optimizing it for a balance of the above is the main hurdle for me now, as each OS & arch. handle things differently (kernel vs. user threads/ context swiching times etc. etc.)

Hopefully I can get it to work on all platforms and make it configurable so each install can be "tweaked" for optimal performance based on client load and available hardware.




Edited by - Darrell on August 11, 2000 9:18:50 PM

This topic is closed to new replies.

Advertisement