NOTE
5.2 Distributed-System Partitioning: Request Processing
Routing components send client reads and writes to the nodes holding the target partitions. These notes examine CRUD requests with and without a sharding key.
This is a historical learning note and may contain outdated or incomplete understanding.
The routing component routes client read and write requests to the node that contains the corresponding partition.
1. Routing Component
2. Request Processing
2.1. Insert Data
- The client generates data containing a sharding key.
- The client sends the insert request to the routing component.
- The routing component forwards the request to the corresponding node using the sharding key.
- The node inserts the data.
2.2. Delete Data
2.2.1. Contains the Sharding Key
- The client deletes data using the sharding key.
- The client sends the delete request to the routing component.
- The routing component forwards the request to the corresponding node using the sharding key.
- The node deletes the data.
2.2.2. Does Not Contain the Sharding Key
- The client deletes data using a keyword.
- The client sends the delete request to the routing component.
- The routing component forwards the request to all nodes.
- Each node deletes the data.
2.3. Query Data
2.3.1. Contains the Sharding Key
- The client queries data using the sharding key.
- The client sends the query request to the routing component.
- The routing component forwards the request to the corresponding node using the sharding key.
- The node queries the data.
2.3.2. Does Not Contain the Sharding Key
- The client queries data using a keyword.
- The client sends the query request to the routing component.
- The routing component forwards the request to all nodes.
- Each node queries the data.
2.4. Update Data
2.4.1. Contains the Sharding Key
- The client updates data using the sharding key.
- The client sends the update request to the routing component.
- The routing component forwards the request to the corresponding node using the sharding key.
- The node updates the data.
2.4.2. Does Not Contain the Sharding Key
- The client updates data using a keyword.
- The client sends the update request to the routing component.
- The routing component forwards the request to all nodes.
- The node updates the data.
2.4.3. Examples
- MySQL CRUD can contain a sharding key or not contain one.
- Redis CRUD contains a sharding key.
- Kafka CRU contains a sharding key; there is no D.
- ZooKeeper does not use partitioning.
- Elasticsearch CRUD can contain a sharding key or not contain one.
3. Secondary Indexes
- Data is not partitioned by secondary indexes.
- When accessing data through a secondary index, the system must determine which partition should receive the read or write request.
3.1. Local Index (document based)
- Each partition maintains only the index for the current partition and stores it locally.
- Disadvantage
- Read/write request routing uses scatter/gather.
- Advantage
- Fast writes.
3.2. Global Index (term based)
- Indexes for all partitions are maintained together, and the index itself is also partitioned.
- Disadvantage
- Slow writes.
- Advantage
- Read/write request routing uses the term to route to the correct partition, similar to a primary-key index.
3.3. Examples
- MySQL secondary indexes use local indexes.
- Redis has no secondary indexes.
- Kafka secondary indexes use local indexes.
- ZooKeeper has no secondary indexes.
- Elasticsearch secondary indexes use local indexes.
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub