Embodiment
In order to make those skilled in the art person understand technical scheme among the present invention better, below in conjunction with the accompanying drawing in the embodiment of the invention, technical scheme in the embodiment of the invention is clearly and completely described, obviously, described embodiment only is the present invention's part embodiment, rather than whole embodiment.Based on the embodiment among the present invention, the every other embodiment that those of ordinary skills obtained should belong to the scope of protection of the invention.
As shown in Figure 1, the optimization method of a kind of application server provided by the invention comprises:
S101, obtain the related data of application server processes SQL (Structured Query Language, Structured Query Language (SQL)) in real time,
Wherein, described related data can comprise: the quantity of the processing time of wall scroll SQL or maximum concurrent processing SQL;
Certainly, it will be appreciated by persons skilled in the art that the related data of SQL can also be other data, for example: the handled SQL type of application server.
Wherein, the processing time of wall scroll SQL can be the maximum processing time of wall scroll SQL in the average handling time of wall scroll SQL in: the Preset Time section or the Preset Time section.
S102, described related data and preset reference value are compared,, then reduce the maximum thread of application server connection pool,, then increase the maximum thread of application server connection pool if less than the preset reference value if greater than the preset reference value.
Wherein, the preset reference value can artificially be set, and also can add up and/or calculate the preset reference value according to the historical record of application server processes SQL.
In actual applications, when described related data equates with the preset reference value, can no longer change the maximum thread of application server connection pool.
Need to prove that the application server connection pool is a kind of equipment that belongs to middleware, can control the quantity that application server is wanted treatment S QL according to maximum thread is set.When the maximum thread of connection pool became big, application server institute SQL quantity to be processed became big; When the maximum thread of connection pool diminished, application server SQL quantity to be processed diminished.For fixing application server, its processing power is fixed, when application server institute SQL quantity to be processed more for a long time, the processing time of wall scroll SQL will be longer.
Be connected with database because application server is many, the behavior of database being inquired about by application server processes SQL, so the quantity of and/or application server concurrent processing SQL long when the time of application server processes SQL more for a long time, phenomenon of blocking can appear in database.So,, can think that stopping up appears in database when described related data during greater than the preset reference value.
The present invention is by using above technical scheme, the processing time and the preset reference value of the Structured Query Language (SQL) obtained in real time can be compared, and according to the automatic corresponding increase of comparative result or reduce the value of application server connection pool, to realize the Automatic Optimal of application server performance.
In actual applications, because each bar SQL might not be identical, so the processing time of wall scroll SQL possibility can not embody the performance of application server on higher degree.So, in other embodiments of the invention, can also obtain the related data of using server process SQL in the Preset Time section earlier, add up then and/or calculate, draw the characteristic of using server process SQL in the predetermined amount of time, as: the maximum processing time of the average handling time of wall scroll SQL, wall scroll SQL.Then described characteristic and preset reference value are compared, and corresponding change application server connection pool maximum thread, to reach the purpose that application server performance is optimized.
As shown in Figure 2, the optimization method of a kind of application server of the embodiment of the invention comprises:
S201, pick up counting;
S202, obtain the processing time of wall scroll SQL in the Preset Time section in real time;
Wherein, the Preset Time section can artificially be set, for example: 10 minutes.
Whether S203, timing reach the length of Preset Time section, if, execution in step S204 then, otherwise, execution in step S202;
S204, the processing time of the wall scroll SQL in the Preset Time section calculated the average handling time of wall scroll SQL;
Wherein, the computing method of the average handling time of wall scroll SQL can for:
The time of using server process SQL in the Preset Time section is added up,, thereby draw the average handling time of wall scroll SQL then divided by using the quantity of server process SQL in the Preset Time section.
S205, average handling time and preset reference value are compared, if greater than the preset reference value, if execution in step S206 then is less than preset reference value, execution in step S207;
Need to prove, in actual applications, before carrying out this method,, also can obtain the related data of server process SQL earlier, draw the preset reference value, and then carry out this method if the application server load is stable.Certainly, the preset reference value also can rule of thumb be accumulated by the technician and set.
Under the situation of the average handling time of wall scroll SQL, the method to set up of preset reference value comprises in related data is the Preset Time section:
Under application server load stable case, according to the historical record of treatment S QL, the average handling time of the server process that is applied wall scroll SQL, with the described average handling time of prearranged multiple as the preset reference value, for the purpose of distinguishing, be called the first preset reference value.
It will be appreciated by persons skilled in the art that the application server load is stable refers to that promptly the quantity of application server concurrent processing SQL remains in certain scope, and number change is little.
S206, reduce the maximum thread of application server connection pool;
The maximum thread of S207, increase application server connection pool.
In actual applications, when average handling time equates with the preset reference value, can no longer change the maximum thread of application server connection pool.
Certainly, in other embodiments of the invention, step S204 can also for:
The processing time of wall scroll SQL in the Preset Time section is added up the maximum processing time that draws wall scroll SQL.
Under the situation in the maximum processing time of wall scroll SQL, the method to set up of preset reference value comprises in related data is the Preset Time section:
Under the stable situation of application server load, according to the historical record of treatment S QL, the maximum processing time of the server process that is applied wall scroll SQL, with described maximum processing time of prearranged multiple as the preset reference value, for the purpose of distinguishing, be called the second preset reference value.
In actual applications, because the amplitude of variation in the maximum processing time of wall scroll SQL is bigger than the average handling time of wall scroll SQL, so the reservation multiple in maximum processing time can be than the reservation multiple height of average handling time.
Certainly, in other embodiments of the invention, can also obtain the maximum processing time of application server processes wall scroll SQL and the average handling time of wall scroll SQL simultaneously, the average handling time of wall scroll SQL and the pairing first preset reference value compare, and the maximum processing time of wall scroll SQL and the pairing second preset reference value compare.
If the average handling time of wall scroll SQL greater than maximum processing time of the first preset reference value or wall scroll SQL greater than the second preset reference value, then reduce the maximum thread of application server connection pool;
If the average handling time of wall scroll SQL less than maximum processing time of the first preset reference value and wall scroll SQL less than the second preset reference value, then increase the maximum thread of application server connection pool.
In actual applications, the situation that also may occur equating:
If the average handling time of wall scroll SQL equals the maximum processing time of the first preset reference value and wall scroll SQL less than the second preset reference value, then increase the maximum thread of application server connection pool;
If the average handling time of wall scroll SQL equals the second preset reference value less than the maximum processing time of the first preset reference value and wall scroll SQL, then increase the maximum thread of application server connection pool;
If the average handling time of wall scroll SQL equals the maximum processing time of the first preset reference value and wall scroll SQL and equals the second preset reference value, then do not change the maximum thread of application server connection pool.
Certainly, in other embodiments of the invention, described related data can also be the quantity of maximum concurrent processing SQL.
Be that the method to set up of described preset reference value comprises under the situation of quantity of maximum concurrent processing SQL in related data:
Obtain the CPU quantity of application server, with the described CPU quantity of prearranged multiple as the preset reference value.
As shown in Figure 3, the optimization method of another kind of application server provided by the invention comprises:
S301, pick up counting;
S302, obtain the quantity of concurrent processing SQL in the Preset Time section in real time;
Wherein, the Preset Time section can artificially be set, for example: 10 minutes.
Whether S303, timing reach the length of Preset Time section, if, execution in step S304 then, otherwise, execution in step S302;
S304, the quantity of the concurrent processing SQL in the Preset Time section is added up the quantity that draws maximum concurrent processing SQL in the Preset Time section;
S305, quantity and the preset reference value of maximum concurrent processing SQL compared, if greater than the preset reference value, if execution in step S306 then is less than preset reference value, execution in step S307;
Be that the method to set up of described preset reference value comprises under the situation of quantity of maximum concurrent processing SQL in described related data:
Obtain the CPU quantity of application server, as the preset reference value, for the purpose of distinguishing, be called the 3rd preset reference value with the described CPU quantity of prearranged multiple.
It will be appreciated by persons skilled in the art that the application server load is stable refers to that promptly the quantity of application server concurrent processing SQL remains in certain scope, and number change is little.
The CPU quantity that it will be appreciated by persons skilled in the art that application server is one of key factor that influences application server processes SQL ability, and the CPU quantity of application server is many more, and the ability of its treatment S QL is big more.
S306, reduce the maximum thread of application server connection pool;
The maximum thread of S307, increase application server connection pool.
In actual applications, when the quantity of maximum concurrent processing SQL equates with the 3rd preset reference value, can no longer change the maximum thread of application server connection pool.
Certainly, in other embodiments of the invention, can also obtain the maximum processing time of application server processes wall scroll SQL, the average handling time of wall scroll SQL and the quantity of maximum concurrent processing SQL simultaneously.The average handling time of wall scroll SQL and the pairing first preset reference value compare, the maximum processing time of wall scroll SQL and the pairing second preset reference value compare, and the quantity of maximum concurrent processing SQL and pairing the 3rd preset reference value compare.
If the average handling time of wall scroll SQL greater than maximum processing time of the first preset reference value, wall scroll SQL greater than the quantity of the second preset reference value or maximum concurrent processing SQL greater than the 3rd preset reference value, then reduce the maximum thread of application server connection pool;
If the average handling time of wall scroll SQL less than maximum processing time of the first preset reference value, wall scroll SQL less than the quantity of the second preset reference value and maximum concurrent processing SQL less than the 3rd preset reference value, then increase the maximum thread of application server connection pool.
Getting rid of under the situation of above-mentioned two kinds of hypothesis, also the situation that may occur equating:
If the average handling time of wall scroll SQL less than maximum processing time of the first preset reference value, wall scroll SQL less than the quantity of the second preset reference value or maximum concurrent processing SQL less than the 3rd preset reference value, then increase the maximum thread of application server connection pool;
If the average handling time of wall scroll SQL equals the quantity that the maximum processing time of the first preset reference value, wall scroll SQL equals the second preset reference value and maximum concurrent processing SQL and equals the 3rd preset reference value, then do not change the maximum thread of application server connection pool.
Corresponding to top method embodiment, the present invention also provides a kind of optimization means of application server.
As shown in Figure 4, the optimization means of a kind of application server provided by the invention comprises:
Data acquisition module 100 is used for obtaining in real time the related data of application server processes Structured Query Language (SQL) SQL,
Wherein, described related data comprises: the quantity of the processing time of wall scroll SQL or maximum concurrent processing SQL;
Wherein, the processing time of described wall scroll SQL can for:
The maximum processing time of wall scroll SQL in the average handling time of wall scroll SQL or the Preset Time section in the Preset Time section.
The related data that it will be appreciated by persons skilled in the art that SQL can also be other data, for example: the handled SQL type of application server.
Wherein, the preset reference value can artificially be set, and also can add up and/or calculate the preset reference value by the historical record of application server processes SQL.
Wherein, the processing time of wall scroll SQL can be the maximum processing time of wall scroll SQL in the average handling time of wall scroll SQL in: the Preset Time section or the Preset Time section.
Data comparison module 200 is used for described related data and preset reference value are compared;
Thread Count changes module 300, is used in described related data reducing the maximum thread of application server connection pool during greater than the preset reference value, during less than the preset reference value, increases the maximum thread of application server connection pool in described related data.
In actual applications, when described related data equates with the preset reference value, can no longer change the maximum thread of application server connection pool.
Need to prove that the application server connection pool is a kind of equipment that belongs to middleware, can control the quantity that application server is wanted treatment S QL according to maximum thread is set.When the maximum thread of connection pool became big, application server institute SQL quantity to be processed became big; When the maximum thread of connection pool diminished, application server SQL quantity to be processed diminished.For fixing application server, its processing power is fixed, when application server institute SQL quantity to be processed more for a long time, the processing time of wall scroll SQL will be longer.
Be connected with database because application server is many, the behavior of database being inquired about by application server processes SQL, so the quantity of and/or application server concurrent processing SQL long when the time of application server processes SQL more for a long time, phenomenon of blocking can appear in database.So,, can think that stopping up appears in database when described dependency number during greater than the preset reference value.
The present invention is by using above technical scheme, the processing time and the preset reference value of the Structured Query Language (SQL) obtained in real time can be compared, and according to the automatic corresponding increase of comparative result or reduce the value of application server connection pool, to realize the Automatic Optimal of application server performance.
In actual applications, because each bar SQL might not be identical, so the processing time of wall scroll SQL possibility can not embody the performance of application server on higher degree.So, in other embodiments of the invention, can also obtain the related data of using server process SQL in the Preset Time section earlier, add up then and/or calculate, draw the characteristic of using server process SQL in the predetermined amount of time, as: the maximum processing time of the average handling time of wall scroll SQL, wall scroll SQL.Then described characteristic and preset reference value are compared, and corresponding change application server connection pool maximum thread, to reach the purpose that application server performance is optimized.
Certainly, the present invention other the device embodiment in, described data acquisition module 100 concrete configurations can for:
Under the stable situation of application server load, according to the historical record of treatment S QL, the average handling time of the server process that is applied wall scroll SQL, with the described average handling time of prearranged multiple as the preset reference value.
Wherein, the computing method of the average handling time of wall scroll SQL can for:
The time of using server process SQL in the Preset Time section is added up,, thereby draw the average handling time of wall scroll SQL then divided by using the quantity of server process SQL in the Preset Time section.
Under the situation of the average handling time of wall scroll SQL, the method to set up of preset reference value comprises in related data is the Preset Time section:
Under application server load stable case, according to the historical record of treatment S QL, the average handling time of the server process that is applied wall scroll SQL, with the described average handling time of prearranged multiple as the preset reference value, for the purpose of distinguishing, be called the first preset reference value.
It will be appreciated by persons skilled in the art that the application server load is stable refers to that promptly the quantity of application server concurrent processing SQL remains in certain scope, and number change is little.
Certainly, the present invention other the device embodiment in, described data acquisition module 100 specifically be provided with can for:
Under the stable situation of application server load, according to the historical record of treatment S QL, the maximum processing time of the server process that is applied wall scroll SQL, with described maximum processing time of prearranged multiple as the preset reference value.
Under the situation in the maximum processing time of wall scroll SQL, the method to set up of preset reference value can comprise in related data is the Preset Time section:
Under the stable situation of application server load, according to the historical record of treatment S QL, the maximum processing time of the server process that is applied wall scroll SQL, with described maximum processing time of prearranged multiple as the preset reference value, for the purpose of distinguishing, be called the second preset reference value.
In actual applications, because the amplitude of variation in the maximum processing time of wall scroll SQL is bigger than the average handling time of wall scroll SQL, so the reservation multiple in maximum processing time can be than the reservation multiple height of average handling time.
Certainly, the present invention other the device embodiment in, described data acquisition module 100 specifically be provided with can for:
Obtain the CPU quantity of application server, as the preset reference value, for the purpose of distinguishing, be called the 3rd preset reference value with the described CPU quantity of prearranged multiple.
The CPU quantity that it will be appreciated by persons skilled in the art that application server is one of key factor that influences application server processes SQL ability, and the CPU quantity of application server is many more, and the ability of its treatment S QL is big more.
Certainly, in other devices of the present invention embodiment, data acquisition module 100 concrete configurations can for: obtain the maximum processing time of application server processes wall scroll SQL and the average handling time of wall scroll SQL simultaneously, the average handling time of wall scroll SQL and the pairing first preset reference value compare, and the maximum processing time of wall scroll SQL and the pairing second preset reference value compare.
If the average handling time of wall scroll SQL greater than maximum processing time of the first preset reference value or wall scroll SQL greater than the second preset reference value, then reduce the maximum thread of application server connection pool;
If the average handling time of wall scroll SQL less than maximum processing time of the first preset reference value and wall scroll SQL less than the second preset reference value, then increase the maximum thread of application server connection pool.
In actual applications, the situation that also may occur equating:
If the average handling time of wall scroll SQL equals the maximum processing time of the first preset reference value and wall scroll SQL less than the second preset reference value, then increase the maximum thread of application server connection pool;
If the average handling time of wall scroll SQL equals the second preset reference value less than the maximum processing time of the first preset reference value and wall scroll SQL, then increase the maximum thread of application server connection pool;
If the average handling time of wall scroll SQL equals the maximum processing time of the first preset reference value and wall scroll SQL and equals the second preset reference value, then do not change the maximum thread of application server connection pool.
Certainly, the present invention other the device embodiment in, data acquisition module 100 concrete configurations can for: obtain the maximum processing time of application server processes wall scroll SQL, the average handling time of wall scroll SQL and the quantity of maximum concurrent processing SQL simultaneously.The average handling time of wall scroll SQL and the pairing first preset reference value compare, the maximum processing time of wall scroll SQL and the pairing second preset reference value compare, and the quantity of maximum concurrent processing SQL and pairing the 3rd preset reference value compare.
If the average handling time of wall scroll SQL greater than maximum processing time of the first preset reference value, wall scroll SQL greater than the quantity of the second preset reference value or maximum concurrent processing SQL greater than the 3rd preset reference value, then reduce the maximum thread of application server connection pool;
If the average handling time of wall scroll SQL less than maximum processing time of the first preset reference value, wall scroll SQL less than the quantity of the second preset reference value and maximum concurrent processing SQL less than the 3rd preset reference value, then increase the maximum thread of application server connection pool.
Getting rid of under the situation of above-mentioned two kinds of hypothesis, also the situation that may occur equating:
If the average handling time of wall scroll SQL less than maximum processing time of the first preset reference value, wall scroll SQL less than the quantity of the second preset reference value or maximum concurrent processing SQL less than the 3rd preset reference value, then increase the maximum thread of application server connection pool;
If the average handling time of wall scroll SQL equals the quantity that the maximum processing time of the first preset reference value, wall scroll SQL equals the second preset reference value and maximum concurrent processing SQL and equals the 3rd preset reference value, then do not change the maximum thread of application server connection pool.
For the convenience of describing, be divided into various unit with function when describing above the device and describe respectively.Certainly, when enforcement is of the present invention, can in same or a plurality of softwares and/or hardware, realize the function of each unit.
As seen through the above description of the embodiments, those skilled in the art can be well understood to the present invention and can realize by the mode that software adds essential general hardware platform.Based on such understanding, the part that technical scheme of the present invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product can be stored in the storage medium, as ROM/RAM, magnetic disc, CD etc., comprise that some instructions are with so that a computer equipment (can be a personal computer, server, the perhaps network equipment etc.) carry out the described method of some part of each embodiment of the present invention or embodiment.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, and identical similar part is mutually referring to getting final product between each embodiment, and each embodiment stresses all is difference with other embodiment.Especially, for device embodiment, because it is substantially similar in appearance to method embodiment, so describe fairly simplely, relevant part gets final product referring to the part explanation of method embodiment.Device embodiment described above only is schematic, wherein said unit as the separating component explanation can or can not be physically to separate also, the parts that show as the unit can be or can not be physical locations also, promptly can be positioned at a place, perhaps also can be distributed on a plurality of network element.Can select wherein some or all of module to realize the purpose of present embodiment scheme according to the actual needs.Those of ordinary skills promptly can understand and implement under the situation of not paying creative work.
The present invention can be used in numerous general or special purpose computingasystem environment or the configuration.For example: personal computer, server computer, handheld device or portable set, plate equipment, multicomputer system, the system based on microprocessor, set top box, programmable consumer-elcetronics devices, network PC, small-size computer, mainframe computer, comprise distributed computing environment of above any system or equipment or the like.
The present invention can describe in the general context of the computer executable instructions of being carried out by computing machine, for example program module.Usually, program module comprises the routine carrying out particular task or realize particular abstract, program, object, assembly, data structure or the like.Also can in distributed computing environment, put into practice the present invention, in these distributed computing environment, by by communication network connected teleprocessing equipment execute the task.In distributed computing environment, program module can be arranged in the local and remote computer-readable storage medium that comprises memory device.
The above only is the specific embodiment of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.