Skip to content

Instantly share code, notes, and snippets.

@imbolc
Created April 24, 2020 03:05
Show Gist options
  • Save imbolc/fa4109b241d081cd952d7af5d01de267 to your computer and use it in GitHub Desktop.
Save imbolc/fa4109b241d081cd952d7af5d01de267 to your computer and use it in GitHub Desktop.
Flask vs Japronto hello-world benchmark
from flask import Flask, jsonify
app = Flask(__name__)
@app.route("/")
def hello_world():
return jsonify(hello="world")
if __name__ == "__main__":
from waitress import serve
serve(app, host="0.0.0.0", port=3000)
from japronto import Application
from japronto_extra import jsonify, router
app = Application()
route = router(app)
@route("/")
@jsonify
def home(request):
return {"hello": "world"}
app.run(port=3000)

Japronto is 40x faster

Flask:

Running 5s test @ http://localhost:3000/
  2 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     3.75ms    2.04ms  31.79ms   89.22%
    Req/Sec     1.41k   420.33     2.15k    76.00%
  14039 requests in 5.00s, 1.93MB read
Requests/sec:   2806.03
Transfer/sec:    394.60KB

Japronto:

Running 5s test @ http://localhost:3000/                            
  2 threads and 10 connections                                                                                                          
  Thread Stats   Avg      Stdev     Max   +/- Stdev                                                                                     
    Latency    88.28us   62.01us   2.52ms   92.98%     
    Req/Sec    58.68k    10.20k   72.20k    66.67%
  595228 requests in 5.10s, 80.61MB read
Requests/sec: 116708.53    
Transfer/sec:     15.80MB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment