Created
March 30, 2018 16:13
-
-
Save asvetlov/13295efdc1301bea241d7d35496e6f81 to your computer and use it in GitHub Desktop.
Simple aiohttp performance check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stop `run_server.sh` after wrk has finished, install snakeviz (`pip install snakeviz`) and run it | |
`snakeviz out.prof` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run with python3 simple_server.py PORT | |
from aiohttp import web | |
import asyncio | |
import sys | |
import uvloop | |
import logging | |
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) | |
async def handle(request): | |
return web.Response(body=b'OK') | |
app = web.Application() | |
app.add_routes([web.get('/', handle)]) | |
logging.basicConfig(level=logging.DEBUG) | |
web.run_app(app, port=sys.argv[1], access_log=None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python -m cProfile -o out.prof run_aiohttp.py 8080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wrk -t 10 http://localhost:8080 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment