Tuesday, May 15, 2007

WSGI Async Framework

I have been playing around with an asynchronous web framework call FAPWS. Took me a while to stub my toe on this one but eventually I found it and have been very impressed with it so far. William the creator of FAPWS (which I am the first to say the project needs a name change) is a great guy has really taken all the feed back I have given him and responded as quickly as he could. He made the FAPWS server able to serve WSGI compliant application. So Pylons (as well as many other WSGI frameworks) can be driven async by FAPWS. First this illustrates the power of WSGI. Second koodos to William.

Template Performance
See the blazing speeds of FAPWS I had to find out how fast it really was. I am a huge template fan for web applications. Once you have template you will never go back. So I pull out my favorite template language (Genshi) and bench marked it. The code just displayed the unix time on a webpage. The first round with I think Python 2.4 and Genshi 0.3 was 765.10 request a second. Now with Python 2.5 and Genshi 0.4 I am getting 1209.19 request a second. None of this is officially really that useful because the apaches benchmarking tool 'ab' was running on my localhost along with the server and I wasn't doing all the things that I am supposed to do to make sure I had a true benchmark. This is blazing fast! In theory if I load balanced my laptop with something like lighty I would be able to do over 2K request a second!

Insane Performance
William has been emailing me about how fast he has gotten FAWPS to work and it may be close to the fastest web server out there. It is still in very early stages of development but I think this is going to be an awesome tool for high performance WSGI applications. As time goes on more backend frameworks like sqlalchemy will support async IO providing a faster over all system.

FAWPS + Pylons
I have been using Pylons lately because of its philosophy of WSGI compliance. Also it is a much simpler framework than Turbogears. If you have a large application I find it better to have a stripped down framework. If you are prototyping and need an application yesterday then I still think TG is the best to have something up and running in 5 minutes. Pylons being so simple can sit under FAWPS so far I have only seen 25% performance increases however there are a lot of integration optimizations I have not done yet. Right now I have a database retrieving some of the data so the bottleneck is the database queries. Once I add caching into the system then we should see a sharp increase in performance because there won't be as much IO blocking.

7 comments:

mormon said...

I assume FAWPS just does the front end web serving? That's pretty rockin' speed-wise. I'm always jealous of Python apps that can cook whereas my Ruby apps...well they try. Hopefully with some asynchronity in there it will begin to work better.

Lateef Jackson said...

I am not sure how well Ruby supports async. It would be fine if most of your request are handled by memchache but there are not a lot of database storage systems that can handle async web server. ZODB is supposed to have some support. I look forward to the day that a storage system can keep up with async web server.

Jerry Ji said...

Hi Jackson,

I've been pulling my hair to run my Pylons application under FAWPS2, could you please share your FAWPS(2) configuration for Pylons?

Many thanks!

Jerry

Lateef Jackson said...

Jerry,
This was back in the days of FAWPS1 days. However I will find the config see if I can get it working with FAWPS2. Give me till end of day on Oct 24.

Jerry Ji said...

Whao, this is the most mind-blowingly fast reply I've ever had! :)

Lateef Jackson said...

If you drop me an email I can send you the pylons project however let me give you as much as I can here.

First I added a run.py in the same directory as the config.ini. This code is below.

import os
from paste.deploy import loadapp
config_path = os.path.abspath(os.path.dirname(__file__))
path = '%s/%s' % (config_path, 'development.ini')
application = loadapp('config:%s' % path)

import _evhttp as evhttp
from fapws2 import base
import sys
sys.setcheckinterval=100000 # since we don't use threads, internal checks are no more required


def start():
evhttp.start("0.0.0.0", 8080)

evhttp.set_base_module(base)

evhttp.gen_http_cb(application)

evhttp.event_dispatch()


if __name__=="__main__":
start()


I have been having issues with it loading index.html. But I have been able to load other static files like images and stuff so not sure what that is all about. I was able to add things to routes and that seems to work. Again if you sling me an email I can email hello world pylons I did.
I can no longer get ahold of William the maintainer of FAWPS his email doesn't work for me anymore. So I don't know how much I can help my code checkout of FAPWS2 is a couple months old. However I did contrib a bit of code so I know the project code pretty well and could probably do some amount of support.

Anonymous said...

hi,

Sorry for disturbance.
you should have your answers here: http://william-os4y.livejournal.com/5726.html

Post a Comment