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

This is a Pro chapter

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

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

Next Step

Continue to Design an e-commerce cart using Redis that persists across sessions.← Back to all NoSQL questions