[{"data":1,"prerenderedAt":117},["ShallowReactive",2],{"seo-verification":3,"blog-deployer-fastapi-vps-en":6},{"google":4,"bing":5},"EycwPY2XMyTkVzas3n1ygeNJFGAH513qrMjfDljzsMQ","",{"id":7,"slug":8,"title":9,"excerpt":10,"readTime":11,"views":12,"isPinned":13,"publishedAt":14,"category":15,"categories":21,"featuredImage":23,"bgImage":24,"posterImage":25,"relatedSolution":26,"intro":28,"sections":29,"ctaTitle":72,"ctaBody":73,"ctaButton":74,"ctaUrl":75,"relatedPosts":76},45,"deployer-fastapi-vps","Deploy a FastAPI Application on a VPS","Deploy FastAPI on a VPS with Uvicorn, Gunicorn, Nginx, and SSL. A guide for Python developers who want a self-hosted async API.",7,665,false,"2026-05-06T00:00:00+00:00",{"id":16,"name":17,"slug":18,"color":19,"icon":20},4,"Development","developpement","bg-warning\u002F10 text-warning","dev",[22],{"id":16,"name":17,"slug":18,"color":19,"icon":20},null,"\u002Fblog\u002Fcovers\u002Fbg.svg","\u002Fblog\u002Fcovers\u002Fdeployer-fastapi-vps-poster.svg",{"categorySlug":18,"appSlug":27},"fastapi","FastAPI has established itself as the Python framework of choice for fast, typed APIs, thanks to its native support for async and OpenAPI documentation. Deploying it on your own VPS gives you control over the number of workers, WebSocket, and latency, with no ceiling imposed by a managed service.",[30,34,44,47,69],{"type":31,"title":32,"body":33},"h2","Why Self-Host FastAPI on a VPS?","FastAPI draws all its performance from the asynchronous ASGI model: persistent WebSocket connections, response streaming, and concurrent calls to other services. Serverless platforms often cut long-lived connections and bill every request, which penalizes a high-throughput or real-time API. On a VPS, you run Uvicorn driven by Gunicorn with as many workers as cores, you keep connections open as long as needed, and you place Nginx at the front for TLS and buffering. You also control the connection pool to PostgreSQL and the Redis cache, two essential levers for handling thousands of requests per second.",{"type":35,"title":36,"items":37},"ul","Concrete Benefits of a Self-Hosted FastAPI",[38,39,40,41,42,43],"WebSockets and Server-Sent Events with no dropped connections or imposed timeout.","Fine-tuning of Uvicorn\u002FGunicorn workers according to the VPS's number of cores.","Low, predictable latency, without the serverless cold start.","Swagger and ReDoc documentation served internally, accessible or protected as you wish.","Direct integration with an asynchronous PostgreSQL pool (asyncpg) and Redis.","Fixed cost regardless of the number of API calls, ideal for a production backend.",{"type":31,"title":45,"body":46},"Hardware and Software Prerequisites","A FastAPI API is lightweight: 1 vCPU and 1 GB of RAM are enough to start, but aim for 2 vCPU and 2 GB as soon as you add a database and a cache on the same VPS. Install Python 3.11+ or use Docker with a `python:3.11-slim` image. Plan for Uvicorn with the `uvicorn.workers.UvicornWorker` worker, Gunicorn as the process manager, and Nginx for the reverse proxy. A domain pointed to the VPS is required for the TLS certificate. Ubuntu 22.04\u002F24.04 LTS is the recommended base.",{"type":48,"title":49,"steps":50},"steps","Deploy FastAPI Step by Step",[51,54,57,60,63,66],{"title":52,"body":53},"Initialize the VPS and the Application","Connect via SSH, install Docker, clone your repository, and create a `.env` with the environment variables (database URL, API keys, CORS origin). Make sure your entry point does expose `app = FastAPI()`.",{"title":55,"body":56},"Containerize with Uvicorn and Gunicorn","In the Dockerfile, install the dependencies, then run `gunicorn main:app -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 --workers 4`. The ideal number of workers is generally `(2 × cœurs) + 1`.",{"title":58,"body":59},"Orchestrate the Services","In `docker-compose.yml`, declare the `api` service, a PostgreSQL `db` service, and a `redis` service. Use `depends_on` and a healthcheck so that the API waits for the database to be ready before starting.",{"title":61,"body":62},"Place Nginx as a Reverse Proxy","Configure a server block with `proxy_pass http:\u002F\u002Fapi:8000` and, for WebSockets, add `proxy_set_header Upgrade $http_upgrade` and `proxy_set_header Connection \"upgrade\"`. Disable buffering for streaming if needed.",{"title":64,"body":65},"Secure with a TLS Certificate","Obtain a Let's Encrypt certificate via Certbot or a companion container, force HTTPS, and redirect HTTP. Remember to restrict access to `\u002Fdocs` and `\u002Fopenapi.json` in production if the API is not public.",{"title":67,"body":68},"Launch and Test","Start with `docker compose up -d`, check health via the `\u002Fhealth` endpoint you added, and test the interactive documentation. Monitor the Uvicorn logs to adjust the number of workers under real load.",{"type":70,"body":71},"tip","For long-running tasks (sending emails, image processing, slow external calls), do not block the event loop: offload them to a background worker with `BackgroundTasks` for simple cases, or to Celery\u002FARQ with Redis for heavy processing. An API that responds quickly and delegates asynchronous work stays responsive even under high concurrency.","Put Your FastAPI API into Production","The ServOrbit Cloud VPS offers a ready-to-use Docker template with Nginx, automatic SSL, and everything needed to host a high-performance, asynchronous FastAPI API.","Deploy My FastAPI VPS","\u002Fvps-cloud",[77,90,104],{"id":78,"slug":79,"title":80,"excerpt":81,"readTime":11,"views":82,"isPinned":13,"publishedAt":83,"category":84,"categories":85,"featuredImage":23,"bgImage":24,"posterImage":87,"relatedSolution":88},5,"deployer-laravel-vps","Deploying Laravel on a VPS: a production guide","Take Laravel to production on a VPS: PHP, workers, cache, database, reverse proxy and HTTPS configured cleanly.",2840,"2026-02-09T00:00:00+00:00",{"id":16,"name":17,"slug":18,"color":19,"icon":20},[86],{"id":16,"name":17,"slug":18,"color":19,"icon":20},"\u002Fblog\u002Fcovers\u002Fdeployer-laravel-vps-poster.svg",{"categorySlug":20,"appSlug":89},"laravel-stack",{"id":91,"slug":92,"title":93,"excerpt":94,"readTime":95,"views":96,"isPinned":13,"publishedAt":97,"category":98,"categories":99,"featuredImage":23,"bgImage":24,"posterImage":101,"relatedSolution":102},43,"deployer-nodejs-vps","Deploy a Node.js Application on a VPS","Deploy a Node.js application to production on a VPS: PM2, Nginx reverse proxy, Let's Encrypt SSL, and automatic startup at boot.",8,591,"2026-05-08T00:00:00+00:00",{"id":16,"name":17,"slug":18,"color":19,"icon":20},[100],{"id":16,"name":17,"slug":18,"color":19,"icon":20},"\u002Fblog\u002Fcovers\u002Fdeployer-nodejs-vps-poster.svg",{"categorySlug":18,"appSlug":103},"nodejs",{"id":105,"slug":106,"title":107,"excerpt":108,"readTime":95,"views":109,"isPinned":13,"publishedAt":110,"category":111,"categories":112,"featuredImage":23,"bgImage":24,"posterImage":114,"relatedSolution":115},44,"deployer-django-vps","Deploy a Django Application on a VPS","Deploy Django on a VPS: Gunicorn, Nginx, PostgreSQL, Docker, and SSL. A complete guide for Python developers who want to self-host.",628,"2026-05-07T00:00:00+00:00",{"id":16,"name":17,"slug":18,"color":19,"icon":20},[113],{"id":16,"name":17,"slug":18,"color":19,"icon":20},"\u002Fblog\u002Fcovers\u002Fdeployer-django-vps-poster.svg",{"categorySlug":18,"appSlug":116},"django",1785628429357]