CN104572974A - Service request processing method and device - Google Patents

Service request processing method and device Download PDF

Info

Publication number
CN104572974A
CN104572974A CN201410854779.3A CN201410854779A CN104572974A CN 104572974 A CN104572974 A CN 104572974A CN 201410854779 A CN201410854779 A CN 201410854779A CN 104572974 A CN104572974 A CN 104572974A
Authority
CN
China
Prior art keywords
connection
database
service request
idle
application
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201410854779.3A
Other languages
Chinese (zh)
Other versions
CN104572974B (en
Inventor
朱超
陈非
王超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201410854779.3A priority Critical patent/CN104572974B/en
Publication of CN104572974A publication Critical patent/CN104572974A/en
Priority to PCT/CN2015/095545 priority patent/WO2016107340A1/en
Application granted granted Critical
Publication of CN104572974B publication Critical patent/CN104572974B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems
    • G06F16/252Integrating or interfacing systems involving database management systems between a Database Management System and a front-end application

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention provides a service request processing method and device. The service request processing method comprises intercepting a service request sent to a database from an application; determining whether the idle connection with the database is formed or not in a connection pool; saving the service request if not and continuing to determine whether the idle connection with the database is formed or not in the connection pool according to a set rule until the idle connection is produced in the connection pool; selecting the produced idle connection and sending the service request to the database through the selected idle connection. According to the service request processing method and device, the service request only needs to be sent at a time and accordingly the service request can be processed through the database, the reduction of the use experience due to the fact that a user receives a message that the service request fails can be avoided, the condition that the service request is sent repeatedly can be avoided, and accordingly the operation burden of a terminal and a network of the application can be reduced and the use experience of the user can be improved.

Description

Service request processing method and device
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a method and an apparatus for processing a service request.
Background
At present, a relational database system and a non-distributed database system mainly adopt an architecture in which an application is directly connected with a database. When the database system with the architecture processes the service request, the application directly sends the service request to the database, and the database returns a corresponding response result to the application.
By adopting the existing service request processing scheme, when the number of service requests currently processed by the database reaches the upper limit supportable by the database (the number of connections of the database reaches the upper limit), and when a new application sends a service request to the database, the database receives the service request and then returns a message of service request failure to the application because no idle connection can be provided for the application. And after receiving the message of failed request, the application will send the service request to the database again, and if the database still has no idle connection, the application will return the message of failed service request to the application again. The application and the database repeat the above operations until an idle connection appears in the database and is provided for the application to perform service request processing.
Therefore, in the existing service request processing scheme, when the number of currently processed service requests of the database reaches the upper limit supportable by the database, and when a new application sends a service request to the database, on one hand, the database directly returns a service request failure message to the application, so that the use experience of a user is influenced. Meanwhile, when the application is used, the service request needs to be repeatedly sent until the request is successful, and the operation burden of the terminal and the network where the application is located can be increased while the use experience of the user is influenced. On the other hand, the database is required to repeatedly determine whether there is an idle connection and return a service request failure message to the application, which also increases the operation burden of the database.
Disclosure of Invention
In view of the above-mentioned existing problems, the present invention has been made to provide a service request processing method and apparatus that overcomes or at least partially solves the above-mentioned problems.
According to an aspect of the present invention, a method for processing a service request is provided, including: intercepting a service request sent by an application to a database; judging whether idle connection with the database exists in a connection pool or not; if not, storing the service request, and continuously judging whether the idle connection with the database exists in the connection pool according to a set rule until the idle connection appears in the connection pool; selecting the idle connection that appears, and sending the service request to the database using the selected idle connection.
According to another aspect of the present invention, there is provided a service request processing apparatus, including: the first interception module is used for intercepting a service request sent by the application device to the database device; the judging module is used for judging whether idle connection with the database device exists in the connection pool or not; a first executing module, configured to store the service request if the determination result of the determining module is that no idle connection exists, and continuously determine whether an idle connection with the database device exists in the connection pool according to a set rule until the idle connection occurs in the connection pool; and the sending module is used for selecting the appeared idle connection and sending the service request to the database device by using the selected idle connection.
The invention intercepts the service request sent by the application to the database in the database system, especially in a non-distributed database system such as a relational database system, selects the idle connection between the database and the connection pool to send the service request, when the idle connection exists in the connection pool, the service request can be directly sent to the database through the idle connection, when the idle connection does not exist in the connection pool, the service request of the application is still normally accepted, when the idle connection occurs, the service request is sent to the database to be processed, and no error or failure message is returned to the application. Therefore, the application can ensure that the service request is processed by the database only by sending the service request once, so that the reduction of use experience caused by the fact that the user receives the message of service request failure can be avoided, and the repeated sending of the service request by the application can be avoided, thereby reducing the operation burden of the terminal and the network where the application is located and improving the use experience of the user. In addition, in the service information processing scheme disclosed by the invention, the service request is sent to the database for processing only when the database has idle connection, and the database does not need to repeatedly judge whether the idle connection exists or not and further does not need to return a message of service request failure to the application, so that the operation burden of the database can be effectively reduced.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a schematic flowchart illustrating steps of a service request processing method according to a first embodiment of the present invention;
fig. 2 is a schematic flowchart illustrating steps of a service request processing method according to a second embodiment of the present invention;
fig. 3 is a schematic flowchart illustrating steps of a service request processing method according to a third embodiment of the present invention;
fig. 4 is a schematic structural diagram of a service request processing apparatus according to a fourth embodiment of the present invention;
fig. 5 is a schematic structural diagram of a service request processing apparatus according to a fifth embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Example one
Referring to fig. 1, a schematic step flow diagram of a service request processing method according to a first embodiment of the present invention is shown.
The service request processing method of the embodiment comprises the following steps:
step S102: and intercepting a service request sent by an application to the database.
The service request is any service request that the application can send to the database, for example: a request for acquiring a certain user number, a request for acquiring a package remaining flow value and the like.
It should be noted that, in this embodiment, the middleware provided between the application and the database may intercept the service request sent by the application to the database, or may intercept the service request by any other suitable device.
Step S104: and judging whether idle connection with the database exists in the connection pool or not.
And establishing corresponding connection for the database in the connection pool according to the supportable connection information of the database. And when the connection with the database in the connection pool is not occupied by the service request, the current state of the connection is idle. After the service request is intercepted, a free connection with the database is selected from the connection pool to send the service request to the database.
Step S106: if the connection pool has no idle connection with the database, the service request is stored, and whether the idle connection with the database exists in the connection pool or not is continuously judged according to a set rule until the idle connection occurs in the connection pool.
It should be noted that the service request may be stored in the processing queue, may also be stored in a preset buffer, or may adopt any other appropriate storage form.
In the actual implementation process, a person skilled in the art can set a specific rule for continuously judging whether an idle connection exists between the connection pool and the database according to actual requirements. For example: and polling the state of each connection between the database and the connection pool at set time intervals to judge whether idle connection exists.
Step S108: the occurring idle connection is selected and the service request is sent to the database using the selected idle connection.
And selecting an idle connection to send the service request to a database, wherein the database can ensure that the service request is processed due to the existence of the idle connection.
By the service request processing method provided by the embodiment, in a database system, particularly a non-distributed database system such as a relational database system, a service request sent by an application to a database is intercepted, an idle connection between the database and the application is selected from a connection pool and sent to the service request, when the idle connection exists in the connection pool, the service request can be directly sent to the database through the idle connection, when the idle connection does not exist, the service request of the application is still normally received, and when the idle connection exists, the service request is sent to the database for processing, and an error or failure message is not returned to the application. Therefore, the application can ensure that the service request is processed by the database only by sending the service request once, so that the reduction of use experience caused by the fact that the user receives the message of service request failure can be avoided, and the repeated sending of the service request by the application can be avoided, thereby reducing the operation burden of the terminal and the network where the application is located and improving the use experience of the user. In addition, the service request is sent to the database for processing only when the database has idle connection, and the database does not need to repeatedly judge whether the database has idle connection or not and return a service request failure message to the application, so that the operation burden of the database can be effectively reduced.
Example two
Referring to fig. 2, a schematic step flow diagram of a service request processing method according to a second embodiment of the present invention is shown.
The service request processing method of the embodiment comprises the following steps:
step S202: the middleware intercepts service requests sent by the application to the database.
In this embodiment, the middleware intercepts a service request sent by an application to a database, and the middleware is disposed between the application and the database. The term "between" is not meant to be in a physical sense, but is referred to as "middleware provided between an application and a database" because the middleware intercepts data transmitted between the application and the database.
It should be noted that the application, the middleware, and the database may be installed on the same device, or may be installed on one device, or may be installed on different devices in a combined manner. One middleware may be provided between the plurality of applications and one database, that is, one middleware is provided for each database, and one middleware may be provided between the plurality of applications and the plurality of databases, that is, one middleware is provided for the plurality of databases.
The service request is any service request that the application can send to the database, for example: a request for acquiring a certain user number, a request for acquiring a package remaining flow value and the like.
Step S204: the middleware judges whether free connection between the middleware and the database exists in the connection pool of the middleware, if so, the step S206 is executed, and if not, the step S208 is executed.
The connection pool of the middleware is provided with connections between the middleware and the database, and the number of the connections is the same as the number of the connections which can be supported by the database. In addition, when a plurality of databases exist, the same data is stored in each database.
Step S206: if the middleware judges that idle connections between the middleware and the database exist in the connection pool of the middleware, one idle connection is selected, and then step S210 is executed.
The specific selection method for selecting one idle connection is not specifically limited in this embodiment, and when there are multiple idle connections, the middleware may randomly select one idle connection, may also select one connection with the longest idle time according to the length of the idle time of the connection, and may also select according to other selection methods.
Step S208: if the middleware judges that the idle connection between the middleware and the database does not exist in the self connection pool, the service request is stored, whether the idle connection between the middleware and the database exists in the connection pool is continuously judged according to a set rule until the idle connection occurs in the connection pool, the occurring idle connection is selected, and then step S210 is executed.
It should be noted that the service request may be stored in the processing queue, may also be stored in a preset buffer, or may adopt any other appropriate storage form.
In the actual implementation process, a person skilled in the art can set a specific rule for continuously judging whether the idle connection between the middleware and the database exists in the connection pool according to the actual requirement. For example: and polling the state of each connection between the database and the connection pool at set time intervals to judge whether idle connection exists.
Step S210: the middleware sends the service request to the database using the selected idle connection.
The middleware selects the idle connection to send the service request to the database, and the database can ensure that the service request is processed due to the existence of the idle connection.
Step S212: the middleware intercepts a response result of the service request, which is returned to the application by the database through the selected idle connection, and sends the intercepted response result to the application sending the service request.
After the database processes the service request, the response result is returned to the application through the connection sending the service request, and at the moment, the middleware intercepts the response result returned by the database and responding to the service request.
How to determine the application corresponding to the response result by the middleware can be set by those skilled in the art according to actual situations, for example: the service request sent to the database by the middleware may carry identification information of an application sending the service request, when the database returns a response result, the response result also carries identification information of the application, and when the middleware intercepts the response result, the corresponding application may be determined according to the identification information of the application in the response result.
In the related art, a non-distributed database system, such as a relational database system, mainly adopts a structure in which an application is directly connected with a database, so that the database cannot respond to service requests exceeding the upper limit of the connection number of the database. The service request processing method provided by the embodiment is characterized in that a middleware between an application and a database is arranged in a database system, particularly a non-distributed database system such as a relational database system, the middleware intercepts a service request sent by the application to the database, selects an idle connection between the middleware and the database from a connection pool of the middleware and sends the idle connection to the service request, and can directly send the service request to the database through the idle connection when the idle connection exists in the middleware, normally accept the service request of the application when the idle connection does not exist in the middleware, and send the service request to the database for processing when the idle connection exists, and an error or failure message cannot be returned to the application. Therefore, the application can ensure that the service request is processed by the database only by sending the service request once, so that the reduction of use experience caused by the fact that the user receives the message of service request failure can be avoided, and the repeated sending of the service request by the application can be avoided, thereby reducing the operation burden of the terminal and the network where the application is located and improving the use experience of the user. In addition, the middleware only sends the service request to the database for processing when the database has idle connection, and the database does not need to repeatedly judge whether the database has idle connection or not and return a service request failure message to the application, so that the operation burden of the database can be effectively reduced.
EXAMPLE III
Referring to fig. 3, a schematic step flow diagram of a service processing method according to a third embodiment of the present invention is shown.
The service processing method of the embodiment specifically includes the following steps:
step S302: and the middleware generates a connection pool according to the connection information which can be supported by the database.
Wherein the middleware is disposed between the application and the database. The connection pool is used for managing the supportable connections of the database.
An alternative generation method for the middleware to generate the connection pool according to the connection information supportable by the database is as follows: the middleware determines a connection upper limit supportable by the database according to the information of the connection supportable by the database; the same number of connections is set in the connection pool. For example: the database can support an upper limit of 50 connections, and the middleware then establishes 50 connections in the connection pool.
The service processing method in this embodiment may be applied to various database systems, and preferably, the service request processing method in this embodiment is applied to a non-distributed database system, and more preferably, to a relational database system. When the current non-distributed database system, such as a relational database system, processes service requests, the application directly sends the service requests to the database, and the database directly responds or rejects the service requests sent by the application. Therefore, the service request processing method in this embodiment is applied to a relational database, a middleware is arranged between the application and the database, the middleware caches the service requests that cannot be processed by the database immediately, and the service requests are sent to the database when the database has an idle connection and can process the service requests, without returning an error or failure message to the application, so that the problem of influencing user experience can be effectively solved.
Step S304: the middleware intercepts the service request sent by the application to the database and returns the message that the service request is accepted to the application.
It should be noted that the returning of the message that the service request is accepted to the application by the middleware is an optional operation, and in an actual implementation process, the middleware may also be configured to intercept the service request sent by the application to the database, but not return the message that the service request is accepted to the application. By returning the message that the service request is accepted to the application, the application can confirm that the service request is successfully accepted, the application is prevented from continuously sending inquiry messages to a database or a middleware, and the operation burden of the application and the information interaction burden of a network are reduced.
Step S306: the middleware judges whether free connection between the middleware and the database exists in the connection pool of the middleware, if so, the step S308 is executed, and if not, the step S310 is executed.
A preferred way for the middleware to determine whether there are free connections between the connection pool and the database is as follows:
the middleware judges whether idle connection exists between the middleware and the database in the connection pool according to the connection state of each connection in the connection pool; when connection with an idle connection state exists, determining that the idle connection exists between the connection pool and the database; and when the states of all the connections are busy, determining that no free connection exists between the connection pool and the database.
Another way for the middleware to determine whether there is a free connection between the connection pool and the database is as follows: the middleware can determine that the idle connection with the database exists in the connection pool when judging that the response result returned by the database is intercepted.
Step S308: if the middleware determines that there is an idle connection in the connection pool, it selects an idle connection, and then performs step S312.
Step S310: if the middleware judges that no idle connection exists in the connection pool, the middleware stores the service request and returns to the step S306.
For example, the middleware stores the service request into a queue to be processed, or stores the service request into a preset cache.
That is, if the middleware determines that there is no idle connection in the connection pool, the middleware returns to step S306 to continuously determine whether there is an idle connection between the connection pool and the database according to the set rule until an idle connection occurs in the connection pool, and selects an idle connection that occurs.
Preferably, the setting rule may be set to include, but is not limited to, the following rules:
in the first rule, the middleware judges whether idle connection exists between the connection pool and the database according to a set time interval. The setting of the time interval can be set by a person skilled in the art according to actual requirements, for example: it is arranged to poll the connections in the connection pool again 1 second after polling all connections between the connection pool and the database.
In the second rule, the middleware judges whether idle connection with the database exists in the connection pool in real time.
It should be noted that, in this step, it is determined whether there is a free connection between the connection pool and the database, and when a free connection occurs in the connection pool, any one of the preferred manners described in step S306 may be selected and used.
Step S312: the middleware changes the connection status of the selected idle connection from idle to busy and sends a service request to the database using the selected idle connection.
The middleware can efficiently and quickly judge the current state of each connection in the connection pool by changing the connection state of the selected idle connection into busy, thereby more effectively selecting the idle connection for the service request.
When the middleware uses the selected idle connection to send the service request to the database, the middleware sends the service request according to the position of the service request in the queue or the priority of the service request, specifically:
when the service requests are stored in the queue to be processed, the service requests are sequentially taken out from the queue to be processed, idle connections are distributed to the taken-out service requests, and the distributed idle connections are used for sending the service requests to the database.
When the service requests are stored in the preset cache, the service requests are sequentially taken out according to the priority of the service requests, idle connections are distributed to the taken-out service requests, and the distributed idle connections are used for sending the service requests to the database.
That is, if the service request saved in step S310 is located at the first position of the pending queue or has the highest priority in the preset buffer, the service request may be directly transmitted to the database when the idle connection is selected. If the service request is not located at the first position of the queue to be processed or is not the service request with the highest priority, waiting is needed until the service request located in front of the service request in the queue to be processed or the service request with the priority higher than the priority is sent to the database, and then the idle connection can not be selected to send the service request to the database.
Step S314: and the middleware intercepts a response result of the service request, which is returned to the application by the database through the selected idle connection.
The database receives the service request, and after the service request is processed, a response result to the service request is returned to the application through the idle connection selected by the middleware. At this point, the middleware intercepts the response result.
Step S316: and the middleware changes the connection state of the connection returning the response result from busy to idle according to the intercepted response result, and simultaneously sends the intercepted response result to the application sending the service request.
In this step, when intercepting a response result returned by a certain connection, the middleware changes the connection state of the connection from busy to idle, so that the middleware can allocate connection for the service request which is not processed yet, and the utilization rate of the connection is improved.
Meanwhile, the middleware sends the intercepted response result to the application sending the service request.
It should be noted that the modification of the connection state and the sending of the response result to the application may be performed simultaneously and concurrently, or may be performed in any order.
Through the service request processing method provided by the embodiment, in a database system, particularly a non-distributed database system such as a relational database system, a middleware between an application and a database is arranged, the middleware intercepts a service request sent by the application to the database, selects an idle connection between the middleware and the database from a connection pool and sends the idle connection to the service request, when the idle connection exists in the connection pool, the service request can be directly sent to the database through the idle connection, when the idle connection does not exist in the connection pool, the service request of the application is still normally received, and when the idle connection exists, the service request is sent to the database for processing, and an error message or a failure message is not returned to the application. Therefore, the application can ensure that the service request is processed by the database only by sending the service request once, so that the reduction of use experience caused by the fact that the user receives the message of service request failure can be avoided, and the repeated sending of the service request by the application can be avoided, thereby reducing the operation burden of the terminal and the network where the application is located and improving the use experience of the user. In addition, the middleware only sends the service request to the database for processing when the database has idle connection, and the database does not need to repeatedly judge whether the idle connection exists in the connection pool or return a service request failure message to the application, so that the workload of the database can be effectively reduced.
Example four
Referring to fig. 4, a schematic structural diagram of a service request processing apparatus according to a fourth embodiment of the present invention is shown.
The service request processing apparatus of the present embodiment may be disposed between the application apparatus and the database apparatus, and the service request processing apparatus includes: a first intercepting module 402, configured to intercept a service request sent by an application device to a database device; a judging module 404, configured to judge whether there is an idle connection with the database device in the connection pool; a first executing module 406, configured to store the service request if the determination result of the determining module is that there is no idle connection, and continuously determine whether there is an idle connection between the connection pool and the database device according to a set rule until there is an idle connection in the connection pool; a sending module 408, configured to select an idle connection that occurs and send the service request to the database apparatus using the selected idle connection. It should be noted that the service request processing device, the application device, and the database device may be disposed in the same device, or may be disposed in different devices. This is not particularly limited in this embodiment.
Through the service request processing device provided by the embodiment, in a database system, particularly a non-distributed database system such as a relational database system, a service request sent by an application device to the database device can be intercepted, an idle connection between the application device and the database device is selected from a connection pool and sent to the service request, when the idle connection exists, the service request can be directly sent to the database device through the idle connection, when the idle connection does not exist, the service request of the application is still normally received, and when the idle connection exists, the service request is sent to the database for processing without returning an error or failure message to the application. Therefore, the application device can ensure that the service request is processed by the database only by sending the service request once, so that the reduction of use experience caused by the fact that the user receives the message of service request failure can be avoided, and the repeated sending of the service request by the application can be avoided, thereby reducing the operation burden of the terminal and the network where the application is located and improving the use experience of the user. In addition, the service request processing device of the embodiment sends the service request to the database device for processing only when the database device has the idle connection, and the database device does not need to repeatedly judge whether the idle connection exists or not and further does not need to return a message of service request failure to the application, so that the operation burden of the database device can be effectively reduced.
EXAMPLE five
Referring to fig. 5, a schematic structural diagram of a service request processing apparatus according to a fifth embodiment of the present invention is shown.
In this embodiment, the service request processing apparatus in the fourth embodiment is further optimized, and the optimized service request processing apparatus includes: a first intercepting module 502, configured to intercept a service request sent by an application device to a database device; a judging module 504, configured to judge whether there is an idle connection with the database device in the connection pool; a first executing module 506, configured to store the service request if the determination result of the determining module is that there is no idle connection, and continuously determine whether there is an idle connection between the connection pool and the database device according to a set rule until an idle connection occurs in the connection pool, and select an idle connection that occurs; a sending module 508, configured to select an idle connection that occurs, and send the service request to the database apparatus using the selected idle connection.
Preferably, the service request processing apparatus of this embodiment further includes: a second executing module 510, configured to select an idle connection if the determination result of the determining module 504 is that there is an idle connection with the database in the connection pool, and send the service request to the database using the selected idle connection.
Preferably, the service request processing apparatus of this embodiment further includes: the second intercepting module 512 is configured to intercept a response result, returned to the application device by the database device through the selected idle connection, to the service request, and send the intercepted response result to the application device that sends the service request.
Preferably, the service request processing apparatus of this embodiment further includes: a connection pool generating module 514, configured to generate a connection pool according to connection information supportable by the database device before the first intercepting module 502 intercepts the service request sent by the application device to the database device, where the connection pool is used to manage the connection supportable by the database device.
Preferably, the first intercepting module 502 is configured to intercept a service request sent by the application device to the database device, and return a message that the service request is accepted to the application device.
Preferably, the determining module 504 includes: a state judgment module 5042, configured to judge, according to a connection state of each connection in a connection pool of the middleware device itself, whether there is an idle connection between the middleware device and the database device in the connection pool of the middleware device itself; a determining module 5044, configured to determine that there is an idle connection with the database apparatus in the connection pool when the determination result of the state determining module 5042 is that there is a connection whose connection state is idle; when the determination result of the status determination module 5042 is that the statuses of all connections are busy, it is determined that there is no free connection with the database device in the connection pool.
Preferably, the sending module 508 is configured to change the connection status of the selected idle connection from idle to busy, and send a service request to the database apparatus using the selected idle connection; the service request message processing apparatus of this embodiment further includes: and a connection state changing module 516, configured to, after the second intercepting module 512 intercepts a response result to the service request, which is returned by the database device to the application device through the selected idle connection, change the connection state of the connection returning the response result from busy to idle according to the intercepted response result.
Preferably, when the first executing module 506 continuously determines whether there is an idle connection between the connection pool and the database device according to the set rule: and when the response result returned by the database device is judged to be intercepted, determining that the idle connection with the database device exists in the connection pool.
Preferably, when the first executing module 506 continuously determines whether there is an idle connection between the connection pool and the database device according to the set rule: judging whether idle connection exists between the connection pool and the database device or not according to a set time interval; or, judging whether idle connection exists between the connection pool and the database device in real time.
Preferably, when the first execution module 506 stores the service request, the service request is stored in the queue to be processed; or storing the service request into a preset cache.
Preferably, when the sending module 508 sends the service request to the database device using the selected idle connection: when the service requests are stored in the queue to be processed, the service requests are sequentially taken out from the queue to be processed, idle connections are distributed to the taken-out service requests, and the distributed idle connections are used for sending the service requests to the database device; and when the service requests are stored in the preset cache, the service requests are sequentially taken out according to the priority of the service requests, idle connections are distributed to the taken-out service requests, and the distributed idle connections are used for sending the service requests to the database device.
Preferably, the service request processing apparatus of the present embodiment is applied to a non-distributed database system.
Preferably, the service request processing apparatus of the present embodiment is applied to a relational database system.
Preferably, the service request processing apparatus of this embodiment is a middleware apparatus, the middleware apparatus is disposed between the application apparatus and the database, a connection pool of the middleware apparatus is disposed in the middleware apparatus, and when the middleware intercepts a service request sent by the application apparatus to the database apparatus, the middleware apparatus determines whether there is an idle connection between the middleware and the database apparatus in the connection pool of the middleware apparatus; and when judging that the idle connection between the middleware and the database device exists, selecting one idle connection, and sending the service request to the database by using the selected idle connection. And when judging that no idle connection exists between the middleware and the database device, storing the intercepted service request, continuously judging whether the idle connection exists between the middleware and the database device in a self connection pool according to a set rule until the idle connection exists in the connection pool, selecting the appearing idle connection, and sending the service request to the database device by using the selected idle connection.
The service request processing apparatus in this embodiment is used to implement the corresponding service request processing methods in the foregoing first embodiment, second embodiment, and third embodiment, and has the beneficial effects of the corresponding method embodiments, which are not described herein again.
The service request processing scheme provided herein is not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with the teachings herein. The structure required to construct a system incorporating aspects of the present invention will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in a service request processing scheme according to embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" or "comprises" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.
The embodiment of the invention discloses A1 and a service request processing method, which comprises the following steps:
intercepting a service request sent by an application to a database;
judging whether idle connection with the database exists in a connection pool or not;
if not, storing the service request, and continuously judging whether the idle connection with the database exists in the connection pool according to a set rule until the idle connection appears in the connection pool;
selecting the idle connection that appears, and sending the service request to the database using the selected idle connection.
A2, the method according to A1, wherein the method further comprises:
and if the connection pool has idle connection with the database, selecting one idle connection, and sending the service request to the database by using the selected idle connection.
A3, the method according to A1, wherein the method further comprises:
intercepting a response result of the database to the service request, returned to the application through the selected idle connection, and sending the intercepted response result to the application sending the service request.
A4, the method according to A1, wherein before the step of intercepting a service request sent by an application to a database, the method further comprises:
and generating the connection pool according to the information of the connection which can be supported by the database, wherein the connection pool is used for managing the connection which can be supported by the database.
A5, the method according to A1, wherein the intercepting of the service request sent by the application to the database includes:
and intercepting the service request sent to the database by the application, and returning the message of receiving the service request to the application.
A6, the method according to A1, wherein the step of judging whether there is a free connection with the database in the connection pool comprises:
judging whether idle connection exists between the connection pool and the database or not according to the connection state of each connection in the connection pool;
when connection with an idle connection state exists, determining that the idle connection exists between the connection pool and the database; and when the states of all the connections are busy, determining that no free connection exists between the connection pool and the database.
A7, the method of A6, wherein the step of sending the service request to the database using the selected idle connection includes:
changing the connection state of the selected idle connection from idle to busy, and sending the service request to the database using the selected idle connection.
A8, the method according to A3, wherein after the step of intercepting the result of the response to the service request returned by the database to the application over the selected idle connection, the method further comprises:
and changing the connection state of the connection returning the response result from busy to idle according to the intercepted response result.
A9, the method according to A8, wherein the step of continuously judging whether a free connection exists between the connection pool and the database according to a set rule comprises:
and when the response result returned by the database is judged to be intercepted, determining that the idle connection between the connection pool and the database exists.
A10, the method according to A8, wherein the step of continuously judging whether a free connection exists between the connection pool and the database according to a set rule comprises:
judging whether idle connection exists between the connection pool and the database or not according to a set time interval;
or,
and judging whether idle connection with the database exists in the connection pool in real time.
A11, the method according to A2, wherein the step of saving the service request includes:
the service request is stored into a queue to be processed; or storing the service request into a preset cache.
A12, the method of A11, wherein the step of sending the service request to the database using the selected idle connection includes:
when the service requests are stored in a queue to be processed, the service requests are sequentially taken out from the queue to be processed, idle connections are distributed to the taken-out service requests, and the distributed idle connections are used for sending the service requests to the database;
when the service requests are stored in a preset cache, the service requests are sequentially taken out according to the priority of the service requests, idle connections are distributed to the taken-out service requests, and the service requests are sent to the database by using the distributed idle connections.
A13, the method according to A1, wherein the service request processing method is applied to a non-distributed database system.
A14, the method according to A1 or A13, wherein the service request processing method is applied to a relational database system.
The embodiment of the invention also discloses B15 and a service request processing device, wherein the service request processing device comprises:
the first interception module is used for intercepting a service request sent by the application device to the database device;
the judging module is used for judging whether idle connection with the database device exists in the connection pool or not;
a first executing module, configured to store the service request if the determination result of the determining module is that no idle connection exists, and continuously determine whether an idle connection with the database device exists in the connection pool according to a set rule until the idle connection occurs in the connection pool;
and the sending module is used for selecting the appeared idle connection and sending the service request to the database device by using the selected idle connection.
B16, the service request processing device according to B15, wherein the device further comprises:
and the second execution module is used for selecting an idle connection if the judgment result of the judgment module is that the idle connection with the database exists in the connection pool, and sending the service request to the database by using the selected idle connection.
B17, the service request processing device according to B15, wherein the device further comprises:
and the second intercepting module is used for intercepting a response result of the database device to the service request, returned to the application device through the selected idle connection, and sending the intercepted response result to the application device sending the service request.
B18, the service request processing device according to B15, wherein the device further comprises:
a connection pool generating module, configured to generate the connection pool according to connection information supportable by the database device before the first intercepting module intercepts a service request sent by an application device to the database device, where the connection pool is used to manage the connection supportable by the database device.
B19, the device for processing service request information according to B15, wherein the first intercepting module is configured to intercept a service request sent by the application device to the database device, and return a message that the service request is accepted to the application device.
B20, the device for processing service request according to B15, wherein the judging module comprises:
the state judgment module is used for judging whether idle connection with the database device exists in the connection pool or not according to the connection state of each connection in the connection pool;
a determining module, configured to determine that there is an idle connection with the database device in the connection pool when a determination result of the state determining module is that there is an idle connection in the connection state; and when the judgment result of the state judgment module is that all the connected states are busy, determining that no free connection exists between the connection pool and the database device.
B21, the device for processing service request according to B20, wherein the sending module is configured to change the connection status of the selected idle connection from idle to busy, and send the service request to the database device using the selected idle connection;
b22, the service request processing device according to B18, the service information processing device further comprises:
and the connection state changing module is used for changing the connection state of the connection returning the response result from busy to idle according to the intercepted response result after the second intercepting module intercepts the response result of the database device to the service request, which is returned to the application device through the selected idle connection.
B23, the device for processing service request according to B22, wherein when the executing module continuously determines whether there is an idle connection between the database device and the connection pool according to a set rule:
and when the response result returned by the database device is judged to be intercepted, determining that the idle connection with the database device exists in the connection pool.
B24, the device for processing service request according to B22, wherein when the executing module continuously determines whether there is an idle connection between the database device and the connection pool according to a set rule:
judging whether idle connection exists between the connection pool and the database device or not according to a set time interval;
or,
and judging whether idle connection with the database device exists in the connection pool in real time.
B25, the device for processing service requests according to B16, wherein the first execution module stores the service requests into a queue to be processed when the service requests are stored; or storing the service request into a preset cache.
B26, the service request processing device according to B25, wherein when the sending module sends the service request to the database device using the selected idle connection:
when the service requests are stored in a queue to be processed, the service requests are sequentially taken out from the queue to be processed, idle connections are distributed to the taken-out service requests, and the distributed idle connections are used for sending the service requests to the database device;
and when the service request is stored in a preset cache, sequentially taking out the service request according to the priority of the service request, allocating an idle connection to the taken-out service request, and sending the service request to the database device by using the allocated idle connection.
B27, the service request processing device according to B15, wherein the service information processing device is applied to a non-distributed database system.
B28, the service request processing device according to B15 or B27, wherein the service information processing device is applied to a relational database system.

Claims (10)

1. A service request processing method comprises the following steps:
intercepting a service request sent by an application to a database;
judging whether idle connection with the database exists in a connection pool or not;
if not, storing the service request, and continuously judging whether the idle connection with the database exists in the connection pool according to a set rule until the idle connection appears in the connection pool; and
selecting the idle connection that appears, and sending the service request to the database using the selected idle connection.
2. The method of claim 1, wherein the method further comprises:
and if the connection pool has idle connection with the database, selecting one idle connection, and sending the service request to the database by using the selected idle connection.
3. The method of claim 1, wherein the method further comprises:
intercepting a response result of the database to the service request, returned to the application through the selected idle connection, and sending the intercepted response result to the application sending the service request.
4. The method of claim 1, wherein prior to the step of intercepting a service request sent by an application to a database, the method further comprises:
and generating the connection pool according to the information of the connection which can be supported by the database, wherein the connection pool is used for managing the connection which can be supported by the database.
5. The method of claim 1, wherein intercepting the service request sent by the application to the database comprises:
and intercepting the service request sent to the database by the application, and returning the message of receiving the service request to the application.
6. The method of claim 1, wherein the determining whether there is a free connection with the database in the connection pool comprises:
judging whether idle connection exists between the connection pool and the database or not according to the connection state of each connection in the connection pool;
when connection with an idle connection state exists, determining that the idle connection exists between the connection pool and the database; and when the states of all the connections are busy, determining that no free connection exists between the connection pool and the database.
7. The method of claim 6, wherein the step of sending the service request to the database using the selected idle connection comprises:
changing the connection state of the selected idle connection from idle to busy, and sending the service request to the database using the selected idle connection.
8. The method of claim 3, wherein after the step of intercepting the result of the response to the service request returned by the database to the application over the selected idle connection, the method further comprises:
and changing the connection state of the connection returning the response result from busy to idle according to the intercepted response result.
9. The method of claim 8, wherein the step of continuously determining whether there is a free connection between the connection pool and the database according to a set rule comprises:
and when the response result returned by the database is judged to be intercepted, determining that the idle connection between the connection pool and the database exists.
10. A service request processing apparatus, the service request processing apparatus comprising:
the first interception module is used for intercepting a service request sent by the application device to the database device;
the judging module is used for judging whether idle connection with the database device exists in the connection pool or not;
a first executing module, configured to store the service request if the determination result of the determining module is that no idle connection exists, and continuously determine whether an idle connection with the database device exists in the connection pool according to a set rule until the idle connection occurs in the connection pool; and
and the sending module is used for selecting the appeared idle connection and sending the service request to the database device by using the selected idle connection.
CN201410854779.3A 2014-12-31 2014-12-31 service request processing method and device Expired - Fee Related CN104572974B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201410854779.3A CN104572974B (en) 2014-12-31 2014-12-31 service request processing method and device
PCT/CN2015/095545 WO2016107340A1 (en) 2014-12-31 2015-11-25 Service request processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410854779.3A CN104572974B (en) 2014-12-31 2014-12-31 service request processing method and device

Publications (2)

Publication Number Publication Date
CN104572974A true CN104572974A (en) 2015-04-29
CN104572974B CN104572974B (en) 2018-10-12

Family

ID=53089036

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410854779.3A Expired - Fee Related CN104572974B (en) 2014-12-31 2014-12-31 service request processing method and device

Country Status (2)

Country Link
CN (1) CN104572974B (en)
WO (1) WO2016107340A1 (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016107340A1 (en) * 2014-12-31 2016-07-07 北京奇虎科技有限公司 Service request processing method and device
CN106021313A (en) * 2016-05-05 2016-10-12 北京元心科技有限公司 Method and system for preventing repeated issue of command
CN106257456A (en) * 2016-07-08 2016-12-28 北京京东尚科信息技术有限公司 The method of data base's stability, Apparatus and system is improved under high concurrent request
CN106302421A (en) * 2016-08-08 2017-01-04 腾讯科技(深圳)有限公司 A kind of information intercepting processing method and device
CN106341447A (en) * 2016-08-12 2017-01-18 中国南方电网有限责任公司 Database service intelligent exchange method based on mobile terminal
CN108259559A (en) * 2017-12-06 2018-07-06 中国航空工业集团公司西安航空计算技术研究所 A kind of more session data transmission realizing methods based on udp protocol
CN109800067A (en) * 2018-12-15 2019-05-24 中国平安人寿保险股份有限公司 Database connection optimization method, device and relevant device based on cloud monitoring
CN106021313B (en) * 2016-05-05 2019-07-16 北京元心科技有限公司 A kind of method and system for preventing instruction from repeating to issue
CN112732441A (en) * 2021-01-07 2021-04-30 山东众阳健康科技集团有限公司 Connection method, device and system of multi-element dynamic connection pool

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112532403B (en) * 2019-09-17 2023-08-08 中盈优创资讯科技有限公司 Network element adaptation driving service device, network element adaptation method and system
CN111078372B (en) * 2019-12-20 2023-08-08 北京思特奇信息技术股份有限公司 Automatic process management method and system
CN112612834B (en) * 2020-12-23 2022-08-02 瀚高基础软件股份有限公司 Database middleware and method for connecting client and server
CN112954076B (en) * 2021-03-31 2023-04-07 沃科合众科技(北京)股份有限公司 Data acquisition method
CN113434479A (en) * 2021-06-07 2021-09-24 北京许继电气有限公司 Method and system for realizing autonomous controllable database connection pool
CN114500628A (en) * 2021-12-30 2022-05-13 天翼云科技有限公司 Connection selection method and device
CN115801886B (en) * 2022-11-16 2024-09-10 浪潮通用软件有限公司 Middleware connection system and method for shielding middleware differences

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070136311A1 (en) * 2005-11-29 2007-06-14 Ebay Inc. Method and system for reducing connections to a database
CN103605571A (en) * 2013-11-20 2014-02-26 国家电网公司 Control method of database connection pool
CN103729373A (en) * 2012-10-15 2014-04-16 北京新媒传信科技有限公司 Database agency method and device
CN104063451A (en) * 2014-06-23 2014-09-24 北京京东尚科信息技术有限公司 Database connection management method and system

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9251178B2 (en) * 2013-04-26 2016-02-02 Oracle International Corporation System and method for connection labeling for use with connection pools
CN104239365B (en) * 2013-06-24 2018-09-04 北京新媒传信科技有限公司 A kind of method and database connection pool connected in acquisition database connection pool
CN104572974B (en) * 2014-12-31 2018-10-12 北京奇虎科技有限公司 service request processing method and device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20070136311A1 (en) * 2005-11-29 2007-06-14 Ebay Inc. Method and system for reducing connections to a database
CN103729373A (en) * 2012-10-15 2014-04-16 北京新媒传信科技有限公司 Database agency method and device
CN103605571A (en) * 2013-11-20 2014-02-26 国家电网公司 Control method of database connection pool
CN104063451A (en) * 2014-06-23 2014-09-24 北京京东尚科信息技术有限公司 Database connection management method and system

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2016107340A1 (en) * 2014-12-31 2016-07-07 北京奇虎科技有限公司 Service request processing method and device
CN106021313A (en) * 2016-05-05 2016-10-12 北京元心科技有限公司 Method and system for preventing repeated issue of command
CN106021313B (en) * 2016-05-05 2019-07-16 北京元心科技有限公司 A kind of method and system for preventing instruction from repeating to issue
CN106257456A (en) * 2016-07-08 2016-12-28 北京京东尚科信息技术有限公司 The method of data base's stability, Apparatus and system is improved under high concurrent request
CN106302421A (en) * 2016-08-08 2017-01-04 腾讯科技(深圳)有限公司 A kind of information intercepting processing method and device
CN106302421B (en) * 2016-08-08 2019-07-16 腾讯科技(深圳)有限公司 A kind of information intercepting processing method and device
CN106341447A (en) * 2016-08-12 2017-01-18 中国南方电网有限责任公司 Database service intelligent exchange method based on mobile terminal
CN108259559A (en) * 2017-12-06 2018-07-06 中国航空工业集团公司西安航空计算技术研究所 A kind of more session data transmission realizing methods based on udp protocol
CN109800067A (en) * 2018-12-15 2019-05-24 中国平安人寿保险股份有限公司 Database connection optimization method, device and relevant device based on cloud monitoring
CN112732441A (en) * 2021-01-07 2021-04-30 山东众阳健康科技集团有限公司 Connection method, device and system of multi-element dynamic connection pool

Also Published As

Publication number Publication date
WO2016107340A1 (en) 2016-07-07
CN104572974B (en) 2018-10-12

Similar Documents

Publication Publication Date Title
CN104572974B (en) service request processing method and device
US7953915B2 (en) Interrupt dispatching method in multi-core environment and multi-core processor
CN107872528B (en) Message pushing method and device
US9256506B1 (en) System and method for performing operations on target servers
CN109408243B (en) RDMA-based data processing method, device and medium
CN106557358B (en) Data storage method and device based on dual-core processor
US9495718B2 (en) System and method for providing low latency to applications using heterogeneous processors
CN103607424B (en) Server connection method and server system
CN104854845B (en) Use the method and apparatus of efficient atomic operation
US20170161669A1 (en) Method and system for submitting content delivery tasks
WO2022227693A1 (en) Command distribution apparatus and method, chip, computer device, and medium
CN105447092A (en) Caching method and apparatus
WO2016202154A1 (en) Gpu resource allocation method and system
WO2016202153A1 (en) Gpu resource allocation method and system
CN110995817B (en) Request callback method and device and client equipment
CN110020383B (en) Page data request processing method and device
CN107294911B (en) Data packet monitoring method and device, remote procedure call system and equipment
CN108429703B (en) DHCP client-side online method and device
CN107332703B (en) Method and device for checking multi-application logs
CN107634978B (en) Resource scheduling method and device
US20130262726A1 (en) Task based message signaled interrupt
CN106598706B (en) Method and device for improving stability of server and server
CN108062224B (en) Data reading and writing method and device based on file handle and computing equipment
CN110597643A (en) Inter-core communication method, processor and electronic equipment
CN110086881A (en) Method for processing business, device and equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20181012

Termination date: 20181231

CF01 Termination of patent right due to non-payment of annual fee