Glossary coding Term Page

Keep-Alive Timeout

Duration a server holds persistent HTTP connections before closing them when no data flows.

keep-alive-timeout #http#fastapi
Korean version

Aliases

keep-alive timeouttimeout-keep-alive

Related Concepts

Core Idea

Keep-alive timeout is the interval an HTTP server (like uvicorn or a load balancer) waits before closing an otherwise idle connection. Streaming workloads and SSE keep sockets open even though data may pause momentarily, so low timeouts cause premature disconnects and half-delivered responses.

Why It Matters Here

Mathbong’s FastAPI lessons highlight that streaming APIs are only stable when the keep-alive timeout is tuned to outlast the expected stream duration. Raising it to match StreamingResponse workloads prevents browsers from retrying mid-download and keeps SSE feeds alive.

Posts Mentioning This Concept