62 ms·
re 1: Bret Taylor addressed db queries in the video on Tornado (the video is on Facebook, but I cannot find the link). If you run more than one instance of Tor
by frognibble 16y ago
re 1: Bret Taylor addressed db queries in the video on Tornado (the video is on Facebook, but I cannot find the link). If you run more than one instance of Tornado per core and you have a decent load balancer in front of the instances, then short blocking calls to the db work just fine. If your db calls are taking a long time, then it might be better to speed up the queries with caching or query optimization before worrying about async.
I like this approach because I prefer writing app logic in a straight line instead of in callbacks. The code is easier to understand and debug.
- paul 16y agoExactly. Async is very important when you're blocking on an external event (such as fetching a page doing doing hanging-GET), but local db or filesystem blocking can most easily be handled by just running more Tornado instances (because they better not be blocking for too long anyway, or else your site is dead).
- joshu 16y agoany recommendations re loadbalancers?
- frognibble 16y agonginx
- timr 16y agohaproxy is brilliant.
- sramov 16y agonginx. And I've heard a bunch of good things about Perlbal, too.
- jfarmer 16y agoYou might be able to do this with decorators in Python, but in Ruby (1.9 or 1.8 w/ the fibers patch) there are libraries that make these calls asynchronous with minimal or no changes to your code, e.g., neverblock. http://www.espace.com.eg/neverblock/ http://www.espace.com.eg/neverblock/
- draegtun 16y agoIn Python i suspect you could use things like Twisted or Multiprocessing (module) here. In Perl there is AnyEvent and luckily CPAN already provides AnyEvent wrappers around pretty much everything! ref: http://search.cpan.org/search?mode=module&query=AnyEvent%3A%3A%2A&complete=1 http://search.cpan.org/search?mode=module&query=AnyEvent... BTW, There is a (fledging but robust) port of Tornado to Perl: http://search.cpan.org/dist/Tatsumaki/ http://search.cpan.org/dist/Tatsumaki/