Handling more concurrent requests

806 views
Skip to first unread message

msoulier

unread,
Apr 14, 2013, 9:48:22 AM4/14/13
to Tornado Web Server
Hi,

I'm new to Tornado, and I was hoping to use it similarly to node.js in
handling a lot of concurrent requests with a small resource footprint,
but using Python, my preferred language. I'm not sure how to handle
incoming requests asynchronously, as I notice that Tornado does not do
this out of the box. I see certain asynchronous handlers for various
tasks, and contributed libraries on the wiki. Is it possible to handle
many concurrent requests asynchronously without running multiple
tornado processes?

Perhaps it wouldn't really help, as asynchronous code won't create
another cpu on the system, but if some requests are fast and others
are slow, I was hoping that the overall throughput would be faster non-
blocking.

Maybe I'm just smoking something odd today...

Mike

Waldecir Santos

unread,
Apr 14, 2013, 10:06:08 AM4/14/13
to python-...@googlegroups.com
For concurrency you will always need extra CPU, the asynchronous is for applications who need do a lot of IO operations, so server dont stop and wait IO he still going on and not block on IO

Grato,

Waldecir



--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



A. Jesse Jiryu Davis

unread,
Apr 14, 2013, 10:24:28 AM4/14/13
to python-...@googlegroups.com
Yeah; look at the example here:

http://www.tornadoweb.org/en/stable/gen.html

That's an asynchronous operation: other work can be accomplished while the request handler is waiting for
http_client.fetch("http://example.com") to complete. More examples of async I/O with my MongoDB driver here:

https://motor.readthedocs.org/en/latest/examples/callbacks-and-generators.html
I think one generally starts as many Tornado processes as one has CPUs, and load-balances them with Nginx or HAProxy.

Michael P. Soulier

unread,
Apr 14, 2013, 11:24:06 AM4/14/13
to python-...@googlegroups.com
On 14/04/13 A. Jesse Jiryu Davis said:

> Yeah; look at the example here:
>
> http://www.tornadoweb.org/en/stable/gen.html
>
> That's an asynchronous operation: other work can be accomplished while the
> request handler is waiting for
>
> http_client.fetch("http://example.com") to complete. More examples of
> async I/O with my MongoDB driver here:
>
> https://motor.readthedocs.org/en/latest/examples/callbacks-and-generators.html
>
> I think one generally starts as many Tornado processes as one has
> CPUs, and load-balances them with Nginx or HAProxy.

Well, I'm currently using django, but I'm moving an app to the raspberry pi,
so I thought I'd try for something with a smaller footprint, and something to
easily support long polling. So I'm evaluating nodejs and tornado.

Mike
signature.asc

A. Jesse Jiryu Davis

unread,
Apr 14, 2013, 11:51:57 AM4/14/13
to python-...@googlegroups.com
Hah, did you get your Pi at PyCon? So, yes, Tornado is great for apps with long-polling. Consider also installing Serge's Tornadio package for a higher-level API. I've used it and it works well:

https://github.com/mrjoes/tornadio2


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAlFqyhYACgkQKGqCc1vIvggBFQCgrqBkl+8an1inRGmOYM7E8FXx
vAoAoLYCRyaUKOBa4MnP3Swjovr8YSvE
=msAd
-----END PGP SIGNATURE-----


Serge S. Koval

unread,
Apr 14, 2013, 12:25:12 PM4/14/13
to python-...@googlegroups.com
Dont start with tornadio2, use sockjs-tornado: http://github.com/mrjoes/sockjs-tornado

Reasons:
1. It is better maintained
2. SockJS is much more stable
3. Python 3 support



Michael P. Soulier

unread,
Apr 14, 2013, 6:01:09 PM4/14/13
to python-...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2013-04-14 11:51 AM, A. Jesse Jiryu Davis wrote:
> Hah, did you get your Pi at PyCon? So, yes, Tornado is great for
> apps with long-polling. Consider also installing Serge's Tornadio
> package for a higher-level API. I've used it and it works well:

No, I've had it for a while. I'm finding an sql db overkill, and
without needing one, my need for Django drops considerably. I almost
want a simple http router, but production grade. nodejs still performs
very well, but I'm not a big fan of the apis.

Mike

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (Darwin)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iD8DBQFRayclKGqCc1vIvggRAtJEAJ0X3esDDZYeMGpLKm+QF+zjzCD54ACdFhWx
xPlc3AEfFYkfPfATTc7i4cA=
=JOew
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages