Skip to content
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

Support sharing connection pools between users #2059

Merged
merged 4 commits into from
Mar 28, 2022

Conversation

miedzinski
Copy link
Contributor

This PR adds support for sharing connection pools between users. It is done by exposing lower level pool (urllib3.PoolManager for HttpUser, geventhttpclient.client.HTTPClientPool for FastHttpUser).

Example usage:

from geventhttpclient.client import HTTPClientPool
from locust import FastHttpUser, HttpUser
from urllib3 import PoolManager


# Both users will be limited to 10 concurrent connections at most.

class UserA(HttpUser):
    pool_manager = PoolManager(maxsize=10, block=True)


class UserB(FastHttpUser):
    client_pool = HTTPClientPool(concurrency=10)

Fixes #1925.

@cyberw
Copy link
Collaborator

cyberw commented Mar 27, 2022

Cool stuff. A few test cases would be nice, ideally one that actually verifies somehow that connections are really pooled. And we’d need to add it to the docs somewhere.

@miedzinski
Copy link
Contributor Author

@cyberw PTAL.

I have no idea why mypy reported that error, because I didn't touch HttpSession.request_name, but adding a type hint fixed it.

@miedzinski
Copy link
Contributor Author

Now black is failing due to psf/black#2964.

@cyberw cyberw merged commit 6ca2724 into locustio:master Mar 28, 2022
@cyberw
Copy link
Collaborator

cyberw commented Mar 28, 2022

Thx! I think merging will get us the fix needed for >3.6 builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make each virtual user to share same connections
2 participants