Bjoern v/s Gunicorn POST requests

10,814

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

Share:
10,814
vin
Author by

vin

Updated on July 16, 2022

Comments

  • vin
    vin almost 2 years

    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:: Gunicorn Request Duration

    Gunicorn Stats

    Bjoern::

    Bjoern Request Duration

    Bjoern Stats

    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

  • vin
    vin over 7 years
    Can you add the link ?
  • Yeasin Ar Rahman
    Yeasin Ar Rahman about 4 years
    For future readers, after the claim of bottle better than flask. I went through the rabbit hole. I found that flask is good for projects of any complexity. Bottle is on the other hand better for tiny services. Hope this helps. :)