Skip to content

A single OkHttpClient instance should be shared across requests #92

@bkoehm

Description

@bkoehm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions