According to this benchmark (https://github.com/the-benchmarker/web-frameworks), Sanic has lower performance in every aspect than Flask. Is it true? or Is there other reasons? If it’s true, I wonder what is the advantage of using Sanic rather than Flask.
That benchmark is a bit flawed. At some point I plan to make another PR to fix the issue. The problem is two-fold.
- It does not use production ready best practices. Leaving
access_log=True
can have a large performance hit. It is generally better to do something like this outside Sanic with a reverse proxy, likenginx
. - It uses
gunicorn
for running the tests. While it is a viable option for deployment, it is not as fast as using either (a) Sanic’s native webserver or (b) an ASGI enabled webserver. Since Sanic’s speed comes fromasyncio
, you need to be able to access those benefits from the server.
1 Like
Does it mean even if I set worker_class = 'sanic.worker.GunicornWorker'
the gunicorn won’t use asyncio
?
Can I consider the 'sanic.worker.GunicornWorker'
as some compatibilities?
Thanks for the comment. the benchmark is surely flawed and must be fixed ASAP, because Sanic promotes itself with speed (go fast).