advancedTop 30 Scenario-Based Questions

Design a messaging system using MongoDB and Redis (similar to Slack).

Architecture: 1) MongoDB: channels: {_id, name, members:[userId...], type}. messages: {_id, channelId, userId, text, attachments, reactions, createdAt}. 2) Index: messages.createIndex({channelId:1, createdAt:-1}). 3) Redis for real-time: SUBSCRIBE channel:{channelId} — WebSocket subscribers listen. On new message: PUBLISH channel:{channelId} {messageId, userId, text, ts}. 4) Recent messages cache:

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Explain how you would handle eventual consistency issues in a multi-region deployment.← Back to all NoSQL questions