Design Data-Intensive Applications

最近的一次阅读是在2023年1月,因为这几年工作中用到了不少书中提到的工具,有一些体会,所以理解起来 比较容易,对相关的概念和知识补充也印象深刻。这本书不太建议没有业界工作经验的人阅读,否则啃起来比 较累效果还不好。

Part I

主要介绍了Data System Foundation.

Reliable, Scalable and Maintainable

各自的定义,分类和要点,从这3个方面考虑去构建适合需求的系统。比如Relability,有hardware, software and human faults; Scalability,用什么去describe workload and performance, 如何处理越来越多的workload; Mainyainability,要多多考虑operations team (run smoothly) ,new engineer (easy to pick up)的感受,以及对未来可能的需求改动留有余地。

Data Models and Query Language

主要讲了传统的relational DB 和 NoSQL中的document DB (suitable for one to many relation), 如何随着需求的改变不断进化,还提到了Graph-like Data Model (many to many relation). 讲到了Declarative language 对比 Imperative的好处,比如SQL,系统可以在内部优 化而不影响Query语句本身。

Storage and Retrieval

数据库的底层实现,从Hash Indexes,到SSTables (String Sorted Table),再到LSM-Trees (Log Structure Merge Tree), 最后到B-Trees (一种在disk上保持sorted structure的结构).

Advantages and downsides of LSM-Trees. 特别是read/write的performance, LSM-Tree的 write operation一般来说比B-Trees效率高,但这里没有一个普世法则,需要通过实际测试才能知道哪种 模式适合你。

In-memory database也提到了,相比于non-inmemory,它不需要encode data in the strucutre to store in disk, 并且可以实现disk上难以实现的index 结构.

最后提到了data warehouse, 这和传统的处理transaction的数据库独立开来了,优化于适合 analytics. column-oriented storage经常在data warehouse中使用,但不全是。要注意的是 Cassandra有column families的概念,但它并不是属于column-oriented storage.

Encoding and Evolution

Everything changes and nothing stands still.

A changes to app’s feature also requires a change to data that it stores, 这就遇 到2个主要的问题: backward compatibility and forward compatibility. backward is commonly to see, forward means old code can read data that was written by new code.

Here encoding has nothing to do with encryption. The translation from in-memory presentation to a byte sequence is called encoding (also known as serialization or marshalling), the reverse is called decoding (parsing, deserialization, unmarshalling).

介绍了一些Language-specific formats,比如Java, Python自带的encoding module or package, but they have deep problems,比如和语言耦合太强,perofrmance太低很verbose.

JSON,XML,CSV很常用,有一些问题但remain popular and good for many purposes.

Binary encoding可以节约一些空间,但它没有schema,所以需要将object field name encode into data.

Schema binary encoding, save a lot compare to JSON/XML/CSV: Thrift (from facebook) and Protocol Buffers (from google), both were made open source. They are more or less similar: define schema (field can be required or optional), then code with field tags, good for schema evolution.

Apache Avro, a sub-project from Hadoop, 对于处理Hadoop的大数据很有效, no field tag. 有writer’s schema and reader’s schema来解决encode, decode的问题,对于schema evolution, 只要保证双方schema compitable就可以。

Part 2

0%