Handle cache-update conflicts in distributed services

Read the full interview experience this question came from →

Quick Overview

This question evaluates a candidate's competency in distributed systems and data consistency, focusing on cache–database consistency, concurrent write handling, versioning/CAS, distributed locking, cache invalidation strategies, idempotency, and failure recovery in high-throughput services.

Handle cache-update conflicts in distributed services

Company: eBay

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Onsite

Your service uses a cache (e.g., Redis) in front of a relational database, and multiple application servers may update the same key concurrently. Design how to prevent and resolve cache–database update conflicts and race conditions: discuss write ordering and atomicity, versioning/ETags or compare-and-set, distributed locks, TTLs and invalidation vs write-through/write-back, idempotent updates, and recovery after partial failures. Specify APIs, data model, consistency guarantees, and trade-offs.

Overview: This question evaluates a candidate's competency in distributed systems and data consistency, focusing on cache–database consistency, concurrent write handling, versioning/CAS, distributed locking, cache invalidation strategies, idempotency, and failure recovery in high-throughput services.

Read the full eBay Software Engineer interview experience this question came from

|Home/System Design/eBay
eBay logo
eBay
Sep 6, 2025
hardSoftware EngineerOnsiteSystem Design
29
0

Design: Cache–Database Consistency with Concurrent Writers

Context

You operate a high-throughput service using a cache (e.g., Redis) in front of a relational database. Multiple application servers may concurrently update the same logical record (key). You must prevent and resolve cache–database update conflicts and race conditions while keeping performance high.

Requirements

Design how to prevent and resolve conflicts across these areas:

  1. Write ordering and atomicity
  2. Versioning/ETags and compare-and-set (CAS)
  3. Distributed locks (when and how)
  4. TTLs and cache invalidation vs write-through/write-back
  5. Idempotent updates and retries
  6. Recovery after partial failures

Specify:

  • APIs (read/write), including headers or RPC fields
  • Data model (DB and cache)
  • Consistency guarantees
  • Trade-offs and when to choose each option

Provide read and write flows, including conflict resolution and failure handling.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...