Once data is split across 30 machines, how does a client know which machine to send a request for a given key to?
Sketch your own answer first, then compare it with the one below.
A strong answer
Something has to hold the map from key to machine, and there are three usual places.
The client can contact any node. That node checks the map, and if it does not own the key, it forwards the request to the node that does. Nodes keep their copies of the map in sync by gossiping changes to one another. It keeps clients trivial and is how Dynamo-style stores work. The cost is an extra hop for some requests.
A routing tier can sit in front. A small set of proxies holds the map and sends each request to the owner. Clients need no knowledge of the layout, and the proxies are one more service to run.
The client can fetch the map itself and connect directly to the owner. This is the fastest path, but the client's copy goes stale whenever a partition moves, so nodes must reply "not mine, ask over there" and the client must refresh.
Whichever is used, the authoritative map has to be consistent, since two nodes both believing they own one partition would corrupt data. Systems often keep it in a coordination service such as ZooKeeper or etcd, which is built to agree on small, critical state.
Sources
- Martin Kleppmann (2017). Designing Data-Intensive Applications.
- Giuseppe DeCandia and others (2007). Dynamo: Amazon's Highly Available Key-value Store.