Summary of the invention
In view of this, the application provides a kind of connection method for building up and device, drawn with solving the starting of service server cluster
The problem of sending out Database Systems access storm.
Specifically, the application is achieved by the following technical solution:
A kind of connection method for building up, which comprises
The time for beginning setting up connection is calculated according to the grouping where this equipment;
When beginning setting up the time of connection described in the arrival, N number of connection request is sent to Database Systems, arrives institute to establish
State N number of connection of Database Systems;
Wherein, N is the natural number more than or equal to 1.
Further, the method also includes:
Before the time of connection is begun setting up described in the arrival, if receiving the service request for needing to access Database Systems
And currently without available connection, then a connection request is sent to the Database Systems, arrives the data base set to establish
One connection of system.
Further, described to include: to the N number of connection request of Database Systems transmission
Judge whether the quantity M of the connection of this current equipment to the Database Systems is less than connection lower limit value, M for greater than
Equal to 0, and it is less than the natural number of connection upper limit value;
If M is less than the connection lower limit value, N number of connection request is sent to the Database Systems, N is the connection
Upper limit value or the difference for connecting lower limit value and M.
Further, described to include: to the N number of connection request of Database Systems transmission
Judge whether the quantity M of the connection of this current equipment to the Database Systems is less than connection lower limit value, M for greater than
Equal to 0, and it is less than the natural number of connection upper limit value;
If M is more than or equal to the connection lower limit value, N number of connection request is sent to Database Systems, N is the connection
The difference of upper limit value and M.
Further, the grouping according to where this equipment, which calculates, begins setting up time of connection and includes:
With the group number of the grouping where this equipment multiplied by preset connection it is time-consuming with obtain it is described begin setting up connection when
Between.
Device is established in a kind of connection, and described device includes:
Time calculating unit calculates the time for beginning setting up connection according to the grouping where this equipment;
First connection unit when beginning setting up the time of connection described in the arrival, sends N number of connection to Database Systems and asks
It asks, to establish the N number of connection for arriving the Database Systems;
Wherein, N is the natural number more than or equal to 1.
Further, described device further include:
Second connection unit needs to access database before beginning setting up the time of connection described in the arrival if received
The service request of system and currently without available connection, Xiang Suoshu Database Systems send a connection request, are arrived with establishing
One connection of the Database Systems.
Further, first connection unit includes:
First judgment sub-unit, judges whether the quantity M of connection of this current equipment to the Database Systems is less than company
Connect lower limit value, M is and to be less than the natural number of connection upper limit value more than or equal to 0;
First transmission sub-unit, when M is less than the connection lower limit value, Xiang Suoshu Database Systems send N number of connection and ask
It asks, N is the connection upper limit value or the difference for connecting lower limit value and M.
Further, first connection unit includes:
First judgment sub-unit, judges whether the quantity M of connection of this current equipment to the Database Systems is less than company
Connect lower limit value, M is and to be less than the natural number of connection upper limit value more than or equal to 0;
Second transmission sub-unit, when M is more than or equal to the connection lower limit value, Xiang Suoshu Database Systems send N number of company
Request is connect, N is the difference of the connection upper limit value and M.
Further, the time calculating unit, specifically with the group number of the grouping where this equipment multiplied by preset connection
Time-consuming is to obtain the time for beginning setting up connection.
It can be seen from above description in this application, the service server in service server cluster is according to this equipment
The grouping at place calculates this equipment and begins setting up time of connection, when beginning setting up the time of connection described in the arrival, to data
Library system sends connection request, establishes connection with Database Systems so as to stagger the time in batches, and Database Systems is avoided to access wind
Cruelly.
Specific embodiment
Example embodiments are described in detail here, and the example is illustrated in the accompanying drawings.Following description is related to
When attached drawing, unless otherwise indicated, the same numbers in different drawings indicate the same or similar elements.Following exemplary embodiment
Described in embodiment do not represent all embodiments consistent with the application.On the contrary, they be only with it is such as appended
The example of the consistent device and method of some aspects be described in detail in claims, the application.
It is only to be not intended to be limiting the application merely for for the purpose of describing particular embodiments in term used in this application.
It is also intended in the application and the "an" of singular used in the attached claims, " described " and "the" including majority
Form, unless the context clearly indicates other meaning.It is also understood that term "and/or" used herein refers to and wraps
It may be combined containing one or more associated any or all of project listed.
It will be appreciated that though various information, but this may be described using term first, second, third, etc. in the application
A little information should not necessarily be limited by these terms.These terms are only used to for same type of information being distinguished from each other out.For example, not departing from
In the case where the application range, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as
One information.Depending on context, word as used in this " if " can be construed to " ... when " or " when ...
When " or " in response to determination ".
The application provides a kind of connection method for building up, can apply on the server, referring to FIG. 1, the application one is implemented
The flow diagram of method for building up is connected in example, above-mentioned connection method for building up may comprise steps of:
Step 101, the time for beginning setting up connection is calculated according to the grouping where this equipment.
In the present embodiment, the grouping where described equipment can be configured in advance by administrative staff, can also be by
Management server in service server cluster distributes group number according to preset strategy for each service server, and the application is to this
It is not particularly limited.
In this step, service server can calculate after starting up according to the group number of the grouping where this equipment
This equipment begins setting up the time of connection, such as: it is time-consuming to obtain multiplied by preset connection with the group number of the grouping where this equipment
To the time for beginning setting up connection.
Step 102, when beginning setting up the time of connection described in the arrival, N number of connection request is sent to Database Systems, with
Establish N number of connection of the Database Systems.
Based on abovementioned steps 101, be obtained by calculation it is described begin setting up the time of connection after, wait and being opened described in reaching
Establish vertical connection time when, by sending N number of connection request to Database Systems, to establish the N number of company for arriving Database Systems
It connects, wherein N is the natural number more than or equal to 1.
It can be seen from above description in this application, the service server in service server cluster is according to this equipment
The grouping at place calculates this equipment and begins setting up time of connection, when beginning setting up the time of connection described in the arrival, to data
Library system sends connection request, establishes connection with Database Systems so as to stagger the time in batches, and Database Systems is avoided to access wind
Cruelly.
Referring to FIG. 2, Fig. 2 is the flow diagram for connecting method for building up in another embodiment of the application, the connection is built
Cube method can be used in server, comprising the following steps:
Step 201, the time for beginning setting up connection is calculated according to the grouping where this equipment.
In the present embodiment, the grouping where described equipment can be configured in advance by administrative staff, can also be by
Management server in service server cluster distributes group number according to preset strategy for each service server, and the application is to this
It is not particularly limited.
By taking administrative staff are the service server setting grouping in service server cluster in advance as an example, it is assumed that business service
There are 1000 service servers in device cluster, then the service server in the service server cluster can be divided by administrative staff
5 are grouped, and include 200 service servers in each grouping.Certainly, administrative staff can also be by the service server cluster
In service server be divided into 10 groupings, then include 100 service servers in each grouping.Administrative staff are setting
After grouping, the group number being grouped where it is issued for service server preservation for every service server.The group number of the grouping
The sequence of connection can be used to indicate to establish with Database Systems, such as: the service server in the smallest grouping of group number is at first
Connection is established with Database Systems, the service server time in the small grouping of group number first establishes connection, group with Database Systems
Service server in number maximum grouping finally establishes connection with Database Systems.The group number of the grouping can since 1,
It can also be since other numerical value.Preferably, it can set the group number of the grouping to since 0, to facilitate server root
The time for beginning setting up connection is calculated according to the group number being grouped where this equipment.
It in this step, can be time-consuming to obtain this equipment multiplied by preset connection with the group number of the grouping where this equipment
Begin setting up the time of connection.Wherein, the preset connection is time-consuming is usually taken by administrative staff according to business in each grouping
Being engaged in, the connection consumed time determines in batches for device foundation.It is assumed that Database Systems are arrived in service server foundation in each grouping
Time consumed by batch connection is 10ms-50ms, then can set any number in 10ms-50ms for the connection time-consuming
Value.
As an example it is assumed that it is 10ms that the preset connection is time-consuming, administrative staff will be in certain service server cluster
Service server is divided into 5 groupings, be respectively as follows: grouping 0, grouping 1 ..., grouping 4.If the industry in the service server cluster
The group number of grouping where business server 1 is 0, then the service server 1 is time-consuming multiplied by the connection with its group number, i.e., 0 ×
10ms, the obtained time for beginning setting up connection are 0ms.If where the service server 2 in the service server cluster
The group number of grouping is 3, then the service server 2 is time-consuming multiplied by the connection with its group number, i.e. 3 × 10ms, what is obtained starts to build
The time of vertical connection is 30ms.
It should be noted that if the service server in above-mentioned service server cluster is divided into 5 points by administrative staff
Group, be respectively as follows: grouping 1, grouping 2 ..., grouping 5, then when computationally stating the time for beginning setting up connection, subtracted with the group number
The difference obtained after going one is time-consuming multiplied by the connection.If where the service server 1 in the service server cluster
The group number of grouping is 1, then the difference that the service server 1 obtains after subtracting one with its group number is time-consuming multiplied by the connection, i.e.,
(1-1) × 10ms, the obtained time for beginning setting up connection remain as 0ms.In this step, those skilled in the art can be according to
The time of connection, the application couple are begun setting up described in the group number and calculating being grouped according to the relevant technologies setting service server cluster
This is not particularly limited.
Step 202, before beginning setting up the time of connection described in the arrival, need to access Database Systems if received
Service request and currently without available connection then sends a connection request to the Database Systems, to establish to described
One connection of Database Systems.
Based on abovementioned steps 201, be calculated it is described begin setting up the time of connection after, can be counted by timer
When, it was waited before the time for beginning setting up connection described in the arrival, is not sent the connection request of batch to Database Systems, than
Such as: waiting can be realized by thread delay.
However, service server cluster after actuation, is sent to service server cluster during actually realizing
Service request may be sent on any one service server, if beginning setting up connection in arrival service server
Time before, which receives the service request for needing to access Database Systems, at this time in the service server
There is not yet the connection to the Database Systems, in order to handle the service request, the service server is to Database Systems
A connection request is sent, to establish a connection to the Database Systems, and based on the connection and the data base set
System is communicated to handle the service request.
As an example it is assumed that the time for beginning setting up connection of service server 2 be 30ms, then if reach 30ms it
Before, such as: service server 2 receives the service request 1 for needing to access Database Systems when 10ms, due to
There is not yet the connection to the Database Systems when 10ms in service server 2, then service server 2 sends 1 company
Request is connect to Database Systems, 1 is established with the Database Systems and connect to handle the service request 1.
Further, it needs to access data base set if the service server 2 receives one when 20ms again
The service request 2 of system has existed 1 connection for arriving Database Systems at this time, then judges that the connection is current in service server 2
Whether can be used, if the connection is currently available, using the connection to handle the service request 2, if the connection currently can not
With, such as: the connection is used by the service request 1 that 10ms is received, then service server 2 sends 1 connection again and asks
Database Systems are sought, another 1 is established with the Database Systems and connect to handle the service request 2.
Step 203, when beginning setting up the time of connection described in the arrival, judge that this current equipment arrives the Database Systems
The quantity M of connection whether be less than connection lower limit value.If the quantity M of connection of this current equipment to the Database Systems is small
In the connection lower limit value, 204 are thened follow the steps.If the quantity M of connection of this current equipment to the Database Systems is big
In being equal to the connection lower limit value, 205 are thened follow the steps.
In the present embodiment, the connection lower limit value and the connection upper limit value are usually configured by administrative staff,
In, the connection lower limit value is the connection number to Database Systems for requesting to be established in order to ensure service server processing business
The minimum value of amount, the connection upper limit value are the maximum value of connection quantity of the service server to Database Systems.
In this step, when beginning setting up the time of connection described in the arrival, first judge that this current equipment arrives the data
Whether the quantity M of the connection of library system is less than the connection lower limit value.Wherein, M be more than or equal to 0, and be less than connection upper limit value
Natural number.If M is less than the connection lower limit value, illustrate that this equipment also needs to establish the company for arriving the Database Systems
It connects, executes step 204.If M is more than or equal to the connection lower limit value, this equipment can continue to establish to the database
The connection of system executes step 205.Certainly, when M is more than or equal to the connection lower limit value, this equipment can also not continued to
The connection of the Database Systems is established, the application is not particularly limited this.
Step 204, Xiang Suoshu Database Systems send N number of connection request, and N is the connection upper limit value or connection lower limit value
With the difference of M.
It is small in the quantity M of connection of this current equipment to the Database Systems based on the judging result of abovementioned steps 203
When the connection lower limit value, Xiang Suoshu Database Systems send connection request, to continue to establish the connection with Database Systems.
Specifically, in this step, N number of connection request is sent to Database Systems, wherein N can be the connection upper limit value and M
Difference, N may be it is described connection lower limit value and M difference, can be specifically configured by developer, the application to this not
Make specifically limited.
As an example it is assumed that the connection upper limit value of certain service server is 10, connection lower limit value is 3, if currently originally set
The quantity M of the standby connection to the Database Systems is 2, then in this step, can send 8 or 1 to Database Systems
Connection request.
Step 205, N number of connection request is sent to Database Systems, N is the difference of the connection upper limit value and M.
It is big in the quantity M of connection of this current equipment to the Database Systems based on the judging result of abovementioned steps 203
It when the connection lower limit value, can continue to send connection request to the Database Systems, to continue foundation and database
The connection of system.Specifically, in this step, N number of connection request is sent to Database Systems, wherein N is the connection upper limit
The difference of value and M.
Still with the connection upper limit value of certain service server for 10, for connection lower limit value is 3, if this current equipment arrives institute
The quantity M for stating the connection of Database Systems is 6, then in this step, can send 4 connection requests to Database Systems.
It can be seen from above description in this application, the service server in service server cluster is according to this equipment
The grouping at place calculates this equipment and begins setting up time of connection, when beginning setting up the time of connection described in the arrival, to data
Library system sends connection request, establishes connection with Database Systems so as to stagger the time in batches, and Database Systems is avoided to access wind
Cruelly.
Corresponding with the application connection embodiment of method for building up, the application also provides a kind of connect and establishes device.This Shen
Device that please be described can also be realized by software realization by way of hardware or software and hardware combining.With software reality
For existing, for the application calibration equipment as the device on a logical meaning, being will be non-easy by the processor of equipment where it
Corresponding computer program instructions are read into memory what operation was formed in the property lost memory.
Please refer to Fig. 3 and Fig. 4, the application provides a kind of connection and establishes device 300, and device 300 is established in the connection can be with
Using on the server, include: time calculating unit 301, the first connection unit 302 and the second connection unit 303.Its
In, first connection unit 302 can also include: the first judgment sub-unit 3021, the first transmission sub-unit 3022 and
Two transmission sub-units 3023.
Wherein, the time calculating unit 301 calculates the time for beginning setting up connection according to the grouping where this equipment.
First connection unit 302 when beginning setting up the time of connection described in the arrival, sends N to Database Systems
A connection request, to establish the N number of connection for arriving the Database Systems;
Wherein, N is the natural number more than or equal to 1.
Second connection unit 303 needs to access before beginning setting up the time of connection described in the arrival if received
The service request of Database Systems and currently without available connection, Xiang Suoshu Database Systems send a connection request, with
Establish a connection of the Database Systems.
Further, first judgment sub-unit 3021 judges that this current equipment arrives the connection of the Database Systems
Quantity M whether be less than connection lower limit value, M is and to be less than the natural number of connection upper limit value more than or equal to 0.
First transmission sub-unit 3022, when M is less than the connection lower limit value, Xiang Suoshu Database Systems send N
A connection request, N are the connection upper limit value or the difference for connecting lower limit value and M.
Further, first judgment sub-unit 3021 judges that this current equipment arrives the connection of the Database Systems
Quantity M whether be less than connection lower limit value, M is and to be less than the natural number of connection upper limit value more than or equal to 0.
Described second sends 3023 yuan of son list, when M is more than or equal to the connection lower limit value, Xiang Suoshu Database Systems hair
N number of connection request is sent, N is the difference of the connection upper limit value and M.
Further, the time calculating unit 301, specifically with the group number of the grouping where this equipment multiplied by preset company
It connects time-consuming to obtain the time for beginning setting up connection.
The function of each unit and the realization process of effect are specifically detailed in the above method and correspond to step in above-mentioned apparatus
Realization process, details are not described herein.
The foregoing is merely the preferred embodiments of the application, not to limit the application, all essences in the application
Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the application protection.