← eBay Interview Insights

eBay·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Jun 2026

Summary

System design round at eBay focused entirely on cache and database consistency. The question had a lot of moving parts and I don't think I covered all of them as well as I should have.

Questions Asked (1)

Q1

You have a cache like Redis sitting in front of a relational database, and multiple app servers can update the same key at the same time. How do you design the system to prevent and resolve conflicts and race conditions? Cover write ordering, atomicity, versioning or compare-and-set, distributed locks, TTL and invalidation versus write-through or write-back, idempotent updates, and recovery from partial failures. Also talk through the API design, data model, consistency guarantees, and trade-offs.

System DesignTechnical Trade-offsData Modeling
Author's notes

This one sprawled in a way I wasn't ready for.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then propose a layered design that combines cache-aside with versioning and atomic operations, and finally discuss trade-offs and failure recovery. Emphasize that the choice depends on consistency needs and access patterns, and that idempotency and conflict resolution are key.

Pro tip: Always tie your design to the business impact: for eBay, stale inventory or pricing data can cause real financial loss, so prioritize correctness over performance for critical keys. Mention that you'd measure and monitor cache hit rates and conflict rates to validate the design.

1. Clarify Requirements and Constraints

Ask about consistency requirements (strong vs eventual), read/write patterns, latency SLAs, and failure tolerance. This determines whether you need distributed locks or can rely on optimistic concurrency.

2. Design the Data Model and API

Define keys with version numbers or timestamps, and design APIs that support conditional writes (e.g., PUT with If-Match header) and idempotency keys. Specify the data model for cache entries including TTL and metadata.

3. Choose a Concurrency Control Strategy

For each key, decide between optimistic (compare-and-set with versioning) and pessimistic (distributed locks) approaches. Explain how to handle write ordering and atomicity using Redis transactions or Lua scripts.

4. Define Cache Invalidation and Write Policies

Select cache-aside, write-through, or write-back based on consistency needs. Describe invalidation strategies (TTL, explicit delete, version-based) and how to handle partial failures (e.g., retries, compensation).

5. Discuss Trade-offs and Recovery

Compare consistency, latency, and complexity trade-offs. Outline recovery mechanisms for partial failures, such as idempotent retries, dead-letter queues, and reconciliation jobs.

Key Points to Mention

  • Versioning and compare-and-set (CAS) using Redis WATCH/MULTI/EXEC or Lua scripts to ensure atomic updates.
  • Distributed locks (e.g., Redlock) with fencing tokens and lease timeouts to prevent deadlocks and ensure safety.
  • Cache invalidation strategies: TTL, write-through vs write-back, and the risks of stale data.
  • Idempotent updates using idempotency keys or request IDs to handle retries safely.
  • Recovery from partial failures: retry with exponential backoff, compensation transactions, and reconciliation.
  • Consistency guarantees: strong vs eventual, and how to communicate them to clients via API contracts.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.