Skip to content

Use uvicorn --factory for fast_web β€” save ~100MB of RAM - #13404

Merged
cdrini merged 2 commits into
masterfrom
factory/fastapi-reloader-memory
Aug 25, 2026
Merged

Use uvicorn --factory for fast_web β€” save ~100MB of RAM#13404
cdrini merged 2 commits into
masterfrom
factory/fastapi-reloader-memory

Conversation

@RayBB

@RayBB RayBB commented Aug 23, 2026

Copy link
Copy Markdown
Collaborator

fast_web with --reload was importing the app in both parent and worker (172MB + 171MB).

Switch to factory uvicorn --factory openlibrary.asgi_app:create_app per https://fastapi.tiangolo.com/deployment/ and https://uvicorn.dev/#application-factories. Remove app = create_app() from openlibrary/asgi_app.py, update docker/ol-web-fastapi-start.sh (prod now openlibrary.asgi_app:create_app()).

Saves ~100MB overall, no compose changes.

fast_web with --reload was importing the whole app in both parent
and worker (172MB + 171MB). Switch to factory
uvicorn --factory openlibrary.asgi_app:create_app per
https://fastapi.tiangolo.com/deployment/ and
https://uvicorn.dev/#application-factories

Remove app = create_app() from openlibrary/asgi_app.py, update
docker/ol-web-fastapi-start.sh (prod now
openlibrary.asgi_app:create_app()). Saves ~100MB overall, no
compose changes.
Comment thread docker/ol-web-fastapi-start.sh Outdated
Co-authored-by: Drini Cami <cdrini@gmail.com>
@RayBB
RayBB requested a review from cdrini August 25, 2026 01:50
@cdrini cdrini changed the title Use uvicorn --factory for fast_web β€” save ~100MB Use uvicorn --factory for fast_web β€” save ~100MB of RAM Aug 25, 2026

@cdrini cdrini left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Lgtm! Confirmed working smoothly on testing. Woohoo less RAM! πŸ₯³

@cdrini
cdrini merged commit 90316e7 into master Aug 25, 2026
9 checks passed
@cdrini
cdrini deleted the factory/fastapi-reloader-memory branch August 25, 2026 01:54
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