[Twisted-web] what are the advantage of using a single-threaded
server? and when should we use deferreds?
inhahe at gmail.com
Sat Apr 26 02:44:54 EDT 2008
hi, excuse my noobness, I have a few basic questions about twisted, or
probably about web servers in general.
what is the advantage of using a single-threaded server?
i figured it makes it more scalable because there's too much overhead to
have a thread for each user when you have many simultaneous users. but a
friend i'm talking to now says that using i/o blocking threads is perfectly
scalable for a large number of simultaneous users.
if that's true i can only see a disadvantage in using a single-threaded
server -- having to use deferreds and stuff to make things asynchronous
i also don't understand how you're supposed to use deferreds
the twisted doc says deferreds won't *make* your code asynchronous. so
let's say you have to do an sql query that takes 10 seconds, deferreds would
be useless for making that not block unless you have a way of making that
sql query non-blocking already? how is that done? do you run a separate
thread of your own for each sql query? one thread for all sql queries?
also I wonder in an typical twisted app, just how slow should an operation
be before you use a deferred? what if a user enters a username and password
and i have to look that up in the database. do i use a deferred? just how
bad should the query be before using a deferred?
(reading the twisted docs is like reading a brick wall for me, it would be
nice if someone could just explain things to me in simple terms.)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Twisted-web