CS System Architecture & Design 2 — Questions and Answers
Question 1: A web application experiences slow response times because every request hits the database. Which architectural component is best suited to reduce database load for frequently read, rarely changed data?
- A message queue between services
- A second load balancer
- A reverse proxy for SSL termination
- A caching layer such as Redis or Memcached (Correct answer)
Correct answer: A caching layer such as Redis or Memcached
A cache stores frequently accessed data in memory, serving reads without repeated database queries.
Question 2: In the CAP theorem, what must a distributed system sacrifice during a network partition if it chooses to remain available?
- Latency
- Scalability
- Consistency (Correct answer)
- Durability
Correct answer: Consistency
CAP states that during a partition a system can guarantee either consistency or availability, not both.
Question 3: Which design pattern decouples a service that produces events from services that consume them, allowing consumers to process work asynchronously?
- Singleton pattern
- Repository pattern
- Model-View-Controller
- Publish-subscribe messaging (Correct answer)
Correct answer: Publish-subscribe messaging
Publish-subscribe lets producers emit events to a broker while consumers subscribe independently and process asynchronously.
Question 4: A company splits its monolithic e-commerce application into independent services for orders, inventory, and payments, each with its own database. What architectural style is this?
- Layered architecture
- Client-server architecture
- Microservices architecture (Correct answer)
- Peer-to-peer architecture
Correct answer: Microservices architecture
Microservices decompose an application into small, independently deployable services, each owning its own data.
Question 5: What is the primary purpose of a load balancer in a horizontally scaled system?
- Encrypt data at rest
- Compile code for multiple architectures
- Back up the database on a schedule
- Distribute incoming traffic across multiple servers (Correct answer)
Correct answer: Distribute incoming traffic across multiple servers
A load balancer spreads requests across server instances to improve throughput and availability.
Question 6: Which scaling approach involves upgrading a single server with more CPU and RAM rather than adding more machines?
- Horizontal scaling
- Sharding
- Elastic scaling
- Vertical scaling (Correct answer)
Correct answer: Vertical scaling
Vertical scaling (scaling up) increases the capacity of one machine instead of adding machines.
Question 7: A stateless service design is preferred for horizontally scaled web servers primarily because it:
- Guarantees zero latency between requests
- Eliminates the need for a database entirely
- Allows any server to handle any request without session affinity (Correct answer)
- Prevents all security vulnerabilities
Correct answer: Allows any server to handle any request without session affinity
Statelessness means no per-user data lives on a specific server, so requests can be routed to any instance.
A web application experiences slow response times because every request hits the database.
Which architectural component is best suited to reduce database load for frequently read, rarely changed data?