advancedTop 30 Scenario-Based Questions

How would you design a URL shortener using Redis and MongoDB?

System design: 1) ID generation: use Redis INCR for atomic sequential IDs: INCR url:counter → 123456 → encode to base62 = 'w7Xk'. 2) Storage: MongoDB for durability: {_id: 'w7Xk', originalUrl:'https://example.com/...', userId, clicks:0, createdAt}. 3) Redis cache: SET url:w7Xk 'https://example.com/...' EX 86400 (24h cache). 4) Redirect: GET url:{code} → hit Redis, return redirect. Miss → query Mon

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 Design an e-commerce cart using Redis that persists across sessions.← Back to all NoSQL questions