Horizontal scaling means running multiple instances of a Spring MVC application behind a load balancer to handle more traffic, rather than making a single instance bigger. Doing this successfully requires the application to be designed so any instance can handle any request.
Key Points: • A load balancer (e.g. Nginx, AWS ELB) distributes incoming requests across multiple running instances of the application. • Sessions must be made stateless, or externalized to a shared store like Redis (Spring Session), so a user's request can land on any instance without losing their session. • The database itself often needs scaling too, through read replicas, sharding, or caching layers, since more app instances mean more concurrent database load. • Splitting a large monolith into smaller microservices lets each service scale independently based on its own load pattern. • Health checks and readiness probes let the load balancer and orchestrator (e.g. Kubernetes) route traffic only to instances that are actually ready to serve requests.
Example: An e-commerce app under Black Friday load might run ten identical Spring Boot instances behind a load balancer, with Spring Session backed by Redis so a user's cart survives even if their next request hits a different instance.
Interview Tip: A concise interview answer is:
"To scale horizontally, I'd run multiple stateless instances behind a load balancer, moving session state to something like Redis via Spring Session so any instance can serve any request. From there, the database usually becomes the next bottleneck, so I'd look at read replicas, caching, or eventually splitting the app into independently scalable services."