A distributed database receives an instruction to read or write data. The instruction includes a key. The database includes a key space defined by attoshards. An attoshard is a segment of key space having a size, in keys, proportional to a total number of nodes in the database. The attoshard includes keys for cluster segments at predefined positions in the attoshard. Each cluster segment corresponds to one cluster. A node of the database hashes the key to generate a token. The node performs a modulo operation on the token using the total number of nodes in the database to compute a remainder value. The node determines a cluster segment of an attoshard based on a position in the attoshard defined by the remainder value. The node determines a cluster for the instruction based on the cluster segment and executes the instruction at the determined cluster.