The System Design is complex and one design doesnt fits all. Below are useful pointers to get unstuck in an interview -
- For a Read-Heavy System - Consider using a Cache.
- For a Write-Heavy System - Use Message Queues for async processing
- For alow_latency Requirement - Consider using a Cache and CDN. Why? latency is delay in network communication, having CDN will load content from nearestgeographic_location and this reduce load time.
- Need ACID 𝐀tomicity, 𝐂onsistency, 𝐈solation, 𝐃urability Compliant DB - Go for RDBMS/SQL Database.
- Have unstructured data - Go for NoSQL Database.
- Have Complex Data (Videos, Images, Files) - Go for Blob/Object storage.
- Complex Pre-computation - Use Message Queue & Cache.
- High-Volume Data Search - Consider search index, Trie or search engine.
- Scaling SQL Database - Implement Database Sharding.
- High Availability, Performance, & Throughput - Use a Load Balancer.
- Global Data Delivery - Consider using a CDN.
- Graph Data (data with nodes, edges, and relationships) - Utilize Graph Database.
- Scaling Various Components - Implementhorizontal_scalability .
- High-Performing Database Queries - Use Database Indexes.
- Bulk Job Processing - Consider Batch Processing & Message Queues.
- Server Load Management & Preventing DOS Attacks- Use a Rate Limiter.
- Microservices Architecture - Use an API Gateway.
- For Single Point of Failure - Implement Redundancy.
- For Fault-Tolerance and Durability - Implement Data Replication.
- For User-to-User fast communication - Use Websockets.
- Failure Detection in Distributed Systems - Implement a Heartbeat.
- Data Integrity - Use Checksum Algorithm.
- Efficient Server Scaling - Implement Consistent Hashing.
- Decentralized Data Transfer - Consider Gossip protocol .
- Location-Based Functionality - Use Quadtree, Geohash, etc.
- Avoid Specific Technology Names - Use generic terms.
- High Availability and Consistency Trade-Off - Eventual Consistency.
- For IP resolution & Domain Name Query - Mention DNS (Domain Name System).
- Handling Large Data in Network Requests - Implement Pagination.
- Cache Eviction Policy - Preferred is LRU cache .
- To handle traffic spikes: Implement auto scaling to manage resources dynamically.
- Need analytics and audit trails: Consider using Datalake orappend_only_databases
- Handling large scale simultaneous connections: Useconnection_pooling and try using protobuff to minimise payload.
Heuristic by Ashish Pratap
- Understand the functional and non-functional requirements before designing.
- Clearly define the use cases and constraints of the system.
- There is no perfect solution. It’s all about tradeoffs.
- Assume requirements will change and design the system to be flexible.
- Assume everything can and will fail. Make it fault tolerant.
- Don’t add functionality until it’s necessary. Avoid over-engineering.
- Design your system for scalability from the ground up.
- Prefer horizontal scaling over vertical scaling for scalability.
- Add Load Balancers to ensure high availability and distribute traffic.
- Consider using SQL Databases for structured data and ACID transactions.
- Opt for NoSQL Databases when dealing with unstructured data.
- Use Database Sharding to scale SQL databases horizontally.
- Use Database Indexing and search engines for efficient data retrievals.
- Use Rate Limiting to prevent system overload and DOS attacks.
- Use WebSockets for real-time communication.
- Employ Heartbeat Mechanisms for failure detection.
- Consider using a message queue for asynchronous communication.
- Implement data partitioning and sharding for large datasets.
- Consider denormalizing databases for read-heavy workloads.
- Consider using event-driven architecture for decoupled systems.
- Use CDNs to reduce latency for a global user base.
- Use write-through cache for write-heavy applications.
- Use read-through cache for read-heavy applications.
- Use blob/object storage for storing media files like files, videos etc..
- Implement Data Replication and Redundancy to avoid single point of failure.
- Implement Autoscaling to handle traffic spikes smoothly.
- Use Asynchronous processing to run background tasks.
- Make operations idempotent where possible to simplify retry logic and error handling.
- When appropriate, use microservices for flexibility, scalability, and maintainability.
- Consider using a data lake or data warehouse for analytics and reporting.