Chaturmind
LearnDSASystem DesignInterview PrepDevOpsEngineering GrowthBlog
Start learning
Chaturmind

Structured learning paths for engineers who want to go deep. Written by practitioners.

Learn

  • Java
  • DSA
  • System Design
  • Spring Boot
  • AI / ML
  • DevOps
  • Engineering Growth
  • Java Interview Prep

Company

  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2026 Chaturmind. All rights reserved.

Built for engineers who want to go deep.


← Java Interview Prep: 8+ Years (Senior & Lead)

Expert Core Java

  • Tricky Java Output, Operators & OOP Edge Cases — Interview Questions
  • Tricky Exceptions, Memory & Keyword Questions — Interview Questions
  • Classic Java Language Questions, Senior-Grade Answers — Interview Questions
  • Classic Collections, Threads & JDK APIs, Senior-Grade Answers — Interview Questions
  • Reflection, Dynamic Proxies, final & Modern OOP Design — Interview Questions

JVM Internals & Performance

  • Class Loading, Bytecode & Object Layout — Interview Questions
  • JIT Compilation & Runtime Optimisations — Interview Questions
  • Garbage Collectors Deep Dive — Interview Questions
  • JVM Tuning, GC Logs & Memory Footprint — Interview Questions
  • Memory Leaks, OutOfMemoryErrors & Profiling Tools — Interview Questions
  • Modules, Agents & Advanced JVM APIs — Interview Questions

Collections & Concurrency at Scale

  • Collections Internals & Complexity — Interview Questions
  • Iterators, Comparators & Ordering Contracts — Interview Questions
  • Concurrent Collections, Queues & Lock-Free Structures — Interview Questions
  • Threads, Executors & ForkJoin Internals — Interview Questions
  • Locks, Atomics, CAS & Synchronizers — Interview Questions
  • Java Memory Model, volatile, Fences & ThreadLocal — Interview Questions
  • Deadlock, Livelock, Starvation & Concurrent Design — Interview Questions
  • CompletableFuture, Parallel Streams & Non-Blocking I/O — Interview Questions

Modern Java (8 to 21+)

  • Lambdas & Functional Interfaces Internals — Interview Questions
  • Streams & Collectors Deep Dive — Interview Questions
  • Optional & Interface Default/Static Methods — Interview Questions
  • Java 9–25 Features & Virtual Threads — Interview Questions

Design Patterns, SOLID & Clean Code

  • Design Pattern Trade-offs & Combinations — Interview Questions
  • SOLID, Clean Code & Anti-Patterns — Interview Questions

Spring & Spring Boot Internals

  • IoC, Dependency Injection & Bean Lifecycle Internals — Interview Questions
  • Spring AOP, Proxies & @Async Internals — Interview Questions
  • Spring Configuration, Auto-Configuration & Custom Starters — Interview Questions
  • Spring MVC & REST Internals, Exception Frameworks — Interview Questions
  • Spring Security Advanced Internals — Interview Questions
  • Spring WebFlux, Reactor & R2DBC — Interview Questions
  • Spring Cloud, Observability & Distributed Tracing — Interview Questions
  • Spring Boot 3, Native Images & Production Scenarios — Interview Questions

JPA, Hibernate & Databases at Scale

  • Spring Data JPA — Queries, Projections, Custom Repositories & Locking — Interview Questions
  • JPA Entity Mapping, Associations & Cascades — Interview Questions
  • JPQL vs Native Queries in Depth — Interview Questions
  • Hibernate Caching — First-Level, Second-Level & Query Cache — Interview Questions
  • Lazy vs Eager Loading, LazyInitializationException & N+1 — Interview Questions
  • JPA Transactions, Propagation, Isolation & Dirty Checking — Interview Questions
  • SQL vs NoSQL, Indexing & Query Tuning — Interview Questions
  • Database Scaling, Replication, Pooling & Consistency Models — Interview Questions
  • Redis, Search, Time-Series, CDC & Transactional Data Modelling — Interview Questions

Testing Strategy & API Design

  • Spring Boot Test Slices, Context & Test Strategy — Interview Questions
  • Testing Web, Persistence, Security, Async & Messaging in Spring Boot — Interview Questions
  • JUnit 5 & Mockito, Advanced — Interview Questions
  • MockMvc, WebTestClient & Testcontainers in Depth — Interview Questions
  • REST Principles, Status Codes & Resource Design — Interview Questions
  • OpenAPI, Validation Errors, API Versioning & GraphQL — Interview Questions

Build, DevOps & Cloud

  • Maven & Gradle at Scale — Interview Questions
  • Git, CI/CD Pipelines & Release Safety — Interview Questions
  • Docker & Kubernetes for Java Engineers — Interview Questions
  • Quality Gates, Artifact Repositories & Secrets Management — Interview Questions
  • AWS Deployment & Scaling for Spring Boot — Interview Questions
  • Multi-Cloud Deployment, High Availability, Cost & Cloud Troubleshooting — Interview Questions

Kafka & Messaging

  • Kafka Internals & Delivery Semantics — Interview Questions
  • Spring Kafka — Error Handling, DLQs, Schemas & Operations — Interview Questions
  • RabbitMQ, JMS & Messaging Models — Interview Questions

Microservices & Architecture

  • Distributed Systems Fundamentals — CAP, Consistency, Availability & SLOs — Interview Questions
  • DDD, Hexagonal Architecture & Service Boundaries — Interview Questions
  • Event-Driven Architecture, CQRS, Event Sourcing, Sharding & Idempotency — Interview Questions
  • Rate Limiting, Resilience, Caching at Scale & Chaos Engineering — Interview Questions
  • Files, Documents & Internationalisation in Java Backends — Interview Questions
  • WebSockets, Schedulers, Notifications & Real-Time Pipelines — Interview Questions

System Design Scenarios

  • Booking Systems, CRS, Inventory & Concurrency Control — Interview Questions
  • Dynamic Pricing & Rule Engines — Interview Questions
  • Partner Integrations — OTA Sync, Retries, Webhooks, Reconciliation & Bulk Data — Interview Questions
  • Designing Caches & Rate Limiters — Interview Questions
  • Event-Driven Architecture, Kafka at Scale, IoT & Real-Time Pipelines — Interview Questions
  • Observability, Logging, Alerting & Audit Systems — Interview Questions
  • Multi-Tenant SaaS, Identity & Platform Services — Interview Questions
  • Search, Notifications, Chat, Fraud Detection & Workflows — Interview Questions
  • Extreme Scale, 99.99% Availability, DR & Project Deep-Dive Stories — Interview Questions

Security for Senior Engineers

  • Tokens, OAuth2 PKCE, Web Attacks & API Security — Interview Questions
  • TLS, mTLS, Zero Trust, Secrets, DDoS & Privacy Compliance — Interview Questions

Leadership & Behavioural

  • Leadership Style, Motivation & Team Health — Interview Questions
  • Delivery, Planning & Decisions Under Uncertainty — Interview Questions
  • Problem Solving, Growth & Career Stories — Interview Questions
  • Stakeholder Communication, Ethics & Compliance — Interview Questions
  • Mentoring, Knowledge Sharing & Code Reviews — Interview Questions
  • Agile & Scrum Practices for Senior Engineers — Interview Questions
  • Architecture Decision-Making — Interview Questions
  • Conflict Resolution & Difficult Conversations — Interview Questions
Chaturmind
← Java Interview Prep: 8+ Years (Senior & Lead)

Expert Core Java

  • Tricky Java Output, Operators & OOP Edge Cases — Interview Questions
  • Tricky Exceptions, Memory & Keyword Questions — Interview Questions
  • Classic Java Language Questions, Senior-Grade Answers — Interview Questions
  • Classic Collections, Threads & JDK APIs, Senior-Grade Answers — Interview Questions
  • Reflection, Dynamic Proxies, final & Modern OOP Design — Interview Questions

JVM Internals & Performance

  • Class Loading, Bytecode & Object Layout — Interview Questions
  • JIT Compilation & Runtime Optimisations — Interview Questions
  • Garbage Collectors Deep Dive — Interview Questions
  • JVM Tuning, GC Logs & Memory Footprint — Interview Questions
  • Memory Leaks, OutOfMemoryErrors & Profiling Tools — Interview Questions
  • Modules, Agents & Advanced JVM APIs — Interview Questions

Collections & Concurrency at Scale

  • Collections Internals & Complexity — Interview Questions
  • Iterators, Comparators & Ordering Contracts — Interview Questions
  • Concurrent Collections, Queues & Lock-Free Structures — Interview Questions
  • Threads, Executors & ForkJoin Internals — Interview Questions
  • Locks, Atomics, CAS & Synchronizers — Interview Questions
  • Java Memory Model, volatile, Fences & ThreadLocal — Interview Questions
  • Deadlock, Livelock, Starvation & Concurrent Design — Interview Questions
  • CompletableFuture, Parallel Streams & Non-Blocking I/O — Interview Questions

Modern Java (8 to 21+)

  • Lambdas & Functional Interfaces Internals — Interview Questions
  • Streams & Collectors Deep Dive — Interview Questions
  • Optional & Interface Default/Static Methods — Interview Questions
  • Java 9–25 Features & Virtual Threads — Interview Questions

Design Patterns, SOLID & Clean Code

  • Design Pattern Trade-offs & Combinations — Interview Questions
  • SOLID, Clean Code & Anti-Patterns — Interview Questions

Spring & Spring Boot Internals

  • IoC, Dependency Injection & Bean Lifecycle Internals — Interview Questions
  • Spring AOP, Proxies & @Async Internals — Interview Questions
  • Spring Configuration, Auto-Configuration & Custom Starters — Interview Questions
  • Spring MVC & REST Internals, Exception Frameworks — Interview Questions
  • Spring Security Advanced Internals — Interview Questions
  • Spring WebFlux, Reactor & R2DBC — Interview Questions
  • Spring Cloud, Observability & Distributed Tracing — Interview Questions
  • Spring Boot 3, Native Images & Production Scenarios — Interview Questions

JPA, Hibernate & Databases at Scale

  • Spring Data JPA — Queries, Projections, Custom Repositories & Locking — Interview Questions
  • JPA Entity Mapping, Associations & Cascades — Interview Questions
  • JPQL vs Native Queries in Depth — Interview Questions
  • Hibernate Caching — First-Level, Second-Level & Query Cache — Interview Questions
  • Lazy vs Eager Loading, LazyInitializationException & N+1 — Interview Questions
  • JPA Transactions, Propagation, Isolation & Dirty Checking — Interview Questions
  • SQL vs NoSQL, Indexing & Query Tuning — Interview Questions
  • Database Scaling, Replication, Pooling & Consistency Models — Interview Questions
  • Redis, Search, Time-Series, CDC & Transactional Data Modelling — Interview Questions

Testing Strategy & API Design

  • Spring Boot Test Slices, Context & Test Strategy — Interview Questions
  • Testing Web, Persistence, Security, Async & Messaging in Spring Boot — Interview Questions
  • JUnit 5 & Mockito, Advanced — Interview Questions
  • MockMvc, WebTestClient & Testcontainers in Depth — Interview Questions
  • REST Principles, Status Codes & Resource Design — Interview Questions
  • OpenAPI, Validation Errors, API Versioning & GraphQL — Interview Questions

Build, DevOps & Cloud

  • Maven & Gradle at Scale — Interview Questions
  • Git, CI/CD Pipelines & Release Safety — Interview Questions
  • Docker & Kubernetes for Java Engineers — Interview Questions
  • Quality Gates, Artifact Repositories & Secrets Management — Interview Questions
  • AWS Deployment & Scaling for Spring Boot — Interview Questions
  • Multi-Cloud Deployment, High Availability, Cost & Cloud Troubleshooting — Interview Questions

Kafka & Messaging

  • Kafka Internals & Delivery Semantics — Interview Questions
  • Spring Kafka — Error Handling, DLQs, Schemas & Operations — Interview Questions
  • RabbitMQ, JMS & Messaging Models — Interview Questions

Microservices & Architecture

  • Distributed Systems Fundamentals — CAP, Consistency, Availability & SLOs — Interview Questions
  • DDD, Hexagonal Architecture & Service Boundaries — Interview Questions
  • Event-Driven Architecture, CQRS, Event Sourcing, Sharding & Idempotency — Interview Questions
  • Rate Limiting, Resilience, Caching at Scale & Chaos Engineering — Interview Questions
  • Files, Documents & Internationalisation in Java Backends — Interview Questions
  • WebSockets, Schedulers, Notifications & Real-Time Pipelines — Interview Questions

System Design Scenarios

  • Booking Systems, CRS, Inventory & Concurrency Control — Interview Questions
  • Dynamic Pricing & Rule Engines — Interview Questions
  • Partner Integrations — OTA Sync, Retries, Webhooks, Reconciliation & Bulk Data — Interview Questions
  • Designing Caches & Rate Limiters — Interview Questions
  • Event-Driven Architecture, Kafka at Scale, IoT & Real-Time Pipelines — Interview Questions
  • Observability, Logging, Alerting & Audit Systems — Interview Questions
  • Multi-Tenant SaaS, Identity & Platform Services — Interview Questions
  • Search, Notifications, Chat, Fraud Detection & Workflows — Interview Questions
  • Extreme Scale, 99.99% Availability, DR & Project Deep-Dive Stories — Interview Questions

Security for Senior Engineers

  • Tokens, OAuth2 PKCE, Web Attacks & API Security — Interview Questions
  • TLS, mTLS, Zero Trust, Secrets, DDoS & Privacy Compliance — Interview Questions

Leadership & Behavioural

  • Leadership Style, Motivation & Team Health — Interview Questions
  • Delivery, Planning & Decisions Under Uncertainty — Interview Questions
  • Problem Solving, Growth & Career Stories — Interview Questions
  • Stakeholder Communication, Ethics & Compliance — Interview Questions
  • Mentoring, Knowledge Sharing & Code Reviews — Interview Questions
  • Agile & Scrum Practices for Senior Engineers — Interview Questions
  • Architecture Decision-Making — Interview Questions
  • Conflict Resolution & Difficult Conversations — Interview Questions
HomeLearnJava Interview PrepJava Interview Prep: 8+ Years (Senior & Lead)Microservices & Architecture
✓ FreeAdvanced· 11 min read

Rate Limiting, Resilience, Caching at Scale & Chaos Engineering — Interview Questions

Designing rate-limited APIs, token bucket and sliding-window algorithms, timeouts done right, fallback design, troubleshooting cascading failures, monitoring latency spikes, cache eviction policies, high-performance caching design, cache stampede prevention, and chaos engineering.

Published September 25, 2026


How to use this lesson

These questions test operational design: protecting systems from overload and dependency failures, and keeping latency predictable. Give the algorithm, the Java or Spring implementation option, and how you'd observe it in production.

Q1. How do you design rate-limited APIs?

Short answer:

  1. Decide what to limit, and for whom: per API key or client, per user, per tenant, per IP (for anonymous traffic), per endpoint (expensive search vs cheap reads), with tiers by plan. Also consider concurrency limits (in-flight requests), and cost-based limits (GraphQL query cost, LLM tokens).
  2. Choose the algorithm: token bucket (bursty but bounded), sliding window (smooth fairness), fixed window (simplest), or leaky bucket (constant output).
  3. Enforce it in layers:
    • at the edge (API gateway, CDN or WAF: Spring Cloud Gateway RequestRateLimiter with Redis, AWS API Gateway usage plans, Envoy's global rate limit service);
    • in the service for fine-grained rules (Bucket4j, backed by Redis or Hazelcast, or Resilience4j RateLimiter for protecting outbound calls).
  4. Distributed state: limits must hold across instances, so use a shared store (Redis) with atomic operations (Lua scripts), or approximate local limits (the global limit divided by the instance count) when some slack is acceptable.
  5. Respond clearly: 429 Too Many Requests, with Retry-After, and RateLimit-Limit/Remaining/Reset headers. Document the limits.
  6. Operate it: metrics per key, alerts on abuse, allow-lists for internal traffic, and fail-open vs fail-closed decisions if Redis is unavailable.

Learn it in depth → Design a Rate Limiter

Q2. What is the token bucket algorithm?

Short answer: A bucket holds up to capacity B tokens, refilled at rate r tokens per second. Each request consumes one token (or a cost-weighted number). If there are no tokens, the request is rejected (or waits). The properties:

  • it allows bursts up to B, while enforcing a long-term average of r;
  • it's simple and memory-cheap: store tokens plus lastRefillTimestamp per key, and refill lazily on each request (tokens = min(B, tokens + elapsed × r)).

It's used by AWS API throttling, Spring Cloud Gateway's RedisRateLimiter, Bucket4j and Guava's RateLimiter (a smooth variant). The leaky bucket is its cousin: a queue drained at a constant rate, which smooths the output.

Bucket bucket = Bucket.builder()
        .addLimit(Bandwidth.builder().capacity(100).refillGreedy(50, Duration.ofSeconds(1)).build())   // burst 100, 50/s
        .build();
if (bucket.tryConsume(1)) proceed(); else throw new TooManyRequestsException(bucket.estimateAbilityToConsume(1).getNanosToWaitForRefill());

Q3. What is sliding-window rate limiting?

Short answer: It limits the number of requests in the last W seconds, avoiding the fixed-window boundary burst (with fixed one-minute windows, a client can send 2× the limit around a window edge):

  • Sliding log: store a timestamp for every request (for example, a Redis sorted set per key); remove the entries older than now − W; count them; allow if the count < limit. It's exact, but the memory is O(requests).
  • Sliding window counter (an approximation): keep the counts for the current and previous fixed windows, and estimate: count = current + previous × (overlap fraction). Memory is O(1) per key, it's accurate enough in practice, and it's used by Cloudflare-style limiters.

Implement it atomically in Redis (a Lua script: ZREMRANGEBYSCORE + ZCARD + ZADD + EXPIRE), to avoid races across instances.

Q4. How should you handle timeouts?

Short answer:

  • Set a timeout on every remote call. The defaults are often infinite, or very long. Configure:
    • connect timeouts and read/response timeouts separately (HTTP clients such as RestClient with JDK HttpClient or Apache HttpClient; WebClient with Netty responseTimeout);
    • connection-pool acquisition timeouts;
    • database statement and lock timeouts;
    • Kafka delivery.timeout.ms/request.timeout.ms.
  • Size them from the dependency's latency distribution: slightly above its p99 (not the average), and within the caller's own budget.
  • Deadline propagation: pass the remaining time budget downstream (gRPC deadlines, or a custom header), so downstream calls don't keep working after the caller has given up. The downstream timeout must be shorter than the upstream one.
  • Combine them with retries (only the idempotent ones, within the overall deadline) and circuit breakers (Resilience4j TimeLimiter).
  • Observe: timeout counts and latency histograms per dependency. Treat timeouts as signals of saturation.

Q5. How do you design fallbacks? What is a circuit-breaker fallback strategy?

Short answer: A fallback is the degraded but acceptable response when a dependency fails, or its circuit is open. Design it per use case:

  • cached or stale data (last known prices, with a "may be outdated" flag);
  • defaults (generic recommendations when the personalisation service is down);
  • graceful feature removal (hide the reviews widget);
  • queue for later (accept an order as PENDING, and process the payment asynchronously);
  • an alternative provider (a secondary payment gateway or SMS vendor);
  • fail fast with a clear error, when there's no safe fallback (you must not fake a payment success).

The principles:

  • fallbacks must be cheap and reliable themselves (no calls to other fragile services);
  • they must be tested (chaos tests);
  • they must be observable (a fallback-rate metric, with alerts);
  • never silently hide correctness-critical failures.

Q6. How do you troubleshoot a cascading failure across services?

Short answer:

  1. Stabilise first:
    • shed load (rate limits, disable non-critical features through flags);
    • open the circuits and fail fast to the unhealthy dependency;
    • scale out the healthy capacity;
    • stop the retry storms (reduce the retries, add backoff);
    • roll back any recent deployment.
  2. Find the origin:
    • distributed traces and service dependency maps: the first service whose latency or errors rose, often a database, a third-party API or a saturated shared resource (connection pool, thread pool, Kafka partition);
    • look at the saturation metrics (pool active or pending, queue depths, CPU throttling, GC);
    • correlate with deployments or configuration changes, and traffic spikes.
  3. Understand the propagation:
    • missing timeouts (threads pile up);
    • retries multiplied across layers;
    • shared thread pools (no bulkheads);
    • synchronous dependency chains;
    • health checks that include dependencies (restart loops).
  4. Fix and prevent: timeouts everywhere, bulkheads, circuit breakers, retry budgets, asynchronous decoupling, load-shedding policies, and chaos tests that reproduce the scenario. Hold a postmortem.

Learn it in depth → Why Microservices Fail

Q7. How do you monitor and investigate latency spikes?

Short answer:

  • Measure the right thing: latency histograms and percentiles (p50, p95, p99, p99.9) per endpoint and dependency. Averages hide the spikes. Enable Micrometer percentile histograms (and OpenTelemetry exemplars).
  • Alert on SLO burn, not on single spikes.
  • Correlate the spikes with:
    • GC pauses (JFR, GC logs);
    • CPU throttling in containers;
    • safepoints and deoptimisations;
    • pool waits (Hikari pending, executor queue);
    • lock contention;
    • slow downstream spans (traces);
    • cold starts or new pods (JIT warm-up after scale-out or deploy);
    • noisy neighbours;
    • network retransmits and DNS latency;
    • database autovacuum or checkpoints;
    • cache expiry storms.
  • Tools: tracing with tail-based sampling that keeps the slow traces, continuous profiling (async-profiler or Pyroscope in wall-clock mode), JFR on demand, and dashboards overlaying deployments and GC.
  • Fix the identified cause (tune the GC or the heap, fix N+1 queries, add caching, increase the pool, jitter the TTLs, pre-warm), and verify with percentiles.

Q8. What cache eviction policies exist?

Short answer:

  • LRU (least recently used): evicts the entries not accessed longest. Good general-purpose recency.
  • LFU (least frequently used): keeps the popular items. It resists scans, but adapts slowly to shifts (it needs ageing).
  • W-TinyLFU (Caffeine): a frequency sketch plus a small LRU window. It's near-optimal hit rates for most workloads, and is Caffeine's default.
  • FIFO, random, and TTL or expiry-based (time-to-live, time-to-idle).
  • Size-based vs weight-based (by bytes).
  • Redis maxmemory-policy: allkeys-lru, allkeys-lfu, volatile-lru/lfu/ttl (only keys with a TTL), noeviction (writes fail when memory is full, which is suitable when Redis is a primary store).

Note that expiry (data becoming stale) and eviction (making room) are different concerns, and you usually need both.

Q9. How do you design high-performance caching?

Short answer:

  • Layers:
    • a CDN or HTTP cache (Cache-Control, ETag) for public content;
    • an in-process L1 (Caffeine: nanosecond access, size-bounded, a short TTL);
    • a distributed L2 (Redis or a Hazelcast cluster);
    • the database.
  • Patterns:
    • cache-aside (most common);
    • read-through or write-through (a library-managed loader);
    • write-behind (buffered writes, with a durability risk);
    • refresh-ahead for hot keys.
  • Data design:
    • cache DTOs or serialised projections, not entities;
    • use compact serialisation (Kryo or Protobuf vs JSON);
    • keep key cardinality under control;
    • avoid huge values (split them, or use hashes).
  • Consistency: evict on write after commit, CDC-driven invalidation, versioned keys, jittered TTLs, and local-cache invalidation broadcasts.
  • Protection: stampede control (Q10), negative caching (short TTLs for "not found" results, which prevent cache penetration), and Bloom filters for key existence.
  • Performance: pipelining or batching (MGET), connection pooling (Lettuce), co-locating caches with services (same availability zone), and sharding hot keys (replicate them to several keys, or keep them in local caches).
  • Measure: hit ratio, latency, evictions and memory. Watch for hot keys (redis-cli --hotkeys).

Q10. How do you prevent a cache stampede?

Short answer: A stampede (thundering herd, dog-piling) happens when a hot key expires or is evicted, and many concurrent requests miss at once, all hitting the database or the expensive computation. The mitigations:

  • Request coalescing (single-flight): only one loader per key computes, and the others wait for its result. Caffeine's get(key, loader) and AsyncCache do this per instance. Spring @Cacheable(sync = true) does it too.
  • A distributed lock or lease on the recomputation (Redis SET NX), with the others serving stale data or briefly waiting.
  • Stale-while-revalidate or soft TTL: serve the stale value while one request refreshes it in the background (refresh-ahead: Caffeine refreshAfterWrite).
  • Probabilistic early expiration (XFetch): each request has a small, rising chance of refreshing before the expiry.
  • Jittered TTLs, so many keys don't expire simultaneously (preventing an avalanche).
  • Pre-warming caches on deployment or scale-out, and on a schedule for known hot keys.
  • Rate-limiting the backend (bulkheads), as a last line of defence.

Q11. What is chaos engineering?

Short answer: Chaos engineering is disciplined experimentation on a system, to build confidence in its ability to withstand turbulent conditions, by injecting failures deliberately:

  1. define the steady state (SLO metrics);
  2. form a hypothesis ("if one availability zone is lost, checkout success stays above 99.5%");
  3. inject faults: kill pods or instances, add latency or packet loss, fail dependencies, exhaust CPU or memory, cut a zone, throttle an API;
  4. observe the outcome;
  5. fix the weaknesses;
  6. automate the experiment.

Tools: Chaos Monkey (Chaos Monkey for Spring Boot), Gremlin, LitmusChaos, Chaos Mesh, AWS Fault Injection Service, Toxiproxy (in tests), and Istio fault injection.

Practise it safely: start in staging, limit the blast radius, have abort conditions, run game days with the teams, and graduate to production with care. It validates timeouts, fallbacks, autoscaling, alerts and runbooks, which is exactly what fails during real incidents.

Follow-up questions this topic invites — and their answers

Q: Where should rate limiting be enforced: client, gateway or service? A: Primarily at the gateway or edge (cheap rejection, global view), with per-service limits for expensive operations. Also on clients calling third-party APIs, so they respect the provider's quotas (outbound limiting with Resilience4j or Bucket4j).

Q: Why can retries make an outage worse? A: Each layer's retries multiply the load on an already struggling dependency (3 retries at 3 layers means 27× the load). Use retry budgets, exponential backoff with jitter, circuit breakers, and retry at a single layer.

Q: What's a hot key, and how do you mitigate it in Redis? A: A key receiving a disproportionate share of traffic (a celebrity profile, or a flash-sale item), which overloads a single shard. Add a local L1 cache in front, replicate the key under several suffixes and read one at random, or split the value.

Q: What is load shedding vs rate limiting? A: Rate limiting enforces per-client quotas, even when the system is healthy. Load shedding drops or deprioritises work when the system is overloaded, whatever the client, to protect the core functions (prioritising checkout over recommendations).

Previous

Event-Driven Architecture, CQRS, Event Sourcing, Sharding & Idempotency — Interview Questions

Next

Files, Documents & Internationalisation in Java Backends — Interview Questions

AI Tutor

Lesson: Rate Limiting, Resilience, Caching at Scale & Chaos Engineering — Interview Questions

Quick actions

AI responses can be inaccurate. Verify critical information.