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.

HardSystem Design
33 practiced
Design an API gateway that terminates TLS, performs authentication, enforces rate-limiting, performs routing, and provides response caching for thousands of backend services while adding no more than 10ms p50 latency. Describe the architectural components, TLS offload options, caching strategies and keys, placement (edge vs regional), scaling model, and monitoring/alerting approach.
EasyTechnical
20 practiced
Compare JSON and Protocol Buffers (protobuf) for inter-service communication in terms of serialization/deserialization speed, payload size, CPU cost, schema evolution, and developer ergonomics. For a high-throughput RPC path between microservices, recommend an approach and justify tradeoffs including backward compatibility, human readability, and operational observability.
EasyTechnical
19 practiced
How do you determine whether a production service is CPU-bound or I/O-bound? Describe the metrics, OS commands, and thresholds you would use (e.g., CPU utilization, iowait, network throughput, disk queue length), and outline a short controlled experiment to confirm your diagnosis.
MediumTechnical
24 practiced
A nightly batch job sorts 100M small records and then aggregates by key, taking hours. Propose algorithmic and systems-level optimizations: external sort/merge (spill to disk), partitioning and distributed shuffle, pre-aggregation, approximate algorithms (HyperLogLog), or using map-reduce frameworks. Compare tradeoffs in latency, accuracy, resource cost, and operational complexity.
MediumTechnical
16 practiced
Explain the tradeoffs between gzip, brotli, and zstd for HTTP response compression. For a JSON API returning ~100KB responses to mobile clients, recommend which compression algorithm and level you'd choose for latency-sensitive users, discussing CPU cost for compression on the server and decompression on the client, and cacheability implications.

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.