Web Framework Internals interview question · Most asked
What layers does a request pass through before reaching application code, and how should their timeouts relate?
Summary
Typically client → CDN or load balancer → reverse proxy or web server (nginx, Apache) → application server (PHP-FPM, Gunicorn/Uvicorn, Node.js, Tomcat) → framework pipeline → your code and its outbound calls. Inner timeouts should be shorter than outer ones, so the innermost layer gives up first, returns a meaningful error and stops the work.
Longer Answer
If an outer layer times out first, users see a generic 504 while inner layers keep working and logging success, and retries multiply the load. Propagate a request ID or W3C trace context through every layer to correlate logs.
Key Points
- CDN/LB → web server → app server → framework → code.
- Inner timeouts shorter than outer ones.
- Outer-first timeouts waste work and confuse logs.
- Propagate request IDs end to end.
Deep dive: Request Lifecycle: The Anatomy of a Request
Explanation
What interviewers look for
The layer chain and correct timeout ordering.
More most-asked Web Framework Internals questions
- What is a request lifecycle, and why should a backend engineer know it for their framework?
- 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?