Skip to main content
ProductsDesktop toolsTASTECADDrawing reviewTASTEFILESFile managementTASTEFTPFile transferTASTESSHRemote workspaceTASTEZIPCompression and extractionTASTEWINMFile managementDeveloper toolsTASTECODERust integrated development environmentTASTESTUDIOIntegrated development and test environmentTASTEETLData integration (ETL)ServersTASTEREMOTERemote desktop serverTASTEGEOGeospatial serverTASTEMAILMail workspaceInvestingTASTESTOCKStock auto-trading desktop appGet startedDownloadsDocumentationBuyAll products
Marketplace
News
TechNewsToday's dev newsDeveloper docsProgramming languagesRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartWeb front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngularServer frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressApp & desktop frameworksTauriFlutterReact NativeElectronAlgorithmsAlgorithm basicsCore algorithmsAdvanced algorithmsPractical algorithms
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcaseCommunity guide
Work with usTech transferWebsite buildDesktop app buildRelease and payment pipelineSales partnerContact
ServicesRemote desktopCustom installer packages
TASTEDEV
Products

Desktop tools

TASTECADComplex drawings, opened with easeTASTEFILESJust the files you need, as fast as possibleTASTEFTPThe tidiest path for your filesTASTESSHA stronger link between you and your serversTASTEZIPPack faster, unpack saferTASTEWINMA keyboard-first file manager with two panes

Developer tools

TASTECODEEdit, build, debug and test Rust apps in one windowTASTESTUDIOFrom editing to remote tests and approved AI fixesTASTEETLMove data while you watch the values

Servers

TASTEREMOTEA remote desktop you run on your own serverTASTEGEORebuilding a GeoServer-compatible geospatial server in RustTASTEMAILTake back control of your email

Investing

TASTESTOCKStock auto-trading that follows the rules you set: when, and what

Get started

DownloadsLatest builds of every productDocsHow to use each productBuySubscriptions and perpetual licencesAll productsEvery product at a glance
All products
MarketplaceNews
Tech

News

Today's dev newsOfficial announcements on languages, frameworks, GitHub and AIDeveloper docsGuides to languages, frameworks and algorithms

Programming languages

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Web front-end frameworksNext.jsReactVue.js · NuxtSvelteKitAngular
Server frameworksSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
App & desktop frameworksTauriFlutterReact NativeElectron

Algorithms

Algorithm basicsComplexity analysis · Sorting · Searching · Basic data structures · Trees and heapsCore algorithmsGraph traversal · Shortest paths & minimum spanning trees · Dynamic programming · Greedy algorithms · Divide and conquer · BacktrackingAdvanced algorithmsString algorithms · Math and number theory · Bit manipulation · Segment trees · Union-findPractical algorithmsCoding interview strategy · LRU cache · Rate limiting · Consistent hashing
All development docs
Community
ProjectsDiscover builders and their workDevelopment logsDecisions and lessons learnedPromptsReusable instructionsAI tool issuesProblems and workarounds for Claude, Codex, GeminiShowcaseFinished resultsCommunity guideHow we build in the open
Work with us
Tech transferNative apps in Rust and eguiWebsite build10 languages, accounts, docs and downloadsDesktop app buildRust and egui, no WebViewRelease and payment pipelineSigning, MSI, deb, rpm, AppImage, hashesSales partnerRecommend us and earn 30%ContactBuilds, partnerships and investment
Services
Remote desktopReach your computer from a browserCustom installer packagesOnly the features you need, settings preloaded
Buy
EN
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Log in
Log in
TASTEDEV

From small tools to better development.

support@tastedev.netSupport TASTEDEV
ProductsProduct lineupBuyDocsDownloadsMarketplaceSupport
CommunityProjectsDevelopment logsPromptsAI tool issuesShowcase
PoliciesAbout usPrivacy policyTerms of serviceSubscription termsRefund policyCommunity guidelines
AccountLog inSign up
Visitors
Today
Yesterday
Total views
Company
GXSOFT
Representative
CHOI YOUNG GU
Business registration number
853-44-00368
Address
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Phone
+82-10-4404-1523
Email
whitecalvin@tastedev.net
Privacy officer
CHOI YOUNG GU

© 2026 TASTEDEVProduct information is based on verified development sources.Released · improving

FastAPI docs
FastAPI
Getting Started with FastAPIProject StructureCore ConceptsData and StateTestingDeployment
Discussions

FastAPI guide · 6/6

Deployment

A FastAPI application has no build step: you deploy it by running it on an ASGI server. This chapter covers running a production server with fastapi run and Uvicorn, choosing the number of worker processes, building a container image, and what to watch for behind a reverse proxy.

Running in production with fastapi run

fastapi dev is for development; in production, use fastapi run. It turns off auto-reload and by default listens on port 8000 on all network interfaces (0.0.0.0).

# a single process
fastapi run app/main.py

# another port, with four worker processes
fastapi run app/main.py --port 80 --workers 4

fastapi run uses Uvicorn under the hood. Running Uvicorn yourself gives the same result; in that case you point it at the app as module:variable instead of a file path.

uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4

Workers and process management

A single Python process effectively uses one CPU core, so to use several cores you start several processes with --workers. Start around the number of cores and tune with load testing. Each worker has its own memory, so keep an eye on memory use if your app loads large models.

If you deploy straight onto a server, use a process manager such as systemd so the app restarts after a reboot or a crash. On platforms like Kubernetes, where the cluster manages how many containers run, the usual approach is a single process per container and scaling by adding replicas.

Building a container image

Containers let you reproduce the runtime environment exactly. The approach recommended in the official docs starts from the official Python image, installs dependencies first and copies the code afterwards, so that changing only the code reuses the cached dependency layer.

FROM python:3-slim

WORKDIR /code

COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt

COPY ./app /code/app

CMD ["fastapi", "run", "app/main.py", "--port", "80"]

In a real project, pin the image tag to the same Python version you develop with. Write CMD in the exec (array) form shown above so that stop signals reach the app and your lifespan cleanup code actually runs.

docker build -t hello-fastapi .
docker run -d --name hello -p 8000:80 --env-file .env hello-fastapi

Keep .env out of the image and supply it at run time with --env-file or your platform's secrets feature. Listing .venv, .env and __pycache__ in .dockerignore keeps the image small.

Behind a reverse proxy

In production, a reverse proxy such as Nginx, Traefik or a cloud load balancer usually terminates HTTPS and forwards requests to the app. So the app can see the original client address and the https scheme, the proxy adds X-Forwarded-* headers, and the app server accepts those headers only from proxies it trusts.

server {
    listen 443 ssl;
    server_name api.example.com;

    location / {
        proxy_pass http://127.0.0.1:8000;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}
uvicorn app.main:app --host 127.0.0.1 --port 8000 --proxy-headers --forwarded-allow-ips="127.0.0.1"

If the proxy serves the app under a path prefix such as /api, tell FastAPI with FastAPI(root_path="/api") or the --root-path /api option so that /docs and generated links use the right URLs.

Pre-deployment checklist

  • Never use fastapi dev or --reload in production.
  • Pass secrets as environment variables; keep them out of the repository and the image.
  • Apply database schema changes with a migration tool such as Alembic.
  • For non-public APIs, you can turn off the docs UI with FastAPI(docs_url=None, redoc_url=None).
  • Expose a health check endpoint such as /health for load balancers and orchestrators.

Summary

  • Run production servers with fastapi run or uvicorn, and set the process count with --workers.
  • Build container images that install dependencies before copying code, to make the most of the cache.
  • Behind a reverse proxy, configure proxy headers and root_path correctly.

For more detail, see the official documentation:

  • FastAPI Deployment
  • FastAPI in Containers - Docker
  • Behind a Proxy
  • Uvicorn Deployment
  • FastAPI documentation
Questions about this chapter?
Previous chapterTesting

0 comments

Top commentsNewest first

Sign in · Sign in to leave a comment.