Summary of the invention
According to the disclosure in a first aspect, providing a kind of method for handling high concurrent request, comprising: reception comes from
The request of requesting party, the request include the request to dynamic resource;The hashed value of the request is calculated, the hashed value can be only
One ground identifies the request;The hashed value is written in the way of optimistic locking and is cached;It, will be described if said write success
It is for processing that request is transmitted to dynamic resource server;And if said write fails, it tries read from caching to described
The response of request.
According to an embodiment, the request is HTTP request, and the method is executed by web server.
According to another embodiment, the hashed value is at least to hash to the following certain applications for including in the HTTP request
Function obtains: requesting method, request URL and request body.
According to yet another embodiment, said write includes: that the version number of the hashed value is set as 1 the caching is written,
And if there are the same Hash value that version number is more than or equal to 1, said write failures in the caching;Otherwise, described to write
Enter success.
According to yet another embodiment, the request further includes the request to static resource.
According to yet another embodiment, the method also includes being taken in the successful situation of said write from the dynamic resource
Business device receives requested dynamic resource, by the dynamic resource and requested static resource together as to the request
Response be stored in the caching, and by it is described response be sent to the requesting party.
According to yet another embodiment, described the method also includes the hashed value and the response to be stored in association with
In caching.
According to yet another embodiment, the hashed value stored in the caching has corresponding life span, and the existence
Time is scheduled or is determined according to the attribute of requested dynamic resource.
According to yet another embodiment, the method also includes delaying after the life span of respective Hash value is expired from described
Deposit middle removing respective Hash value and associated response.
According to yet another embodiment, the method also includes in the case where said write failure, executing described attempt up to pre-
Number is determined, until the response to the request is successfully read from described cache, wherein the pre-determined number is equal to the request
Time-out time handles the time divided by single request.
According to yet another embodiment, if the method also includes not reading successfully to described in the pre-determined number
The response of request then sends request timed out notice to the requesting party;Otherwise, the response read is sent to the request
Side.
According to the second aspect of the disclosure, a kind of system for handling high concurrent request is provided, comprising: reception group
Part is configured to receive the request from requesting party, wherein the request packet includes the request to dynamic resource;Computation module,
Its hashed value for being configured to calculate the request, wherein the hashed value can uniquely identify the request;Component is written,
It is configured to that the hashed value is written in the way of optimistic locking and caches;Transfer assembly, if being configured to said write group
The hashed value is successfully written the caching by part, then it is for processing to forward the request to dynamic resource server;And
Reading assembly, if being configured to the write-in failure of said write component, it tries read the response to the request from caching.
According to an embodiment, the request is HTTP request.
According to another embodiment, the hashed value is at least to hash to the following certain applications for including in the HTTP request
Function obtains: requesting method, request URL and request body.
According to yet another embodiment, said write component is further configured to the version number of the hashed value being set as 1 to be written
The caching, and if there are the same Hash value that version number is more than or equal to 1, said write failures in the caching;It is no
Then, said write success.
According to yet another embodiment, the request further includes the request to static resource.
According to yet another embodiment, the receiving unit is further configured in the successful situation of said write, is moved from described
State Resource Server receives requested dynamic resource, and the dynamic resource and requested static resource one are acted as
To be stored in the caching to the response of the request, and the transfer assembly is further configured to for the response being sent to
The requesting party.
According to yet another embodiment, the hashed value is also stored in association in the caching with the response.
According to yet another embodiment, the hashed value stored in the caching has corresponding life span, and the existence
Time is scheduled or is determined according to the attribute of requested dynamic resource.
According to yet another embodiment, after the life span of respective Hash value is expired, it is corresponding that this is removed from the caching
Hashed value and associated response.
According to yet another embodiment, the reading assembly is further configured in the case where said write failure, described in execution
It attempts to reach pre-determined number, until the response to the request is successfully read from described cache, wherein the pre-determined number is equal to institute
The time-out time for stating request handles the time divided by single request.
According to yet another embodiment, if the transfer assembly is further configured to the reading assembly in the pre-determined number
The response to the request is not read successfully, then sends request timed out notice to the requesting party;Otherwise, the transmission group
The response that part is configured to read is sent to the requesting party.
According to the third aspect of the disclosure, a kind of system for handling high concurrent request is provided, comprising: processor;
And it is arranged to the memory of storage computer executable instructions, the executable instruction makes the processor when executed
Execute the method as described in the first aspect according to the disclosure.
Various aspects generally comprise as substantially herein by reference to described by attached drawing and the method as explained by attached drawing,
Equipment, system, computer program product and processing system.
Foregoing teachings have sketched the contours of the exemplary feature and technical advantage according to the disclosure broadly so that following is detailed
Thin description can be better understood.Additional feature and advantage will describe hereafter.Disclosed concept and specific example can
It is easily used as modifying or being designed to carry out the basis of the other structures of purpose identical with the disclosure.Such equivalent constructions
Without departing from the scope of the appended claims.The characteristic of concepts disclosed herein two aspect of its organizing and operating method with
And associated advantage is better understood due to will be described below because being considered in conjunction with the accompanying.Each attached drawing is for explaining and retouch
It states purpose to provide, and does not define limitations on the claims.
Specific embodiment
It is intended as the description of various configurations below in conjunction with the attached drawing 1-5 detailed description illustrated, and is not intended to indicate to practice
Only configuration of concept described herein.This detailed description includes detail to provide the thorough reason to each conception of species
Solution.However, it will be apparent to those skilled in the art that, these concepts can be practiced without these specific details.
Term is explained:
Static resource: the resource being generally referred to as stored at web server, such as website pattern file, js resource,
Html Static web page documents, picture file, etc.;
Dynamic resource: it is opposite with static resource, generally referred to as need web server to calculate by program internal memory to return
All resources returned.Dynamic resource, which is generally required, could return to institute to user by database manipulation or program internal memory calculation processing
The resource of request.It typically is provided with following essential characteristic: 1. interactivity: webpage can be moved with selection acording to the requirement of user
Changes and respond to state;2. automatically updating: html document need not be updated manually, new page will be automatically generated, it can be significantly
Save workload;3. because when become because of people: will appear the different pages when different time, different user access same network address.
CDN:CDN is that the content distributing network constructed on network passes through by the Edge Server for being deployed in various regions
The functional modules such as load balancing, content distribution, the scheduling of central platform, content needed for obtaining user nearby reduce network and gather around
Plug improves user's access response speed and hit rate;
In existing web system, static resource is such as distributed to using CDN by the general access only accelerated to static resource
Different networks.When user requests resource, nearest network node is looked for be responded.It is common for dynamic resource
Scheme is on interface using caching.In response to client initiate first time request, by based on input parameter key assignments with ask
Response is asked to store in caching together.For subsequent same request, then response is read directly from caching, to protect downstream
Resource.
But when the client same time initiating a large amount of same requests, does not respond still, will lead to accordingly in caching
All requests all can execute a rear end process by server, so as to cause the wasting of resources.For single request processing when
Between it is especially true for longer situation.In the case where serious waste of resources, this may result in server resource exhaust or
Database corruption, so that system is unavailable.
For example, as shown in Figure 1, it illustrates in existing web system to the processing timing diagram of the request from client.This
Field technical staff is it will be appreciated that for clarity, static resource is not shown in Fig. 1.
With reference to Fig. 1, firstly, client (for example, web client) by resource request (such as comprising to dynamic resource
Request) it is sent to server (for example, web server).Web server upon receipt of the request, for web client to dynamic
State Resource Server issues resource acquisition request.Dynamic resource server is asked receiving the resource acquisition from web server
After asking, corresponding business processing is executed to generate requested resource.Then, dynamic resource server is by resource generated
(that is, result of business processing) returns to web server.Web server is then by the response (example from dynamic Resource Server
Such as, web client requested resource or fail to generate web client requested resource in dynamic resource server
In the case of failure notification) return to web client.Web client is then rendered based on the response received to mention
Supply user.
It can be seen that existing system shown in FIG. 1 (not exists each request from web client in web server
In the case where finding respective response in caching) all send dynamic resource server to, this initiates big in the web client same time
When measuring same request, will lead to all requests all can execute a business processing flow by dynamic Resource Server, to lead
Cause the wasting of resources.
The system and method for the disclosure can be identified when server (for example, web server) receives client request
Whether it is high frequency same request, and only handles one in these same requests request, and processing result is shared to these
Other requests in same request, to protect server end to calculate, memory source, safeguards system service is continuously available.Therefore,
The system and method for the disclosure are particularly suitable for that single call (for example, web call) takes a long time and there may be continuous simultaneously
The scene of calling.
2-5 describes each example embodiment of the system and method for the disclosure with reference to the accompanying drawing.
As shown in Fig. 2, it illustrates the exemplary methods 200 requested for handling high concurrent according to all aspects of this disclosure
Flow chart.
With reference to Fig. 2, in frame 210, method 200 may include receiving the request from requesting party, and the request includes to dynamic
The request of resource.For example, in one example, requesting party is web client, and web server reception is sent out by the web client
The access request to the webpage comprising dynamic resource out.In this example, which can be HTTP request, generally at least
Including each portion such as requesting method (for example, POST, GET, etc.), request URL, http protocol and version, request header, request body
One or more of point.
For example, as shown in figure 3, when it illustrates according to all aspects of this disclosure for handling the example of high concurrent request
Sequence figure.As can be seen, web client 305 can send out resource request (for example, the request includes the request to dynamic resource)
Give web server 310.Web server 310 can receive this request from web client 305 and carry out subsequent place
Reason.
Later with continued reference to Fig. 2, in frame 220, method 200 may include calculating the hashed value of the request received.On continuing
State example, web server the request can be parsed after the HTTP request received with find out including each field
Part, and at least using include in HTTP request requesting method, request URL and request body portion by hash function come
Calculate hashed value corresponding with the request.For example, web server 310 can parse the money from web client with reference to Fig. 3
Source request, and using the various pieces of the request that parses (for example, parameters, i.e. requesting method, request URL and asking
Seek body, etc.) one or more of calculate the hashed value of the request, using the hashed value being calculated as the request
Globally unique identifier.It will be understood by those skilled in the art that hashed value is only a kind of exemplary forms of globally unique identifier, may be used also
The request is uniquely identified in a manner of taking any other suitable, such as each section of the request is serially connected, etc.
Deng.Additionally, it is to be appreciated that hashed value is that various known or exploitation in the future hashing algorithm can be used to be calculated, it is all
Such as MD4, MD5, SHA-1.Those skilled in the art are to be further understood that web server can be used in the request received
Including any part and/or combination thereof calculate corresponding hashed value, as long as these parts and/or combination thereof is used to calculate
Obtained hashed value can be used to uniquely identify the request.
Fig. 2 is referred back to, and in frame 230, method 200 may include the hashed value being calculated being write in the way of optimistic locking
Enter (that is, storage is arrived) caching.
It will be understood by those skilled in the art that optimistic locking is a kind of locking mechanism of data access, it is based on number mostly
It is realized according to colophon mechanism, as data increase a version number.In the version solution based on database table, one
As be to be realized by increasing " version (version) " field for database table.When reading data, together by this version number
It reads, then when submitting data to be updated, this version number adds one.At this point, version number and database table that data will be submitted
The current version number of corresponding record is compared.If the versions of data number submitted is greater than database table current version number, give
To update;Otherwise it is assumed that being stale data and abandoning.
Specifically, continue the example presented above, web server after the hashed value for calculating the HTTP request received,
The hashed value being calculated can be written in the way of optimistic locking and be cached.In this example, said write may include will be described
The version number of hashed value is set as 1 the caching is written, rather than writes direct in the caching.
In this example, if the request received is the first request in multiple same requests, caching in there has been no
The hashed value, therefore there is no the hashed values that version number is more than or equal to 1 in the caching.In this case, the hash
Value is written successfully.
Otherwise, if the request received is not first request in multiple same requests, in the caching
There are identical hashed values, and its version number is at least 1.In this case, according to optimistic lock mechanism, the write-in of this hashed value
Since its version number's (that is, set value 1) is less than or equal to the version number (for example, 1) of stored same Hash value in caching
And fail.As a result, in the presently disclosed embodiments, optimistic lock mechanism is employed to ensure that in multiple same requests only by one quilt
Server (for example, web server) is transmitted to dynamic resource server, and make in these same requests other it is each request not
It is forwarded to dynamic resource server.
In one embodiment, in the case where caching is separated with web server, web server can will be calculated
Hashed value sends caching in a manner of by caching come by optimistic locking to execute storage operation.
For example, with reference to Fig. 3, schematically illustrate that caching is implemented as separating with web server 310 with caching number
According to library 315.It will be understood by those skilled in the art that cache database 315 can be realized using database technology, however its
It can be any other realization that can pay optimistic lock mechanism, and it can also be realized as being located at web server 310
Place.
With continued reference to Fig. 3, for web server 310 after the hashed value for calculating the request received, can attempt should
Hashed value (together with the version number for being set as 1) is written in cache database 315.Cache database 315 is receiving the hashed value
Later, the return value for storing the hashed value and returning to storage success or not to web server can be attempted.
If said write success, method 200 can proceed to frame 240, here, forwarding the request to dynamic resource clothes
Business device is for processing.For example, continuing the example presented above, in the case where being written successfully, web server can determine that the request is
It requests for the first time, forwards the request to dynamic resource server to be made by the dynamic resource server to the request
Response, and the response to the request is received from the dynamic resource server.
For example, with reference to Fig. 3, dotted line frame 350 show successfully stored in cache database 315 it is related to resource request
The sequence of operation after the hashed value of connection.In the case where hashed value is written successfully (that is, cache database 315 successfully stores
Hashed value), web server 310 requests to obtain resource to dynamic resource server 320 based on described, such as the request is turned
It is for processing to issue dynamic resource server 320.Corresponding business processing can be performed then to prepare in dynamic resource server 320
The good requested dynamic resource of requesting party, and return to web server 310 as processing result, i.e., to web server
310 make a response.Web server 310 then receives the processing result returned from dynamic Resource Server 320 and (rings that is, receiving
It answers).
In this embodiment, method 200 may also include response storage in the buffer.For example, in HTTP request
In example, web server can receive response (wherein response bag to HTTP request from dynamic resource server
Include requested dynamic resource) after, it stores it in caching.
In another embodiment, in the case where web client also requests static resource, method 200 may also include by
Associated static resource and the response (that is, dynamic resource) from dynamic resource server are collectively stored in caching.
In this embodiment, method 200 may also include hashed value and the requested dynamic resource of web client and static state
Resource (in the case where web client requests static resource) stores in association.In this way, after web server receives
After continuous same request, the hashed value being calculated can be used and come from caching directly to search accordingly as key word of the inquiry
Response, deal with without request dynamic Resource Server again.
For example, it illustrates receiving the processing result from dynamic resource server 315 (that is, corresponding with reference to Fig. 3
Dynamic resource) after, web server 310 is related to the hashed value being calculated by 305 requested resource of web client
Connection ground write-in cache database 315, for being used for subsequent same request.Cache database 315 perform storage operation after,
It can notify 310 processing result of web server (for example, storage is completed).
Although those skilled in the art, which are to be further understood that in Fig. 3 using single cache database 315, stores hashed value
With the response to request, but for store hashed value caching and physical cache can be different to the caching of the response of request
And they can also be located at one or separate each other by any means with web server, such as storing the slow of hashed value
Depositing can be located at one with web server, and the caching for being used to store the response to request can be located at another equipment, or
Both of which is located at web server.
Then, method 200, which may also include to web client, returns to its resource requested.For example, as shown in figure 3, web takes
Being engaged in device 310 can be to the return requested resource of web client 305.
With continued reference to Fig. 2, if said write fails, method 200 can proceed to frame 250, here, attempting to read from caching
Response to the request.For example, continue the example presented above, in the case where failure is written, web server can determine with it is described
It requests to be processed before identical request or just processed, and therefore there may be ask before identical in caching
The response asked.In this case, web server can be used the hashed value being calculated attempted as key word of the inquiry from
Caching reads the response to the request, without forwarding the request to dynamic resource server, to save Internet resources
With the process resource of dynamic resource server.
For example, Fig. 3 shows the sequence of operation in the case where caching failure is written at frame 360.In web services
In the case that device 310 receives the notice (that is, write-in failure) of the storage failure from cache database 315, web server
310 can determine that this request from web client 305 received is not the request for the first time in multiple same requests, and
And the response for the request may be stored in cache database 315.In this way, web server 310 can be to cache database
For 315 sending read requests to read the response for being directed to the request, cache database 315 executes corresponding read operation simultaneously in turn
Its response stored is returned to web server 310.Web server 310 can be returned after receiving respective response
Back to the web client 305 for issuing request.Web client 305 carries out subsequent processing, such as wash with watercolours to the resource received in turn
Dye.
In one embodiment, if the trial for the first time for reading response does not succeed, method 200, which may also include, to be continued to attempt to
The response to the request is read from caching and reaches pre-determined number, until successfully reading the response to the request from described cache.
For example, continuing the example presented above, each trial time of web server can be the processing time of single request.For example, web takes
Business device can handle the time according to the history of all previous request to determine the trial time for reading response from caching.
In a preferred embodiment, when the time-out time that the pre-determined number is equal to the request is handled divided by single request
Between.In this way, web server can notify request timed out to requesting party after the time-out time of the request expires, without
It is further continued for attempting.
However, in this embodiment, if not reading the response to the request successfully in the pre-determined number,
Then method 200 may include that request timed out notice is sent to the requesting party.For example, for the example of HTTP request, it is assumed that time-out
Time is 500ms, and the time that web server and dynamic resource server process are once requested is 50ms, then pre-determined number can quilt
It is arranged to 500/50=10 times.In this example, if web server attempts to read response from caching up to 10 times, web services
Device abandons the request, and sends time-out notification to the web client for issuing request.
In the another embodiment of the disclosure, the hashed value stored in the caching has corresponding life span, and
After the life span is expired, corresponding hashed value is removed from hash caching, to vacate the sky of hash caching
Between.In a further embodiment, the life span is the attribute according to requested dynamic resource (for example, dynamic resource
Renewal frequency, etc.) come what is determined.As an example, assume that requested dynamic resource is the public accumalation fund for housing construction data of user,
It is usually monthly carried out due to the update of the data, so life span can be configured to one month or shorter.In the implementation
In example, if the life span of respective Hash value is expired, the respective Hash value is removed from the caching.For example, in house
In the example of public accumulation fund data, if hashed value is stored over one month in the buffer (is configured to one in life span
In the case where a month), then the hashed value is removed, so that it is guaranteed that the dynamic resource that requesting party obtains is effective.In addition, in phase
Answer hashed value life span expire and from caching remove after, associated response can also be removed from caching, to rise
The space cached out.
Fig. 4 is the block diagram for explaining the example system 200 for handling high concurrent request according to all aspects of this disclosure.
As shown in figure 4, system 400 includes: receiving unit 401, it is configured to receive the request from requesting party, wherein
The request includes the request to dynamic resource;Computation module 403 is configured to calculate the hashed value of the request, wherein
The hashed value can uniquely identify the request;Component 405 is written, is configured to the hash in the way of optimistic locking
Value write-in caching;The hashed value is successfully written described delay if being configured to said write component by transfer assembly 407
It deposits, then it is for processing to forward the request to dynamic resource server;And reading assembly 409, if being configured to institute
State write-in component write-in failure, it tries read the response to the request from caching.
According to an embodiment, the request is HTTP request.
According to another embodiment, the hashed value is at least to hash to the following certain applications for including in the HTTP request
Function obtains: requesting method, request URL and request body.
According to yet another embodiment, write-in component 405 is further configured to the version number of the hashed value being set as 1 to be written
Caching is stated, and if there are the same Hash value that version number is more than or equal to 1, said write failures in the caching;Otherwise,
Said write success.
According to yet another embodiment, the request further includes the request to static resource.
According to yet another embodiment, receiving unit 401 is further configured in the successful situation of said write, from the dynamic
Resource Server receives requested dynamic resource, and by the dynamic resource and requested static resource together as
The response of the request is stored in the caching, and transfer assembly 407 is further configured to the response being sent to institute
State requesting party.
According to yet another embodiment, the hashed value is also stored in association in the caching with the response.
According to yet another embodiment, the hashed value stored in the caching has corresponding life span, and the existence
Time is scheduled or is determined according to the attribute of requested dynamic resource.
According to yet another embodiment, after the life span of respective Hash value is expired, it is corresponding that this is removed from the caching
Hashed value and associated response.
According to yet another embodiment, reading assembly 409 is further configured to taste described in execution in the case where said write failure
Examination reaches pre-determined number, until the response to the request is successfully read from described cache, wherein the pre-determined number is equal to described
The time-out time of request handles the time divided by single request.
According to yet another embodiment, if transfer assembly 407 is further configured to reading assembly 409 and does not have in the pre-determined number
Have and successfully read the response to the request, then sends request timed out notice to the requesting party;Otherwise, transfer assembly 407
The response for being configured to read is sent to the requesting party.
Fig. 5 is to explain showing for another example system 500 according to all aspects of this disclosure for handling high concurrent request
It is intended to.
As shown, system 500 includes processor 505 and memory 510.It is executable that memory 510 is stored with computer
Instruction 515, these instructions can be executed to realize the above method described in conjunction with Fig. 1 by processor 505.
As described above, disclosed method and system are raw by using the key mark in request (for example, HTTP request)
Identify whether requested content is identical at signature (for example, hashed value), and by optimistic lock mechanism come identical ask of only letting pass
Thus first request in asking protects the dynamic of back-end server so that back-end server only handles a service request
State resource.
For example, for web services, disclosed method and system while retaining web site high concurrent characteristic,
Protect the efficient utilization rate of the dynamic resource of back-end server.
It will be understood by those skilled in the art that although specifically combining web resource access to describe according to each reality in the disclosure
The method and system of example is applied, but these method and systems are not only applicable to web resource access, but being suitable for includes to dynamic
Any scene of the access of resource.
The above specific embodiment includes the reference to attached drawing, and attached drawing forms the part of specific embodiment.Attached drawing passes through
Illustrate to show the specific embodiment that can be practiced.These embodiments are referred to herein as " example ".Such example may include
Element in addition to those of shown or described element.However, also contemplating the example including shown or described element.In addition,
What is also contemplated is the example of any combination or arrangement using those of shown or described element, or referring to shown herein or
The particular example (or one or more in terms of) of description, or referring to other shown or described herein examples (or one
Or many aspects).
In the dependent claims, term " includes " and "comprising" are open, that is to say, that in the claims
System, equipment, product or the process of element in addition to those of enumerating element after such term are regarded as falling in that
In the scope of the claims.In addition, in the dependent claims, term " first ", " second " and " third " etc. are merely used as
Label, and it is not intended to the numerical order shown to their object.
In addition, the order respectively operated explained in this specification is exemplary.In an alternate embodiment, each operation can
To execute by from different order shown in the drawings, and each operation can be merged into single operation or split into more multioperation.
Above description is intended to illustrative and not restrictive.For example, in combination with other embodiments come using retouching above
The example (or in terms of one or more) stated.Can such as by those of ordinary skill in the art check above description it is later
Use other embodiments.Abstract allows reader to quickly determine the nature of the disclosure of the art.The abstract is submitted, and understands that this is plucked
It will not be used to interpret or limit the scope of the claims or meaning.In addition, various features can in the above specific embodiment
Jointly in groups so that the disclosure is smooth.However, claim can not state each feature disclosed herein, because implementing
Example can characterize the subset of the feature.In addition, embodiment may include feature more less than feature disclosed in particular example.
Therefore, the appended claims are hereby incorporated into specific embodiment, a claim as individual embodiment and
It is individually present.The range of embodiment disclosed herein should be assigned referring to the appended claims and such claim
The full breadth of the equivalence of right determines.