Small Light and Fast Web Applications Using WSGI

Posted on January 9, 2009

In some of my recent work at fotoglif.com, I’ve been assisting the development of the public API. My goal with the project has been to make the entire stack as small and minimalist as possible to make it easier to maintain and extend in the future. I came to this conclusion after prototyping a few ideas in various popular Python frameworks such as Turbogears and Django. Each framework allowed for easy maintainability and had all the batteries included, but the huge call-chain invoked for each request felt like overkill for the task at hand. What I needed was a simple WSGI interface to our database.

The project still needed to be easy to maintain as it could eventually become rather complex. This precluded writing the application on bare-metal mod_wsgi and led me to webpy. Webpy is a very minimal framework — it feels more like a Python module from which you can import what you need. There is a little bit of “magic” going on, but it’s tolerable for the amount of room it gives you as the developer to design your application to your needs.

We also went with SQLAlchemy as our ORM as I felt it would give us the most flexibility while we discovered the “kinks” in our application as we moved forward. Integrating it with webpy is a dream of course and for the most part, required no wrapping or extra layers. Very handy if you want to stay light and fast.

We’ll be punishing the new API in beta in a week or two. I might post a few benchmarks and statistics to show you just how wonderful it is to work with minimalist frameworks for high-availability applications.

For further reading and inspiration, check out Eric Florenzano’s, “Writing Blazing Fast, Infinitely Scalable, Pure-WSGI Utilities.”