主题: distributed-systems
-
Verteiltes Tracing in Umrissen: Spans, Eltern-Kennungen und W3C Trace Context
Ein Trace ist ein Baum aus Spans, jeder mit Trace-Kennung, eigener Span-Kennung, Eltern-Span-Kennung, Zeitstempeln, Attributen und Status; der W3C-Header traceparent trägt Trace-Kennung, Eltern-Kennung und ein Sampled-Flag über Prozessgrenzen, und ein Dienst, der beide Header nur weiterreicht, hält Traces trotzdem zusammen.
-
What a Raft cluster guarantees: majorities, one leader and linearizable reads
Consensus systems such as etcd (Raft) let a majority of servers agree on an ordered log; they stay correct under any number of failures but make progress only while a majority is reachable. Linearizable reads go through consensus and cost latency; serializable reads are served locally and may be stale.
-
Idempotente Operationen und sichere Wiederholungen entwerfen
Eine Operation ist idempotent, wenn ihre mehrfache Ausführung dieselbe Wirkung hat wie eine einzelne; RFC 9110 legt das für HTTP-Methoden fest, und ein Idempotency-Key-Header überträgt die Eigenschaft auf POST. Schlüssel samt Fingerabdruck und Ergebnis speichern, Konflikte mit 409 und 422 melden, Schlüssel nach dokumentierter Frist löschen.
-
Saga:跨服务的多步骤工作流,以补偿代替回滚
Saga 是不同服务中一系列本地事务,每个事务触发下一个;若某步失败,开发者编写的补偿事务会撤销此前步骤。Saga 无需分布式事务即可恢复一致性,但放弃隔离性,因此中间状态可见,补偿必须明确设计,不能想当然。
-
Tail latency amplification: when one request waits for the slowest of a hundred
A request that fans out to N backends is as slow as the slowest reply, so a 1-in-100 slow response per backend makes about 63% of hundred-way requests slow. The leaf's p99 becomes the root's median; the remedies are fewer leaves, hedged or tied requests after a percentile delay, deadlines with partial results, and removing the causes of leaf tails.
-
Publishing events reliably with a transactional outbox
Write the event into an outbox table in the same database transaction as the state change, then let a separate relay publish it to the broker. This removes the window in which state is saved but the event is lost (or the reverse), at the price of at-least-once delivery and a relay to operate.
-
Per-dependency bulkheads keep unrelated endpoints available when one dependency stalls
Hypothesis: when a service calls several dependencies from one shared pool of threads or concurrency slots, a dependency that becomes slow (not down) takes unrelated endpoints with it once the pool is exhausted; giving each dependency its own bounded pool keeps the other endpoints near their baseline latency and error rate during the same stall.
-
Read replicas and replication lag: what stale reads look like and how to bound them
A streaming replica applies the primary's log with some delay, so a read right after a write may not see the write. Route reads by how much staleness each caller tolerates, use synchronous replication modes only where their latency is acceptable, and understand that replaying the log can cancel long queries on the replica.
-
gRPC 基础:protobuf 契约、流式调用与适用场景
gRPC 调用 .proto 文件定义的方法,以 Protocol Buffers 作为接口定义和传输格式;它在 HTTP/2 上提供一元与流式调用、截止期限、元数据和固定状态码集合。适合服务间通信和移动后端;浏览器需要 gRPC-Web,公开集成方则通常期望 HTTP 上的 JSON。
-
一致性哈希:节点增减时保持稳定的键分布
将键哈希对节点数取模,会在节点增加或移除时重映射大多数键。一致性哈希把节点和键放到环上,只移动变化节点附近的键;虚拟节点均衡负载,Maglev 等基于表的变体则以部分分布稳定性换取更快的查找。
-
分布式追踪概览:span、父级 ID 与 W3C 追踪上下文传播
一条 trace 是由 span 构成的树,每个 span 都有追踪 ID、自身的 span ID、父 span ID、时间戳、属性和状态。W3C traceparent 头跨进程边界传递追踪 ID、父级 ID 和 sampled 标志;服务即使只转发两个相关头,也能保持追踪的连贯性。
-
CAP and PACELC as decision aids rather than slogans
CAP forbids only one corner of the design space: perfect availability and linearizable consistency while a network partition lasts. PACELC adds the everyday trade-off between latency and consistency when there is no partition. Used as questions rather than labels, both help decide, per operation, where a system may return stale data and where it must coordinate.
-
背压与有界队列:让最慢的阶段决定节奏
无界队列会把过载变成内存耗尽和无限增长的延迟。背压意味着消费者告诉生产者自己能接收多少数据,Reactive Streams 的需求信号和 Node.js 中 write() 返回 false 都是例子。每个服务阶段至少需要一个有界队列,以及队列满时明确的处理方式。
-
Which overload signal should a small service shed load on: queue wait, in-flight count or CPU?
Open question: guidance lists CPU, latency, queue length and thread count as possible triggers for load shedding and calls the choice service-specific. For a service with a few instances and no global quota system, which signal, threshold and priority rule have teams actually kept in production, and how did they tune them?
-
Distributed locks and leader leases: expiry, fencing tokens and what a lock cannot promise
A distributed lock is a lease that expires; a process paused by garbage collection, CPU contention or a delayed network can keep acting after its lease has passed to someone else. Only a monotonically increasing fencing token checked by the protected resource makes such a lock safe for correctness, and a lock used merely to avoid duplicate work needs less.
-
Logical clocks: Lamport timestamps, vector clocks and hybrid clocks
Wall clocks on different machines disagree, so ordering events by timestamp loses updates. Lamport timestamps give an order consistent with causality, vector clocks additionally detect concurrent updates, and hybrid logical clocks keep a value close to wall time while preserving causal order.
-
熔断器:在依赖不可用或缓慢时快速失败
熔断器统计对依赖的失败调用和慢调用;超过阈值后断开,立即拒绝调用,然后进入半开状态,让少量试探调用通过,再重新闭合。它保护调用方的线程,并给依赖恢复的空间,但前提是采用合理的统计窗口、回退方案,以及底层调用超时。
-
至多一次、至少一次与恰好一次投递
消息系统可以至多投递一次(可能丢失)、至少投递一次(可能重复),或在实际效果上恰好一次(由消费者去重);至少一次加幂等消费者是实用的默认选择,而“恰好一次”是整条流水线的属性,不是消息代理自身的属性。
-
Deletion pipelines across services, derived stores and backups
Model deletion of one person's data as a job with a state per store in the data map: fan out an event, require each owning service to report done with counts, handle versioned object storage and derived stores explicitly, bound how long backups keep the data or destroy per-subject keys, and keep a suppression list so restores can re-delete.
机器可读: JSON