Interview Questions on State, Security & Middleware in Web/Application Servers

Q1. A web application is deployed on multiple servers behind a load balancer. Users report being logged out when their requests go to a different server. What is a quick, configuration-only solution to maintain session continuity for each user?




Q2. An internal microservice API must ensure that only clients with valid digital certificates can connect, providing mutual identity verification on top of TLS encryption. Which mechanism best meets this requirement?




Q3. A developer has added identical request logging code to dozens of handler functions in a web service. What is a better architectural approach to implement request logging across all requests?




Q4. To mitigate cross-site scripting (XSS) attacks by controlling which sources of scripts can execute on your web pages, which HTTP header should you configure?




Q5. Users can upload files via your web application, but very large uploads are causing memory issues on the server. What’s the best way to prevent excessively large request bodies from impacting the server?




Q6. Your web application cluster uses load balancer session affinity (sticky sessions) to maintain user sessions on one server. What is a potential drawback of relying on sticky sessions for session management?




Q7. You need to allow third-party web applications to act on behalf of your users (with their consent) without sharing user passwords. Which authentication standard is most appropriate for this scenario?




Q8. Several endpoints in your REST API should only be accessible to users with an administrator role. How can you enforce this rule uniformly without duplicating the authorization logic in every endpoint handler?




Q9. You plan to extend an open-source web server’s functionality by adding custom request processing logic, but you don’t want to maintain a fork of the server’s code. What’s a proper way to integrate your custom logic?




Q10. Your web application has a state-changing endpoint (e.g. transferring funds) that is being triggered by malicious cross-site requests (CSRF) when a user visits an attacker’s page while logged in. What defense can you implement to prevent such Cross-Site Request Forgery exploits?




Q11. Your team is replacing server-side session storage with stateless JWTs for user sessions to improve scalability. What is a known challenge introduced by using stateless JWTs for session management?




Q12. A web framework lets you register multiple middleware components that process an HTTP request sequentially (each can modify the request/response or decide to stop the propagation). This middleware pipeline is an example of which design pattern?




Q13. An API gateway in front of your services performs IP-based rate limiting and also verifies OAuth access tokens on incoming requests. To minimize wasted work under high traffic, what is a sensible order to apply these checks?




Q14. To ensure no single user exceeds 5 requests per second, an engineer proposes enforcing this limit within the database layer (e.g. rejecting queries if a user’s requests exceed the threshold). What is a major downside of this approach?




Q15. In a web application, a developer placed a business-specific rule (e.g. calculating a user’s discount eligibility) inside a global request middleware so it runs on every request. Why is implementing business logic in the middleware layer generally discouraged?




software-architecture