Performance
508 bites tagged Performance — interview questions with model answers, and 60-second explainers.
What is a Node.js Stream and why use one
A stream processes data in chunks over time, so memory stays bounded and work starts before all data arrives; ideal for large files and network IO. Understanding chunked processing and memory efficiency.
Solving the N+1 query problem in Sequelize
Define N+1 as one parent query plus one per child, detect it via SQL logging, fix with eager loading using include. ORM performance awareness. looping over results and querying associations individually.
http.Agent and connection pooling
The agent pools and keeps sockets alive, avoiding repeated TCP and TLS handshakes, controlled by keepAlive and maxSockets. reusing TCP connections for outbound requests. thinking each request always needs a fresh connection.
fs.watch vs fs.watchFile
Watch uses OS event notifications, efficient but inconsistent across platforms, watchFile polls stat at an interval, reliable but slower. file change detection mechanisms. not knowing watch is event based versus polling.
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.
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.
Diagnose database CPU saturation under load
Find the expensive queries via the database's stats, check for missing indexes and full scans, then fix with indexing, query rewrites, caching, or read replicas. DB performance diagnosis.
Load vs stress vs soak testing
Load tests expected traffic, stress pushes past limits to find the breaking point, soak runs sustained load for hours to expose leaks. Performance-test vocabulary.
Diagnosing a healthy p50 but breaching p99
One percent of requests are slow, hurting power users and fan-out calls; investigate GC, locks, contention, cold caches, retries. Understanding tail latency. Dismissing it because the average looks fine.
Performance Profiling
Profiling measures where a program actually spends its time and resources, attributing CPU cycles, memory, or wall-clock latency to specific functions or call paths. It replaces guesswork with data so optimization effort targets the real bottleneck.
Pinning exclusive CPU cores to a pod
Set kubelet CPU Manager policy to static, make the pod Guaranteed QoS with integer CPU limits equal to requests, so it gets exclusive dedicated cores. Achieving CPU pinning.
What do immutable ConfigMaps and Secrets solve?
Setting immutable true blocks data edits, preventing accidental updates and letting the kubelet skip watches, reducing API server load. knowledge of the immutable field.
Performance trade-offs of abstracting native UI
Bridge/serialization overhead, JS-thread bottlenecks for lists, and mitigations like virtualization, native modules, and profiling both threads. cost of cross-platform abstraction.
Minimizing library bundle-size impact on consumers
Track size in CI with size-limit, support granular imports, externalize peers, lazy-load heavy parts, audit with bundle analyzers. controlling bundle cost at scale. relying on tree-shaking alone with no measurement.
CSS-in-JS vs pre-compiled CSS for distribution
Runtime cost and dynamic theming of CSS-in-JS versus cacheability and SSR simplicity of static CSS. styling distribution trade-offs. declaring one universally better with no mention of runtime or caching.
Diagnosing high Redis eviction and cache misses
Use INFO memory and stats to confirm pressure, check fragmentation ratio, pick LFU over LRU for skewed access, set sane TTLs. practical Redis memory debugging. just raising maxmemory without finding the cause.
Diagnosing and optimizing a slow production query
Read the EXPLAIN ANALYZE plan, find the costly node, then fix via indexing, rewrite, or stats. methodical query-performance debugging. guessing at indexes before reading the actual execution plan.
Predicate pushdown and why it speeds queries
Apply WHERE conditions at the scan or remote source, prune partitions and rows early, shrink data movement. moving filters close to the data.
Tuning a database connection pool
Max size, min idle, connection and max-lifetime timeouts; size from cores and latency, not guesswork. connection-pool sizing intuition.
The N+1 query problem and how to fix it
One query for a list plus one per item for its relation, fix with eager loading or a batched join. recognizing ORM lazy-loading waste. blaming the database, or fixing it by caching instead of reducing round trips.
The small files problem in data lakes
Many tiny files create per-file overhead and metadata pressure, hurting scans; fix via compaction, batching writes, and tuning partitioning. diagnosing storage-layout performance issues.
Fixing an ORM's inefficient aggregation query
Drop to raw SQL or a view for the heavy report, or restructure the ORM query and add indexes. Raw SQL is fast but couples to the schema; tuning keeps portability. ORM escape hatches.
Eager vs lazy loading in an ORM
Eager fetches related data up front (joins/extra query); lazy defers until accessed. Lazy in a loop causes the N+1 query problem. ORM loading strategy. not naming N+1 or thinking eager is always cheaper.
Pooled connection lifecycle and close() semantics
Borrow from pool, use, then close() returns it to the pool rather than tearing down the socket. pooled connection semantics. thinking close() physically severs the connection, or never closing and leaking connections.
Get Performance bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.