-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Hi,
I have a problem with my application since aiohttp 0.22. The application makes a lot of requests to an external REST API. It uses the aiohttp basic API and it suffers from significant slow down as the asyncio event loop gets flooded with cookie expiration timers. I know that the basic API is not effective in general as it creates a new session for every request. However, it makes no difference in my case. The external server closes connection after every request so there are no keep-alive connections and the basic API is much more comfortable in this case.
The CookieJar sets up a new expiration timer on every cookie update. In request-heavy applications, it leads to flooding the asyncio event loop with timer tasks effectively slowing down the whole process.
In my opinion, the expiration timers should be canceled on updates of existing cookies and replaced with new ones. In case of the basic API, the default CookieJar should be replaced with a dummy one to avoid scheduling the timers at all. No cookie storage is needed in case of the basic API.
Moreover, the CookieJar implementation does not need to use the timers at all. You can simply remove expired cookies when you access them.