Showing posts with label tornado. Show all posts
Showing posts with label tornado. Show all posts

Thursday, November 22, 2012

Tornado and Blob Chunking

The Tornado web framework is a great choice for implementing an application that can anticipate lots of client connections. It's claim to fame is that it can support thousands of concurrent users. And it does all of this in a single-threaded IO loop. Which can block on certain IO operations — like serving large blob objects.

The trick with Tornado is to understand where this blocking behavior occurs, and how that contrasts to the threaded-approach of handling many client connections concurrently. With a threaded-approach, the concept of a request handler, the code the application developer writes to fulfill user requests, doesn't need to do anything special. The framework takes care of maintaining thread management for any given request. With IO loops, we need to be conscientious of the fact that only one request handler is handled at any given time. So the trick is this — exit from the request handler as quickly as possible.

Tuesday, October 16, 2012

Lean Tornado

Tornado is a lean web framework. Vague, yes. Allow me to explain. Tornado doesn't get in the way of the developer trying to build an application by imposing too many conventional constraints. Each web framework that gets put out there in the community, be it Python or otherwise, adopts its own conventions. Usually from inception onward. Conventions establish a standard set of practices, patterns — call them what you will — they're essentially rules that explain how to best utilize the framework because some other developer had done it that way before. By and large, this approach works. Develop a toolkit that has a vast collection of reusable components and an instruction manual on how to use them in isolation as well as building new, larger components from smaller ones. By following these conventions on how to get the most reuse out of these parts, the developer really only needs to tap their previous project experience with similar code and the rest should just fall into place — assuming they've read all the documentation and learn how to follow the patterns of the framework very quickly.