title: Bjoern v/s Gunicorn POST requests
body: <p>Isn't Bjoern supposed to faster that Gunicorn ??</p>
  
  <p>simple_app.py</p>
  
  <pre><code>from flask import Flask, request, jsonify
  
  app = Flask(__name__)
  
  
  @app.route('/suggest/', methods=['POST'])
  def hello():
      content = request.get_json()
      return jsonify(**content), 200
  </code></pre>
  
  <p>app_server.py</p>
  
  <pre><code>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 &gt; 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)
  </code></pre>
  
  <p>Running Bjoern server as:</p>
  
  <pre><code>python app_server.py
  </code></pre>
  
  <p>Running Gunicorn as:</p>
  
  <pre><code>gunicorn -w 2 --bind 0.0.0.0:5000 simple_app:app --timeout 90
  </code></pre>
  
  <p>Main stats:</p>
  
  <p>Gunicorn: request   7.53 msec <strong>highest 10sec mean</strong></p>
  
  <p>Bjoern: request 1mn 24sec <strong>highest 10sec mean</strong></p>
  
  <p>Gunicorn::
  <a href="https://i.stack.imgur.com/rZDB9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rZDB9.png" alt="Gunicorn Request Duration"></a></p>
  
  <p><a href="https://i.stack.imgur.com/W6A7v.png" rel="noreferrer"><img src="https://i.stack.imgur.com/W6A7v.png" alt="Gunicorn Stats"></a></p>
  
  <p>Bjoern::</p>
  
  <p><a href="https://i.stack.imgur.com/lptCo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lptCo.png" alt="Bjoern Request Duration"></a></p>
  
  <p><a href="https://i.stack.imgur.com/SiJdh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SiJdh.png" alt="Bjoern Stats"></a></p>
  
  <p>Configuration of the nodes both are ec2 instances: (Used one core to run the app_server, another to run tsung)</p>
  
  <p>Ubuntu 12.04.5 LTS (GNU/Linux 3.2.0-115-virtual x86_64)</p>
  
  <p>Number of vCPUs : 2</p>