Isn't Bjoern supposed to faster that Gunicorn ??
simple_app.py
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/suggest/', methods=['POST'])
def hello():
content = request.get_json()
return jsonify(**content), 200
app_server.py
import bjoern
import os
import signal
from simple_app import app
host = '0.0.0.0'
port = 5000
NUM_WORKERS = 2
worker_pids = []
bjoern.listen(app, host, port)
for _ in xrange(NUM_WORKERS):
pid = os.fork()
if pid > 0:
# in master
worker_pids.append(pid)
elif pid == 0:
# in worker
try:
bjoern.run()
except KeyboardInterrupt:
pass
exit()
try:
for _ in xrange(NUM_WORKERS):
os.wait()
except KeyboardInterrupt:
for pid in worker_pids:
os.kill(pid, signal.SIGINT)
Running Bjoern server as:
python app_server.py
Running Gunicorn as:
gunicorn -w 2 --bind 0.0.0.0:5000 simple_app:app --timeout 90
Main stats:
Gunicorn: request 7.53 msec highest 10sec mean
Bjoern: request 1mn 24sec highest 10sec mean
Gunicorn::
Bjoern::
Configuration of the nodes both are ec2 instances: (Used one core to run the app_server, another to run tsung)
Ubuntu 12.04.5 LTS (GNU/Linux 3.2.0-115-virtual x86_64)
Number of vCPUs : 2
Test bottle + bjoern, it's really fast. Also bottle + gunicorn + meinheld worker
Bottle is rather faster than flask
bottle: http://bottlepy.org/docs/dev/
meinheld: https://github.com/mopemope/meinheld
requests per second:
bottle-py3 408,379
flask-py3 124,800
info: https www techempower.com/benchmarks/#section=data-r13&hw=ph&test=plaintext
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With