-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
question #2992
Comments
And if I use those three request in a loop and will be executed for many times, would it be better to create 3 ClientSession first, and use them for 3 different hosts or just create one ClientSession and use it for those 3 hosts. |
Client session shared cookies and uses a connection pool under the hood. Consider it as a browser window. How many open windows do you have? |
@asvetlov "So if you’re making several requests to the same host, the underlying TCP connection will be reused, which can result in a significant performance increase (see HTTP persistent connection)." |
Yes, this is a working plan |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs. |
I have several different requests on different urls, like google.com, facebook.com, twitter.com. Should I just use one aiohttp.ClientSession for 3 requests or I use 'async with' to create 3 new different ClientSession and then close it at once? Because I wonder if the aiohttp.ClientSession is like the requests.Session, which should be used for the same host according to the doc.
"The Session object allows you to persist certain parameters across requests. It also persists cookies across all requests made from the Session instance, and will use urllib3’s connection pooling. So if you’re making several requests to the same host, the underlying TCP connection will be reused, which can result in a significant performance increase (see HTTP persistent connection)."
The text was updated successfully, but these errors were encountered: