Package web2py :: Package gluon :: Module sneaky
[hide private]
[frames] | no frames]

Module sneaky

source code


Experimetal multi-threaded web server created by Massimo Di Pierro
For lack of a better we'll call it Sneaky.
License: GPL2

This code would have not been possible without CherryPy wsgiserver,
a great example of Python web server.

- This code implements WSGI
- This code is API compatible with cherrypy
- It consists of less than 260 lines of code
- It is multi-threaded
- The number of threads changes dynamically between a min and a max
- Can handle chunking (request and response) [to be tested]
- supports SSL via the Cherrypy ssl adaptors

You can find an example of usage at the bottom of this file.

here are some tests and comparisons performed by Garrett Smith

RPS = requests per second
Time = average time in milliseconds to server each request
Benchmark = `ab -t 10 -c <number of concurrent requests>-r http://localhost`

100 Concurrent Requests
-----------------------
===============
App Server         RPS
==============
Fapws             7174
Landshark         4479
PHP-5             4191
modwsgi           3651
Tomcat 6          3554
Tornado           2641
Sneaky WSGI(*)    2372
CherryPy WSGI     2102
Phusion           1873
Jetty 6            937
Django WSGI        785
WEBrick             43
===============

1,000 Concurrent Requests
-------------------------
===============
App Server         RPS
===============
Fapws             5359
Landshark         4477
modwsgi           3449
PHP 5             3062
Tomcat 6          3014
Tornado           2452
Sneaky WSGI(*)    2415
CherryPy WSGI     2126
Phusion           1585
Jetty 6           1095
Django WSGI        953
WEBrick             50
===============

10,000 Concurrent Requests
--------------------------
===============
App Server         RPS
===============
Fapws             5213
Landshark         4239
Tomcat 6          2369
Tornado           2265
PHP 5             2239
Sneaky WSGI (*)   2225
modwsgi           2115
CherryPy WSGI     1731
Phusion           1247
Jetty 6            794
Django WSGI        890
WEBrick             84
===============

20,000 Concurrent Requests
--------------------------
===============
App Server         RPS
===============
Fapws             4788
Landshark         2936
Tornado           2153
Sneaky WSGI(*)    2130
PHP 5             1728
modwsgi           1374
Tomcat 6          1362
CherryPy WSGI     1294
Phusion            961
Django WSGI        790
Jetty 6            616
WEBrick             63
===============

Classes [hide private]
  ChunkedReader
class used to read chunked input
  Worker
class representing a worker node
  Sneaky
the actual web server
Functions [hide private]
 
formatdateRFC822() source code
 
errors_numbers(errnames)
utility to build a list of socket errors
source code
 
test_wsgi_app(environ, start_response)
just a test app
source code
Variables [hide private]
  regex_head = re.compile(r'^((http|https|HTTP|HTTPS)://[^/]+)?(...
  regex_header = re.compile(r'^\s*(?P<key>.*?)\s*:\s*(?P<value>....
  regex_chunk = re.compile(r'^(?P<size>\w+)')
  BUF_SIZE = 10000
  SERVER_NAME = 'Sneaky'
  socket_errors_to_ignore = set([9, 32, 38, 52, 53, 54, 60, 61, ...
Variables Details [hide private]

regex_head

Value:
re.compile(r'^((http|https|HTTP|HTTPS)://[^/]+)?(?P<method>\w+)\s+(?P<\
uri>\S+)\s+(?P<protocol>\S+)')

regex_header

Value:
re.compile(r'^\s*(?P<key>.*?)\s*:\s*(?P<value>.*?)\s*$')

socket_errors_to_ignore

Value:
set([9, 32, 38, 52, 53, 54, 60, 61, 64, 65])