Interview Notes Search

Hello InterviewQuick Reference

Full Article

Common Patterns

Realtime Updates

Transport Protocol

HTTP polling is the default until it no longer serves needs and is simplest but not the most efficient, while Server-sent events and Websockets are purpose-built for realtime updates but their infrastructure can be tricky.

  • HTTP polling : Default until it no longer serves needs; simplest, but not the most efficient.
  • Server-sent events (SSE) : Purpose-built for realtime updates; infrastructure can be tricky.
  • Websockets : Purpose-built for realtime updates; infrastructure can be tricky.

Server-Side Fanout

Pub/Sub services decouple publisher and subscriber for pushing updates, while stateful servers with a consistent hash ring fit heavier server-side processing.

  • Pub/Sub services : Decouple publisher and subscriber for pushing updates.
  • Stateful servers : Use with a consistent hash ring when server-side processing is heavier.

Async Coordination

Task Execution

Synchronous processing is the default for short-running jobs with simpler architecture and clearer back-pressure; Async worker pools are for tasks taking more than a few seconds and return a job ID within milliseconds.

  • Synchronous processing : Default for short-running jobs; simpler architecture and clearer back-pressure.
  • Async worker pools : Use for tasks taking more than a few seconds; return a job ID within milliseconds.

Job Observability

Job status tracking exposes final state after returning the job ID; Progress exposure exposes progress after returning the job ID.

  • Job status tracking : Expose final state after returning the job ID.
  • Progress exposure : Expose progress after returning the job ID.

Failure Handling

Retries re-run failed jobs instead of making users resubmit heavy work; Dead letter queues handle poison messages that fail normal processing.

  • Retries : Re-run failed jobs instead of making users resubmit heavy work.
  • Dead letter queues : Handle poison messages that fail normal processing.

Workflow Coordination

Event sourcing has each step emit events that trigger subsequent steps; Workflow engines such as Temporal or AWS Step Functions handle state, failure recovery, and retries.

  • Event sourcing : Each step emits events that trigger subsequent steps.
  • Workflow engines : Temporal or AWS Step Functions handle state, failure recovery, and retries.

Contention Control

Atomicity and transactions are the default starting point using database guarantees before distributed coordination; Pessimistic locking is a database-level approach for simultaneous access to the same resource; Optimistic concurrency control is a database-level approach for preventing race conditions; Distributed locks are used when contention coordination spans distributed systems; Queue-based serialization serializes contended operations through a queue.

  • Atomicity and transactions : Default starting point; use database guarantees before distributed coordination.
  • Pessimistic locking : Database-level approach for simultaneous access to the same resource.
  • Optimistic concurrency control : Database-level approach for preventing race conditions.
  • Distributed locks : Use when contention coordination spans distributed systems.
  • Queue-based serialization : Serialize contended operations through a queue.

Data Scaling

Read Progression

1

Optimize with indexing

First scale read performance within the database.

2

Denormalize reads

Store read-friendly shapes before adding external infrastructure.

3

Add read replicas

Scale horizontally once the primary database read path is not enough.

4

Add Redis and CDNs

Use external caching layers after database-side scaling.

Write Strategies

Horizontal sharding distributes data across multiple servers and requires careful partition keys; Vertical partitioning separates different types of data; Write queues buffer temporary write spikes; Load shedding prioritizes important writes during overload; Batching groups writes to reduce per-operation overhead.

  • Horizontal sharding: Distribute data across multiple servers; choose partition keys carefully.
  • Vertical partitioning : Separate different types of data.
  • Write queues : Buffer temporary write spikes.
  • Load shedding : Prioritize important writes during overload.
  • Batching : Group writes to reduce per-operation overhead.

Files And Location

Upload And Metadata Strategy

Direct client-to-storage

Use for large files; avoid routing gigabytes through application servers.

Event notifications

Keep database metadata and blob storage state consistent.

Database metadata and blob storage state

Keep database metadata and blob storage state consistent.

Download Distribution

CDN delivery serves downloads globally; Global delivery serves downloads globally.

  • CDN delivery : Serve downloads globally.
  • Global delivery : Serve downloads globally.

Download Access Control

Signed URLs provide access control; Scoped credentials are temporary scoped credentials.

  • Signed URLs : Use signed URLs for access control.
  • Scoped credentials : Temporary scoped credentials.

Scan all items for a map of 1,000 items because it is cheaper than purpose-built index overhead; Geospatial indexes are for hundreds of thousands or millions of local proximity entities.

  • Scan all items : Use for a map of 1,000 items; cheaper than purpose-built index overhead.
  • Geospatial indexes : Use for hundreds of thousands or millions of local proximity entities.