Handling an increase in transactional data without requiring relocation of preexisting data between shards

A method, system and computer program product for handling an increase in transactional data load without requiring the relocation of preexisting data. A range of attribute values and identifications of associated shards are stored in a data structure. In response to adding a new shard, the data structure is updated by associating a range of attribute values to the added shard while maintaining the same range of attribute values being associated with one of the pre-existing shards. As a result, the new data assigned within this range of attribute values will be stored in the newly added shard while the older data assigned within this range of attribute values will continue to be stored in one of the preexisting shards. In this manner, an increase in transactional data load can be handled by adding a new shard without requiring the relocation of preexisting data.

TECHNICAL FIELD

The present invention relates generally to data partitioning, and more particularly to handling an increase in transactional data without requiring relocation of preexisting data between shards.

BACKGROUND

Data may be partitioned between multiple data sources, such as a “shard.” In such an architecture, the data to be stored in the shards is assigned an identifier, such as a customer's e-mail address or store number. A range of identifier values is then mapped to a specific shard. When data is created, it is placed in a corresponding shard based on its assigned identifier value. For example, data for the first 100 stores of a customer is to be stored in one shard, data for the second 100 stores of the customer is to be stored in another shard and so forth.

As the volume of data to be stored increases though, there will be a need to add additional shards. However, by adding additional shards, this presents a problem of how to relocate existing data from existing shards to the new ones. For instance, referring to the above example, instead of having data for stores1-100being stored in a single shard (e.g., shard #1), data for stores1-50may be stored in shard #1, whereas, data for stores51-100may be stored in a new shard (e.g., shard #2). As a result, existing data needs to be moved from one shard into another shard, such as moving data for stores51-100stored in shard #1into shard #2. Although database replication software exists to move data from one shard into another shard, it requires significant computational resources to move the data, such as moving hundreds of millions of orders in an online transaction processing environment. Furthermore, the shared data and the applications which access such shared data may contain the old shard's database information, which now has to be updated for every single record that is moved.

BRIEF SUMMARY

In one embodiment of the present invention, a method for handling an increase in transactional data load without requiring relocation of preexisting data comprises storing one or more ranges of attributes values and one or more identifications of shards in a data structure, where each of the one or more shards is associated with a range of attribute values. Furthermore, each of the one or more shards stores data with an attribute value within its associated range of attribute values. The method further comprises adding a new shard to one or more preexisting shards to handle additional data to be stored. Additionally, the method comprises updating, by a processor, the data structure by associating a first range of attribute values to the new shard while maintaining the first range of attribute values being associated to one of the one or more preexisting shards.

DETAILED DESCRIPTION

The present invention comprises a method, system and computer program product for handling an increase in transactional data load without requiring the relocation of preexisting data. In one embodiment of the present invention, a range of attribute values and identifications of associated shards are stored in a data structure. An attribute value, as used herein, refers to a value assigned to data that is stored in a particular shard. Each shard is associated with a range of attribute values and stores data assigned with an attribute value within this range of attribute values. A new shard is added to handle additional data to be stored (i.e., handle the increase in transactional data load). In response to adding a shard, the data structure is updated by associating a range of attribute values to the added shard while maintaining the same range of attribute values being associated with one of the pre-existing shards (referring to those shards that existed prior to adding the new shard). As a result, the new data assigned within this range of attribute values will be stored in the newly added shard while the older data (referring to the data previously stored prior to adding the new shard) assigned within this range of attribute values will continue to be stored in one of the preexisting shards. In this manner, an increase in transactional data load can be handled by adding a new shard without requiring the relocation of preexisting data.

While the following discusses the present invention in connection with adding a new shard in a database system without requiring the relocation of preexisting data, the principles of the present invention may be applied to any system (e.g., file system) storing data, where the data is stored among multiple shards. A person of ordinary skill in the art would be capable of applying the principles of the present invention to such implementations. Further, embodiments applying the principles of the present invention to such implementations would fall within the scope of the present invention.

Referring now to the Figures in detail,FIG. 1illustrates a network system100configured in accordance with an embodiment of the present invention. Network system100includes client devices101A-101C (identified as “Client Device A,” “Client Device B,” and “Client Device C,” respectively, inFIG. 1) connected to a middle tier system102via a network103. Client devices101A-101C may collectively or individually be referred to as client devices101or client device101, respectively. Client device101may be any type of computing device (e.g., portable computing unit, personal digital assistant (PDA), smartphone, laptop computer, mobile phone, navigation device, game console, desktop computer system, workstation, Internet appliance and the like) configured with the capability of connecting to network103and consequently communicating with database system104as discussed below.

Network103may be, for example, a local area network, a wide area network, a wireless wide area network, a circuit-switched telephone network, a Global System for Mobile Communications (GSM) network, Wireless Application Protocol (WAP) network, a WiFi network, an IEEE 802.11 standards network, various combinations thereof, etc. Other networks, whose descriptions are omitted here for brevity, may also be used in conjunction with system100ofFIG. 1without departing from the scope of the present invention.

Network system100further includes a database system104connected to middle tier system102. While middle tier system102is shown to be directly connected to database system104, middle tier system102may be connected to database system104via a network (not shown), similar to network103. Database system104contains one or more shards105A-105C (identified as “Shard1,” “Shard2,” and “Shard3,” respectively, inFIG. 1). Shards105A-105C may collectively or individually be referred to as shards105or shard105, respectively. In one embodiment, shard105is a partition in the database and may reside on a separate database server (not shown) or physical location within database system104. WhileFIG. 1illustrates database system104containing three shards105, database system104may contain any number of shards105.

Users of client devices101generate requests for service to middle tier system102, at least some of these requests requiring access to information in shards105of database system104. Middle tier system102acts as a server to client device101; it may provide various services to client devices101(not all of which necessarily involve database access), but in particular it functions as an intermediary between client devices101and database system104in handling client requests to access information in shard105. Where necessary to provide a requested service, middle tier system102uses the client request for information in a general form to generate one or more requests to database system104in a specific form required by shard105to be accessed. Database system104generates responses to those requests (e.g., copies of selective information, results of queries, acknowledgments of changes made to the information, etc.), which are transmitted to middle tier system102, and used by middle tier system102to provide a response to client devices101. Middle tier system102, which handles all direct interaction with client devices101, appears to client devices101as database system104. From the perspective of database system104, middle tier system102functions as a representative of multiple client devices101to transmit and receive information from client devices101. A description of an embodiment of a hardware configuration of middle tier system102is provided below in connection withFIG. 2.

FIG. 1is intended to represent a typical environment at a high level of generality, and is not intended to represent all components of an environment in detail, or all possible permutations of an environment for accessing a database. Numerous variations of the environmental representation ofFIG. 1are possible, of which the following in particular are possible, the description of particular variations herein being intended by way of example only and not by way of limitation. For example, embodiments of the present invention discussed herein may be implemented in several environments, including a cloud environment. Furthermore, although client devices101, middle tier system102and database system104are shown as separate and distinct entities, some or all of these may in fact be combined.

Referring now toFIG. 2,FIG. 2illustrates a hardware configuration of middle tier system102(FIG. 1) which is representative of a hardware environment for practicing the present invention. Referring toFIG. 2, middle tier system102has a processor201coupled to various other components by system bus202. An operating system203runs on processor201and provides control and coordinates the functions of the various components ofFIG. 2. An application204in accordance with the principles of the present invention runs in conjunction with operating system203and provides calls to operating system203where the calls implement the various functions or services to be performed by application204. Application204may include, for example, a program for handling an increase in transactional data load without requiring the relocation of preexisting data as discussed further below in association withFIGS. 3-7.

Referring again toFIG. 2, read-only memory (“ROM”)205is coupled to system bus202and includes a basic input/output system (“BIOS”) that controls certain basic functions of middle tier system102. Random access memory (“RAM”)206and disk adapter207are also coupled to system bus202. It should be noted that software components including operating system203and application204may be loaded into RAM206, which may be middle tier system's102main memory for execution. Disk adapter207may be an integrated drive electronics (“IDE”) adapter that communicates with a disk unit208, e.g., disk drive. It is noted that the program for handling an increase in transactional data load without requiring the relocation of preexisting data, as discussed further below in association withFIGS. 3-7, may reside in disk unit208or in application204.

Middle tier system102may further include a communications adapter209coupled to bus202. Communications adapter209interconnects bus202with an outside network (e.g., network103ofFIG. 1) thereby enabling middle tier system102to communicate with client devices101and database system104.

As stated in the Background section, data may be partitioned between multiple data sources, such as a “shard.” In such an architecture, the data to be stored in the shards is assigned an identifier, such as a customer's e-mail address or store number. A range of identifier values is then mapped to a specific shard. When data is created, it is placed in a corresponding shard based on its assigned identifier value. For example, data for the first 100 stores of a customer is to be stored in one shard, data for the second 100 stores of the customer is to be stored in another shard and so forth. As the volume of data to be stored increases though, there will be a need to add additional shards. However, by adding additional shards, this presents a problem of how to relocate existing data from existing shards to the new ones. For instance, referring to the above example, instead of having data for stores1-100being stored in a single shard (e.g., shard #1), data for stores1-50may be stored in shard #1, whereas, data for stores51-100may be stored in a new shard (e.g., shard #2). As a result, existing data needs to be moved from one shard into another shard, such as moving data for stores51-100stored in shard #1into shard #2. Although database replication software exists to move data from one shard into another shard, it requires significant computational resources to move the data, such as moving hundreds of millions of orders in an online transaction processing environment. Furthermore, the shared data and the applications which access such shared data may contain the old shard's database information, which now has to be updated for every single record that is moved.

The principles of the present invention provide a means for handling an increase in transactional data load, such as by adding a new shard, without requiring the relocation of preexisting data as discussed further below in connection withFIGS. 3-7.FIG. 3is a flowchart of a method for handling an increase in transactional data load, such as by adding a new shard, without requiring the relocation of preexisting data.FIG. 4illustrates a data structure configured to store ranges of attributes values and associated identifications of shards prior to adding a new shard.FIG. 5illustrates a new shard being added to the database system.FIG. 6illustrates the data structure being updated to associate a range of attribute values to the newly added shard while maintaining the association of the same range of attribute values to a preexisting shard.FIG. 7is a flowchart of a method for accessing data stored in multiple shards using the data structure of the present invention.

As stated above,FIG. 3is a flowchart of a method300for handling an increase in transactional data load, such as by adding a new shard, without requiring the relocation of preexisting data in accordance with an embodiment of the present invention.

Referring toFIG. 3, in conjunction withFIGS. 1-2, in step301, middle tier system102stores ranges of attribute values and identifications of associated shards105of database system104in a data structure as illustrated inFIG. 4.FIG. 4illustrates a data structure400configured to store ranges of attributes values and associated identifications of shards105prior to adding a new shard in accordance with an embodiment of the present invention.

As illustrated inFIG. 4, data structure400includes a listing of ranges of attribute values401and the associated identifications of shards (shard numbers)402. An attribute value, as used herein, refers to a value assigned to data that is stored in a particular shard105. For example, the range of attribute values X1-Z1is associated with the identification of shard #1(e.g., shard105A ofFIG. 1), the range of attribute values X2-Z2is associated with the identification of shard #2(e.g., shard105B ofFIG. 1) and the range of attribute values X3-Z3is associated with the identification of shard #3(e.g., shard105C ofFIG. 1). Hence, as illustrated inFIG. 4, each shard105is associated with a range of attribute values. Furthermore, each shard105stores data with an attribute value within its associated range of attribute values. For example, data with an attribute value within the range of attribute values X1-Z1would be stored in shard105associated with the identification of shard #1(e.g., shard105A). In one embodiment, data structure400resides in memory (e.g., ROM205) or in a storage medium (e.g., disk unit208).

Returning toFIG. 3, in conjunction withFIGS. 1-2 and 4, in step302, middle tier system102adds a new shard105to handle additional data to be stored (i.e., handle the increase in transactional data load) as illustrate inFIG. 5.FIG. 5illustrates a new shard105D being added to database system104in accordance with an embodiment of the present invention.

Referring toFIG. 5, shard105D (identified as “New Shard4”) is added to database system104containing preexisting shards105A-105C to handle the additional transactional data load. New shard105D and preexisting shards105A-105C may collectively or individually be referred to as shards105or shard105, respectively. In one embodiment, shard105D is added to store new data assigned to a range of attribute values while the older data assigned to the same range of attribute values is to be maintained in the preexisting shard(s)105as discussed further below.

Returning toFIG. 3, in conjunction withFIGS. 1-2 and 4-5, in step303, middle tier system102, in response to having a shard105(e. g., shard105D) added to database system104, updates data structure400by associating a range of attribute values to the added shard105D while maintaining the same range of attribute values being associated with one of the pre-existing shards105(referring to those shards105, such as shards105A-105C, that existed prior to adding the new shard, such as105D) as illustrated inFIG. 6.FIG. 6illustrates data structure400being updated to associate a range of attribute values to the newly added shard105D while maintaining the association of the same range of attribute values to a preexisting shard105(e.g., shard105C) in accordance with an embodiment of the present invention.

Referring toFIG. 6, in conjunction withFIG. 5, data structure400has been updated to reflect that new data assigned within the range of attribute values Y3-Z3will be stored in shard105associated with the identification of shard #4(e.g., shard105D). Furthermore, data structure400has been updated to reflect that the older data (referring to the data previously stored prior to the new shard105, such as shard105D, being added to database system104) assigned within the range of attribute values Y3-Z3will be stored in shard105associated with the identification of shard #3(e.g., shard105C). In one embodiment, the mapping of the range of attribute values assigned to the older data, such as Y3-Z3, to one of the preexisting shards105, such as shard105C, is maintained by metadata.

An example of utilizing the principles of the present invention to handle an increase in transactional data load, such as by adding a new shard, without requiring the relocation of preexisting data is as follows. Suppose that a website starts with 200 electronic stores split across two shards105with 100 stores in each shard105(e.g., data from stores1-100stored in shard105A and data from stores101-200stored in shard105B). All orders for the first 100 stores are stored in shard105A while the orders for stores101-200are stored in shard105B. As business grew and volumes of data to be stored increased, there was a need to add a new shard105, such as shard105D, to store the new data. For instance, the data to be stored from the first 100 stores (stores1-100) may be split into two shards105, which each storing data from50of the first 100 stores. The new data from stores1-50may now be stored in the newly added shard105D. However, there is still a need to retrieve the orders that had previously transpired. As a result, some of the orders will reside in preexisting shard105A while some will reside in newly added shard105D. In order to retrieve these orders, a metadata engine, which may reside in application204, is configured to maintain a mapping of historically assigned shards105, such as in this case shard105A. All new orders will be created in the newly added shard104, however, the older orders can still be retrieved from shard105A. In this manner, an increase in transactional data load can be handled by adding a new shard105(e.g., shard105D) without requiring the relocation of preexisting data.

As will be discussed in further detail below, middle tier system102will retrieve data from multiple shards105(e.g., shards105C and105D) in situations when the requested data is assigned an attribute value that is within a range of attribute values associated with multiple shards105. By having the old and new data being assigned a range of attribute values associated with multiple shards105(a new shard105D and a preexisting shard105, such as shard105C), relocation of preexisting data is no longer required.

Data can be accessed from multiple shards105, such as a new shard105(e.g., shard105D) and a preexisting shard105, such as shard105C, as discussed below in connection withFIG. 7.

FIG. 7is a flowchart of a method700for accessing data stored in multiple shards105(e.g., shards105C,105D) using data structure400of the present invention in accordance with an embodiment of the present invention.

Referring toFIG. 7, in conjunction withFIGS. 1-6, in step701, middle tier system102receives a request from client device101(e.g., client device101A) to read data from database system104, where the request includes an attribute value assigned to the data to be read. In one embodiment, a services layer of middle tier system102receives the request from client device101. In one embodiment, such a services layer is one of the layers in the service oriented architecture. In one embodiment, the services layer is a collection of application programming interfaces.

In step702, middle tier system102performs a look-up in data structure400to identify two or more shards105associated with a range of attribute values that include the attribute value of the request.

In step703, middle tier system102identifies two or more shards105associated with a range of attribute values that includes the attribute value of the request. For example, referring toFIG. 6, if the request received in step701was associated with an attribute value of Y3, then middle tier system102would identify shard #4(e.g., shard105D) storing the new data and shard #3(e.g., shard105C) storing the older data assigned to an attribute value of Y3.

In step704, middle tier system102reads the requested data from the identified two or more shards105(e.g., shards105C,105D). In one embodiment, the data read is aggregated into a single response to be sent to the requesting client device101. In one embodiment, the read data is aggregated at the application level as opposed to the database level.