Web Framework Internals interview question · Most asked
What is a request lifecycle, and why should a backend engineer know it for their framework?
Summary
The request lifecycle is the ordered sequence of steps a framework runs for each HTTP request: server hand-off, bootstrap, middleware or filters, routing, authentication and validation, the controller or view, response creation, the response passing back out, and post-response work. Knowing it tells you where to put each piece of logic and explains many production bugs.
Longer Answer
Ordering bugs are common: middleware that runs before the user is loaded, exceptions raised in a layer the error handler doesn't cover, guards that see unvalidated input, expensive bootstrap work paid on every request, or state leaking between requests in long-running workers. Each framework names the stages differently, but the shape is the same.
Key Points
- Ordered steps from server hand-off to post-response work.
- Tells you where cross-cutting logic belongs.
- Explains ordering and error-handling bugs.
- Same shape, different names per framework.
Deep dive: Request Lifecycle: The Anatomy of a Request
Explanation
What interviewers look for
A general model plus concrete examples from at least one framework.
Follow-up questions
- Describe the lifecycle in the framework you use most.
- What runs after the response is sent?
More most-asked Web Framework Internals questions
- What layers does a request pass through before reaching application code, and how should their timeouts relate?
- Walk through the Django request lifecycle.
- How does Express handle a request, and how are errors routed?
- What is the NestJS request lifecycle?
- Describe the Spring MVC request flow and where exceptions are handled.
- Where should authentication, authorisation, validation and error formatting live in a web framework?
- Walk through the Laravel request lifecycle and say where you would add code that must run on every request.
- What is the middleware 'onion' model?