Skip to content

perf(http): reuse one reqwest Client instead of building one per request#303

Open
allamiro wants to merge 1 commit into
lixmal:masterfrom
allamiro:fix/reuse-http-client
Open

perf(http): reuse one reqwest Client instead of building one per request#303
allamiro wants to merge 1 commit into
lixmal:masterfrom
allamiro:fix/reuse-http-client

Conversation

@allamiro

@allamiro allamiro commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #285.

Problem

Http::get_request built a fresh reqwest::Client (its own connection pool and TLS state) for every single request, so nothing was ever reused.

Change

The client is created once in Http::new and stored in the struct; get_request borrows it. Client::new() panics only on TLS backend initialization failure — same failure mode as before, just at construction.

Testing

cargo test: 9/9 pass (the mockito-based HTTP backend tests cover read/write paths).


Summary by cubic

Reuse a single reqwest::Client across all HTTP calls to enable connection pooling and TLS session reuse, reducing per-request overhead. The client is now created once in Http::new and reused by get_request (same TLS init failure behavior, now at construction).

Written for commit 2744614. Summary will update on new commits.

Review in cubic

A new Client was constructed for every request, defeating connection
pooling and TLS session reuse. The client is now created once in
Http::new.
@allamiro allamiro force-pushed the fix/reuse-http-client branch from 2744614 to bfdd11c Compare June 13, 2026 00:17
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.

HTTP db backend builds a new reqwest Client per request

1 participant