1. Technical Field
This invention generally relates to computer systems and more specifically relates to database apparatus and methods.
2. Background Art
Many modern computer systems are a complex combination of different hardware and software that are interconnected on a network. Networks allow computers to share information. Shared information may be stored in a central database.
A modern development is to divide a database into multiple partitions, and to have a database server that is dedicated to servicing one of the database partitions. Thus, a database that has four partitions will include four database servers, one per partition. In the prior art, when multiple database servers are present, an application server selects one of the database servers, and sends all database requests to that selected database server. If a database request should be handled by the selected database server, the selected database server processes the database request and returns the results of the database request. If a database request should be handled by a different database server, the selected database server routes the database request to the correct database server, which returns the results to the selected database server, which, in turn, returns the results to the application server. As the number of partitions, and hence database servers, increases, the likelihood that the selected server is the correct server to process the database request goes down. The routing of database requests to other database servers, and the routing of the results back to the selected database server, then to the application server, creates overhead that results in significant performance penalties. Without a way to reduce the amount of redirection of database requests and results, the computer industry will continue to suffer from inefficient methods for processing database requests in a partitioned database system.
According to the preferred embodiments, an apparatus and method provide client-side routing of database requests to enhance the performance of a partitioned database system. In a first embodiment, the database client determines from a map of the database the correct server to handle a transaction, and submits all database requests in the transaction directly to the correct server, which returns the results directly to the database client. In a second embodiment, the database client submits a database request to a selected database server. If the selected database server is the correct database server for the database request, the selected database server processes the request and returns the results to the database client. If the selected database server is not the correct server for the database request, the selected database server returns a code to the database client indicating the correct database server for the transaction. The database client then submits all the database requests for the transaction directly to the correct database server, and receives the results directly from the correct database server. In a third embodiment, the database client opens connections to all database servers, which also have connections between themselves. The database client submits a database request to a selected database server. If the selected database server is the correct database server for the database request, the selected database server processes the database request and returns the results to the database client. If the selected database server is not the correct server for the database request, the selected database server routes the database request to the correct database server, which sends the results to the database client via its direct connection to the database client. In all three embodiments, the database client may inform an application server regarding which database server to enlist for a transaction. This enlistment provides for transaction recovery according to methods known in the art.
The foregoing and other features and advantages of the invention will be apparent from the following more particular description of preferred embodiments of the invention, as illustrated in the accompanying drawings.
The preferred embodiments of the present invention will hereinafter be described in conjunction with the appended drawings, where like designations denote like elements, and:
The preferred embodiments allow client-side routing of database requests to improve system performance in a partitioned database system. The database client determines the correct server, then routes database requests in a transaction to the correct server. By directly communicating with the correct server, the performance of the database client is substantially improved.
Referring now to
Main memory 120 in accordance with the preferred embodiments contains data 121, an operating system 122, a partitioned database 123, multiple database servers 124, and an application server 125. Data 121 represents any data that serves as input to or output from any program in computer system 100. Operating system 122 is a multitasking operating system known in the industry as OS/400; however, those skilled in the art will appreciate that the spirit and scope of the present invention is not limited to any one operating system. Partitioned database 123 is any suitable database, whether currently known or developed in the future, that is divided into multiple partitions. Database servers 124 process database requests for the partitioned database 123. In the most preferred implementation, there is one database server 124 for each database partition in partitioned database 123.
The application server 125 provides an interface for computer programs known as “applications” to access the partitioned database 123. The application server 125 includes a database client 126, which receives calls from applications that include database requests in the form of database statements, such as statements in Structured Query Language (SQL). The database client 126 includes a database server selection mechanism 127 that allows the database client 126 to determine the correct database server for a transaction, and to directly route database requests for the transaction to the correct database server. The application server 125 also includes a client-specified database server enlistment mechanism 128. In the prior art, at the beginning of a transaction, an application server enlists a database server, and all database requests and results are routed through the selected database server. In the application server 125 of the preferred embodiments, the database server selection mechanism 127 in the database client 126 determines the correct database server for the transaction, and directly routes database requests for the transaction to the correct database server. In addition, the database client specifies to the application server which database server should be enlisted for the transaction. Note, however, that the enlistment need not be performed before processing any database requests in the transaction. The enlistment simply needs to be done before the application server does transaction commit processing. In addition, the enlistment may be done asynchronously with respect to the database requests and results flowing between the database client 126 and the correct database server. The purpose of the enlistment is to provide for error-recovery of the transaction. The concepts of enlistment of database servers for the purpose of error recovery is well-known in the art, and is therefore not discussed in more detail here.
Computer system 100 utilizes well known virtual addressing mechanisms that allow the programs of computer system 100 to behave as if they only have access to a large, single storage entity instead of access to multiple, smaller storage entities such as main memory 120 and DASD device 155. Therefore, while data 121, operating system 122, partitioned database 123, database servers 124, and application server 125 are shown to reside in main memory 120, those skilled in the art will recognize that these items are not necessarily all completely contained in main memory 120 at the same time. It should also be noted that the term “memory” is used herein to generically refer to the entire virtual memory of computer system 100, and may include the virtual memory of other computer systems coupled to computer system 100.
Processor 110 may be constructed from one or more microprocessors and/or integrated circuits. Processor 110 executes program instructions stored in main memory 120. Main memory 120 stores programs and data that processor 110 may access. When computer system 100 starts up, processor 110 initially executes the program instructions that make up operating system 122. Operating system 122 is a sophisticated program that manages the resources of computer system 100. Some of these resources are processor 110, main memory 120, mass storage interface 130, display interface 140, network interface 150, and system bus 160.
Although computer system 100 is shown to contain only a single processor and a single system bus, those skilled in the art will appreciate that the present invention may be practiced using a computer system that has multiple processors and/or multiple buses. In addition, the interfaces that are used in the preferred embodiment each include separate, fully programmed microprocessors that are used to off-load compute-intensive processing from processor 110. However, those skilled in the art will appreciate that the present invention applies equally to computer systems that simply use I/O adapters to perform similar functions.
Display interface 140 is used to directly connect one or more displays 165 to computer system 100. These displays 165, which may be non-intelligent (i.e., dumb) terminals or fully programmable workstations, are used to allow system administrators and users to communicate with computer system 100. Note, however, that while display interface 140 is provided to support communication with one or more displays 165, computer system 100 does not necessarily require a display 165, because all needed interaction with users and other processes may occur via network interface 150.
Network interface 150 is used to connect other computer systems and/or workstations (e.g., 175 in
At this point, it is important to note that while the present invention has been and will continue to be described in the context of a fully functional computer system, those skilled in the art will appreciate that the present invention is capable of being distributed as a program product in a variety of forms, and that the present invention applies equally regardless of the particular type of signal bearing media used to actually carry out the distribution. Examples of suitable signal bearing media include: recordable type media such as floppy disks and CD RW (e.g., 195 of
Referring to
The database client 224 in the application server 220 provides an interface for accessing the database 260. The database client 224 may thus be called to access the database 260.
Referring now to
The application server then sends the first statement in the transaction that was received from the database client to the enlisted database server (step 330). If the first statement targets the enlisted database server (step 340=YES), the enlisted database server executes the statement (step 342). Note that a statement targets the enlisted database server if the statement accesses the database partition that corresponds to the enlisted database server. If the statement does not target the enlisted database server (step 340=NO), the enlisted database server sends the statement to the correct database server (step 350). The correct database server then executes the statement (step 360). The result is then returned from the correct database server to the enlisted database server (step 370). The enlisted database server then returns the results to the application server (step 380). The application server, in turn, returns the results to the database client (step 380). The database client may then return the results to the program that called the database client to execute the transaction.
The prior art method of handling database requests in a partitioned database system suffers from overhead that significantly and adversely affects system performance. Because all database statements are directed to a single database server, then routed to the correct server, this double-handling of database statements negatively impacts system performance. As the number of database servers grows, the likelihood that the enlisted bootstrap server can directly process the database statement goes down, which leads to additional overhead. In addition, providing a single bootstrap database server that routes all requests to the other database servers presents a single point of failure in the bootstrap database server. Should the bootstrap database server 230 fail, the entire partitioned database system 200 would fail. The combination of high overhead and single-point failure create a need for a new and improved system for accessing a partitioned database.
Referring now to
The goal of the preferred embodiments is to allow the database client to directly route database statements in a transaction to the correct database server, instead of having all database statements go through a single database server that has been enlisted for the transaction. The database client 126 determines which database server should process the transaction, then sends statements in the transaction directly to the correct database server. This may be done in different ways, as represented by the three illustrative embodiments described herein.
At this point the steps in method 600 in
There are different ways for the database client to determine the correct database server for the first statement of the transaction in step 510 of
One specific implementation of method 500 in
In method 700 shown in
Referring now to
Method 900 begins by the database client opening connections to all database servers (step 910). The database client sends the first statement of a transaction to one of the bootstrap database servers (step 920). If the bootstrap database server that received the first statement is the correct database server for this first statement (step 930=YES), the bootstrap database server executes the statement (step 940), and the result is returned on the connection between the bootstrap database server and the database client (step 950). If the bootstrap database server that received the first statement is not the correct database server for this statement (step 930=NO), the bootstrap database server sends the statement to the correct database server via direct connection between the two (step 960). The correct database server then executes the statement (step 970), and returns the result to the database client on the connection between the correct database server and the database client (step 980). The database client then sends (or routes) all subsequent statements in the transaction directly to the correct database server for the transaction (step 990). At this point, the steps of method 600 in
The embodiments disclosed herein assume that a transaction only accesses data in a single database partition. This assumption is valid for most commercial partitioned database systems. While a system administrator may want to perform some queries or statements that access multiple database partitions, or may want to include statements to multiple database partitions in the same transaction, these types of operations would likely be for troubleshooting or system administration only. The preferred embodiments provide a way to streamline the processing of transactions that are typically repeated a large number of times on data within a single database partition, thereby providing a significant increase in system performance.
Note that the term “database statement” is used herein to denote any type of statement that is capable of accessing a database, including SQL statements and queries. A database statement as used herein is one specific type of database request that may be processed in accordance with the preferred embodiments.
One skilled in the art will appreciate that many variations are possible within the scope of the present invention. Thus, while the invention has been particularly shown and described with reference to preferred embodiments thereof, it will be understood by those skilled in the art that these and other changes in form and details may be made therein without departing from the spirit and scope of the invention.