← TikTok Interview Insights

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

SeniorPrefer not to say
May 2026

Summary

System design round at TikTok for a software engineer role. The whole thing was centered on one big problem: a hotel booking backend that has to survive viral traffic spikes. Felt like a solid interview but there's a lot of ground to cover and I definitely ran out of time on some parts.

Questions Asked (5)

Q1

Design the backend for a large-scale hotel booking system that needs to handle viral traffic spikes, near real-time availability, and guaranteed no double-bookings.

System DesignTechnical Trade-offs
Author's notes

This is the main question and it sprawls in every direction.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and scale, then design a high-level architecture that separates read and write paths. Focus on the core challenge of preventing double-bookings under high concurrency, using a combination of distributed locking, idempotency, and transactional consistency. Finally, address availability and caching strategies to handle viral traffic spikes.

Pro tip: Emphasize that correctness (no double-bookings) trumps availability during booking writes, but reads can be eventually consistent. Mention that you'd use a saga pattern or two-phase commit only if necessary, and prefer single-digit millisecond locking with Redis or a database with strong consistency.

1. Clarify Requirements and Scale

Ask about expected traffic (e.g., millions of concurrent users), booking patterns, consistency needs, and geographic distribution. Define functional and non-functional requirements.

2. High-Level Architecture

Propose a microservices-based architecture with separate services for search, booking, inventory, and payment. Use API gateway, load balancers, and CDN for static content.

3. Data Model and Storage

Design a schema for hotels, rooms, availability, and bookings. Choose a relational database (e.g., PostgreSQL) for bookings to ensure ACID, and NoSQL or in-memory stores for availability caching.

4. Concurrency and Consistency

Detail how to prevent double-bookings: use distributed locks (e.g., Redis Redlock) or optimistic concurrency control with versioning. Ensure idempotent booking requests and handle failures with retries and compensating transactions.

5. Scalability and Availability

Explain how to handle viral spikes: auto-scaling, read replicas, caching availability data, and rate limiting. Discuss trade-offs between consistency and availability (CAP theorem) and how to achieve eventual consistency for reads.

Key Points to Mention

  • Distributed locking mechanisms (e.g., Redis, ZooKeeper) for preventing double-bookings
  • Idempotency keys for booking requests to handle retries safely
  • Database sharding and replication strategies for scalability
  • Caching layers (e.g., Redis, CDN) for near real-time availability
  • Message queues (e.g., Kafka) for asynchronous processing and decoupling
  • Monitoring and alerting for booking conflicts and system health

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

Q2

When would you choose a low-overhead protocol like UDP or persistent WebSocket connections instead of plain HTTP for parts of this system, and which flows can tolerate message loss versus which cannot?

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

Availability count updates to the UI are fine to lose since a stale count just gets refreshed on the next poll.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the system's requirements and the specific flows involved, then compare protocols based on latency, overhead, reliability, and ordering needs. For each flow, decide whether it can tolerate message loss or requires guaranteed delivery, and justify your protocol choice with trade-offs.

Pro tip: Demonstrate maturity by acknowledging that most systems use a mix of protocols and that the choice depends on the specific use case, not a one-size-fits-all solution. Also, mention that you would measure and monitor the impact of protocol choices on key metrics like latency and error rates.

1. Clarify requirements

Ask questions to understand the system's scale, latency requirements, and the nature of the data flows (e.g., real-time updates, video streaming, chat).

2. Identify flow characteristics

List the different flows in the system and categorize them by whether they require reliability, ordering, low latency, or can tolerate loss.

3. Compare protocol trade-offs

For each flow, compare UDP, WebSocket, and HTTP based on overhead, latency, reliability, and complexity. Consider factors like connection setup, head-of-line blocking, and statefulness.

4. Match protocols to flows

Assign the most suitable protocol to each flow, explaining why it fits the requirements and what trade-offs are acceptable.

5. Address reliability and fallbacks

For flows that cannot tolerate loss, describe how you would ensure reliability (e.g., application-level acks, retries) and consider fallback mechanisms.

Key Points to Mention

  • UDP is suitable for real-time, low-latency applications like live video streaming or gaming where occasional packet loss is acceptable.
  • WebSocket provides full-duplex communication over a single TCP connection, ideal for real-time bidirectional flows like chat or live comments.
  • HTTP is stateless and request-response based, best for traditional API calls where reliability and simplicity are more important than latency.
  • Message loss tolerance depends on the flow: video/audio streaming can tolerate some loss, but financial transactions or chat messages cannot.
  • Consider the overhead of connection establishment and maintenance: WebSocket requires an initial HTTP handshake but then has lower per-message overhead.
  • For flows that require reliability over UDP, you can implement application-level acknowledgments and retransmissions, but be aware of increased complexity.

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

Q3

Under high concurrency, how do you prevent two users from both successfully booking the last available room for the same dates?

System DesignTechnical Trade-offs
Author's notes

My first instinct was a distributed lock per room-night, which I knew was going to invite follow-up about lock contention.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: the system must guarantee that only one booking succeeds for the last room under high concurrency. Then propose a layered solution combining database-level atomic operations (e.g., conditional updates or unique constraints) with application-level locking or optimistic concurrency control, and discuss trade-offs like performance, consistency, and scalability.

Pro tip: Mention that you would use a database transaction with a conditional UPDATE (e.g., UPDATE rooms SET available = available - 1 WHERE room_id = ? AND available > 0) and check the affected row count, as this is simple, atomic, and avoids race conditions without distributed locks. Also highlight the importance of idempotency keys to handle retries safely.

1. Clarify requirements and constraints

Confirm the expected scale, consistency requirements (strong vs. eventual), and whether the system is single-node or distributed. This sets the context for choosing the right concurrency control mechanism.

2. Identify the critical section

Pinpoint the exact operation that must be atomic: checking availability and decrementing inventory for the specific room and dates. This is the race condition hotspot.

3. Choose a concurrency control strategy

Select from options like database transactions with row-level locks, optimistic concurrency control (version numbers), conditional updates, or distributed locks (e.g., Redis). Explain why your choice fits the scenario.

4. Address edge cases and failure modes

Discuss handling of retries, idempotency, deadlocks, lock timeouts, and network partitions. Explain how to ensure correctness even if a node fails mid-operation.

5. Evaluate trade-offs and scalability

Compare performance, complexity, and consistency guarantees of your approach. Mention how it scales under high concurrency and whether it introduces bottlenecks.

Key Points to Mention

  • Database transactions with SELECT ... FOR UPDATE or conditional UPDATE to ensure atomicity.
  • Optimistic concurrency control using version numbers or timestamps to detect conflicts.
  • Distributed locking with Redis or ZooKeeper for cross-service coordination, noting its complexity and potential for bottlenecks.
  • Idempotency keys to prevent duplicate bookings from retries.
  • Handling of race conditions in a distributed system, including clock skew and network delays.
  • Trade-offs between strong consistency (e.g., serializable isolation) and performance/availability.

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

Q4

How would you horizontally partition load for a hotel that suddenly goes viral? Compare sharding by room versus bucketing by user ID.

System DesignData Modeling
Author's notes

Sharding by room type or room ID keeps all writes for a given room on one shard which makes the no-double-booking guarantee easier to enforce.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the workload characteristics and access patterns for a viral hotel scenario, then compare sharding by room versus bucketing by user ID across dimensions like scalability, hotspot mitigation, and query efficiency. Conclude with a recommendation that balances even load distribution with operational simplicity, possibly using a hybrid approach.

Pro tip: Emphasize that the choice depends on the dominant query pattern: if most queries are by room (e.g., availability, bookings), sharding by room is natural; if user-centric (e.g., recommendations, history), bucketing by user ID is better. Also mention that viral events often cause skewed traffic, so a dynamic sharding strategy may be needed.

1. Clarify Requirements and Workload

Identify the primary access patterns (read/write ratio, queries per second, data size) and the nature of the viral event (e.g., sudden spike in bookings vs. views).

2. Analyze Sharding by Room

Discuss how partitioning by room ID distributes data and load, and evaluate its pros (locality for room-specific queries) and cons (hotspots if certain rooms are popular).

3. Analyze Bucketing by User ID

Explain how bucketing by user ID (e.g., hash of user ID) spreads load across shards, and assess its pros (even distribution for user-centric operations) and cons (cross-shard queries for room data).

4. Compare and Recommend

Weigh the trade-offs based on the workload, and propose a solution (e.g., shard by room for booking data, bucket by user for session data) or a hybrid approach with consistent hashing.

5. Address Scalability and Hotspots

Discuss how to handle hotspots (e.g., dynamic rebalancing, caching, read replicas) and ensure the system can scale horizontally during viral spikes.

Key Points to Mention

  • Consistent hashing to minimize rebalancing when adding/removing shards
  • Hotspot mitigation techniques: caching, read replicas, dynamic shard splitting
  • Query patterns: room-centric vs. user-centric operations and their impact on shard key choice
  • Data locality and cross-shard query costs
  • Scalability and elasticity during sudden traffic spikes
  • Trade-offs between simplicity (single shard key) and flexibility (hybrid or multi-level sharding)

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

Q5

What data model would you use for hotels, rooms, inventory, and bookings, and how does it support both fast availability lookups and transactional booking writes?

Data ModelingSystem Design
Author's notes

Kept it fairly standard: hotels table, room_types table, an inventory table keyed on (hotel_id, room_type_id, date) with a count column, and a bookings table.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the core entities and their relationships, then propose a normalized relational schema with appropriate indexes for fast availability lookups. Explain how to handle transactional booking writes using ACID transactions and isolation levels, and discuss scaling strategies like sharding or caching for high read throughput.

Pro tip: Mention that availability lookups can be optimized with a materialized view or a separate inventory table that tracks room counts per date, updated transactionally. This shows you understand the trade-off between read performance and write consistency.

1. Identify Entities and Relationships

Define the main entities: Hotel, RoomType, Room, Inventory, and Booking. Establish relationships: a hotel has many room types, each room type has many rooms, inventory tracks availability per room type per date, and bookings link to specific rooms and dates.

2. Design the Schema

Propose a normalized relational schema with tables for Hotels, RoomTypes, Rooms, Inventory (with columns like room_type_id, date, total_rooms, booked_rooms), and Bookings. Use foreign keys to enforce referential integrity.

3. Optimize for Fast Availability Lookups

Create indexes on Inventory (room_type_id, date) and consider denormalizing availability into a separate table or using a materialized view. Discuss caching strategies (e.g., Redis) for frequently accessed dates.

4. Ensure Transactional Booking Writes

Use database transactions with appropriate isolation levels (e.g., Serializable or Repeatable Read) to prevent double-booking. Implement optimistic concurrency control with versioning or pessimistic locking on inventory rows.

5. Address Scalability and Trade-offs

Discuss sharding by hotel_id or region, read replicas for availability queries, and the trade-offs between consistency and latency. Mention eventual consistency for non-critical data like reviews.

Key Points to Mention

  • Normalized schema with separate tables for hotels, room types, rooms, inventory, and bookings.
  • Inventory table tracking total and booked rooms per room type per date for quick availability checks.
  • Use of database transactions and isolation levels to prevent double-booking during concurrent writes.
  • Indexing and caching strategies to speed up availability lookups.
  • Sharding and read replicas for horizontal scalability.
  • Trade-offs between strong consistency for bookings and eventual consistency for other data.

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