← Sesame Interview Insights

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

Senior
May 2026

Summary

System design round at Sesame for a software engineering role. The whole thing was basically one big networking question dressed up as a product feature, which I didn't fully appreciate until I was halfway through explaining threads.

Questions Asked (1)

Q1

Design a TCP-based chat server where multiple clients can connect, send messages that get broadcast to all other connected clients, and the server handles clients joining and leaving cleanly. Walk through your concurrency model, how you'd handle message framing on a raw TCP stream, and graceful shutdown.

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

I jumped straight into thread-per-connection because it felt obvious, and the interviewer just kind of waited.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements (scale, persistence, auth) and then present a high-level architecture. Walk through the concurrency model (e.g., thread-per-client or event-driven), explain message framing with length-prefixed messages, and cover graceful shutdown with connection draining and resource cleanup.

Pro tip: Mention that you'd use a length-prefixed framing protocol (e.g., 4-byte header) to avoid message boundary issues, and discuss how you'd handle partial reads/writes and backpressure.

1. Clarify Requirements and Scope

Ask about expected number of concurrent clients, message size limits, persistence, authentication, and whether ordering matters. This shows you think before coding.

2. Choose Concurrency Model

Discuss trade-offs between thread-per-connection (simple, but limited scalability) and event-driven (e.g., epoll/kqueue, scalable but complex). Mention hybrid approaches like thread pools with non-blocking I/O.

3. Design Message Framing

Explain that TCP is a stream, so you need framing. Propose length-prefixed messages (e.g., 4-byte big-endian length followed by payload) and describe handling partial reads and writes.

4. Handle Client Join/Leave and Broadcast

Describe a shared registry of clients (e.g., concurrent set) with synchronization. For broadcast, iterate over clients and send messages, handling slow clients with timeouts or queues.

5. Implement Graceful Shutdown

Explain how to stop accepting new connections, notify clients, drain pending messages, and close sockets cleanly. Use signals (e.g., SIGTERM) and a shutdown flag.

Key Points to Mention

  • Thread-per-client vs. event-driven (e.g., epoll) concurrency models and their trade-offs
  • Length-prefixed message framing to handle TCP stream boundaries
  • Handling partial reads/writes and backpressure with slow clients
  • Thread-safe client registry and broadcast mechanism
  • Graceful shutdown: draining connections, sending close notifications, and resource cleanup
  • Error handling: disconnections, timeouts, and malformed messages

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