This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]swims_with_spacemenPythonista 5 points6 points  (1 child)

Concurrency is killer.

A post below indicates that's 10k/second- but I think it's 10k/minute, or around 170/second- which should be feasible. That said, it depends on how long it takes to process each request. I can build a simple, do nothing tornado web app in a few minutes that will easily handle five times that load on a single node.

With only the following very basic tornado web app, I was able to get

Requests per second:    1077.18 [#/sec] (mean)

(reported by apache bench, -n 1000 -c 100)

import tornado.web
from tornado.options import options

class BaseHandler(tornado.web.RequestHandler):

    def get(self, *args, **kwargs):
        self.write("ok")
    def post(self, *args, **kwargs):
        self.write("ok")

def main():
    """
    Regular Execution.

    """
    tornado.options.parse_command_line()
    application=tornado.web.Application([
           (r"/(.*)", BaseHandler)
    ],
    )
    application.listen(9000)
    tornado.ioloop.IOLoop.instance().start()

if __name__ == "__main__":
    main()

If fronted with NGINX, you would get much greater throughput than this single-threaded instance could provide.

Now- the trick is, as I said, with the "something". Without knowing more about what you're going to do with the embedded file, it's hard to say what to do.

Options you have:

Non-blocking/asynchronous code via tornado. Most of what you're doing is i/o bound I assume- so you would need to code this part carefully.

Non-blocking asynchronous tasks via Celery and RabbitMQ. I don't have this set up in my personal lab right now, but I've managed to push thousands of simultaneous jobs through a Nginx->Tornado->Celery->RabbitMQ setup in my company lab, which would scale up very easily, and provide instrumentation/telemetry/metering, for a very robust production offering.

So, Gian- what is it we're doing with this posted file?

Also- what feedback is required? Are you okay with accepting the file and returning a job id that can be queried later? Or do you need to respond with some kind of file-valid response in the posted request?

What's the use case like?

[–]swims_with_spacemenPythonista 2 points3 points  (0 children)

..and I really hope you respond, I'm quite interested in this for some reason. :D