What are the key responsibilities for Nginx versus Uvicorn?

This tests the reverse-proxy versus ASGI-server boundary. A strong answer gives Nginx TLS termination, static files, buffering, and load balancing, while Uvicorn runs the Python app and async workers.
What's really being asked
This question probes whether you understand the production deployment boundary between a reverse proxy and an ASGI server. Interviewers want to see that you know why FastAPI documentation recommends placing Uvicorn behind Nginx rather than exposing Uvicorn directly to the internet. The core signal is your ability to separate infrastructure concerns like TLS and static files from application concerns like async request handling and Python code execution.
The full answer
A strong answer assigns distinct responsibilities to each layer. Nginx should handle TLS termination and HTTPS certificate management, serve static assets directly from disk without touching Python, buffer slow client connections to free Uvicorn workers, and load balance traffic across multiple Uvicorn worker processes. Uvicorn should handle running the Python ASGI application, managing the async event loop, executing FastAPI path operations, and keeping connections to Nginx over plain HTTP on a local port or Unix socket. You should also mention that Nginx is written in C and handles thousands of concurrent keepalive connections efficiently, whereas Uvicorn workers are single-threaded async processes that should not be tied up waiting on slow network IO from end users.
The mistakes people make
Red flags include suggesting Uvicorn should terminate TLS for public traffic, claiming Nginx should execute Python logic or replace Uvicorn entirely, or stating that Uvicorn alone is sufficient for production because it is fast. Another mistake is omitting slow-client protection or forgetting that static file serving belongs in Nginx, not FastAPI, for performance.
What usually comes next
Interviewers may ask how you would scale Uvicorn workers, whether to use Gunicorn as a process manager in front of Uvicorn, how Unix sockets versus TCP ports affect performance, or how Nginx location blocks route API traffic versus static content. They might also probe how you handle WebSocket connections through Nginx with upgrade headers.
A concrete example
Imagine a deployment on an Ubuntu server. You configure Nginx to listen on port 443 with SSL certificates from Let's Encrypt. Nginx serves images and JavaScript from /var/www/static directly. API requests matching location /api are proxied with proxy_pass to http://127.0.0.1:8000 using keepalive connections and proxy buffering enabled. Uvicorn binds to localhost port 8000 with four workers, running the FastAPI app. If a user on a mobile network uploads a large file, Nginx buffers the upload so the Uvicorn worker can process it immediately rather than waiting for the slow upload to finish.
Interview question
A FastAPI service behind Uvicorn becomes unresponsive during traffic spikes from users on slow networks. Which architectural fix addresses the underlying issue?
- a.Increase Uvicorn worker processes to absorb the traffic spike
- b.Configure Nginx to execute the FastAPI application directly
- c.Place Nginx in front to buffer slow client connections and offload network I/OCorrect
- d.Move TLS termination and certificate management to Uvicorn
Why? this is the answer
Nginx buffers slow client connections so Uvicorn workers are not blocked waiting on network I/O. Simply increasing Uvicorn workers is insufficient because each single-threaded worker can still be tied up by a slow client.
Just read this? Test yourself on what you have been reading.
Read the original → fastapi.tiangolo.com
- #fastapi
- #nginx
- #uvicorn
- #deployment
- #python
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on fastapi — each one lists the topics its interview covers.
See open roles