Skip to content
CAP Theorem Debunked: Not 'Choose 2 of 3' — Master 10 Core Distributed System Topics for Interviews

CAP Theorem Debunked: Not 'Choose 2 of 3' — Master 10 Core Distributed System Topics for Interviews

This comprehensive guide corrects the common CAP theorem misconception, then deep-dives into 10 high-frequency distributed system topics — CAP/BASE, distributed IDs (UUID to Meituan Leaf), distributed locks (DB, Redis, ZooKeeper, Etcd), distributed transactions (2PC to RocketMQ), consistent hashing, rate limiting algorithms, load balancing, circuit breaking (Hystrix vs Sentinel), configuration centers, and distributed tracing — with 30+ diagrams, comparison tables, code snippets, and production pitfalls.

Rain's Path to Java Mastery
Rain's Path to Java Mastery
Rain's Path to Java Mastery

CAP Theorem & BASE Theory

CAP theorem, proposed by Eric Brewer in 2000, states a distributed system cannot simultaneously satisfy Consistency (all nodes see same data), Availability (every request gets a response), and Partition Tolerance (system operates despite network partitions). The core insight: P is mandatory because network failures are inevitable; we only choose between C and A during a partition.

Common Misconceptions

Not "choose 2 of 3" — P is required, so it's really CP vs AP.

Not binary — consistency ranges from strong to eventual; availability has SLA tiers.

Real-World Classification

CA          CP              AP
─────────────────────────────────────
Single DB   Zookeeper       Eureka / Nacos
MySQL repl  etcd/Consul     Cassandra

CA : Single-node DBs; impractical in distributed settings.

CP : ZooKeeper pauses service during leader election to avoid split-brain.

AP : Eureka uses async replication; remains available during partition, merges later.

BASE Theory

Extends AP: Basically Available (core functions stay up), Soft State (intermediate states allowed), Eventually Consistent (replicas converge). Contrasts with ACID.

Java Production Patterns

Local message table + scheduled job / MQ for eventual consistency.

Nacos AP mode for service discovery.

Sentinel for rate limiting & degradation.

Choose CP locks (ZooKeeper/etcd) for finance; AP locks (Redis Redlock) for high availability after careful evaluation.

Distributed ID Generation: UUID → DB Auto-Increment → Snowflake → Meituan Leaf

Comparison

Scheme          Pros                                    Cons                                      Scenario                Perf    Trend
UUID            Local, global unique, simple            Unordered → B+ tree splits; 36 chars; no biz meaning   Log tracing, temp IDs   ★★★★★   ❌
DB Auto-Inc     Ordered, simple, small storage          Single point, low throughput, sharding conflicts       Monolith, low concurrency ★★      ❌
Snowflake       64-bit, trend-increasing, high perf, decodable timestamp  Clock drift → duplicate IDs; workerId allocation; 4096 IDs/ms limit  Most distributed systems ★★★★    ✅
Meituan Leaf    Solves clock drift; dual mode (segment + snowflake); HA; open-source  Needs separate service; segment mode gaps on restart  Large-scale production   ★★★★    ✅

Snowflake Deep Dive

0 | 41-bit timestamp | 10-bit workerId | 12-bit sequence

Clock drift solutions : wait for clock catch-up, fallback clock, or throw exception. Leaf-snowflake uses ZooKeeper persistent sequential nodes for workerId; on startup checks last timestamp — if drift <5 ms wait, else reject & alert.

Leaf Segment Mode

DB grants segment [1000,2000] → local atomic increment → fetch new segment when exhausted

Double-buffer pre-loading ensures HA; IDs may be non-continuous after restart (acceptable).

Interview Answer Framework

State requirements: global unique, trend-increasing, high perf, HA.

Evolution: UUID → DB auto-inc → Snowflake → Leaf.

Highlight: Snowflake clock drift fixes, Leaf double-buffer & workerId management.

Real case: order system uses Leaf-segment for perf & PK friendliness.

Mention alternatives: Redis incr, Baidu UidGenerator, Didi Tinyid.

Distributed Locks: DB vs Redis vs ZooKeeper vs Etcd

Core Concerns

Safety (mutual exclusion), Liveness (eventual acquisition), Performance, Deadlock handling.

1. Database Lock

Pessimistic: SELECT ... FOR UPDATE Optimistic: version column UPDATE ... WHERE version=? Unique index: INSERT to acquire, DELETE to release.

❌ Poor perf, single point, deadlock risk if client crashes, non-reentrant.

2. Redis Lock

Atomic acquire: SET key value NX EX timeout Watchdog (Redisson) auto-renews lease.

Release via Lua:

if redis.call('get',KEYS[1]) == ARGV[1] then return redis.call('del',KEYS[1]) else return 0 end

RedLock: quorum across multiple masters; controversial due to clock/GC issues.

✅ High perf, mature client libs; ❌ single-instance SPOF, master failover may lose lock.

3. ZooKeeper Lock

Ephemeral sequential nodes under a persistent parent.

Smallest sequence gets lock; others watch previous node.

Session expiry → auto-delete → natural deadlock prevention.

✅ Strong consistency (ZAB), fair lock, blocking wait; ❌ lower perf, complex watchers.

4. Etcd Lock

TXN: PUT key value prevExist=false with Lease.

KeepAlive renews lease; delete key or revoke lease to release.

Fair lock via prefix + Watch (like sequential nodes).

✅ Raft strong consistency, lighter than ZK, lease-based expiry, cloud-native standard; ❌ perf < Redis.

Comparison

Dimension       DB          Redis       ZooKeeper   Etcd
Performance     ★★          ★★★★★       ★★★         ★★★★
Reliability     ★★★         ★★★ (failover risk) ★★★★★   ★★★★★
Complexity      ★           ★★          ★★★★        ★★★
Auto-release    ❌ manual   ✅ TTL + watchdog ✅ session expiry ✅ lease expiry
Reentrant       DIY         Redisson ✅  Curator ✅   DIY
Fair lock       ❌          ❌          ✅          ✅
Blocking wait   polling     polling/pubsub ✅ Watch    ✅ Watch
Thundering herd severe      severe      minimal     minimal
SPOF            severe      mitigated by replica none      none
Consistency     strong      eventual    strong      strong

Production Pitfalls

Redis lock must carry unique token; release via Lua.

Don't use lock TTL as business timeout — task may exceed TTL.

Redisson is best practice (watchdog, reentrant, RedLock).

ZK: avoid InterProcessSemaphoreMutex; use InterProcessMutex.

Etcd: handle lease renewal failure with fallback.

Selection Guide

Default: Redis (90% cases).

Cloud-native + strong consistency: Etcd.

Existing ZK cluster + strict consistency: ZK.

Never DB unless trivial/low concurrency.

Distributed Transactions: 2PC, 3PC, TCC, SAGA, Local Message Table, RocketMQ Transactional Messages

Evolution Spectrum

Strong consistency ──────────────────────────────► Eventual consistency
 2PC ──► 3PC ──► TCC ──► SAGA ──► Local Msg Table ──► RocketMQ Tx Msg
 ▲      ▲      ▲      ▲          ▲                    ▲
Sync    Timeout Biz    Long-tx   Most pragmatic       Built-in
block   mech   invade compensation                RocketMQ

Principle : Prefer eventual consistency; avoid strong consistency unless required.

2PC (Two-Phase Commit)

Coordinator + participants; Prepare (reserve resources) → Commit (all-vote).

✅ Strong consistency, simple; ❌ Sync blocking, coordinator SPOF, data inconsistency if coordinator + participants crash in phase 2.

Used in traditional XA transactions; banned in high-concurrency internet systems .

3PC (Three-Phase Commit)

2PC: prepare → commit
3PC: canCommit → preCommit → doCommit
       ↑ new canCommit phase with timeout

Reduces blocking scope, adds timeout; still risks inconsistency under network partition.

Extra RPC, worse perf, no mature components — theoretical only .

TCC (Try-Confirm-Cancel)

try:    reserve resources (freeze stock)
confirm: execute biz (deduct stock)
cancel:  release reservation (unfreeze stock)

Compensating transaction; business code implements three phases.

✅ Good perf, no locks, flexible; ❌ High intrusion, idempotency critical, dev cost high.

Scenarios: core trading (order freeze stock, payment freeze balance).

SAGA

Long transaction = series of local short transactions + compensations.

Orchestration (central coordinator) vs Choreography (event-driven).

✅ No locks, good for long transactions; ❌ Eventual consistency only, complex compensations.

Tools: Seata SAGA, Spring Cloud orchestration.

Local Message Table

Business DB adds `local_msg` table:
┌─────────────┬────────────────┬────────┐
│ business_id │ payload        │ status │
└─────────────┴────────────────┴────────┘

Local TX writes biz data + message; scheduled poller publishes; consumer ensures idempotency.

✅ Simple, low cost, reliable (Alipay used this); ❌ Couples message table, polling latency, simple cross-service only.

Enhance with Canal (binlog async publish) to remove polling.

RocketMQ Transactional Messages

Half-message → local TX → Commit/Rollback; broker checks back if producer crashes.

✅ Low intrusion, high perf, reliable, built-in check-back; ❌ Requires RocketMQ 4.3+, consumer idempotency, eventual consistency only.

Top choice for most internet biz (e.g., order pay → send tx msg → points service consumes).

Comparison Summary

Scheme              Consistency   Perf   Dev Cost  Intrusion  Scenario              One-Liner
2PC                 Strong        Poor   Low       Low        Traditional cross-DB  Locks you down 😵
3PC                 Strong        Medium Medium    Low        Theory only           Locks you down 😵
TCC                 Eventual      Good   High      High       Core trading          Write your own compensation 🔥
SAGA                Eventual      Good   Medium    Medium     Long transactions       Forward push, backward rollback ⛰️
Local Msg Table     Eventual      Good   Low       Medium     Non-core              Humble but solid 🙏
RocketMQ Tx Msg     Eventual      Good   Low       Low        Most internet biz     Native support, sweetest 🚀

Key Interview Points

TCC vs SAGA: TCC = reserve-confirm (short tx), SAGA = execute-compensate (long tx); TCC stronger consistency, higher cost.

RocketMQ prevents loss: half-message + check-back + consumer retry.

Empty rollback / suspension / idempotency: solved via transaction status table recording each phase state.

Personal Selection Rule

Use RocketMQ transactional messages by default; TCC+Seata for strong resource reservation; local message table for legacy low-risk; SAGA for long flows without immediate consistency. Essence: distributed TX = business compensation, not tech show-off.

Consistent Hashing

Problem

Traditional hash(key) % N remaps ~N/(N+1) keys when nodes change → cache avalanche.

Core Idea

Map nodes and keys onto a ring (0..2^32-1) ; key belongs to first node clockwise. Adding/removing node only affects its clockwise neighbor's keys.

Key Properties

Monotonicity : only adjacent interval keys remap.

Balance : keys spread evenly across nodes.

Virtual Nodes Fix Skew

Few physical nodes → uneven ring distribution (one node gets 80% traffic). Solution: each physical node maps to 100-200 virtual nodes ( node#1, node#2...).

Java Skeleton

public class ConsistentHash<T> {
  private final TreeMap<Integer, T> ring = new TreeMap<>();
  private final int virtualNodeCount;
  public void addNode(T node) {
    for (int i = 0; i < virtualNodeCount; i++) {
      int hash = hash(node.toString() + "#" + i);
      ring.put(hash, node);
    }
  }
  public T getNode(String key) {
    int hash = hash(key);
    Map.Entry<Integer, T> entry = ring.ceilingEntry(hash);
    if (entry == null) entry = ring.firstEntry(); // wrap
    return entry.getValue();
  }
  private int hash(String s) { return Math.abs(s.hashCode()); }
}
TreeMap

simulates ring; ceilingEntry = clockwise search; O(log N).

Applications

Redis Sharding: Jedis ShardedJedis uses consistent hashing

Dubbo LB: ConsistentHashLoadBalance routes same param to same provider

CDN / Object Storage: Ceph, MinIO data distribution

MQ Partitioning: Custom Kafka partitioners for ordering

Gateway Rate Limit: Hash userId to fixed counter machine

Interview Bonus Points

Hash function: use MurmurHash/FNV, not hashCode().

Weighted virtual nodes: assign more virtual nodes to stronger machines.

Limitation: still some migration inconsistency; combine with dual-write / cache warm-up.

Contrast with Rendezvous Hashing (HRW).

Rate Limiting Algorithms

1. Fixed Window Counter

Time split into fixed windows; counter resets each window.

✅ Simplest, best perf; ❌ Boundary burst : 100 req at 0.99s + 100 at 1.01s = 200 instantaneous.

2. Sliding Window

Log-based: store timestamps, evict old, count remaining.

Counter-optimized (Sentinel): slice window into small grids (1s → 10 grids); approximate with current + previous * overlap_ratio.

✅ Fixes boundary burst; ❌ Slightly more complex, more memory.

3. Leaky Bucket

Requests pour into bucket; bucket leaks at fixed rate; overflow = reject.

✅ Smooths bursts, guarantees stable output rate; ❌ Cannot utilize idle capacity for bursts.

Use case: MQ consumption, 3rd-party API calls.

4. Token Bucket

Tokens added at fixed rate up to capacity; request consumes 1 token; no token = reject.

✅ Smooths traffic and absorbs bursts (pre-filled tokens); ❌ More complex.

Most common in internet apps.

Pseudo-code:

now = System.currentTimeMillis();
tokens = min(capacity, stored + (now - lastRefill) * rate);
lastRefill = now;
if (tokens >= 1) { stored = tokens - 1; return true; } else return false;

Comparison

Algorithm       Difficulty  Precision  Burst Handling  Core Idea                 Representative
Counter         Simple      Low        Poor            Limit window total        Guava RateLimiter (early)
Sliding Window  Medium      Medium     Fair            Limit sliding total       Sentinel sliding window
Leaky Bucket    Medium      High       Poor            Control outflow rate      Nginx limit_conn
Token Bucket    Harder      High       Good            Control token gen rate    Guava RateLimiter, Resilience4j

Production Notes

Guava RateLimiter = token bucket + warm-up for smooth ramp-up.

Sentinel supports both sliding window (QPS) and token bucket (smooth rate).

Distributed rate limiting: Redis + sliding window / token bucket using atomic ops.

Load Balancing Algorithms

1. Round Robin

Sequential assignment; stateless, fair.

❌ Ignores server capacity & real-time load; slow node still gets traffic → avalanche risk.

2. Weighted Round Robin

Higher weight = more requests; Nginx uses smooth weighted RR to interleave (e.g., A:5, B:1, C:1 → A,A,B,A,C,A,A).

✅ Handles static heterogeneity; ❌ Still ignores dynamic load.

3. Least Connections

Pick server with fewest active connections; dynamic, fair for long-lived connections (WebSocket, DB pool, RPC).

✅ Real-time load awareness; ❌ State maintenance overhead.

4. Consistent Hashing

Map key & servers to ring; key → first clockwise server. Ensures same key hits same node (cache affinity, session stickiness).

✅ Minimal reshuffle on scaling; ❌ Skew without virtual nodes (150-200 per physical node).

Comparison

Algorithm       Core Idea     Pros                Cons                Typical Use
Round Robin     Sequential    Simple, fair        Ignores capacity    Static resource servers
Weighted RR     By weight     Handles static diff Ignores dynamic load Nginx default
Least Connections By load     Dynamic fairness    Complex impl        DB, file upload
Consistent Hash Ring mapping  Scales well         Data skew           Redis Cluster, Dubbo

Nginx Smooth Weighted RR

Each server: weight (config) + current_weight (dynamic).

Each request: current_weight += weight; pick max current_weight; then current_weight -= total_weight.

Circuit Breaking & Degradation: Hystrix vs Sentinel

Core Concepts

Circuit Breaker : Cut calls to failing downstream (fuse trips on overcurrent).

Degradation : Strategically disable non-core features under pressure (mall cuts ad lights, keeps elevators).

Breaker = switch; Degradation = fallback logic.

Hystrix (Netflix, 2012, maintenance mode since 2018)

Command pattern: wrap each dependency in HystrixCommand.

State machine: CLOSED → (error threshold) → OPEN → (timeout) → HALF_OPEN (probe) → CLOSED/OPEN.

Isolation: Thread pool (default, physical isolation, thread-switch cost) or Semaphore (lightweight, no timeout interrupt).

Sliding window metrics via RxJava.

❌ Thread pool explosion (dozens per service), complex config, dead project, weak dashboard.

Sentinel (Alibaba, 2018, active)

Resource-centric: SphU.entry("resource") + rules (flow control, circuit break, degradation).

Richer break strategies: slow-call ratio (e.g., >5 calls/s & >50% >200ms), exception ratio, exception count.

Half-open auto-recovery with slow-start (gradual traffic restore).

Fine-grained limiting: API, method, param, IP, user.

Powerful dashboard: real-time monitoring, dynamic rule push, topology, hot params.

Isolation: thread pool + semaphore + hot-param limiting.

Comparison

Dimension       Hystrix                 Sentinel
Origin          Netflix, 2012           Alibaba, 2018
Maintenance     Maintenance mode        Active
Break Strategies Error rate only        Error rate, RT, exception count, QPS
Limit Granularity Coarse (thread pool)  Fine (param, IP, user...)
Dashboard       Basic, single-instance  Cluster, dynamic config, topology
Isolation       Thread pool primary     Thread pool + semaphore + hot params
Recovery        Fixed window retry      Slow-start gradual restore
Ecosystem       Spring Cloud native     Spring Cloud Alibaba, Dubbo, gRPC
Learning Curve  Medium (annotations)    Low (simple config, Chinese docs)

When to Use What

Breaker : Downstream has recoverable faults (DB timeout, network jitter) — give it breathing room.

Degradation : Clear fallback exists (cached data, static response, retry hint).

Rate Limit : Upstream flood — protect self, throw FlowException → unified degradation.

Combo: Rate limit blocks burst → errors trigger breaker → both route to same fallback.

Selection Guide

New projects: Sentinel (richer, active, Chinese docs).

Legacy Hystrix: Keep but plan migration.

Fine-grained limiting (param-level): Must use Sentinel.

Dynamic rule push (Nacos/Apollo): Sentinel supports; Hystrix needs restart.

Distributed Configuration Center Design

Pain Points Solved

Configs scattered, require restart to change.

Env (dev/test/prod) config chaos.

No dynamic update / gray release.

No version control / audit.

Secrets in plaintext.

Architecture: Client-Server Three Layers

Client SDK : Bootstrap fetch + register listener + local disk cache (survives server down).

Server : CRUD, versioning, gray release, RBAC, push changes to clients.

Storage : MySQL (primary) + Redis (hot cache).

Key Technical Points

1. Pull + Push Hybrid

Pull: startup full fetch + periodic poll (30s default).

Push: Long-polling (Nacos: 30s hang, retry) or WebSocket/gRPC (Apollo 1.6+).

Hybrid: Pull primary, push secondary; guarantees eventual consistency.

2. Local Cache

Memory + local disk snapshot; three-tier fallback: memory → disk → remote.

TTL expiry + active invalidation.

3. Version Control

Every change → new version; rollback to any history; audit log (who, when, what).

4. Gray Release

By IP, app name, labels; pause/rollback anytime.

5. Security

AES encryption for sensitive values; RBAC; HTTPS transport.

Design Deep Dives

Config Model (Namespace / Group / DataId)

Namespace: multi-env / multi-tenant isolation.

Group: module grouping within app.

DataId: atomic key-value unit.

Dynamic Push: Long-Polling vs Long-Connection

Polling: simple, poor real-time, wasteful.

Long-polling: client hangs request; server responds on change. Nacos uses this — server-friendly.

Long-connection (gRPC/WebSocket): true push, higher connection mgmt complexity.

Recommend: Hybrid — default long-poll; high-frequency configs switch to long-connection.

Dynamic Bean Refresh

Spring Cloud: @RefreshScope + ContextRefresher.refresh() rebuilds beans.

Large scale: Spring Cloud Bus + MQ broadcasts refresh event → batch refresh.

HA & Disaster Recovery

Component   Strategy
Server      Stateless cluster behind LB; shared DB/Redis/etcd; horizontal scale.
Storage     DB master-slave, Redis cluster, etcd cluster.
Client      Local disk snapshot at startup; auto-failover across server nodes.
Network     Multi-DC deployment, cross-DC DR.

Common Issues & Fixes

Push latency: optimize long-connection, priority lanes for critical configs.

Conflicts: Optimistic locking (version check); merge tool for concurrent edits.

Server avalanche: Client-side rate limit; server-side circuit break; prioritize core services.

Selection Advice

Java stack, medium scale: Nacos (doubles as registry, low ops).

Large scale, rich features (approval, audit, gray workflow): Apollo.

Avoid DIY unless extreme compliance/custom needs — ROI low.

Distributed Tracing Design

Why Needed

Microservices: one request → dozens of services. Without tracing: don't know where latency/error occurs, full call path invisible.

Core Concepts

Concept       Meaning               Role                            Analogy
Trace         Full request chain    Global unique ID linking all calls  Entire trip
Span          Single method/service call  Records latency, status, tags   One flight leg
SpanContext   Cross-process context Carries TraceID, SpanID, Baggage    Boarding pass barcode

Data Model

TraceID: 8a3c92f4d7e6b5a1
├─ SpanID: 1 (root, gateway)
│  ├─ SpanID: 2 (user svc)
│  │  └─ SpanID: 3 (DB query)
│  └─ SpanID: 4 (order svc)
│     ├─ SpanID: 5 (stock svc)
│     └─ SpanID: 6 (pay svc)
└─ SpanID: 7 (log svc)

ParentSpanID builds call tree; UI assembles spans into timeline.

Context Propagation

Inject (client): Serialize SpanContext into headers — HTTP ( X-B3-TraceId, X-B3-SpanId), RPC (Dubbo attachment, gRPC metadata), MQ (message properties).

Extract (server): Parse headers → create child Span.

Standard formats: Zipkin B3, W3C Trace Context ( traceparent).

Async/Thread-pool pitfall : Context lost in CompletableFuture /thread pools. Fix: MDC propagation or wrap executor (Sleuth's LazyTraceExecutor); Alibaba transmittable-thread-local.

Collection & Storage

Instrumentation : Java Agent (bytecode enhancement, zero-code) — SkyWalking, Pinpoint; or Framework interceptors/filters — Sleuth + Feign/RestTemplate.

Transport : Direct HTTP to Zipkin, or Kafka buffer (standard for high volume, avoids back-pressure).

Storage : Elasticsearch (fast writes, full-text search, real-time diag); Cassandra/HBase (massive long-term, linear scale).

Sampling : Head-based (fixed %, may drop errors); Tail-based (force-report error spans); Adaptive (token-bucket dynamic rate).

Full Architecture Layers

Probe: Bytecode enhancement (ByteBuddy/ASM) — zero intrusion.

Collector: Generate Trace/Span, local aggregation.

Transport: Batch async send, compression, retry, rate limit.

Storage: ES (mainstream), Cassandra, ClickHouse.

Query: API for UI & alerting.

Visualization: Trace view, flame graph, topology map.

Key Challenges & Solutions

Challenge               Solutions
Performance overhead    Sampling (1% default, 100% errors), async everything, batch send, drop non-critical under load
Full context propagation Support sync/async/cross-thread; wrap Runnable/Callable; OpenTelemetry cross-lang
Data explosion          Tiered storage (hot ES, cold object store), compression (gzip/snappy), field trimming

Mainstream Implementations

Tool        Pros                            Cons                Best For
SkyWalking  Zero-code, full features, great Chinese docs  Slightly heavier    Domestic SMEs
Jaeger      High perf, CNCF graduated, OpenTelemetry native  Simpler features    Cloud-native, K8s
Zipkin      Lightweight, simple, easy deploy  Fewer features, avg perf  Small projects, prototypes
OpenTelemetry Unified standard, multi-lang    Still evolving        Future-proof; adopt early

Production Lessons

Start minimal, enhance later.

Manual instrumentation critical for core biz logic.

Print TraceID in logs → correlate tracing + logs.

Tune sampling: balance perf vs completeness.

Alert on slow spans / high error rates.

Java Ecosystem Quick-Starts

Sleuth + Zipkin : Add spring-cloud-starter-sleuth (auto adds [app, traceId, spanId] to logs) + spring-cloud-sleuth-zipkin → report to Zipkin. Low intrusion, fast setup.

SkyWalking : Java Agent attach, zero code changes. Built-in storage, UI, topology, slow endpoint, JVM metrics. Transparent to devs.

Choose: Sleuth+Zipkin for quick diagnostics; SkyWalking for long-term ops.

Designing a Minimal Viable Tracer (Interview "Wheel-Building")

TraceID gen : Snowflake/UUID at gateway → inject X-Trace-Id header.

Interceptor + TransmittableThreadLocal : Entry filter puts header into TransmittableThreadLocal, creates SpanID. AOP/proxy writes TraceID into outbound RPC/HTTP headers.

Timing : System.nanoTime() at span start; finally finishSpan().

Async propagation : Alibaba transmittable-thread-local or custom executor wrapper.

Collect & Show : Structured JSON logs → ELK; later async queue → ES → Kibana/Grafana.

This minimal version demonstrates thinking on context propagation, intrusion, overhead — exactly what big-tech interviewers want.

Interview Bonus Points

Perf sensitivity: sampling tuning, span object pooling, local file buffer + async upload.

Observed pathologies: loop calls, long-tail latency, retry storms.

Observability triangle: TraceID in logs → slow-query metrics → trace → code.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Distributed Systemscap-theoremload-balancingdistributed-tracingrate-limitingdistributed-transactionscircuit-breakerconsistent-hashingconfiguration-centerdistributed-locks
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.