Event driven server that wastes CPU when threaded doesn't

Snor leo at snorland.com
Sun Oct 29 06:19:22 EST 2006


I'm attempting to create a lobby & game server for a multiplayer game,
and have hit a problem early on with the server design. I am stuck
between using a threaded server, and using an event driven server. I've
been told time and time again that I should use an event driven server
design (that is, use twisted).

There is a lot of interaction between the clients and they would often
need to write to the same list of values, which of course becomes a
problem with a threaded server - so event driven solves that problem,
and I assumed it would solve all my problems. However some requests
from clients would require that the server goes on to query a mySQL
server (separate machine from the server). As this occurs, there is a
small amount of lag while the communication with the mySQL server takes
place, and there could be another 100 clients waiting to make a request
at this point, meanwhile the server is idling while waiting for a
response from the mySQL server - obviously not a good server model.

I will want the server to support as many users as is possible on any
given machine - and so wasted CPU cycles is something I am trying to
avoid.

Is the only solution to use a threaded server to let my clients make
their requests and receive a response in the fastest possible time?




More information about the Python-list mailing list