Design a Concurrent Car Reservation Service
Company: Salesforce
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Onsite
# Design a Concurrent Car Reservation Service
### Prompt
Design a car reservation service. A customer searches for an available car for a location and time interval, places a temporary hold, confirms or cancels it, and later sees the reservation status. The central challenge is limited inventory: many customers may try to reserve the same car or the last car in a class concurrently.
Describe the APIs, data model, availability search, hold and confirmation workflow, concurrency control, and behavior when requested inventory is no longer available.
**Candidate hint:** Search results are advisory. Identify the single transition at which the system must prove that an inventory unit is still available.
### Constraints & Assumptions
- Reservation intervals may overlap, and one car cannot be committed to overlapping customers.
- Holds expire automatically if they are not confirmed.
- Clients and internal workers may retry requests.
- Search may be eventually consistent, but confirmation must not double-book a car.
- State assumptions about assigning a specific car versus reserving a vehicle class.
### Clarifying Questions to Ask
- Is a customer reserving an exact car or a class of equivalent cars?
- Can pickup and return occur at different locations?
- How long does a hold last, and may it be extended?
- Should the service offer a waitlist or substitutes when inventory is exhausted?
### What a Strong Answer Covers
- Reservation states and idempotent API behavior
- An availability model that handles time intervals and stale search results
- A concrete atomicity mechanism that prevents double booking
- Hold expiry, cancellation, retries, and recovery from partial failures
- Inventory-shortage behavior and an explicit fairness or substitution policy
- Scaling, partitioning, auditability, and operational metrics
### Follow-up Questions
1. How would you prevent one customer from holding the last several cars indefinitely?
2. What changes if reservations are by vehicle class and exact cars are assigned shortly before pickup?
3. How do you handle a car becoming unavailable after a reservation is confirmed?
4. How would you prove that an expiry worker and a confirmation request cannot both win?
Quick Answer: Design a concurrent car reservation service with availability search, temporary holds, confirmation, cancellation, and status lookup. Explain interval conflicts, atomic inventory claims, retry safety, hold expiry, stale search results, substitutions, partitioning, and double-booking prevention.