3 ms·
BTW being ASGI is not excuse because ASGI spec (PEP 3333) have a section on how to expose and make use of sendfile kernel routine. https://peps.python.org/pep-
by alsadi 4y ago
BTW being ASGI is not excuse because ASGI spec (PEP 3333) have a section on how to expose and make use of sendfile kernel routine.
https://peps.python.org/pep-3333/#optional-platform-specific-file-handling https://peps.python.org/pep-3333/#optional-platform-specific...
- kkirsche 4y agoYou’re correct, sort of. But you’re not testing JUST FastAPI’s performance, you’re also testing Uvicorn’s. For them to be equivalent tests, both need the same run patterns. It’s closer to comparing Flask running as a script with flask running behind gunicorn as written and as I read it. And no, I’m not going to fix your benchmarks for you. This does not provide any value to me but does come at a time cost. I appreciate you raising the issue and performing research on it, that’s valuable and I applaud you for that. I simply don’t believe that this is a valid benchmark from a technical soundness perspective.
- alsadi 4y agoAs I pointed out in my other comment, serving a static file should be a single call to a kernel routine called sendfile (sendfile in c or in python io.sendfile or loop.sendfile). No loop, no memory copy, no further context switch. Again if you think I was not fair to fastapi, suggest a change to the fastapi part. Do not cripple the competing solution. If you want believe the time is wasted by the introduction of uvicorn layer as opposed to pure python implementation, I can run the fastapi in pure python ASGI without that layer, it would be worse. Because you uvicorn is one of the best implements.
- alsadi 4y agohere I've eliminated uvicorn, nothing changed https://gist.github.com/muayyad-alsadi/3a1e1cdbafca34df8b17810a09805faf https://gist.github.com/muayyad-alsadi/3a1e1cdbafca34df8b178...