← Series B+ Startup Interview Insights

Series B+ Startup·Software Engineer·Technical Phone Screen·Intermediate

IntermediateRejected
May 2026

Summary

Pair programming round for a software engineer role, had to build a pub-sub system in Python using the threading library. Didn't make it past this one.

Questions Asked (1)

Q1

Implement a simple Publish-Subscribe system using Python's threading library, in a pair programming session.

System DesignTechnical Trade-offsAPI & Integrations
Author's notes

This wrecked me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then outline a simple design with a thread-safe broker and subscriber callbacks. Implement incrementally, explaining your choices and trade-offs as you code, and test with multiple threads to demonstrate correctness.

Pro tip: Use a lock to protect shared state and consider using a queue for message delivery to decouple publishers and subscribers, but be ready to discuss the trade-offs of synchronous vs asynchronous delivery.

1. Clarify Requirements

Ask questions to understand expected scale, delivery guarantees, and whether subscribers should be called synchronously or asynchronously. Confirm the scope: simple in-memory pub-sub with threads.

2. Design the API

Define the core classes: Broker with subscribe, unsubscribe, and publish methods; Subscriber with a callback. Decide on thread-safety mechanisms (e.g., locks).

3. Implement Incrementally

Code the Broker with a lock-protected subscriber list. Implement publish to iterate over subscribers and invoke callbacks. Add unsubscribe. Test with simple single-threaded cases first.

4. Add Thread Safety and Testing

Ensure all shared state is protected. Write a test with multiple publisher and subscriber threads to verify no race conditions. Consider using a queue for asynchronous delivery if needed.

5. Discuss Trade-offs and Extensions

Explain choices: lock granularity, synchronous vs asynchronous, error handling in callbacks. Mention potential improvements like topic-based filtering or using condition variables.

Key Points to Mention

  • Thread safety: use locks or other synchronization primitives to protect shared data structures.
  • Synchronous vs asynchronous delivery: trade-offs between simplicity and decoupling/performance.
  • Error handling: how to handle exceptions in subscriber callbacks without affecting other subscribers.
  • Scalability: limitations of a simple in-memory broker and potential improvements (e.g., queues, topic filtering).
  • Testing: importance of stress-testing with multiple threads to catch race conditions.
  • API design: clear separation of concerns between broker and subscribers, and ease of use.

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