var http = require('http');
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('hello, world!\n');
}).listen(8080, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8080/');
$ ~/local/bin/weighttp -n100000 -t4 -c16 -k http://127.0.0.1:8080/
weighttp - a lightweight and simple webserver benchmarking tool
finished in 9 sec, 82 millisec and 931 microsec, 11009 req/s, 1698 kbyte/s
requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored
status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 15800000 bytes total, 13400000 bytes http, 2400000 bytes data
meinheld is world fastest Python web server.
import meinheld
from multiprocessing import Process
import signal
workers = []
def hello_world(environ, start_response):
status = '200 OK'
res = "Hello world!"
response_headers = [('Content-type','text/plain'),('Content-Length', '12')]
start_response(status, response_headers)
return [res]
def run(app, i):
meinheld.run(app)
def kill_all(sig, st):
for w in workers:
w.terminate()
def start(num=2):
for i in range(num):
p = Process(name="worker-%d" % i, target=run, args=(hello_world,i))
workers.append(p)
p.start()
signal.signal(signal.SIGTERM, kill_all)
meinheld.set_keepalive(10)
meinheld.set_access_logger(None)
meinheld.set_error_logger(None)
meinheld.listen(("0.0.0.0", 8000))
start()
$ ~/local/bin/weighttp -n100000 -t4 -c16 -k http://127.0.0.1:8000/
weighttp - a lightweight and simple webserver benchmarking tool
finished in 3 sec, 174 millisec and 522 microsec, 31500 req/s, 4983 kbyte/s
requests: 100000 total, 100000 started, 100000 done, 100000 succeeded, 0 failed, 0 errored
status codes: 100000 2xx, 0 3xx, 0 4xx, 0 5xx
traffic: 16200000 bytes total, 15000000 bytes http, 1200000 bytes data