Skip to content

fix: Fixed the issue where a “reqwuest” client was being created with…#70

Merged
ttatsato merged 1 commit into
mainfrom
64-perf-reuse-a-shared-reqwestclient-across-proxy-requests
Apr 24, 2026
Merged

fix: Fixed the issue where a “reqwuest” client was being created with…#70
ttatsato merged 1 commit into
mainfrom
64-perf-reuse-a-shared-reqwestclient-across-proxy-requests

Conversation

@ttatsato

@ttatsato ttatsato commented Apr 24, 2026

Copy link
Copy Markdown
Owner

Summary / 概要

サーバー起動時にreqwest::Clientを一つだけ作る。
そのClientを引数でcreate_routerに渡す。
AxumのStateけいゆでproxyハンドラに配る

Background / 背景 *

reqwest::Client は内部にコネクションプールを持っていて、一度開いた TCP/TLS 接続をプールに保持しておき、次のリクエストで再利用する(= HTTPkeep-alive)仕組みになっています。

  • 修正前: 毎リクエストで Client を新規作成 → プールが毎回空 →上流への接続を毎回張り直す(TCP ハンドシェイク、HTTPS なら TLSハンドシェイクも毎回発生)
  • 修正後: 1 つの Client を全リクエストで共有 → プールに接続が溜まる → 2 回目以降は既存接続を使い回せる

Issue (or Discussion) Link / イシューまたはディスカッションのリンク

#64

Impact / 影響範囲

Changes / 変更内容

Testing / テスト*

  • cargo fmt && cargo clippy pass with no warnings

Checklist / セルフチェックリスト

  • Updated relevant documentation (Wiki, comments, etc.) / 関連するドキュメント(Wikiやコメント)を更新した

Screenshots or Video / スクリーンショット・動画

Notes / 備考

@ttatsato ttatsato linked an issue Apr 24, 2026 that may be closed by this pull request
@ttatsato ttatsato merged commit def3254 into main Apr 24, 2026
3 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: reuse a shared reqwest::Client across proxy requests

1 participant