I created an http api using aipstar, why the test results using ab show so slow


#1

this code :

from apistar import ASyncApp, Route

async def hello_world() -> dict:
    return {'hello': 'async'}

routes = [
    Route('/', method='GET', handler=hello_world)
]

app = ASyncApp(routes=routes)

if __name__ == "__main__":
    app.serve('127.0.0.1', 6060, debug=True)

and i use ab -n 1000 -c 1000 -r 127.0.0.1:6060/,
The result is about 1000 requests per second.
Why is it so slow, is there any way to improve it? I see that the CPU usage is very low. What can improve the usage rate of the CPU to improve the speed?


#2

The built in server is for development, checkout https://docs.apistar.com/api-guide/deployment/ i guess that will give you a bit more performance