Real-World Design & Interview Scenarios Flashcards
Apply NoSQL to build scalable, real-world systems. "Design a high-scale chat application using NoSQL databases." "How would you store and retrieve user sessions efficiently?" Designing a messaging app (Redis pub/sub, MongoDB for message history) Session management using Redis E-commerce catalog using MongoDB IoT data ingestion using Cassandra Graph-based recommendations using Neo4j Cost vs performance trade-offs (e.g., DynamoDB vs MongoDB Atlas) (20 cards)
Design a high-scale chat application using NoSQL databases.
Use Redis Pub/Sub for real-time message delivery and MongoDB to persist chat history for retrieval and analytics.
How would you store and retrieve user sessions efficiently?
Use Redis to store session data due to its in-memory speed, TTL support, and ability to expire stale sessions automatically.
How would you design an e-commerce product catalog using NoSQL?
Use MongoDB to store product documents with flexible schema for categories, variants, and descriptions; supports indexing and fast search.
How is Cassandra suited for IoT data ingestion?
Cassandra handles high-throughput, time-series data ingestion with tunable consistency, making it ideal for distributed IoT workloads.
How can Neo4j help build a recommendation engine?
Use Neo4j to model users, items, and interactions as a graph and query relationship patterns for real-time recommendations.
What are cost vs performance trade-offs between DynamoDB and MongoDB Atlas?
DynamoDB offers predictable scaling and built-in autoscaling but has limitations in flexibility; MongoDB Atlas provides a richer query language but may require manual tuning and management overhead.
What is a real-world use case of Redis in applications?
Redis is used for caching API responses, storing sessions, and implementing real-time features like leaderboards or chat.
What are the benefits of using MongoDB in e-commerce?
Flexible schema, powerful indexing, and document-based modeling make it easy to store complex product data and serve fast queries.
Why use Cassandra for time-series data?
Cassandra excels at high write throughput, linear scalability, and handling large volumes of time-stamped data efficiently.
What makes graph databases ideal for social apps?
Graph databases naturally model relationships, making them great for friend-of-friend queries, mutual connections, and recommendations.
What are architectural implications of choosing NoSQL?
Architectural impacts include schema flexibility, need for eventual consistency handling, and trade-offs in indexing and joins.
What are performance trade-offs in using Redis Pub/Sub?
Pub/Sub provides low-latency messaging but lacks durability and message replay, requiring additional layers for persistence.
What are challenges in using NoSQL for session storage?
Challenges include data eviction under memory pressure, scaling for large user bases, and ensuring fault-tolerant session replication.
What is the best practice for chat message durability?
Persist messages in MongoDB or Cassandra after publishing through Redis Pub/Sub to ensure delivery even if users are offline.
What are common interview questions around NoSQL system design?
‘Design a chat app using NoSQL’, ‘How would you use Redis for session management?’, ‘How do you model IoT data in Cassandra?’
What is a potential gotcha in using Redis for session storage?
Using volatile memory alone risks data loss on crashes; ensure persistence or backup strategies are in place if needed.
How do you monitor NoSQL-based systems?
Use database-specific tools (e.g., Redis MONITOR, MongoDB Atlas metrics), external tools (Prometheus, Grafana), and logging to track latency, memory, replication, and throughput.
What are debugging challenges in distributed NoSQL systems?
Debugging can be complex due to eventual consistency, network partitions, replication lag, and lack of centralized logs.
What is polyglot persistence in real-world design?
Using multiple databases based on strengths: Redis for cache, MongoDB for documents, Cassandra for writes, Neo4j for relationships.
What is a sample architecture for a scalable chat app?
Use Redis for message delivery, MongoDB for history, Cassandra for metrics/time-series, and a message queue for retries and async processing.