-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cold start issue within the infra with limited resource #3415
Comments
I have no idea why is you box so slow. Numbers are 10 times different from yours 4-8 sec. |
I provided exact constraints for the docker container that are considered to be bare minimum requirements for the UDS servers written with various programming languages to start: Your laptop is definitely not the best device to debug this issue, definitely. |
Have you a concrete proposal for improvement? |
@denismakogon I suggest stating what is being imported. I wouldn't import |
I’m not doing thing like |
Looking at numbers from tables above I see that the import of asyncio itself is 2.8 secs from the first table and 1.5 sec from the second. |
The difference between table one and table two is in a number of imports from the asyncio, that’s why you see the difference. |
All related routine to an aiohttp is here (master branch): https://github.com/fnproject/fdk-python/blob/master/fdk/http_stream.py#L90-L159 And here's the code that i plan to use as a substitution on aiohttp: https://github.com/fnproject/fdk-python/blob/performance/fdk/http_stream.py#L66-L115 I can provide steps to reproduce including code samples of this lib with dockerfiles, so you can build and see the numbers by yourself. So, @asvetlov you asked me about the solution here. Well, the best we can do is to actually extract HTTP core API to a library that would be a native asyncio-based http framework which is very similar to SimpleHTTP server (https://docs.python.org/3/library/http.server.html) and make aiohttp be based on it. Like if you need a simple concurrent asyncio HTTP server - use lib, if you'd like to go to production lots of nifty features - go with aiohttp. |
If you've found a solution that satisfies all your needs -- that's fine. Closing the issue. |
interesting that |
Long story short
I've been working on a UDS HTTP server and found that aiohttp has pretty sane API to make it work.
However, with some testing being done I've found out that aiohttp has a problem of the cold start. Within the constraint-bound infrastructure, imagine a docker container with the following resources:
aiohttp UDS HTTP server consumes unfortunate amount of time for the cold start, here's the statistics of the imports from Python 3.7 with
PYTHONPROFILEIMPORTTIME=1
:As you may see, aiohttp takes at least 8 seconds to start, which is not quite expected. The validation system that ensures that a UDS server is up and running expects it to become active within 2-4 seconds at maximum within given constraints, but aiohttp takes at least 8 seconds to start.
The thing is, if I would use native tools like asyncio with some custom HTTP routine, i can speed up cold start up to 1.8 seconds:
Expected behaviour
cold start shouldn't be a problem to aiohttp
Actual behaviour
cold start within the given constraints is a huge problem to aiohttp
Steps to reproduce
A library that uses aiohttp is in OSS, https://github.com/fnproject/fdk-python.
Feel free to reach out me for more details and code spinnets.
Your environment
Python 3.7.1
Docker (latest)
Linux Alpine, Debian Stretch
The text was updated successfully, but these errors were encountered: