Paxos Replication vs. Leader-Follower Replication

If you are operating some stateful services, chances are you have to replicate your data. There are use cases of single replica database, in which cases, the user can tolerate dataloss. It's optimizing for throughput, low latency, etc. But vast majority of stateful services have to deal with replication. Replication…

Different ways of caching and maintaining cache consistency

Phil Karlton [http://www.meerkat.com/karlton/] once said, "There are only two hard things in Computer Science: cache invalidation and naming things.[1]" There are other good variations of the quote. Mine personal favorite is Jeff Atwood's quote [https://twitter.com/codinghorror/status/506010907021828096?lang=en], "There are two…

请不要再称数据库是CP或者AP (Please stop calling databases CP or AP)

经Martin Kleppman本人同意,这篇文章是他英文原文 [https://martin.kleppmann.com/2015/05/11/please-stop-calling-databases-cp-or-ap.html] 的中文翻译。Authorized by Martin Kleppmann, this is a Chinese translation of his original blog post [https://martin.kleppmann.com/2015/05/11/please-stop-calling-databases-cp-or-ap.html] . 在 Jeff Hodges 精彩的博客文章给年轻人关于分布式系统的笔记 [https://www.somethingsimilar.com/2013/01/14/notes-on-distributed-systems-for-young-bloods/] 中,他建议我们用CAP定理…

State Machine and Synchronization

This is the second of two notes of Lamport's Time-Clock paper[1]. The first one is here [https://blog.the-pans.com/time-and-order/]. The problem We will be focusing on how to use Logical Clock to solve an actual problem. The problem is to grant the resource to a process, that…

A Look into Return Value Optimization of C++

I am learning C++ and ran into a "bizarre" issue, which was because Return Value Optimization (RVO) took place. In the spirit of learning C++, let's take a look into what's happening here. This is the code we will be looking at. struct Foo { Foo() { cout << "foo constructed" << endl; } Foo(…

Time and Order

This is the first of two notes of Lamport's Time-Clock paper[1]. Abstract Order is a more basic concept than Time. And it's critical to how we reason. However physical time, which even though gives us total ordering on all events, cannot be observed within the system. So, we introduced…