Event driven server that wastes CPU when threaded doesn't

2006-10-29 Thread Snor
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?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Event driven server that wastes CPU when threaded doesn't

2006-11-05 Thread Snor
> You got a lot of long-winded replies, but the short reply is that
> Twisted has packaged solutions for this. 
> Seehttp://twistedmatrix.com/projects/core/enterprise
>
>   "Twisted provides an interface to any Python DB-API 2.0 compliant
> database through an asynchronous interface which allows database
> connections to be used, and multiplexed by multiple threads, while still
> remaining thread-safe for use with Twisted's event-based main loop.
> Twisted Enterprise provides these services by leveraging Twisted
> Internet's utilities for managing thread pools and asynchronous
> programming."

Thanks for this - exactly what I needed. Thanks for the other replies
too even if they weren't so much help :)

-- 
http://mail.python.org/mailman/listinfo/python-list