InterviewStack.io LogoInterviewStack.io

Performance and Code Optimization Questions

Covers techniques and decision making for improving application and code performance across levels from algorithm and memory access patterns to frontend bundling and runtime behavior. Candidates should be able to profile and identify bottlenecks, apply low level optimizations such as loop unrolling, function inlining, cache friendly access patterns, reducing branching, and smart memory layouts, and use compiler optimizations effectively. It also includes higher level application and frontend optimizations such as code splitting and lazy loading, tree shaking and dead code elimination, minification and compression, dynamic imports, service worker based caching, prefetching strategies, server side rendering versus client side rendering trade offs, static site generation considerations, and bundler optimization with tools like webpack Vite and Rollup. Emphasize measurement first and avoiding premature optimization, and explain the trade offs between performance gains and added complexity or maintenance burden. At senior levels expect ability to make intentional trade off decisions and justify which optimizations are worth their complexity for a given system and workload.

EasyTechnical
18 practiced
A public endpoint runs the SQL: SELECT * FROM orders WHERE customer_id = ? ORDER BY created_at DESC LIMIT 20. The orders table has 100M rows and created_at is not indexed. Describe immediate changes you would apply to reduce latency, including index strategy, pagination pattern, and any trade-offs for read freshness and write cost.
MediumTechnical
22 practiced
A multi-threaded Java service shows heavy contention on a single synchronized block. Propose refactorings and alternative concurrency primitives to reduce contention, including sharding, concurrent collections, ReadWriteLock, and lock-free options. Discuss trade-offs in complexity and correctness.
HardTechnical
20 practiced
Your service shows acceptable median latency but p99 and p999 latencies spike unpredictably. List possible root causes (including GC, OS scheduling, head-of-line blocking, retries) and describe instrumentation and mitigation strategies for each cause to reduce tail latency.
HardSystem Design
19 practiced
Architect a globally distributed caching layer for session data supporting 10M active users with target read latency <50ms and strong per-user consistency. Cover data placement, replication, consistency model, cache coherence, failover, and operational monitoring. Explain trade-offs between latency and consistency.
HardTechnical
22 practiced
A large monorepo with frontend and backend teams has slow CI builds and slow developer feedback loops. Propose tooling and architectural changes such as remote caching, build system choice (e.g., Bazel), dependency graphs, and incremental builds to speed up developer iteration. Discuss trade-offs and migration plan.

Unlock Full Question Bank

Get access to hundreds of Performance and Code Optimization interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.