Sunday, December 19, 2021

[SysD] Data Partition/Sharding, CAP theorem

Why?

Database partitioning is normally done for manageability, performance or availability[1] reasons, or for load balancing.

How?

  • Range partitioning example: from 0 - 100, then 101 - 200....
  • List partitioning ex: user defined list into one partition : all europ countries
  • Composite partitioning: or example first applying a range partitioning and then a hash partitioning
  • Round-robin partitioning : by order : 0 to p0, 1 to p1, 2 to p2 ...
  • Hash partitioning: hash and modulo

Tow directions:

  • Horional partition:
    • partition of rows with a key
  • Vertical partition
    • column spliting
    • "normalization"
    •  A columnar database can be regarded as a database that has been vertically partitioned until each column is stored in its own table.

Problemes:

  1. rebalancing data : a shard is outgrown and we need to split it 
  2. Joining data from multiple shards
  3. how to partition data in a shard

理論計算機科學中,CAP定理(CAP theorem),又被稱作布魯爾定理(Brewer's theorem),它指出對於一個分布式计算系統來說,不可能同時滿足以下三點[1][2]

  • 一致性(Consistency) (等同于所有节点访问同一份最新的数据副本)
  • 可用性Availability)(每次请求都能获取到非错的响应——但是不保证获取的数据为最新数据)
  • 分区容错性Partition tolerance)(以实际效果而言,分区相当于对通信的时限要求。系统如果不能在时限内达成数据一致性,就意味着发生了分区的情况,必须就当前操作在C和A之间做出选择[3]。)

ref:

sharding:  http://highscalability.com/blog/2009/8/6/an-unorthodox-approach-to-database-design-the-coming-of-the.html

https://iswade.github.io/articles/partition/

https://en.wikipedia.org/wiki/Partition_(database)

No comments:

Post a Comment