5 ms·
Brett Taylor discusses this issue in his tech talk on Tornado (http://bret.appspot.com/entry/tornado-tech-talk http://bret.appspot.com/entry/tornado-tech-talk).
by frognibble 17y ago
Brett Taylor discusses this issue in his tech talk on Tornado (http://bret.appspot.com/entry/tornado-tech-talk http://bret.appspot.com/entry/tornado-tech-talk). He uses a hybrid approach: Use synchronous programming when requests block for a short time (fetching data from local db or memcache) and async programming when something blocks for a long time (calling out to third party services, long polling requests).
He does not go all async because programming with callbacks or deferreds is more complicated than straight line synchronous programming.
Brett also mentions that the instances of the server are created once and reused. He does not fork an instance of the server per request.
- enneff 17y agoTwisted has a nice asynchronous db api (http://twistedmatrix.com/documents/current/core/howto/rdbms.html http://twistedmatrix.com/documents/current/core/howto/rdbms....) that mitigates these concerns at the database level. More generally, I'd think the cleanest approach is to write async wrappers for your synchronous code, rather than forking an async server to service multiple requests. Otherwise you miss out on a lot of benefits of an async architecture, IMO.
- deleted 17y ago[deleted]