• Stars
    star
    712
  • Rank 63,595 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 9 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Another benchmark for some python frameworks

Async Python Web Frameworks comparison

https://klen.github.io/py-frameworks-bench/

Updated: 2022-03-14

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

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 (2022-03-14)

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)
blacksheep 1.2.5 18546 2.80 4.53 3.41
muffin 0.87.0 16571 3.09 5.17 3.83
sanic 21.12.1 15558 4.70 5.14 4.08
falcon 3.0.1 15554 3.29 5.49 4.08
baize 0.15.0 13880 3.69 6.21 4.58
starlette 0.17.1 13797 3.70 6.16 4.60
emmett 2.4.5 13380 5.54 6.10 4.75
fastapi 0.75.0 9060 5.46 9.79 7.03
aiohttp 3.8.1 7240 8.74 9.01 8.84
quart 0.16.3 3425 18.99 20.08 18.68
tornado 6.1 3232 19.76 19.94 19.81
django 4.0.3 1002 59.00 66.26 63.72

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)
sanic 21.12.1 10777 6.97 7.67 5.90
blacksheep 1.2.5 10505 4.70 8.16 6.07
muffin 0.87.0 10319 4.79 8.41 6.17
falcon 3.0.1 10133 4.88 8.61 6.28
starlette 0.17.1 8135 6.03 10.76 7.83
emmett 2.4.5 7091 7.17 11.58 9.12
baize 0.15.0 6581 9.96 10.24 9.71
fastapi 0.75.0 5882 8.36 15.16 10.85
aiohttp 3.8.1 4496 14.15 14.32 14.24
tornado 6.1 2780 22.95 23.17 23.02
quart 0.16.3 2146 29.42 30.05 29.81
django 4.0.3 883 68.00 71.74 72.37

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)
blacksheep 1.2.5 5604 8.87 15.77 11.40
sanic 21.12.1 5025 10.44 16.83 12.72
muffin 0.87.0 4425 11.14 19.99 14.43
falcon 3.0.1 3433 14.56 25.48 18.73
baize 0.15.0 2834 21.89 24.48 22.57
starlette 0.17.1 2434 20.10 36.39 26.26
aiohttp 3.8.1 2218 28.81 29.09 28.84
fastapi 0.75.0 2099 23.61 41.91 30.44
tornado 6.1 2067 30.89 31.09 30.95
quart 0.16.3 1746 36.68 37.58 36.63
emmett 2.4.5 1414 41.83 50.86 45.21
django 4.0.3 689 86.45 89.44 92.51

Composite stats

Combined benchmarks results

Sorted by completed requests

Framework Requests completed Avg Latency 50% (ms) Avg Latency 75% (ms) Avg Latency (ms)
blacksheep 1.2.5 519825 5.46 9.49 6.96
sanic 21.12.1 470400 7.37 9.88 7.57
muffin 0.87.0 469725 6.34 11.19 8.14
falcon 3.0.1 436800 7.58 13.19 9.7
starlette 0.17.1 365490 9.94 17.77 12.9
baize 0.15.0 349425 11.85 13.64 12.29
emmett 2.4.5 328275 18.18 22.85 19.69
fastapi 0.75.0 255615 12.48 22.29 16.11
aiohttp 3.8.1 209310 17.23 17.47 17.31
tornado 6.1 121185 24.53 24.73 24.59
quart 0.16.3 109755 28.36 29.24 28.37
django 4.0.3 38610 71.15 75.81 76.2

Conclusion

Nothing here, just some measures for you.

License

Licensed under a MIT license (See LICENSE file)

More Repositories

1

pylama

Code audit tool for python.
Python
1,048
star
2

mixer

Mixer -- Is a fixtures replacement. Supported Django, Flask, SqlAlchemy and custom python objects.
Python
942
star
3

muffin

Muffin is a fast, simple and asyncronous web-framework for Python 3
Python
671
star
4

graphite-beacon

Simple alerting system for Graphite metrics
Python
453
star
5

django_markdown

Django markdown support and wysiwig
JavaScript
391
star
6

peewee_migrate

Simple migration engine for Peewee
Python
353
star
7

nvim-test

A Neovim wrapper for running tests
Lua
181
star
8

Flask-Foundation

Quick start with Flask
Python
154
star
9

nvim-config-local

Secure load local config files for neovim
Lua
150
star
10

aioauth-client

OAuth client for aiohttp
Python
141
star
11

atmark

Awk+Sed for humans
Python
69
star
12

python-scss

Python scss parser.
Python
67
star
13

dealer

Make some staff
Python
62
star
14

marshmallow-peewee

Peewee ORM integration with the marshmallow (de)serialization library.
Python
59
star
15

zeta-library

Css, scss, js parser and linker. Also framework for working with static files
Python
52
star
16

Flask-Collect

Collect static files in flask application
Python
49
star
17

makesite

makesite is a collection of scripts for deploying and managing web projects
Python
47
star
18

flask-pw

Peewee ORM integration for Flask framework
Python
45
star
19

peewee-aio

Async support for Peewee ORM
Python
45
star
20

adrest

Another django rest framework
Python
42
star
21

.vim

my vim settings
Vim Script
39
star
22

django-netauth

django auth backend
Python
36
star
23

asgi-tools

Tools to build ASGI apps
Python
35
star
24

pomodoro-tracker-locales

Language files
24
star
25

asgi-babel

Adds internationalization (i18n) support to ASGI applications (Asyncio/Trio)
Python
24
star
26

http-router

A simple router for HTTP applications
Python
24
star
27

rope-vim

Pathogen compatable ropevim plugin. Dont need install rope libs in system.
Python
21
star
28

bottle-peewee

Integrate Peewee ORM to Bottle framework
Python
19
star
29

muffin-admin

Admin interface for Muffin Framework
Python
18
star
30

mahjong.horneds.com

Riichi Mahjong Scores Trainer
CoffeeScript
18
star
31

flask-restler

Yet another REST library for Flask
Python
15
star
32

unite-radio.vim

Play radio stations in your VIM
Vim Script
15
star
33

aio-databases

Async Support for various databases
Python
14
star
34

django-gitrevision

Django git revision, simple add current git revision to request object for use in tempaltes and views.
Python
14
star
35

imgproxy

Python support for ImgProxy image processing server (https://imgproxy.net)
Python
14
star
36

pytest-aio

Is a simple pytest plugin for testing async python code
Python
12
star
37

klen.github.io

My github powered site.
HTML
12
star
38

muffin-rest

REST helpers for Muffin Framework
Python
12
star
39

aio-peewee

Tools to make Peewee work when using Asyncio
Python
11
star
40

muffin-jinja2

Jinja2 templates for Muffin framework
Python
11
star
41

donald

Make asyncio great again
Python
10
star
42

pypika-orm

Async ORM based on PyPika
Python
9
star
43

bottle-login

Implement users' sessions in Bottle framework
Python
9
star
44

asgi-prometheus

Support Prometheus metrics for ASGI applications
Python
9
star
45

muffin-peewee

Peewee integration to Muffin framework
Python
9
star
46

asgi-sessions

Signed Cookie-Based HTTP sessions for ASGI applications
Python
8
star
47

muffin-session

Session for Muffin Framework
Python
7
star
48

muffin-mongo

MongoDB support for Muffin framework
Python
7
star
49

starter

Create the skeleton for new projects.
Python
6
star
50

muffin-redis

Redis support for Muffin framework
Python
6
star
51

muffin-sentry

Sentry integration to Muffin Framework.
Python
5
star
52

pyserve

Serve local dirs (human version)
Python
5
star
53

muffin-example

Example Muffin application
Python
5
star
54

dotfiles

kk .dotfiles / use it for your own risks
Shell
4
star
55

bottle-jade

Provide Jade templates for Bottle framework
Python
4
star
56

django-gishelper

Useful commands for geodjango
Python
4
star
57

muffin-oauth

OAuth1/2 support for Muffin framework.
Python
4
star
58

muffin-databases

Async support for a range of databases for Muffin Framework
Python
4
star
59

knocker

A self contained service to make HTTP calls
Python
4
star
60

muffin-debugtoolbar

Debug Toolbar for Muffin applications
JavaScript
4
star
61

muffin-babel

Extension to Muffin that adds localization support with help of babel.
Python
3
star
62

inirama

Simple INI parser
Python
3
star
63

pylama_pylint

Pylint support for pylama.
Makefile
3
star
64

starlette-plugins

Create Starlette Plugins easier
Python
3
star
65

example_tornadio_project

Sources for http://klen.github.com/tornadio_socket-io-ru.html
Python
3
star
66

muffin-peewee-aio

Peewee integration to Muffin framework with async support
Python
2
star
67

redux-axios-reducers

Redux Reducers for Axios
CoffeeScript
2
star
68

pytest-redislite

Pytest plugin for testing code using Redi
Python
2
star
69

bottle-manage

Script manager for bottle framework.
Python
2
star
70

muffin-grpc

GRPC Support for Muffin Framework
Python
2
star
71

fquest

ZeroQuest lazy RPG. Moscow Facebook Hackday.
Python
2
star
72

aio-apiclient

Simple Asyncio Client for any HTTP APIs
Python
2
star
73

muffin-jade

Jade templates for Muffin Framework
Python
2
star
74

signalbus

Simple and small library to broadcast signals with typing support
Python
2
star
75

muffin-metrics

Send application metrics to Graphite
Python
2
star
76

hvim

Haskell mode for vim
Vim Script
2
star
77

Flask-jsonrpc-example

Some flask experements
Python
2
star
78

starlette-views

A helper to make views faster with Starlette
Python
2
star
79

hydrogenjs

Simple MVC system for atomjs
JavaScript
1
star
80

simpletree

Fastest and simplest tree implementations for Django
Python
1
star
81

filler

Simple game on javascript and canvas.
JavaScript
1
star
82

modconfig

Simple hierarchic configuration manager for apps
Python
1
star
83

sailplay

Python client for API sailplay.ru
Python
1
star
84

zeta-libs

Frameworks repo for zetalibrary
JavaScript
1
star
85

redux-code

Yet another creators library
TypeScript
1
star
86

tweetchi

Python
1
star
87

muffin-prometheus

Prometheus metrics exporter for Muffin framework
Python
1
star
88

fl

Forbidden lands russian generator
TypeScript
1
star