Category Archives: design

Rewrite lock, copy-on-write

Rewrite lock. Lock a data, then write it, then release the lock. copy-on-write, copy the data into a new place, update the date in new place. Then update the data’s reference to the new place.

Write ahead log(WAL)

WAL persistents operation to disk, then write to cache. If each operation needs to persistent to disk, then it is low efficient. Instead, do batching, this helps to improve performance, also reduce the error to batch level. Flushing every log write to the disk gives a strong durability guarantee (which is the main purpose… Read More »

What is bad code, OO design from Uncle Bob

rigidity code, modules are coupled. Change in module1, requires change module2, then requires change in module3. fragile code, change in module1, but it caused issue in other module or system, which is very unrelated to the module1. Bazzare break, weird break. Like your car window can’t be opened, mechanics fixed the window, but the car… Read More »

Flink study summary

Different windows Tumbling Windows, fixed window. BI analysis. Only cares about the result within a certain time. Sliding Window, 有步长,数据可能会重复使用。场景,需要实时分析,给出结果。如股票交易,最近一段时间的交易情况. Session Window, if long time haven’t received event, then it comes a new window. It’s like timeout. Watermark, TimestampExtractor etc. Flink Watermark, watermark can be treated as a special event. Every event which the… Read More »

Dockerfile CMD requires foreground command

Start a docker container with below Dockerfile. Since it has CMD [“nginx”]. The docker container exists after nginx command is finished. It couldn’t be connected even with –detach mode. In order to keep the docker container running, needs the CMD run in foreground. Let it keep running. So it needs a “daemon off” in nginx.conf… Read More »


Install docker on mac: brew install docker Download docker.dmg and install Run jenkins in background docker run -d -p 8080:8080 -p 50000:50000 jenkins // 8080:80, host port 8080, container port 80 -d makes it to run background. Just like nohup Run centos in docker docker run -it centos /bin/bash -it makes it run interactive mode,… Read More »


jenkins start/stop Create Jenkins pipeline with Freestyle project

TPS = connections / latency

If one connection supports 5TP, then 5 connection supports 25TPS. In another word, if a connection supports 5TPS, that means request latency is 200ms. We have: TPS = number_of_connection / request_latency So TPS relates to TPS per connection and number of connection. How to find max TPS? set connection to 1, literally increase TPS from… Read More »

Read-after-write model vs eventually consistency model

Below is the read-after-write model: GET /key-prefix/cool-file.jpg 404 PUT /key-prefix/cool-file.jpg 200 GET /key-prefix/cool-file.jpg 200 As we can see, file doesn’t exist at beginning. As long as PUT is done, GET always return successfully. Below is eventually consistency model: GET /key-prefix/cool-file.jpg 404 PUT /key-prefix/cool-file.jpg 200 GET /key-prefix/cool-file.jpg 404 File doesn’t exist, after PUT is done, GET… Read More »

Proxy Pattern

Instead of interact with direct resource, client interacts with proxy, then proxy interacts with real resources. Reasons could be: cache, security, encapsulation(http). A proxy has same interface as the original class. In this case, the proxy has same behavior as original class. Adaptor changes the interface. Facade enhances the interface. In below graph: RealSubject implements… Read More »