Prev: crash-recovery-algorithms Next: distributed-oltp-database-systems
We can use the building blocks that make consistent single-node DBMSses to make distributed database systems. One key point is to make them fault tolerant, where one node failing does not take down the whole system.
Differences between parallel and distributed DBMSs:
Parallel Databases:
Distributed Databases:
A DBMS’s system is concerned with shared resources directly accessible to CPUs. A Single-node DBMS has a shared everything architecture, where it owns its own local memory and disk.
Some questions naturally result:
As well, the hardware matters:
Is it Homogeneous where every node is on similar hardware, so each cluster can perform the same set of tasks? This lends itself to a shared nothing architecture, where provisioning and failover are easier.
Is it Heterogeneous where nodes have different capabilities? Communication must occur between nodes to carry out a task. A single physical node can host multiple virtual node types for dedicated tasks, and they can scale independently from one node to the other.
To increase capacity of the database, we can split the database across disk, nodes, and processors. This is called sharding sometimes. The DBMS runs query fragments on each partition and then combines the results to produce a single answer. Users should not need to know where the data is physically located, and how/if the tables are partitioned or replicated. An SQL query that works on a single-node DBMS should work the same on a distributed DBMS.
A partitioning scheme should maximize single-node transactions. This allows the DBMS to avoid coordination overhead, which is more efficient and less error prone.
For logically partitioned nodes, particular nodes are in charge of accessing specific tuples from shared disk. For physically partitioned nodes, each shared nothing node reads and updates tuples it contains on its local disk.
Naive Table Partitioning: Each node stores one table. Each query is routed to a specific partition that uses that table. If query load is equally distributed between tables, this works well, and avoids coordination overhead. If there are a lot of joins or hot tables, then this scales poorly.
Horizontal Partitioning: Split a table’s tuples into disjoint sets. Then, choose a column that divides the database equally in size, load, or usage. This is called the partition key. The DBMS can partition a database physically (shared nothing) or logically (shared disk) via hash partitioning or range partitioning.
The DBMS needs a way to support distributed transactions. Some ways are:
Coordinator: There is a global coordinator. The client communicates with the coordinator to acquire locks on partitions that the client wants to access. Once it receives acknowlegement from the coordinator, the client sends its query to those partitions. Once the query is done, the client sends a commit request to the coordinator. The Coordinator then verifies to make sure that transaction is allowed to commit.
Decentralized: Nodes organize themselves. The client directly sends queries to one of the partitions. The home partition will send results back to the client. The home partition is in charge of communicating with other partitions and committing. Decentralized approaches have a hard time with distributed locking, however.
Prev: crash-recovery-algorithms Next: distributed-oltp-database-systems