CS FundamentalsVery hardProduct-company system-design interview
A feed API uses ?offset=20&limit=20 pagination. While a user reads page 1, 5 new items are inserted at the top. What goes wrong on page 2, and what fixes it?
- A. Nothing; offsets are stable
- B. Page 2 skips 5 items; the fix is a larger limit
- C. The API returns 404; the fix is caching
- D. 5 items from page 1 appear again on page 2; cursor (keyset) pagination using the last seen item's key avoids it
Correct answer: D. 5 items from page 1 appear again on page 2; cursor (keyset) pagination using the last seen item's key avoids it
New rows shift every offset by 5, so the first 5 items of the new page 2 are the old items 16-20 already seen. Keyset pagination ('items older than id X') is stable under inserts and faster on large tables.
Practise more Software Engineering, Git and Cloud Basics questionsSoftware Engineering, Git and Cloud Basics: notes and key points
More Software Engineering, Git and Cloud Basics questions
- During a network partition between two data centres, a replicated database must either reject some writes or accept writes on both sides…
- An order service and a payment service each own their database. Placing an order must reserve stock, charge the card and create the order…
- A circuit breaker protecting calls to a slow service has three states. Which sequence is correct?
- A Kubernetes pod takes 60 seconds to warm its cache after start-up. During that time it should get no traffic but must not be restarted…
- A CI workflow uses a build matrix of 3 operating systems x 4 language versions, with 2 specific combinations excluded. How many jobs run…
- Which pairing of security testing approaches is correct?