Asyncio -- delayed calculation

Chris Angelico rosuav at gmail.com
Fri Dec 2 09:54:14 EST 2016


On Sat, Dec 3, 2016 at 1:26 AM, Frank Millman <frank at chagford.com> wrote:
> Then Twisted made a strong case for an asynchronous approach. One of their
> claims (which I have no reason to doubt) was that, because each user
> 'session' spends most of its time waiting for something - keyboard input,
> reply from database, etc - their approach allows hundreds of concurrent
> users, something that I believe would not be possible with threading or
> multi-processing.

I'm not sure that "hundreds" would be a problem - I've had processes
with hundreds of threads before - but if you get up to hundreds of
*thousands* of threads, then yes, threads start to be a problem. When
you have that sort of traffic (that's multiple requests per
millisecond, or over a million requests per minute), you have to think
about throughput and efficiency, not just simplicity. But for low
traffic environments (single digits of requests per second), threads
work just fine. Actually, for traffic levels THAT low, you could
probably serialize your requests and nobody would notice. That's the
simplest of all, but it scales pretty terribly :)

Not everyone needs the full power of asyncio, so not everyone will
really see the point. I like that it's available to everyone, though.
If you need it, it's there.

ChrisA


More information about the Python-list mailing list