Hacker News new | comments | show | ask | jobs | submit login

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.




Exactly. 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).


You 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/


In 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...

BTW, There is a (fledging but robust) port of Tornado to Perl: http://search.cpan.org/dist/Tatsumaki/


any recommendations re loadbalancers?


haproxy is brilliant.


nginx


nginx. And I've heard a bunch of good things about Perlbal, too.




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: