← Preply Interview Insights

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

Senior
Apr 2026

Summary

System design round at Preply for a software engineering role. The whole thing revolved around one big question about building a course reservation system, and they went pretty deep on concurrency and failure scenarios.

Questions Asked (4)

Q1

Design a course registration system where students can reserve time slots. Walk through the database schema, API design, concurrency handling, and how you'd scale it.

System DesignData ModelingTechnical Trade-offs
Author's notes

This is deceptively wide.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (e.g., scale, read/write ratio, consistency needs) and then walk through the design in layers: data model, API, concurrency, and scaling. Emphasize trade-offs and justify decisions based on the context of a course registration system like Preply's.

Pro tip: Proactively discuss how you'd handle peak load (e.g., course opening) and prevent overselling, showing you understand real-world constraints. Mention idempotency and graceful degradation to demonstrate maturity.

1. Clarify Requirements and Constraints

Ask about expected scale (users, courses, slots), read/write patterns, consistency requirements, and any specific features like waitlists or cancellations. This ensures the design meets actual needs.

2. Design the Database Schema

Propose tables for students, courses, time slots, and registrations. Discuss normalization vs. denormalization, indexing, and how to model slot capacity and reservations.

3. Define the API

Outline RESTful endpoints for listing courses, reserving a slot, canceling, etc. Include request/response formats, status codes, and idempotency keys for critical operations.

4. Handle Concurrency

Explain how to prevent double-booking using techniques like optimistic locking, pessimistic locking, or distributed locks. Discuss trade-offs and potential bottlenecks.

5. Scale the System

Describe scaling strategies: caching, read replicas, sharding, queueing, and rate limiting. Address how to handle spikes and ensure high availability.

Key Points to Mention

  • Database schema: tables for students, courses, time_slots, registrations with appropriate foreign keys and indexes.
  • API design: RESTful endpoints with clear semantics, idempotent reservation endpoint, and proper error handling.
  • Concurrency control: optimistic vs. pessimistic locking, database transactions, and isolation levels to prevent overselling.
  • Caching: use Redis or similar to cache course availability and reduce database load.
  • Scaling: read replicas for read-heavy workloads, sharding by course or time slot, and asynchronous processing for non-critical tasks.
  • Trade-offs: consistency vs. availability, latency vs. correctness, and complexity vs. maintainability.

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

Q2

How would you prevent double-booking when many students try to reserve the same slot at the same time?

System DesignTechnical Trade-offs
Author's notes

Went with optimistic locking initially, version column on the slot row, retry on conflict.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: expected concurrency, consistency needs, and user experience. Then propose a layered solution: database-level constraints (unique index, transactions) as the source of truth, combined with application-level locking (optimistic or pessimistic) and possibly a distributed lock or queue for high contention. Finally, discuss trade-offs and how you would test and monitor the solution.

Pro tip: Emphasize that the database should be the ultimate arbiter of truth—application-level locks can fail in distributed systems, so a unique constraint on (slot_id, student_id) or (slot_id) with proper transaction isolation is essential. Also mention that you'd handle the race condition gracefully by returning a clear error and suggesting alternative slots.

1. Clarify requirements and constraints

Ask about expected traffic, consistency requirements (strong vs eventual), and whether overbooking is acceptable. This shows you don't jump to solutions without understanding the problem.

2. Identify the race condition

Explain that double-booking occurs when two requests read the same available slot and both attempt to book it. Highlight the need for atomicity in the check-and-book operation.

3. Propose database-level guarantees

Suggest using a unique constraint on the slot (e.g., unique index on slot_id in the bookings table) and wrapping the booking in a transaction. Mention isolation levels (e.g., SERIALIZABLE or SELECT ... FOR UPDATE) to prevent phantom reads.

4. Add application-level coordination

For high contention, consider optimistic locking (version column) or pessimistic locking (row-level locks). In distributed systems, use a distributed lock (e.g., Redis Redlock) or a queue to serialize requests per slot.

5. Discuss trade-offs and fallbacks

Compare performance, complexity, and failure modes. For example, database locks may hurt throughput, while distributed locks add complexity. Also mention idempotency keys to handle retries and user experience for failed bookings.

Key Points to Mention

  • Unique constraint on slot_id (or slot_id + student_id) to enforce one booking per slot.
  • Transaction isolation levels (e.g., SERIALIZABLE, REPEATABLE READ) and their impact on preventing race conditions.
  • Optimistic vs pessimistic locking: version numbers vs SELECT FOR UPDATE.
  • Distributed locking (e.g., Redis, ZooKeeper) for multi-instance deployments.
  • Idempotency and retry handling to avoid duplicate bookings from network issues.
  • Monitoring and alerting for booking conflicts and system performance.

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

Q3

What API endpoints would you expose for this reservation service, and how would you handle idempotency on the confirm step?

API & IntegrationsSystem Design
Author's notes

Search, hold, confirm, cancel.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the core reservation flow (search, hold, confirm, cancel) and then propose RESTful endpoints that map to each step, emphasizing resource-oriented design. For idempotency on confirm, explain that the client must send a unique idempotency key, and the server must store and enforce it to prevent duplicate bookings.

Pro tip: Mention that idempotency keys should be scoped to the user and endpoint, and that you'd return the same response (including status code) for repeated requests with the same key, even if the first request is still in progress. This shows you understand real-world race conditions and client retry behavior.

1. Clarify the reservation lifecycle

Briefly outline the main states: searching for availability, holding a slot, confirming the reservation, and canceling. This sets context for the endpoints.

2. Design RESTful endpoints

Propose endpoints like GET /availability, POST /reservations (to create a hold), POST /reservations/{id}/confirm, and DELETE /reservations/{id} for cancellation. Use nouns and HTTP verbs appropriately.

3. Explain idempotency for confirm

Describe how the client generates a unique idempotency key (e.g., UUID) and sends it in a header like Idempotency-Key. The server stores the key and the result of the operation, returning the same response for repeated requests.

4. Address storage and concurrency

Mention that idempotency keys should be stored in a fast, persistent store (e.g., Redis or a database) with a TTL, and that you need to handle concurrent requests with the same key using locks or atomic operations.

5. Discuss error handling and edge cases

Cover what happens if the first request fails, if the key expires, or if the client retries with a different payload. Emphasize returning consistent errors and documenting the idempotency contract.

Key Points to Mention

  • Use of idempotency keys (e.g., UUID) in request headers for the confirm endpoint.
  • Server-side storage of idempotency keys with TTL and associated response.
  • Returning the same response (status code and body) for repeated requests with the same key.
  • Handling concurrent requests with the same key using locking or atomic operations.
  • Scoping idempotency keys to the user and endpoint to prevent collisions.
  • Considering idempotency for other state-changing endpoints like cancellation or hold creation.

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

Q4

How would you handle failures and ensure consistency if a reservation is partially written or a node goes down mid-transaction?

System DesignTechnical Trade-offs
Author's notes

Talked about transactional writes at the DB level for the happy path, then outbox pattern for anything that needs to propagate downstream.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the consistency requirements (e.g., ACID vs BASE) and the specific failure scenarios. Then propose a combination of transactional boundaries, idempotency, and compensating actions (Saga pattern) to handle partial writes and node failures. Finally, discuss trade-offs between consistency, availability, and complexity, and how you would monitor and recover from failures.

Pro tip: Emphasize idempotency and the use of unique transaction IDs to safely retry operations, and mention that you would design for failure by testing with chaos engineering. This shows you think beyond just the happy path and consider real-world operational resilience.

1. Clarify requirements and failure modes

Ask about the consistency model (strong vs eventual), the expected failure scenarios (node crash, network partition, partial write), and the business impact of inconsistency.

2. Choose a consistency strategy

Decide between ACID transactions (e.g., using a distributed transaction protocol like 2PC) or BASE with compensating transactions (Saga pattern), based on the requirements.

3. Design for idempotency and retries

Ensure operations are idempotent using unique transaction IDs, so that retries after failures do not cause duplicate reservations or inconsistent state.

4. Implement failure recovery and monitoring

Use write-ahead logging, periodic reconciliation, and dead-letter queues to detect and recover from partial writes. Set up alerts for failed transactions.

5. Discuss trade-offs and alternatives

Compare the chosen approach with alternatives (e.g., 2PC vs Saga) in terms of latency, complexity, and consistency guarantees, and explain why your choice fits the use case.

Key Points to Mention

  • ACID vs BASE consistency models and their trade-offs
  • Two-phase commit (2PC) and its limitations (blocking, coordinator failure)
  • Saga pattern with compensating transactions for long-running workflows
  • Idempotency keys and exactly-once semantics
  • Write-ahead logging (WAL) and database recovery mechanisms
  • Monitoring, alerting, and reconciliation for eventual consistency

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