19. Highload & Scalability
What is Load Balancing?
MiddleAnswer: Distributing network or application traffic across multiple servers to improve responsiveness and availability.
How to optimize a slow GET endpoint that retrieves many records?
SeniorAnswer:
- Use pagination.
- Use caching (Redis/Memcached).
- Optimize database queries (indexing, select only needed columns).
- Use Eager Loading to avoid the N+1 problem.
What is the CAP Theorem?
SeniorAnswer: In a distributed system, you can only provide two of the following three guarantees: Consistency, Availability, and Partition Tolerance.
What is Database Replication?
SeniorAnswer: Copying data from one database server (Master) to another (Slave) to improve reliability, fault tolerance, and performance.