You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unclear how to use the new AsyncClient at scale - memory leaks or timeouts #874
As a result, its not clear how to use the new library at scale. It seems like the optimal solution would be to manage a pool of AsyncClients and scale them up/down as QPS goes up/down. Looking for suggestions/advice on how to handle this. Thanks!
To Reproduce
Use this as the client:
def get_openai_client() -> AsyncOpenAI:
if not hasattr(get_openai_client, "client"):
get_openai_client.client = AsyncOpenAI(
api_key="...",
)
return get_openai_client.client
And then send a bunch of requests/see timeouts.
Code snippets
No response
OS
Linux
Python version
3.11
Library version
1.3.4
Reacted by Joseph Zhang, Brian Goo and Karim Iskakov
Activity
rattrayalex commentedon Nov 23, 2023
I recommend instantiating the client once, using expanded connection pool limits, like those suggested here: #821 (comment)
For example:
Details: https://www.python-httpx.org/advanced/#pool-limit-configuration
richardknudsen commentedon Feb 7, 2024
@rattrayalex for any other future readers that may stumble over the following as well:
Shouldn't it be
httpx.AsyncClientinstead ofhttpx.Client?feat(api): updates (#874)
feat(api): updates (#874)