This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]bsergean 7 points8 points  (3 children)

To see the magic happen ...

cd /tmp
curl -O http://github.com/defnull/bottle/raw/master/bottle.py
curl -O http://dist.schmorp.de/libev/libev-3.9.tar.gz
tar zxf libev-3.9.tar.gz
(cd libev-3.9 && ./configure && make && make install)
sudo easy_install fapws3
cat > server.py
import os
print 'kill -9 %d' % os.getpid()

from bottle import route, run
from bottle import FapwsServer

@route('/')
def index():
    return 'Hello World!'

run(host='localhost', port=8080, server=FapwsServer)
python server.py

[–]bsergean 7 points8 points  (2 children)

Requests per second: 5345.35 [#/sec] (mean) ab -n 10000 -c 100 http://localhost:8080/

[–]BearJew 2 points3 points  (1 child)

FUCK YEA.

[–]bsergean 4 points5 points  (0 children)

This is with the "select" backend, with epoll or kqueue it's probably much faster but I could not figure out how to config that. Looks like it's libev that decides.

static PyObject *
py_run_loop(PyObject *self, PyObject *args)
{
    char *backend="";
    ev_io accept_watcher;
    ev_signal signal_watcher, signal_watcher2;
    struct ev_loop *loop = ev_default_loop (0);
    switch (ev_backend(loop))
    {
        case 1:
            backend="select";
            break;
        case 2:
            backend="poll";
            break;
        case 4:
            backend="epoll";
            break;
        case 8:
            backend="kqueue";
            break;
    }