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:

This is a Pro chapter

Sign in, then upgrade to Pro or Power to unlock this and the full Databases Mastery library.

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

Next Step

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