I have a python web application to return some data from a DB. But when I have 100 concurrent users, it gets much slower. First, I thought it's the DB issue. But everything works fine on the DB. So I removed all the DB related code. It's just an aiohttp service by itself.
import asyncio
import asyncpg
from aiohttp import web
import os
import logging
import sys
import time
async def handle(request):
return web.Response(text="hi")
async def init_app():
"""Initialize the application server."""
app = web.Application()
# Configure service routes
app.router.add_route('GET', '/', handle)
return app
logging.basicConfig(
level=logging.DEBUG,
format='%(levelname)7s: %(message)s',
stream=sys.stderr,
)
LOG = logging.getLogger('')
loop = asyncio.get_event_loop()
app = loop.run_until_complete(init_app())
web.run_app(app)
Now, if I run one user, the response time is 2ms. But if I put 100 users, the response time 295 ms. Is this the nature of the aiohttp?