# US 9,355,134 B1 · Facilitating data redistribution in database sharding

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 9,355,134 B1
- Document ID: US9355134B1
- Status: Granted
- Kind: B1
- Application number: 13/867,450
- Filed: 2013-04-22
- Granted: 2016-05-31
- Earliest claimed: 2011-09-27
- Assignees: Amazon Technologies, Inc.
- Applicants: Amazon Technologies, Inc.
- Inventors: Weinan Wang; Joseph Magerramov; Maxym Kharchenko; Min Zhu; Aaron Drew Alexander Kujat; Alessandro Gherardi; Jason Curtis Jenks
- Web page: https://patentgrep.com/patent/US9355134B1

## CPC

- G06F 16/2255: {Hash tables}
- G06F 16/182: Distributed file systems
- G06F 16/21: Design, administration or maintenance of databases
- G06F 16/278: {Data partitioning, e.g. horizontal or vertical partitioning}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Disclosed are various embodiments for facilitating data redistribution in database sharding. A database is maintained that is horizontally partitioned into a set of first buckets using modulo-based assignments. A fixed number of the first buckets are stored in each of multiple physical data stores. The database is repartitioned into a set of second buckets using modulo-based assignments. The number of second buckets in the set is a multiple of the sum of a positive integer and the quantity of the physical data stores. The data in the database is unmoved between the physical data stores by repartitioning.

## Claims

### Claim 1

A non-transitory computer-readable medium embodying a program executable in a computing device, wherein when executed the program causes the computing device to at least:
maintain a database that is stored in a plurality of physical data stores through horizontal partitioning, the database including a plurality of data items;
assign individual ones of the plurality of data items to individual ones of a plurality of first buckets by generating a respective hash code from a standardized portion of the individual one of the plurality of data items and determining the respective hash code modulo the number of the plurality of first buckets, wherein a first fixed number of the plurality of first buckets are stored in corresponding ones of the plurality of physical data stores according to a mapping;
reassign the individual ones of the plurality of data items to individual ones of a plurality of second buckets by determining the respective hash code modulo the number of the plurality of second buckets, the number of the plurality of second buckets being a multiple of the number of first buckets in the plurality of first buckets, a multiple of a current number of physical data stores, and a multiple of an increased number of physical data stores; and
update the mapping to map a second fixed number of the plurality of second buckets to corresponding ones of the plurality of physical data stores, wherein the plurality of data items are unmoved between the plurality of physical data stores by updating the mapping.

### Claim 2 (depends on 1)

The non-transitory computer-readable medium of claim 1, wherein when executed the program further causes the computing device to at least determine one of the plurality of physical data stores in which a given one of the plurality of data items is stored by:
generating the respective hash code for the given one of the plurality of data items;
generating a second bucket identifier based at least in part on the respective hash code modulo the number of the plurality of second buckets; and
determining the one of the plurality of physical data stores that corresponds to the second bucket identifier according to the mapping.

### Claim 3 (depends on 1)

The non-transitory computer-readable medium of claim 1, wherein when executed the program further causes the computing device to at least: add at least one physical data store to the plurality of physical data stores;
migrate the data items which are assigned to a subset of the plurality of second buckets to the at least one physical data store that has been added; and
update the mapping to map a third fixed number of the plurality of second buckets to corresponding ones of the plurality of physical data stores, wherein an even distribution of the plurality of second buckets is achieved among the plurality of physical data stores.

### Claim 4

A system, comprising:
a plurality of physical data stores;
at least one computing device including a processor and a memory; and
a data store management application executable in the at least one computing device, wherein when executed the data store management application causes the at least one computing device to at least:
maintain a database of data that is horizontally partitioned into a set of first buckets using modulo-based assignments, a fixed number of the set of first buckets being stored in individual ones of the plurality of physical data stores; and
repartition the database into a set of second buckets using modulo-based assignments, the number of second buckets in the set of second buckets being a multiple of the number of first buckets in the set of first buckets, a multiple of a current number of physical data stores, and a multiple of an increased number of physical data stores, wherein the data in the database is unmoved between the plurality of physical data stores by repartitioning.

### Claim 5 (depends on 4)

The system of claim 4, wherein when executed the data store management application further causes the at least one computing device to at least determine a modulo-based assignment for a data item in the database by generating a hash code from a standardized portion of the data item and calculating the modulo-based assignment based at least in part on a result of the hash code modulo a quantity of buckets.

### Claim 6 (depends on 5)

The system of claim 5, wherein the standardized portion of the data item corresponds to a key.

### Claim 7 (depends on 4)

The system of claim 4, wherein the fixed number is an integer greater than one.

### Claim 8 (depends on 4)

The system of claim 4, wherein the modulo-based assignments are stored in association with the data.

### Claim 9 (depends on 4)

The system of claim 4, wherein the modulo-based assignments are determined dynamically in response to accessing the data.

### Claim 10 (depends on 4)

The system of claim 4, wherein when executed the data store management application further causes the at least one computing device to at least:
add at least one other physical data store to the plurality of physical data stores; and
migrate the data in the database corresponding to a subset of the set of second buckets to the at least one other physical data store.

### Claim 11 (depends on 10)

The system of claim 10, wherein migrating the data further comprises updating a mapping of the set of second buckets to the plurality of physical data stores.

### Claim 12

A method, comprising:
maintaining a plurality of physical data stores corresponding to horizontal partitions of a database containing a plurality of data items, wherein the plurality of data items are assigned to respective ones of a plurality of first buckets, and the data items assigned to a respective first bucket are stored in a mapped one of the plurality of physical data stores; and
reassigning, via a computing device, for individual ones of the plurality of first buckets, the data items which are assigned to the first bucket to a second bucket in a corresponding subset of a plurality of second buckets, the corresponding subset of the plurality of second buckets being distinct for each first bucket, the second buckets in the corresponding subset being stored in the mapped one of the plurality of physical data stores corresponding to the first bucket, the number of second buckets in the corresponding subset being a fixed number for all of the plurality of first buckets, the number of second buckets in the plurality of second buckets being a multiple of the number of first buckets in the plurality of first buckets, a multiple of a current number of physical data stores, and a multiple of an increased number of physical data stores.

### Claim 13 (depends on 12)

The method of claim 12, wherein an individual one of the plurality of data items is associated with a key, and the method further comprises assigning, by the computing device, the individual one of the plurality of data items to one of the plurality of first buckets by:
generating, by the computing device, a hash code from the key of the individual one of the plurality of data items;
determining, by the computing device, a first bucket identifier by calculating the hash code modulo the number of the plurality of first buckets; and
assigning, by the computing device, the individual one of the plurality of data items to the one of the plurality of first buckets corresponding to the first bucket identifier.

### Claim 14 (depends on 13)

The method of claim 13, wherein assigning, by the computing device, the individual one of the plurality of data items to the one of the plurality of first buckets corresponding to the first bucket identifier further comprises storing, by the computing device, the first bucket identifier in association with the individual one of the plurality of data items.

### Claim 15 (depends on 12)

The method of claim 12, wherein an individual one of the plurality of data items is associated with a key, and reassigning further comprises:
for the individual one of the plurality of data items:
generating, by the computing device, a hash code from the key of the individual one of the plurality of data items;
determining, by the computing device, a second bucket identifier by calculating the hash code modulo the number of second buckets; and
reassigning, by the computing device, the individual one of the plurality of data items to the second bucket corresponding to the second bucket identifier.

### Claim 16 (depends on 15)

The method of claim 15, wherein reassigning, by the computing device, the individual one of the plurality of data items to the second bucket corresponding to the second bucket identifier further comprises storing, by the computing device, the second bucket identifier in association with the individual one of the plurality of data items, the second bucket identifier replacing a first bucket identifier.

### Claim 17 (depends on 12)

The method of claim 12, further comprising:
adding, by the computing device, at least one physical data store to the plurality of physical data stores.

### Claim 18 (depends on 17)

The method of claim 17, further comprising migrating, by the computing device, the data items that are assigned to a second bucket in the corresponding subset of second buckets from the mapped one of the plurality of physical data stores to the at least one physical data store that has been added.

### Claim 19 (depends on 12)

The method of claim 12, further comprising determining, by the computing device, one of the plurality of physical data stores in which a given one of the plurality of data items is stored by:
generating, by the computing device, a hash code for the given one of the plurality of data items;
generating, by the computing device, a second bucket identifier based at least in part on the hash code modulo the number of second buckets; and
determining, by the computing device, the one of the plurality of physical data stores that corresponds to the second bucket identifier.

### Claim 20 (depends on 12)

The method of claim 12, wherein the plurality of data items are unmoved between the plurality of physical data stores by the reassigning.
