Skip to content

bug: httpx.AsyncClient created per-request in server-https/app.py #75

Closed as not planned

Description

@GunaPalanivel

Context

server-https/app.py (line 202) creates a new httpx.AsyncClient on every incoming request rather than reusing a shared instance.

Problem

Every request opens a new connection pool and tears it down — redundant TLS handshakes, file descriptor churn, no benefit from HTTP keep-alive. Under any real load this becomes measurable overhead and can exhaust fd limits.

Why This Order

Same file as the CORS fix (#76) and replacing the linear query flow in server-https/app.py. Fix the client lifecycle first so subsequent changes don't build on top of the broken pattern.

Acceptance Criteria

  • A single httpx.AsyncClient is created at app startup via FastAPI lifespan
  • All route handlers reuse it via request.app.state
  • Client is properly closed on shutdown — no ResourceWarning in tests

Related

Activity

  1. chasecadet commented on Nov 20, 2026

    @chasecadet
    Contributor

    Thank you for reporting this!

    We are closing pre-restructure issues targeting the legacy server/, server-https/, manifests/, kagent-feast-mcp/, or in-process SentenceTransformer prototype code. In #207, #210, #233, #240, and #249, kubeflow/docs-agent migrated to dedicated TEI (text-embeddings-inference), FastMCP (docs-agent-mcp/mcp-server/), shared modular KFP pipelines (docs-agent-mcp/pipelines/), and Helm charts (docs-agent-mcp/charts/).

    If you still observe an equivalent issue on the current main stack, please feel free to open a new issue using the current issue templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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