Monolith vs Microservices
Q1. What is a Monolithic Architecture?
Answer:
A monolithic architecture is a design where the entire application is built as one single unit.
All components—UI, business logic, and database access—are tightly coupled and deployed together.
Key Characteristics:
- Single codebase
- Single deployment
- Tight coupling
- Simple to start, hard to scale later
Example:
An e-commerce application where users, orders, payments, and inventory are all part of one application.
Q2. What is Microservices Architecture?
Answer:
Microservices architecture breaks an application into small, independent services, each responsible for one business capability.
Key Characteristics:
- Independent deployment
- Loose coupling
- Each service has its own database
- Scales independently
Example:
- Order Service
- Payment Service
- Inventory Service
Q3. Monolith vs Microservices – Key Differences
| Feature | Monolith | Microservices |
|---|---|---|
| Codebase | Single | Multiple |
| Deployment | Single unit | Independent |
| Scalability | Entire app | Per service |
| Technology | Uniform | Polyglot |
| Complexity | Low initially | High initially |
Interview Tip:
Microservices are not always better. Choose based on business needs.
Q4. When should you choose Monolith?
Answer:
Choose Monolith when:
- Team size is small
- Application is simple
- Faster time to market is required
- Low operational complexity is preferred
Q5. When should you choose Microservices?
Answer:
Choose Microservices when:
- Application needs high scalability
- Teams work independently
- Frequent deployments are required
- Fault isolation is critical
High-Level Design Questions
Q1. What is High-Level Design (HLD)?
Answer:
High-Level Design focuses on overall system architecture, not code.
It answers:
- How components interact
- How data flows
- How system scales
- How failures are handled
Q2. What are the main components in High-Level Design?
Answer:
Typical HLD components include:
- Client (Web/Mobile)
- Load Balancer
- Application Servers
- Databases
- Cache
- Message Queue
- CDN
Q3. How do you approach a System Design interview question?
Answer (Udemy step-by-step):
- Clarify requirements
- Identify functional & non-functional requirements
- Draw high-level architecture
- Discuss scalability
- Handle failures
- Talk about trade-offs
Interview Tip:
Interviewers value clear thinking, not perfect diagrams.
Scalability
Q1. What is Scalability?
Answer:
Scalability is the system’s ability to handle increased load without performance degradation.
Q2. Vertical vs Horizontal Scaling
Answer:
Vertical Scaling (Scale Up):
- Add more CPU/RAM to a single machine
- Simple but limited
Horizontal Scaling (Scale Out):
- Add more machines
- More complex but highly scalable
Q3. How do large systems scale?
Answer:
Large systems scale using:
- Load balancers
- Stateless services
- Distributed databases
- Caching
- Asynchronous processing
Q4. What is Stateless vs Stateful Services?
Answer:
- Stateless: No user session stored on server (preferred for scaling)
- Stateful: Session stored on server (harder to scale)
Caching
Q1. What is Caching?
Answer:
Caching stores frequently accessed data in fast memory to reduce database load and improve performance.
Q2. Where can caching be applied?
Answer:
- Browser cache
- CDN
- Application cache
- Database cache
Q3. Common Caching Strategies
Answer:
- Cache Aside
- Write Through
- Write Behind
Interview Favorite:
Cache Aside is the most commonly used strategy.
Q4. Cache Invalidation – Why is it hard?
Answer:
Because stale data can be served if cache is not updated properly.
Common techniques:
- TTL (Time To Live)
- Event-based invalidation
Databases
Q1. SQL vs NoSQL – When to use what?
Answer:
SQL:
- Strong consistency
- Structured data
- ACID properties
NoSQL:
- High scalability
- Flexible schema
- Eventually consistent
Q2. What is Database Sharding?
Answer:
Sharding splits a large database into smaller chunks to improve scalability.
Example:
User data split by user ID ranges.
Q3. What is Replication?
Answer:
Replication creates multiple copies of data to improve availability and read performance.
Q4. CAP Theorem
Answer:
A distributed system can guarantee only two of three:
- Consistency
- Availability
- Partition Tolerance
Real Interview Problems
Q1. Design a URL Shortener (like Bitly)
Key Components:
- API Gateway
- Short URL Generator
- Database
- Cache
- Redirect Service
Important Concepts:
- Hashing
- Collision handling
- Read-heavy optimization
Q2. Design a Notification System
Answer:
- Event producer
- Message queue (Kafka/RabbitMQ)
- Notification service
- Retry & failure handling
Q3. Design a File Storage System (like Google Drive)
Key Points:
- Chunking
- Metadata storage
- CDN
- Access control
- Versioning