Skip to content

perf(apps): vendor fastapi without the [standard] extra - #727

Open
deanq wants to merge 1 commit into
mainfrom
deanq/sls-1045-vendor-fastapi-no-standard
Open

deanq wants to merge 1 commit into
mainfrom
deanq/sls-1045-vendor-fastapi-no-standard

Conversation

@deanq

@deanq deanq commented Nov 13, 2026

Copy link
Copy Markdown
Member

What

Vendor plain fastapi for the API runtime instead of fastapi[standard]:

API_RUNTIME_REQUIREMENTS = ("fastapi", "uvicorn>=0.30")

Why

Every app with a load-balanced resource vendored fastapi[standard], giving a 5,937-file / 31.9 MB artifact (pygments, opentelemetry, sentry_sdk, google, dns, fastapi_cloud_cli). The runtime only imports fastapi and uvicorn, and the [standard] extras are already present in the API images through sdk-runtime's own dependency. uvicorn still finds uvloop and httptools in the image's site-packages, because the vendored env is placed ahead of the image packages, not instead of them.

Measured

Metric main candidate
Artifact size 31.9 MB 14.2 MB
QB GPU cold unpack 2,650 ms 900 ms
QB GPU container start to SDK ready 4,745 ms 3,369 ms
LB GPU cold unpack 1,750 ms 500 ms

Test plan

  • test_api_runtime_vendors_fastapi_without_the_standard_extra.
  • make quality-check: 3458 passed, 7 skipped.

Risks

  • User code that relied on fastapi[standard] extras being vendored (for example python-multipart for forms) still gets them from the built-in API images. Custom images install runpod-sdk-runtime, which depends on fastapi[standard] itself.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the change to vendor plain FastAPI while retaining Uvicorn.

No open issues 🎉

What changed in this PR

This PR reduces API worker artifact size and cold-start overhead by vendoring plain fastapi instead of fastapi[standard], while retaining uvicorn>=0.30.

Changes:

  • Removes FastAPI’s standard extras from vendored API runtime requirements and documents reliance on API images for optional dependencies.
  • Adds a regression test confirming that plain FastAPI and Uvicorn are requested without FastAPI extras.
File Description
tests/​test_apps/​test_build.py Adds coverage for API runtime vendoring requirements.
runpod/​apps/​build.py Removes the FastAPI standard extra and explains the dependency choice.

Review effort: Balanced

@deanq
deanq requested review from KAJdev and justinwlin November 14, 2026 03:47

This branch has not been deployed

No deployments
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.

2 participants