Database cache system

A database query system is provided. The database cache system includes: a network library which processes an access request issued by the online game server by using an input output completion port (IOCP); at least one database connection module which provides a connector for reading data from the database or recording data to the database; a database cache which stores data read from the database by the database connection module; and at least one cache buffer which is allotted to an IOCP worker thread corresponding to a database query request issued by the online game server and stores data read from the database, which is to be transmitted to the online game server.

CROSS-REFERENCE TO RELATED PATENT APPLICATION

This application claims the benefit of Korean Patent Application No. 10-2004-0108154, filed on Dec. 17, 2004, in the Korean Intellectual Property Office, the disclosure of which is incorporated herein in its entirety by reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a database cache system, and more particularly, to a database cache system that helps an online game server to access a database.

2. Description of the Related Art

In the case of an online game in which several thousands or tens of thousands of users can participate at the same time, the two most important factors that determine the cost effectiveness and the quality of services of an online game server are how effectively the online game server can operate and the lag of responses to users' queries. Dozens or several hundreds of queries are generally made every second by users regarding how they will play an online game and what are the rules of the online game. However, databases are generally not capable of keeping up with such a breakneck speed of generating queries. Therefore, once databases lag behind in dealing with queries made by users, they also lag behind in timely responding to the queries, a phenomenon which is called query lag. The query lag, which may considerably deteriorates the quality of services, can be reduced to some extent by separating a database from an online game server, in which case, however, additional service expenses are undesirably incurred.

SUMMARY OF THE INVENTION

The present invention provides a database cache system that guarantees a high efficiency and a high reliability of a database for online games by maximizing a server's efficiency of using the database.

According to an aspect of the present invention, there is provided a database cache system which is located between an online game server and a database, supports a non-blocking query processing approach, and minimizes query compilations, transaction processing, and physical disc accesses. The database cache system includes: a network library which processes an access request issued by the online game server by using an input output completion port (IOCP); at least one database connection module which provides a connector for reading data from the database or recording data to the database; a database cache which stores data read from the database by the database connection module; and at least one cache buffer which is allotted to an IOCP worker thread corresponding to a database query request issued by the online game server and stores data read from the database, which is to be transmitted to the online game server.

Accordingly, it is possible to reduce database development costs and guarantee an efficient use of databases. In addition, it is possible to improve the quality of online games by reducing online game service expenses and minimizing query lag. Moreover, it is possible to guarantee high productivity in terms of the development and management of databases.

DETAILED DESCRIPTION OF THE INVENTION

Database middleware, i.e., a database interface between a database and a user, has been used in various fields for communication, Internet service, and financial applications. Accordingly, much research has been conducted on optimizing database modules for specific services or modules for general services. One of the major purposes of developing database middleware is to respond to users' queries as quickly as possible, since a system comprised of a database, a user access module, and database middleware has a potential for overcoming the limits of a conventional information system.

FIG. 1is a diagram illustrating a basic concept of a database cache system for an online game. Referring toFIG. 1, game service expenses and the quality of game services are dependent on the performance of an online game server100. Users may make dozens or several hundreds of queries every second to a database110while playing an online game. The response speed of the database110considerably affects the performance of the online game server100. Since the database110deals with the queries in a blocking state, threads of the online game server100have no option but to be in standby until the online game server100respond to the queries, which is highly inefficient. In addition, query compilations, transaction processes, and physical disc accesses may increase the inefficiency of an entire query processing operation by increasing the amount of time required by the database110to respond to the queries.

Referring toFIG. 1, a database cache system120, which is located between the online game server100and the database110, helps the database110to deal with the queries made thereto in a non-blocking state and minimizes the numbers of query compilations, transaction processes, and physical disc accesses. Thus, the inefficiency of the entire query processing operation decreases, and the performance of the online game server100considerably improves.

FIG. 2is a block diagram of a database cache system120according to an exemplary embodiment of the present invention. Referring toFIG. 2, the database cache system120is located between a plurality of online game servers100and a plurality of databases110(MYSQL, MSSQL, and Oracle). When each of the online game servers100issues an access request to the database cache system120using Transmission Control Protocol/Internet Protocol (TCP/IP), the database cache system120processes the access request issued by each of the online game servers100using input output completion port (IOCP) technology. In addition, the database cache system120includes a connection module for connecting the database cache system120to all of the databases110(MYSQL, MSSQL, and Oracle) and thus can maintain its connection to the databases110(MYSQL, MSSQL, and Oracle). In other words, the online game servers100can easily use the databases110(MYSQL, MSSQL, and Oracle) via the database cache system120and can improve the speed of responding to a user by minimizing the number of times it needs to access the databases110(MYSQL, MSSQL, and Oracle) while processing the user's queries.

Referring toFIG. 2, the database cache system120includes an IOCP network library210, a plurality of cache buffers220, a plurality of database connectors230, and a database cache240.

The IOCP network library210is a module for handling queries made by the online game server100connected to the database cache system200. Therefore, the stability and efficiency of the IOCP network library210are emphasized.

The cache buffers220are modules for helping database query requests issued by the online game servers100to be quickly processed. The cache buffers220can minimize the allocation, removal, and use of memories. The database query requests issued by the online game servers100are processed by using the cache buffers220allotted to the respective IOCP worker threads. The cache buffers220are recyclable and thus can minimize the inefficiency of allotting a memory to the online game servers100or removing the allotted memory whenever the online game servers100issue database query requests.

The database connectors230are modules for connecting the database cache system120to the databases110(MYSQL, MSSQL, and Oracle) and include a number of ports corresponding to the number of databases110. The online game servers100can use any of the databases110(MYSQL, MMSQL, and Oracle) simply by accessing the database cache system120, regardless of the types of the databases110(MYSQL, MMSQL, and Oracle). Since the database connectors230enable the online game servers100to use different types of databases, the applicability and expendability of the database cache system120can be enhanced.

The database cache240is a module for managing data and is an essential part of the database cache system120. The database cache system120may fetch as much information as possible from the database cache240via the cache buffers220and may additionally read data from the databases110(MYSQL, MMSQL, and Oracle) only when the information fetched from the database cache240is insufficient to process a user's query. Alternatively, the cache database system120may fetch all information necessary to process a user's query from the databases110(MYSQL, MMSQL, and Oracle) and then may not access the databases110(MYSQL, MMSQL, and Oracle) afterwards for the purpose of referencing data stored in the databases110(MYSQL, MMSQL, and Oracle).

FIG. 3is a block diagram of a database cache system120according to an exemplary embodiment of the present invention. InFIGS. 2 and 3, like reference numerals represent like elements, and thus their detailed descriptions will be skipped.

Referring toFIG. 3, the database cache system120includes an IOCP network library210, a gateway library310, a database cache library320, and a database library350.

The gateway library310receives a database query request issued by each of the online game servers100and transmits the received request to the database cache library320. The gateway library310includes a gateway main312, a TCP reception socket314, and a TCP session socket316. A developer of the gate library310may develop additional modules for the functional expansion of the gateway library310.

The database cache library320is an essential part of the database cache system120. The database cache library320includes a cache client322with a cache buffer220installed therein, a cache client manager324, a cache table manager326, a cache table database328, a cache column database340, and a database cache226. The cache table manager326, the cache table database328, and the cache column database340are modules for managing data under the control of the database cache226. The cache client322includes the cache buffer220for quickly processing a query request and determines whether a response to the query request is to be transmitted to the databases110or to the database cache226. The cache client manager324manages the cache client322. The cache table manager326manages the cache table database328. The cache table database328includes data recorded in a variety of tables related to running online games, authenticating online game users, and imposing online game fees, such as a login table, a fee imposition table, a game character table, a game item table, a search table, and a game guild table.

FIGS. 4A through 4Dare diagrams illustrating the standardization of queries ‘SELECT’, ‘UPDATE’, ‘INSERT’, and ‘DELETE’ for minimizing query compilations. The queries ‘SELECT’, ‘UPDATE’, ‘INSERT’, and ‘DELETE’ may each contain some of the following pieces of query information: query type information Type; query table information TableName; query command information Command; and query search information Search. The queries ‘SELECT’ and ‘UPDATE’ include all of the query type information Type, the query table information TableName, the query command information Command, and the query search information Search. The query ‘INSERT’ includes the query type information Type, the query table information TableName, and the query command information Command. The query ‘DELETE’ includes the query type information Type, the query table information TableName, and the query search information Search. The online game servers100divide the queries ‘SELECT’, ‘UPDATE’, ‘INSERT’, and ‘DELETE’ in advance into their respective sets of query information and issue data query requests to the database cache system120with reference to the query information constituting each of the queries ‘SELECT’, ‘UPDATE’, ‘INSERT’, and ‘DELETE’, thereby minimizing the query compilation costs. In addition, it is possible to easily generate an SQL query that can be executed in the databases110by referencing the query information constituting each of the queries ‘SELECT’, ‘UPDATE’, ‘INSERT’, and ‘DELETE’.

FIG. 5is a diagram illustrating a method of loading data in advance necessary to determine the data loading characteristics of an online game server100. Referring toFIG. 5, an intellectual method in which, when a user logs on to the online game server100, fee information and login information are read to prepare for a request issued by the user. Information needed by the online server100after the user selects a game character, such as game character information, game item information, game quest information, and game guild information, is also read in advance so that requests issued by the user after selecting the game character can be efficiently handled. This type of data loading method is exemplary, and thus, it is possible to develop an appropriate data loading method for an online game using the database cache system120. Therefore, the database cache system120can provide an efficient and general way of enhancing the speed of responding to the user.

FIG. 6is a diagram illustrating simulation results for the analysis of the performance of a database cache system according to an exemplary embodiment of the present invention. Referring toFIG. 6, test results obtained when loading all data using a database MSSQL with the aid of the database cache system120were compared with test results obtained when loading all data using a database MSSQL without the aid of the database cache system120. The efficiency of processing a query request is third times higher when using the database cache system120than when not using the database cache system120, and the amount of time required to process a query request when using the database cache system120is about one third of the amount of time required to process a query request when not using the database cache system120. In addition, a method of loading data whenever it is necessary was adopted, in which case, the efficiency of processing a query request increased by about 38%. It is expected to further improve the efficiency of processing a query request by using the data loading method as illustrated inFIG. 5. A module for generating a random query request, which is included in a library of the database cache system120, was used for testing the database cache system120.

FIG. 7is a diagram illustrating a simulation environment in which the performance of a database cache system120according to an exemplary embodiment of the present invention is tested. Referring toFIG. 7, assuming that a database110operates properly, it is determined whether results obtained when accessing with the aid of the database cache system120are identical to results obtained when accessing the database110without the aid of the database cache system120. If the results obtained when accessing the database110with the aid of the database cache system120are identical to the results obtained when accessing the database110without the aid of the database cache system120, the database cache system120operates properly.

The database cache system120can ensure the integrity of database by accessing existing databases from time to time and has already been proved to be stable through various stability tests. The database cache system120processes most of a plurality of query requests that it receives on a physical memory level, thus removing unnecessary accesses to a physical disc. In addition, the database cache system120can ensure a high efficiency by minimizing memory allocations or removals.

Moreover, the database cache system120can reuse data fetched from databases. In the case of an online game, data cannot be reused and thus needs to be fetched from the databases whenever a user issues a query request or a user's game character takes some action, which is inefficient. However, the database cache system120can prevent data from being repeatedly fetched from the databases by reusing data fetched from the databases with the aid of the database cache240installed therein.

Furthermore, the database cache system120determines how an online game server loads data and thus reads data necessary to handle a query request issued to the online server in advance in the database cache240. For example, the database cache system120fetches all information necessary to authenticate a user, such as login information and fee information, from the databases to the database cache240when the user logs on thereto and thus can quickly process subsequent operations. In addition, when the user selects a predetermined game character, the database cache system120can fetch information regarding the game character selected by the user from the databases and thus can enable an online game to be run without the need to further reference the databases.

The present invention can be realized as computer-readable code written on a computer-readable recording medium. The computer-readable recording medium may be any type of recording device in which data is stored in a computer-readable manner. Examples of the computer-readable recording medium include a ROM, a RAM, a CD-ROM, a magnetic tape, a floppy disc, an optical data storage, and a carrier wave (e.g., data transmission through the Internet). The computer-readable recording medium can be distributed over a plurality of computer systems connected to a network so that a computer-readable code is written thereto and executed therefrom in a decentralized manner. Functional programs, code, and code segments needed for realizing the present invention can be easily deduced by one of ordinary skill in the art.

As described above, it is possible to reduce database development costs and efficiently use databases by applying the database cache system according to the present invention to the development of a large-scale online game. Therefore, it is possible to improve the quality of an online game by reducing game service charges and response delays. In addition, since the database cache system according to the present invention allows an online game server to access any type of database, it is possible to further reduce database development and management costs and shorten the period of time taken to develop databases.