← Anthropic Interview Insights

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

SeniorPrefer not to say
Apr 2026

Summary

System design round at Anthropic for a software engineer role, focused entirely on building a 1:1 chat system. The interviewer pushed hard on the transport layer choices and Kafka internals specifically, which I wasn't fully ready for.

Questions Asked (6)

Q1

Design a 1:1 chat system scoped to single-device web users. No group chat. Walk through the full architecture.

System DesignTechnical Trade-offs
Author's notes

I started with the usual WebSocket setup and a message store, which felt fine at first.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints (single-device, 1:1 only, web users) to bound the problem, then propose a high-level architecture with a clear data flow for message send/receive. Dive into key components like real-time transport, message storage, and delivery guarantees, explicitly discussing trade-offs at each decision point.

Pro tip: Anchor the design around the simplest reliable transport (e.g., WebSocket with HTTP fallback) and explicitly call out what you are NOT building (group chat, multi-device sync) to show scoping discipline—interviewers at Anthropic value clear reasoning over feature bloat.

1. Clarify requirements and constraints

Ask about scale (DAU, messages/sec), latency expectations, delivery guarantees (at-least-once vs exactly-once), and persistence needs. Confirm that single-device means no multi-device sync, and no group chat simplifies fan-out.

2. Sketch high-level architecture

Draw clients connecting via WebSocket to a connection gateway, which routes messages through a chat service to a message store and a delivery service. Include a presence service and a push notification fallback for offline users.

3. Detail message flow and storage

Explain how a sent message is persisted (e.g., in a message table keyed by conversation ID and timestamp), then delivered to the recipient if online, or queued for later retrieval. Discuss ordering (per-conversation sequence numbers) and idempotency.

4. Address reliability and scaling

Cover reconnection logic, message acknowledgment, offline delivery via pull-on-reconnect, and horizontal scaling of WebSocket servers using a pub/sub layer (e.g., Redis) to route messages between servers.

5. Discuss trade-offs and alternatives

Compare WebSocket vs long-polling vs SSE, SQL vs NoSQL for message storage, and synchronous vs asynchronous delivery. Justify choices based on the stated requirements and scale.

Key Points to Mention

  • WebSocket as primary transport with HTTP long-polling fallback for compatibility
  • Message persistence with per-conversation ordering and unique message IDs for idempotency
  • Presence service to track online/offline status and enable real-time delivery
  • Offline message queue and pull-on-reconnect mechanism for reliable delivery
  • Horizontal scaling via a pub/sub layer (e.g., Redis) to decouple WebSocket servers
  • Trade-offs between consistency, latency, and complexity (e.g., at-least-once vs exactly-once delivery)

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

Q2

If the recipient is offline when a message is sent, how do you ensure they receive it once they come back online?

System DesignTechnical Trade-offs
Author's notes

Talked through a durable inbox stored in the DB and a separate notification mechanism.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements and constraints (e.g., scale, latency, durability) and then propose a design that decouples message acceptance from delivery. Focus on durable storage, reliable retrieval upon reconnection, and trade-offs between consistency, availability, and complexity.

Pro tip: Emphasize idempotency and exactly-once semantics to avoid duplicate messages, and discuss how you would handle message ordering and expiration. Showing awareness of these edge cases demonstrates production maturity.

1. Clarify Requirements

Ask about scale (users, messages per second), latency expectations, durability guarantees, and whether ordering matters. This ensures your design meets the actual needs.

2. Design Durable Storage

Propose persisting messages in a reliable store (e.g., database, message queue) as soon as they are sent, so they survive server restarts and are available for later delivery.

3. Implement Delivery on Reconnection

When the recipient comes online, have them fetch undelivered messages from the store, using a mechanism like a message queue or pull-based API. Ensure the client acknowledges receipt to mark messages as delivered.

4. Handle Edge Cases

Address duplicates (via idempotency keys), ordering (using sequence numbers), and expiration (TTL). Also consider push notifications or fallback channels for timely delivery.

5. Discuss Trade-offs

Compare options: e.g., using a dedicated message queue vs. database polling, synchronous vs. asynchronous delivery, and the impact on latency, cost, and complexity.

Key Points to Mention

  • Durable message storage (e.g., database, message queue) to persist messages until delivery.
  • Pull-based retrieval upon reconnection, with client acknowledgments to confirm delivery.
  • Idempotency and deduplication to prevent duplicate messages.
  • Message ordering and sequencing to maintain conversation integrity.
  • Time-to-live (TTL) and expiration policies to manage storage and relevance.
  • Trade-offs between consistency, availability, and partition tolerance (CAP theorem) in the design.

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

Q3

How would you detect whether a user is currently online or offline?

System DesignAPI & Integrations
Author's notes

Heartbeat over the persistent connection plus a last-seen timestamp in a fast store.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: what does 'online' mean (active session vs. actively interacting), scale, and latency tolerance. Then propose a heartbeat-based mechanism with a TTL in a fast store like Redis, and discuss trade-offs and edge cases.

Pro tip: Mention that you'd combine heartbeats with graceful disconnect signals (e.g., WebSocket close) to reduce false positives, and set the TTL to 2-3x the heartbeat interval to tolerate transient network issues.

1. Clarify Requirements

Ask about scale, definition of 'online' (e.g., logged in vs. actively using), and acceptable latency for status changes.

2. Choose a Detection Mechanism

Propose heartbeats from the client at regular intervals, or use persistent connections (WebSocket) with ping/pong.

3. Store and Expire Status

Use a fast data store like Redis with TTL: update a key on each heartbeat, and consider the user offline when the key expires.

4. Handle Edge Cases

Account for network partitions, app crashes, and multiple devices; use graceful disconnect signals when possible.

5. Scale and Optimize

Discuss sharding, reducing write load (e.g., batched updates), and using pub/sub to notify interested services of status changes.

Key Points to Mention

  • Heartbeat interval and TTL trade-off (e.g., 30s heartbeat, 90s TTL)
  • Using Redis with TTL for efficient expiry and lookups
  • WebSocket ping/pong or TCP keepalive for persistent connections
  • Graceful disconnect handling to mark offline immediately
  • Handling multiple devices/sessions per user
  • Scalability considerations: sharding, write volume, and pub/sub for notifications

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

Q4

Compare Kafka and Redis as the backing transport for messages and presence data. When would you choose one over the other?

System DesignTechnical Trade-offsData Modeling
Author's notes

This is where the interview got real.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the distinct requirements of message transport (durability, ordering, throughput) versus presence data (low-latency reads/writes, ephemeral state, TTL). Then compare Kafka and Redis against those requirements, highlighting trade-offs in consistency, scalability, and operational complexity. Finally, give concrete scenarios where each excels, and discuss hybrid architectures if appropriate.

Pro tip: Emphasize that presence data is often ephemeral and read-heavy, making Redis's in-memory speed and TTL support ideal, while Kafka's durability and replayability suit event streaming. Mention that using both in tandem—Kafka for reliable event logs and Redis for real-time presence—can be a pragmatic choice.

1. Clarify requirements

Identify the key needs for message transport (durability, ordering, throughput, replay) and presence data (low latency, high read/write, TTL, ephemeral nature).

2. Compare Kafka and Redis

Evaluate each system against the requirements: Kafka's persistent log, partitioning, and consumer groups vs. Redis's in-memory speed, pub/sub, and data structures with TTL.

3. Analyze trade-offs

Discuss consistency, scalability, fault tolerance, and operational complexity. For example, Kafka guarantees durability but adds latency; Redis is fast but may lose data on failure without persistence.

4. Choose based on use case

Decide when to use Kafka (e.g., event sourcing, stream processing, reliable message delivery) vs. Redis (e.g., real-time presence, caching, ephemeral state).

5. Consider hybrid approaches

Explain how combining both can leverage strengths: Kafka for durable event streaming and Redis for low-latency presence and caching.

Key Points to Mention

  • Kafka's durability, ordering, and replayability vs. Redis's in-memory speed and TTL
  • Presence data is often ephemeral and requires low-latency reads/writes, suiting Redis
  • Message transport may need guaranteed delivery and ordering, suiting Kafka
  • Scalability: Kafka scales via partitions; Redis scales via clustering/sharding
  • Consistency and fault tolerance: Kafka replicates and persists; Redis may lose data without persistence
  • Hybrid architecture: use Kafka for event log and Redis for real-time presence

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

Q5

Walk me through Kafka internals: topics, partitions, replication, ISR, consumer groups, and offsets.

System DesignTechnical Trade-offs
Author's notes

I knew enough to not embarrass myself but ISR (in-sync replicas) is where I got fuzzy.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Structure your answer as a logical flow from the write path (producer to broker) to the read path (consumer), explaining how each component (topics, partitions, replication, ISR, consumer groups, offsets) fits together. Emphasize the trade-offs and design decisions that enable Kafka's scalability, fault tolerance, and ordering guarantees.

Pro tip: Tie every concept back to a real-world implication—e.g., how partition count affects parallelism and ordering, or how ISR and acks settings balance durability and latency. This shows you understand not just the mechanics but also the operational consequences.

1. Start with the write path: topics and partitions

Explain that a topic is a logical stream, divided into partitions for scalability and parallelism. Describe how producers append messages to partitions, and how partition choice (key-based or round-robin) affects ordering.

2. Explain replication and ISR for fault tolerance

Describe how each partition has a leader and followers, and how the ISR (in-sync replicas) tracks replicas that are caught up. Mention how acks and min.insync.replicas settings affect durability.

3. Cover the read path: consumer groups and offsets

Explain that consumers in a group divide partitions among themselves, and each consumer tracks its offset (position) in each partition. Mention offset commit strategies and how they affect delivery semantics.

4. Discuss trade-offs and failure scenarios

Highlight how partition count, replication factor, and acks settings involve trade-offs between throughput, latency, durability, and ordering. Briefly mention what happens during broker failure or consumer rebalance.

Key Points to Mention

  • Topics are logical, partitions are physical; partitions enable parallelism and ordering within a partition.
  • Replication factor and ISR: leader handles reads/writes, followers replicate; ISR shrinks when followers lag.
  • acks=all + min.insync.replicas ensures durability; acks=1 or 0 trades durability for latency.
  • Consumer groups: partitions are assigned to consumers; rebalancing occurs when consumers join/leave.
  • Offsets: consumers commit offsets to __consumer_offsets topic; auto-commit vs manual commit affects at-least-once vs at-most-once.
  • Partition count is fixed (can only increase) and determines max consumer parallelism in a group.

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

Q6

How would you handle session persistence and correct ordering of message history?

System DesignData Modeling
Author's notes

Talked through storing messages with a monotonically increasing sequence ID per conversation, with the session state kept server-side.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the requirements: what kind of session persistence is needed (e.g., client-side vs. server-side), and what ordering guarantees are required (e.g., causal, total). Then propose a design that combines a durable storage layer (like a database or log) with a mechanism to assign and enforce order, such as sequence numbers or timestamps, and discuss trade-offs.

Pro tip: Mention that ordering and persistence are often coupled: you can use a distributed log (e.g., Kafka) or a database with monotonic sequence numbers to achieve both, but you must handle edge cases like concurrent writes and network partitions.

1. Clarify requirements

Ask about scale, consistency needs, and whether ordering is per-session or global. Determine if sessions are long-lived or short-lived.

2. Choose persistence strategy

Decide between client-side storage (e.g., cookies, localStorage) and server-side storage (e.g., database, Redis). Consider durability, scalability, and security.

3. Design ordering mechanism

Use sequence numbers, timestamps, or a centralized log to assign order. Ensure that the ordering is consistent across replicas if distributed.

4. Handle concurrency and failures

Address race conditions, idempotency, and retries. Use optimistic concurrency control or locks where necessary.

5. Discuss trade-offs and alternatives

Compare options like using a single database vs. a distributed log, and explain how you'd handle scaling and latency.

Key Points to Mention

  • Session ID generation and management
  • Sequence numbers or logical clocks for ordering
  • Durable storage options (SQL, NoSQL, distributed logs)
  • Consistency models (strong vs. eventual)
  • Idempotency and deduplication
  • Handling out-of-order messages (buffering, reordering)

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