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

A single OkHttpClient instance should be shared across requests #92

Open
bkoehm opened this issue Feb 7, 2025 · 0 comments
Open

A single OkHttpClient instance should be shared across requests #92

bkoehm opened this issue Feb 7, 2025 · 0 comments

Comments

@bkoehm
Copy link

bkoehm commented Feb 7, 2025

com.duosecurity.client.Http is a per-request object and it is instantiating a new OkHttpClient instance in its constructor. OkHttpClient should be shared across all requests rather than a new instance created for each request.

From the OkHttpClient documentation:

OkHttpClients Should Be Shared

OkHttp performs best when you create a single OkHttpClient instance and reuse it for all of your HTTP calls. This is because each client holds its own connection pool and thread pools. Reusing connections and threads reduces latency and saves memory. Conversely, creating a client for each request wastes resources on idle pools.

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

No branches or pull requests

1 participant