Skip to content

Latest commit

 

History

History
 
 

render

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Async Python Web Frameworks comparison

Updated: {{ now.strftime('%Y-%m-%d') }}

benchmarks tests


This is a simple benchmark for python async frameworks. Almost all of the frameworks are ASGI-compatible (aiohttp and tornado are exceptions on the moment).

The objective of the benchmark is not testing deployment (like uvicorn vs hypercorn and etc) or database (ORM, drivers) but instead test the frameworks itself. The benchmark checks request parsing (body, headers, formdata, queries), routing, responses.

Table of contents

{% set chart_data = '{type:"bar",data:{labels:["' + results|join("","", attribute="name") + '"],datasets:[{label:"num of req",data:[' + results|join(",", attribute="req") + ']}]}}' %}

The Methodic

The benchmark runs as a Github Action. According to the github documentation the hardware specification for the runs is:

  • 2-core vCPU (Intel® Xeon® Platinum 8272CL (Cascade Lake), Intel® Xeon® 8171M 2.1GHz (Skylake))
  • 7 GB of RAM memory
  • 14 GB of SSD disk space
  • OS Ubuntu 20.04

ASGI apps are running from docker using the gunicorn/uvicorn command:

gunicorn -k uvicorn.workers.UvicornWorker -b 0.0.0.0:8080 app:app

Applications' source code can be found here.

Results received with WRK utility using the params:

wrk -d15s -t4 -c64 [URL]

The benchmark has a three kind of tests:

  1. "Simple" test: accept a request and return HTML response with custom dynamic header. The test simulates just a single HTML response.

  2. "API" test: Check headers, parse path params, query string, JSON body and return a json response. The test simulates an JSON REST API.

  3. "Upload" test: accept an uploaded file and store it on disk. The test simulates multipart formdata processing and work with files.

The Results ({{ now.strftime('%Y-%m-%d') }})

Accept a request and return HTML response with a custom dynamic header

The test simulates just a single HTML response.

Sorted by max req/s

Framework Requests/sec Latency 50% (ms) Latency 75% (ms) Latency Avg (ms)
{% for res in results_html -%}
[{{ res.name }}](https://pypi.org/project/{{ res.name }}/) {{ versions[res.name] }} {{ res.req }} {{ res.lt50 }} {{ res.lt75 }} {{ res.lt_avg }}
{% endfor %}

Parse path params, query string, JSON body and return a json response

The test simulates a simple JSON REST API endpoint.

Sorted by max req/s

Framework Requests/sec Latency 50% (ms) Latency 75% (ms) Latency Avg (ms)
{% for res in results_api -%}
[{{ res.name }}](https://pypi.org/project/{{ res.name }}/) {{ versions[res.name] }} {{ res.req }} {{ res.lt50 }} {{ res.lt75 }} {{ res.lt_avg }}
{% endfor %}

Parse uploaded file, store it on disk and return a text response

The test simulates multipart formdata processing and work with files.

Sorted by max req/s

Framework Requests/sec Latency 50% (ms) Latency 75% (ms) Latency Avg (ms)
{% for res in results_upload -%}
[{{ res.name }}](https://pypi.org/project/{{ res.name }}/) {{ versions[res.name] }} {{ res.req }} {{ res.lt50 }} {{ res.lt75 }} {{ res.lt_avg }}
{% endfor %}

Composite stats

Combined benchmarks results

Sorted by completed requests

Framework Requests completed Avg Latency 50% (ms) Avg Latency 75% (ms) Avg Latency (ms)
{% for res in results -%}
[{{ res.name }}](https://pypi.org/project/{{ res.name }}/) {{ versions[res.name] }} {{ res.req }} {{ res.lt50 round(2) }} {{ res.lt75
{% endfor %}

Conclusion

Nothing here, just some measures for you.

License

Licensed under a MIT license (See LICENSE file)