Skip to content
tezvyn:

Concurrency

183 bites tagged Concurrency — interview questions with model answers, and 60-second explainers.

Node.js & Express1 min read

postMessage vs SharedArrayBuffer in worker_threads tradeoffs?

Structured cloning copies data, SharedArrayBuffer shares memory. IPC performance and memory model understanding. cloning has overhead but safety isolation, SharedArrayBuffer is zero-copy but requires atomic operations.

TypeScript & Web APIs2 min read

Dedicated vs Shared vs Service Workers compared

Dedicated worker serves one page for offloading CPU; Shared worker is one instance across same-origin contexts via ports; Service worker is a network proxy for caching and push, event-driven and killable. Browser worker types and roles.

React & Next.js1 min read

Tearing and useSyncExternalStore in concurrent React

Tearing is inconsistent UI when an interruptible render reads a changed external store mid-pass; useSyncExternalStore subscribes and forces consistent snapshots, re-rendering synchronously on change. Concurrency consistency guarantees.

React Native2 min read

Threading of native module methods

Methods run on a dedicated native module queue, not the UI thread; long blocking work stalls other module calls; offload to a background executor or override methodQueue, returning results via promise. native module threading.

React Native1 min read

How do you move a 500ms blocking task off the JS thread?

Offload to a native module or C++ TurboModule, a worklet/worker thread, or chunk the work and yield; never block JS. concurrency strategy in RN. wrapping a synchronous loop in a Promise and assuming it stops blocking.

Python & FastAPI1 min read

SQLAlchemy connection pooling across Uvicorn workers

Each worker has its own pool; total DB connections equal workers times (pool_size plus max_overflow); overflow connections are temporary; misconfiguration exhausts DB… Connection pool sizing under multi-process concurrency.

Python & FastAPI1 min read

asyncio.gather vs asyncio.wait

Gather returns ordered results and propagates the first exception (or captures them); wait returns done/pending sets and never raises, you inspect each. Whether you know how each aggregates results and handles errors.

Node.js & Express1 min read

worker_threads versus cluster: when to use each

Worker_threads offloads CPU-bound compute within one process with shared-memory transfer; cluster forks processes to scale IO-bound request throughput across cores. Matching the concurrency tool to the workload.

Node.js & Express2 min read

Offloading CPU work with worker_threads

Heavy sync work blocks the single event loop and stalls all requests; move it to a Worker, message the input, await the result asynchronously, and ideally pool workers. Keeping the event loop free during CPU-bound work.

Node.js & Express1 min read

Purpose of the Node.js cluster module

Cluster forks worker processes sharing one listening port, so requests spread across CPU cores via the OS, raising throughput and adding resilience. Knowing Node is single-threaded per process and how to use all cores.

Node.js & Express1 min read

Atomic order creation with Sequelize transactions

Wrap dependent writes in sequelize.transaction, pass the transaction to each query, let managed transactions auto-commit or roll back. atomicity and transaction handling.

Node.js & Express1 min read

Promise.all vs Promise.allSettled

All rejects on the first failure; allSettled always fulfills with a status/value or reason per input. Use allSettled when partial success is acceptable. choosing fail-fast vs collect-all.

Node.js & Express2 min read

Bounded concurrency for many async requests

Chunk the array and await Promise.all per chunk, or run a fixed worker pool pulling from a shared index; cap in-flight requests. limiting concurrency, not just running parallel. firing all 1000 at once or going fully serial.

Node.js & Express1 min read

Running independent requests with Promise.all and race

Start all requests then await Promise.all to get all results or fail fast on first rejection; use Promise.race when only the fastest settled result matters. concurrent Promise combinators.

Node.js & Express1 min read

Offloading CPU-bound work with Worker Threads

Synchronous CPU work freezes the loop and all requests; offload to a Worker, communicate via messages or SharedArrayBuffer, use a pool. knowing the single thread blocks on CPU work. suggesting async I/O fixes CPU blocking.

Node.js & Express1 min read

Order of the Node.js event loop phases

Timers, pending callbacks, poll, check, close phases in order; I/O completion runs in poll. understanding of libuv's loop, not just async vibes. claiming Node is single-phase or fully multithreaded.

Monitoring & SRE2 min read

Why does 200ms latency drop requests? Diagnose it.

Little's Law shows added latency raises in-flight requests, exhausting the thread or connection pool; check pool saturation, timeouts, and retries. Reasoning about concurrency limits and queueing.

Monitoring & SRE1 min read

Little's Law for capacity planning

L equals lambda times W, concurrency equals arrival rate times time in system; rearrange to size threads or concurrency for a target throughput and latency. Queueing fundamentals.

Monitoring & SRE1 min read

Backpressure

Backpressure is a mechanism by which a slow consumer signals an upstream producer to slow down or stop, preventing unbounded queues and resource exhaustion. It keeps systems stable under overload by propagating capacity limits backward through a pipeline.

Databases & Architecture1 min read

SQL isolation levels and the anomalies they prevent

Read Uncommitted allows dirty reads; Read Committed blocks them; Repeatable Read blocks non-repeatable reads; Serializable blocks phantoms. the isolation-anomaly mapping.

Databases & Architecture2 min read

Iceberg vs Delta Lake metadata and ACID

Iceberg uses a tree of metadata and manifest files with atomic pointer swaps and optimistic concurrency; Delta uses an ordered transaction log of JSON commits with optimistic concurrency. deep table-format internals.

Databases & Architecture1 min read

Unit of Work / Session pattern in ORMs

The Unit of Work tracks new, dirty, and deleted objects, then flushes them as one batched transaction at commit. ORM session mechanics.

Databases & Architecture1 min read

Transaction isolation levels and their tradeoffs

Isolation levels control which concurrency anomalies (dirty/non-repeatable reads, phantoms) are allowed; higher levels mean stronger consistency but more blocking and less concurrency. isolation tradeoffs.

Databases & Architecture1 min read

Connection pools and the problem they solve

A pool reuses pre-opened connections so requests skip the expensive connect handshake; without one, every request pays setup latency and may overwhelm the database. connection reuse basics.

Get Concurrency bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.

Concurrency — 183 bites · Tezvyn