Skip to main content

Fast Asynchronous Python Web Server

Project description

This README file was originally written by William, the author of fapws3, and modified by Wu Zhe, the maintainer of nfapws python package to detail some installing instructions.

Introduction

This is a python web server using the wonderfull libev

http://software.schmorp.de/pkg/libev.html

library. Thus this is yet an another asynchronous web server like Medusa, Twisted, Apricot. And Fapws is a WSGI compliant web server.

What are Fapws2 and Fapws3 about ?

Fapws1, Fapws2 and Fapws3 are “internal” project’s name. The rename correspond to a full re-write.

In the begining I made Fapws1, a Python extension based on the Apricot code. Then, quickly comes the need to have much more features in it, and I’ve called it Fapws2. Fapws1 has never been published. Fapws2 is rebuild based on the http library of libevent. Works great, but I’ve been forced to modify the evhttp_handle_request. Despite seevral mails to the libevent mailing list, no one was agreed to accept my patch to the http code of libevent. Thus, or use use it with libevent <1.3e or you must change the code of libevent before using it for Fapws. This is not a so good way of working ;-(. Than comes Fapws3, a rebuild of Fapws2 without dependencies to http’s API of libevent. At that moment Marc Lehmann posts, in the libevent mailinglist, a mail describing the creation of a “new” and optimized event’s library similar to libevent. Because the code was much more clean to me and because the documentation provided

http://pod.tst.eu/http://cvs.schmorp.de/libev/ev.pod

was very clear, I’ve decided to give it a try.

Support for Fapws2 will be strictly limited to bug fixing. My current work will be focused on Fapws3.

Why a new python web server ?

In that case, the usual question is why an new one ? In short, the answer is because it sounds that Apricot is not more maintained, and because Medusa and Twisted can not go as fast as Apricot. Indeed, after several pure performance tests it appears that, thanks to the libevent library used in Apricot, is the fastest python web server.

But that not the only reason. Personnally, I prefer event’s web server. Indeed, such architecture gives more performant web server and with a much more limited memory foot print. You can easly install them a memory limited machines (like VDS for example).

Philosophy:

Fapws must stay the most simple web server and the fastest. Thus the core of the application is quite limited. Every additional feature will be placed inside a “contrib” sub-directory. This is valontary for disk space “foot print” reasons. Thus Fapws must also facilitate the disk utilisation.

How to install fapws?

Pre-requisit:

  • Python with header files, version >= 2.4, (in Debian, sudo aptitude install python python-dev)

  • Libev with header files, version >= 3.49 (in Debian, sudo aptitude install libev3 libev-dev)

WARNING:

To avoid conflicts with the previous version (called Fapws2), better to remove it before installation of the new one.

Install fapws:

sudo easy_install nfapws

How to use Fapws ?

Using Fapws is quite simple and can be done in 4 major steps:

  1. You define the main parameters of your webserve with the method “start” and the method “base”. Unless you really know what you are doing, I strongly suggest to use the “base” module provided within the package.

  2. You define you WSGI python callbacks.

  3. You link the URL patht he the python callbacks previously created.

  4. You start you webserver by triggering the “run” method.

  5. As describbed in the Libev documentation, you can controle the Event Loop used. By default Libev estimate what’s the best one for your architecture, but you can overwrite this selection by using the environment variable: LIBEV_FLAGS. Choices are: 1=select, 2=poll (everywhere except windows), 4=epoll (Linux), 8=kqueue (BSD clones), 16=devpoll (solaris 8), 32=port (solaris 10)

For more help, check the samples.

How to get news about Fapws?

You will find information concerning Fapws on my own blog: http://william-os4y.livejournal.com/

Where it can run?

Theoritically anywhere where both Python and Libev are running.

Have fun with Fapws.

William

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nfapws-0.3.2.tar.gz (27.4 kB view hashes)

Uploaded Source

Built Distribution

nfapws-0.3.2-py2.5-linux-i686.egg (56.4 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page