← preply Interview Insights

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

SeniorPrefer not to say
May 2026Remote

Summary

System design round at Preply for a software engineer role. The whole session was basically one big question about building a course reservation system, and they went pretty deep on the concurrency side of things which I wasn't fully prepared for.

Questions Asked (2)

Q1

Design a course registration and appointment-booking service 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

I started with the schema and felt okay there.

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 a structured way: data model, API, concurrency, and scaling. Emphasize trade-offs and justify your choices, especially around handling double-booking and scaling reads/writes.

Pro tip: Proactively discuss how you'd handle edge cases like time zone differences, cancellations, and waitlists, and mention monitoring and metrics for booking success rates. This shows you think beyond the happy path and consider operational concerns.

1. Clarify Requirements and Scope

Ask questions to understand expected scale (users, courses, bookings per second), read/write patterns, consistency requirements, and any constraints like time zones or recurring slots.

2. Design the Data Model

Propose a schema with tables for users, courses, time slots, and bookings. Discuss indexes, constraints (e.g., unique on slot_id and student_id), and how to handle cancellations and waitlists.

3. Define the API

Outline RESTful endpoints for listing available slots, booking, canceling, and viewing bookings. Mention idempotency keys for booking requests and pagination for listing slots.

4. Handle Concurrency

Explain how to prevent double-booking using transactions, optimistic locking (versioning), or pessimistic locking. Discuss trade-offs between consistency and performance.

5. Scale the System

Describe scaling strategies: read replicas for slot searches, sharding by course or time, caching popular slots, and using a queue for booking requests to smooth spikes.

Key Points to Mention

  • Database schema: tables for users, courses, time slots, bookings; unique constraint on (slot_id, student_id) to prevent duplicates.
  • API design: REST endpoints with idempotent POST for booking, GET for available slots with filters, and proper status codes.
  • Concurrency: use transactions with SELECT ... FOR UPDATE or optimistic locking to avoid race conditions.
  • Scaling: read replicas, caching, sharding, and asynchronous processing for high write throughput.
  • Time zones and recurring slots: store times in UTC and handle conversions; support recurring slots with a separate table or cron jobs.
  • Monitoring and metrics: track booking success rate, latency, and error rates to detect issues.

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 under high contention? Compare optimistic locking, pessimistic locking, and distributed locks for this use case.

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

This came as a follow-up and honestly it's where the interview got interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the booking scenario (e.g., tutor time slots) and the contention level, then compare optimistic locking, pessimistic locking, and distributed locks in terms of correctness, performance, and complexity. Recommend a hybrid approach: use optimistic locking for low contention, pessimistic locking for high contention within a single database, and distributed locks only when coordinating across services or databases.

Pro tip: Emphasize that the best solution is often to avoid contention altogether by designing the system to serialize bookings per resource (e.g., using a queue or partitioning by tutor ID), and mention that distributed locks add latency and failure modes, so they should be a last resort.

1. Clarify requirements and constraints

Ask about the expected contention level, consistency requirements, and whether the system is single-node or distributed. This sets the context for comparing locking strategies.

2. Explain optimistic locking

Describe how it works with version numbers or timestamps, and that it's efficient for low contention but can cause retries and poor user experience under high contention.

3. Explain pessimistic locking

Describe how it locks rows or tables upfront, ensuring serialized access. It's simple and effective for high contention within a single database but can lead to deadlocks and reduced throughput.

4. Explain distributed locks

Describe using Redis, ZooKeeper, or etcd to coordinate across services. It's necessary for distributed systems but adds complexity, latency, and potential for lock failures.

5. Recommend a solution and trade-offs

Propose a hybrid or alternative approach (e.g., database constraints, queues, or partitioning) and justify based on the scenario. Highlight that the choice depends on contention level and system architecture.

Key Points to Mention

  • Optimistic locking uses version checks and is suitable for low contention but requires retry logic.
  • Pessimistic locking (e.g., SELECT FOR UPDATE) prevents conflicts but can cause deadlocks and block other transactions.
  • Distributed locks (e.g., Redlock) are needed for cross-service coordination but introduce latency and failure modes.
  • Database unique constraints or transactions can prevent double-booking without explicit locks.
  • Alternative strategies: queue-based serialization, partitioning by resource ID, or using a single-threaded actor per resource.
  • Consider the CAP theorem and trade-offs between consistency and availability in distributed locking.

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