Specific embodiment
Below in conjunction with the accompanying drawings, embodiments of the invention are described.
Date storage method, application server and remote storage server that the embodiment of the present application is provided, it is adaptable to apply
The scene of the application server for storage data in server cluster, the application server cluster is used to dispose same operation system
(e.g., Taobao's transaction system and Alipay account system etc.), it can include more than two application servers.
The application scenarios schematic diagram of the date storage method that Fig. 1 is provided for the application, in Fig. 1, same operation system is simultaneously
It is deployed on two application servers, namely application server cluster 10 can include two application servers, this two applications
Server is respectively:Application server 101 and application server 102, wherein, the Internet protocol address of application server 101
(Internet Protocol Address, IP) is:IP1, the IP of application server 102 are:IP2.Two application servers
Composition structure it is identical, by taking application server 101 as an example for, its can include caching component (component) and locally delay
(also referred to as internal memory or local data center) is deposited, the associated component of local cache is encapsulated in caching component simultaneously and is remotely delayed
The associated component deposited, it is used for the data storage in local cache, is additionally operable to the data storage in remote storage server.One
In individual example, caching component is to carry out data storage in the form of key-value pair (Key-Vlaue) in local cache, e.g.,<
Key1, data1>,<Key2, data2>...,<Keyn, datan>, wherein, data1, data2 ..., datan refer to storage
Data true, and key1, key2 ..., keyn refers to the mark of above-mentioned data, and it is typically by operation system according to industry
The most frequently used use condition is engaged in set.Such as, the operation system disposed on application server cluster 10 is transaction system of Taobao
During system, the mark of data can be the unique mark (identifier, ID) of commodity, and be disposed on application server cluster 10
Operation system be Alipay account system when, above-mentioned data mark can be user ID (user_id).
Remote storage server 20 in Fig. 1 can include control unit 201 (also referred to as control centre) and memory cell 202
(also referred to as data center), control unit 201 is used to record the ground for having set up the application server being connected with remote storage server
Location, and for recording the gap marker of remote storage server and the communication channel of the application server.In one example, on
Stating address can corresponding storage with gap marker.Memory cell 202 is used to store the data of application server transmission, and it can be
Refer to that internal memory may also mean that external memory, when memory cell 202 is external memory, the external memory can be disk etc..It is understood that depositing
Data in storage unit 202 can also be stored in the form of key-value pair.
The date storage method flow chart that Fig. 2 is provided for a kind of embodiment of the application.The executive agent of methods described can be with
It is the equipment with disposal ability:Server or system or device, the application server in such as Fig. 1.As shown in Fig. 2 institute
Stating method can specifically include:
Step 210, the first application server determines data to be written.
The first application server herein can be for appointing for disposing in the application server cluster of same operation system
One application server.Such as, can be any application server for disposing in the application server cluster of Taobao's transaction system,
Can also be for disposing any application server in Alipay account systematic difference server cluster.
In step 210, the first application server can determine data to be written by two ways:First way
It is that the first application server is wanted to improve the access efficiency of a certain data, then the data can be defined as into data to be written.The
Two kinds of modes are that the first application server receives the write data requests of called side, and the write data requests include the number of request write-in
According to, then can by the request write data be defined as data to be written.
Alternatively, it is determined that after data to be written, the mark of the data to be written can also be determined.In an example
In, the first application server can determine above-mentioned mark according to the most frequently used use condition of business.Such as, in application server collection
Group 10 on dispose operation system be Taobao's transaction system when, it is determined that data to be written mark can be commodity ID,
And on application server cluster 10 dispose operation system be Alipay account system when, it is determined that data to be written mark
It can be the ID of user to know.
Step 220, is written into data Cun Chudao local caches.
Local cache herein can refer to the internal memory of the first application server.
Alternatively, the data in local cache can be stored in queue.Data in local cache are storages
When in queue, the first application server can first judge the length of queue before data Cun Chudao local caches are written into
Whether degree exceedes predetermined threshold value, if not less than predetermined threshold value, being directly written into the afterbody of queue described in data Cun Chudao;And
If exceeding predetermined threshold value, algorithm can be removed according to default data, the data in queue are removed, such as, according to
Data in queue are removed by first in first out (First In FirstOut, FIFO) algorithm, and data are written into afterwards
Store remove data after queue in.
Certainly, in actual applications, the first application server can also by another way safeguard the queue of internal memory,
The application is not construed as limiting to this.Such as, the first application server can periodically judge data in queue whether over-time threshold
Value, if over-time threshold value, the data is removed.
It should be noted that in the case where the mark of data to be written is also determined, the first application server can also be by
The mark is also stored into the queue of local cache.In one example, the mark of data and to be written can be written into
Data in the form of the key-value pair storage in the queue of local cache.Such as,<KEY, DATA>, wherein, KEY refers to data to be written
Mark, DATA refers to data to be written.
Step 230, sends the first far call and asks to remote storage server.
Wherein, the first far call request can include data to be written, and the first far call is asked long-range for indicating
Storage server is written into the corresponding memory cell of data Cun Chudao remote storage servers.
It should be noted that in the case where the mark of data to be written is also determined, the first application server can also be by
The mark is sent to remote storage server, so that remote storage server can be by the mark and data to be written with key assignments
To form storage in corresponding memory cell.In one example, above-mentioned first far call request can be:put
(keyi, datai), wherein, keyi is the mark of data to be written, and datai is data to be written.
Alternatively, above-mentioned first far call request can also include the address (e.g., IP) of the first application server.
When the request of one far call also includes the address of the first application server, remote storage server is receiving the first far call
After request, the first application server can be searched from control unit according to the address, if finding, be written into number
According to or data to be written and mark storage in memory cell;If not finding, remote storage server can be attempted
Communication channel is set up with the first application server, and for the communication channel assignment channel is identified, is recorded in a control unit afterwards
The corresponding relation of address above mentioned and gap marker, further, it is also possible to individually record address above mentioned.In one example, control single
The address recorded in unit can be:[IP1, IP2, IP3 ..., IPN], and the address recorded in control unit and gap marker
Corresponding relation can be:<IP1, gap marker 1>,<IP2, gap marker 2>...,<IPM, gap marker M>.Individually recording
After the corresponding relation of address above mentioned or record address above mentioned and gap marker, remote storage server can be written into number
According to or data to be written and mark storage in memory cell.
To sum up, because the application is written into data Cun Chudao remote storage servers, and the long-range storage service
Device can be accessed by whole application server cluster, thus, it is possible to improve the access of the data of whole application server cluster
Efficiency.Additionally, the application is also written into data Cun Chudao local caches, when the application service in application server cluster
Device can search the data from local cache first when data are read, and search less than in the case of, just from long-range storage clothes
Searched in business device, it is possible thereby to avoid when in application server cluster while when having the same data of multiple application server access,
The data hot issue for causing.
After completion above-mentioned steps 210- steps 230 are performed;Or, according to the first application server local cache with
And in remote storage server data storage mode, when the other application server in application server cluster is in local cache
And in the memory cell of remote storage server in the form of the key-value pair after data storage and corresponding mark, the application
Embodiment can also comprise the following steps:
Step A:Receive the read data request that called side sends.
Herein, can be that the read data request that called side sends is received by the first application server, the read data request can
With the first mark including data to be read.
Step B:According to the first mark, data to be read are searched from local cache.
Such as, data to be read can be searched from the queue of local cache according to the first mark.
Step C:If finding data to be read, the reading data are returned into called side.
Thus, it is possible to improve the access efficiency of the data of the first application server.
Step D:If not finding data to be read, send the second far call to remote storage server and ask.
Wherein, the second far call request can include the first mark, and the second far call is asked for indicating remotely to deposit
Storage server searches data to be read according to the first mark from memory cell.
Specifically, remote storage server, can be according to the second long-range tune after the request of the second far call is received
With the second mark in request, data to be read are searched from memory cell, if not finding data to be read, directly to the
One application server is returned searches failure for expression, then is used to this by the first application server represent that lookup fails
Message be transmitted to called side.If finding data to be read, the data to be read are returned to by remote storage server
One application server.
Step E:Receive the data to be read that remote storage server sends.
Step F:By in data Cun Chudao local caches to be read, and data to be read are returned to called side.
First application server after data to be read are received, first by the data to be read or data to be read
And second mark storage in local cache, so as to when the data to be read are accessed again, can directly from locally delaying
Got in depositing.After data to be read are stored in the local cache, the first application server can return the data to be read
Back to called side.
Alternatively, above-mentioned second far call request can also include the address of the first application server.It is long-range second
When call request also includes the address of the first application server, remote storage server is searched from memory cell in execution and continued
Before access evidence, the step of searching the first application server in a control unit is first carried out, and searched less than in the case of, held
The address of row the first application server of record, the communication channel of foundation and the first application server, assignment channel are identified and remembered
The step of corresponding relation of record address and gap marker, its specific implementation procedure is same as above, does not repeat again herein.In execution
After stating step, then perform according to the second mark, the step of search data to be read from memory cell.
In can be seen that the application by above-mentioned steps A- steps F, when the application server in application server cluster is being read
Access according to when, the data can be searched from local cache first, search less than in the case of, just from remote storage server
Search, it is possible thereby to avoid when in application server cluster while when having the same data of multiple application server access, causing
Data hot issue.
After completion above-mentioned steps 210- steps 230 are performed;Or, execution is completed after above-mentioned steps A- steps F;Or
Person, according to the mode of the first application server data storage in local cache and remote storage server, works as application service
Other application server in device cluster is in the memory cell of local cache and remote storage server with the shape of key-value pair
After formula data storage and corresponding mark, embodiments herein can also comprise the following steps:
Step X:Determine the second mark of data to be deleted.
Herein, can determine that the second of data to be deleted identify by the first application server.In one example, when true
Determine identical identify corresponding two data it is inconsistent when, then the corresponding data of the mark that will have been stored are defined as number to be deleted
According to.Such as, it is assumed that the data for having stored are:<Key1, data1>, and the data for newly obtaining are:<Key1, data2>, then data1 be
Data to be deleted.
Step Y:According to the second mark, data to be deleted are searched from local cache, and delete data to be deleted.
It should be noted that when stored in the form of key-value pair in local cache data to be deleted and second mark
When, the key-value pair is directly deleted, e.g., delete<Key1, data1>.
Step Z:The 3rd far call is sent to remote storage server to ask.
Wherein, the 3rd far call request can include the second mark.In one example, the 3rd far call request can
Think:Delete (keyj, dataj), wherein, keyj is the mark of data to be deleted, and datai is data to be deleted.
Remote storage server, can be according to the second mark, from memory cell after the 3rd call request is received
Search and delete data to be deleted.Herein, when data to be deleted and second are stored in memory cell in the form of key-value pair
During mark, the key-value pair is directly deleted.
After data to be deleted are deleted, there is the corresponding relation of the address and gap marker for having recorded in a control unit
In the case of, remote storage server has been set up during application server cluster is obtained from control unit with remote storage server
The address of the other application server of connection, and obtain the corresponding gap marker in the address.Afterwards, it is corresponding by gap marker
Communication channel sends to other application server and indicates message, and the instruction message is used to indicate other application server from corresponding
Data to be deleted are searched and deleted in local cache.As an example it is assumed that in Fig. 1, application server 101 and application server
102 establish with remote storage server and are connected, and the content of the control unit of remote storage server is as follows:[IP1,
IP2];<IP1, gap marker 1>,<IP2, gap marker 2>.When the application server 101 in Fig. 1 is sent out to remote storage server
When sending three call requests, remote storage server after data to be deleted are deleted according to the request of the 3rd far call because
Get application server 102 and established with remote storage server and be connected, it is possible to obtained from control unit and application
The corresponding gap marker of server 102:Gap marker 2, and by the corresponding communication channel of gap marker 2 to application server
102 send instruction message, and the instruction message can include the second mark.Application server 102 receive indicate message after,
Identified according to second, data to be deleted are searched and deleted from local cache.
It is achieved that by above-mentioned steps X- steps Z same between the local cache of application server and remote storage server
Step communication mechanism, it is possible thereby to ensure the uniformity of data between the two.
The date storage method flow chart that Fig. 3 is provided for the application another kind embodiment.The executive agent of methods described can
Think the equipment with disposal ability:Server or system or device, the remote storage server in such as Fig. 1.Such as Fig. 3 institutes
Show, methods described can specifically include:
Step 310, remote storage server receives the first application server and is being written into data Cun Chudao local caches
The the first far call request for sending afterwards.
The first application server herein be for dispose in the application server cluster of same operation system it is any should
Use server.Above-mentioned first far call request can include data to be written, in addition, it can include the mark of data to be written
Know.
It should be noted that above-mentioned first application server is written into data Cun Chudao local caches can refer to:The
One application server is written into the queue of data Cun Chudao local caches.Data are written into the first application server to deposit
Before storing up the queue of local cache, can first judge whether the length of queue exceedes predetermined threshold value, if not less than predetermined threshold value,
Then directly it is written into the afterbody of queue described in data Cun Chudao;And if exceed predetermined threshold value, can be according to default data
Algorithm is removed, the data in queue are removed, be written into afterwards in the queue after data Cun Chudao removes data.
Also, it should be noted that when the request of the first far call also includes the mark of data to be written, the first application clothes
Can also be also stored into the mark in the queue of local cache by business device.In one example, the mark of data can be written into
Know and data to be written in the form of the key-value pair storage in the queue of local cache.
Step 320, asks according to the first far call, is written into that data Cun Chudao remote storage servers are corresponding to deposit
In storage unit.
When the request of the first far call also includes the mark of data to be written, the first application server can also mark this
Knowledge is sent to remote storage server, so that remote storage server can be by the mark and data to be written with key-value pair
Form is stored in corresponding memory cell.
Alternatively, above-mentioned first far call request can also include the address (e.g., IP) of the first application server.
When the request of one far call also includes the address of the first application server, remote storage server is receiving the first far call
After request, the first application server can be searched from control unit according to the address, if finding, be written into number
According to or data to be written and mark storage in memory cell;If not finding, remote storage server can be attempted
Communication channel is set up with the first application server, and for the communication channel assignment channel is identified, is recorded in a control unit afterwards
The corresponding relation of address above mentioned and gap marker, further, it is also possible to individually record address above mentioned.Individually record address above mentioned or
Person is recorded after the corresponding relation of address above mentioned and gap marker, and remote storage server can be written into data or to be written
Enter data and mark is stored in memory cell.
After completion above-mentioned steps 310- steps 320 are performed, embodiments herein can also comprise the following steps:
Step a, receives first mark of first application server in the data to be read sent according to called side, from local
The the second far call request sent during data to be read is not found in caching.
The second far call request herein can include the first mark.
Step b, according to the first mark, searches data to be read from memory cell.
Step c:If not finding data to be read, directly returned for representing lookup failure to the first application server
Message.
Afterwards, this is used to represent the first application server searching failure is transmitted to called side.
Step d:If finding data to be read, data to be read are returned to the first application server, for first
Application server returns to data to be read by data Cun Chudao local caches to be read to called side.
First application server after data to be read are received, first by the data to be read or data to be read
And second mark storage in local cache, so as to when the data to be read are accessed again, can directly from locally delaying
Got in depositing.After data to be read are stored in the local cache, the first application server can return the data to be read
Back to called side.
Alternatively, above-mentioned second far call request can also include the address of the first application server.It is long-range second
When call request also includes the address of the first application server, remote storage server is searched from memory cell in execution and continued
Before access evidence, the step of searching the first application server in a control unit is first carried out, and searched less than in the case of, held
The address of row the first application server of record, the communication channel of foundation and the first application server, assignment channel are identified and remembered
The step of corresponding relation of record address and gap marker, its specific implementation procedure is same as above, does not repeat again herein.In execution
After stating step, then perform according to the second mark, the step of search data to be read from memory cell.
After completion above-mentioned steps 310- steps 320 are performed;Or, execution is completed after above-mentioned steps a- steps d, this
The embodiment of application can also comprise the following steps:
Step w:The first application server is received according to the second of data to be deleted the mark, is searched simultaneously from local cache
Delete the 3rd far call request sent after data to be deleted.
The 3rd far call request herein can include the second mark.
It should be noted that when stored in the form of key-value pair in local cache data to be deleted and second mark
When, the first application server directly deletes the key-value pair.
Step x:Identified according to second, data to be deleted are searched and deleted from memory cell.
Remote storage server, can be according to the second mark, from memory cell after the 3rd call request is received
Search and delete data to be deleted.Herein, when data to be deleted and second are stored in memory cell in the form of key-value pair
During mark, the key-value pair is directly deleted.
Step y:Obtained from control unit and its that be connected has been set up with remote storage server in application server cluster
The address of its application server, and obtain the corresponding gap marker in address.
After data to be deleted are deleted, there is the corresponding relation of the address and gap marker for having recorded in a control unit
In the case of, remote storage server has been set up during application server cluster is obtained from control unit with remote storage server
The address of the other application server of connection, and obtain the corresponding gap marker in the address.
Step z:Sent to other application server by the corresponding communication channel of gap marker and indicate message
The instruction message is used to indicate other application server to be searched from corresponding local cache and delete number to be deleted
According to.
It is achieved that by above-mentioned steps w- steps z same between the local cache of application server and remote storage server
Step communication mechanism, it is possible thereby to ensure the uniformity of data between the two.
With above-mentioned date storage method accordingly, a kind of application server that the embodiment of the present application is also provided, such as Fig. 4 institutes
Show, the application server includes:
Determining unit 401, for determining data to be written.
Memory cell 402, in the data Cun Chudao local caches to be written that determine determining unit 401.
Memory cell 402 specifically can be used for:
Judge whether the length of the queue of local cache exceedes predetermined threshold value;
If exceeding predetermined threshold value, algorithm is removed according to default data, the data in queue are removed;
It is written into the queue after data Cun Chudao removes data.
Transmitting element 403, asks for sending the first far call to remote storage server, and first far call please
Ask including data to be written, the first far call is asked long-range for indicating remote storage server to be written into data Cun Chudao
In storage server.
Alternatively, the application server can also also include:
Receiving unit 404, the read data request for receiving called side transmission, read data request includes data to be read
First mark.
First searching unit 405, for the first mark received according to receiving unit 404, searches from local cache and treats
Read data.
Transmitting element 403, if being additionally operable to the first searching unit 405 does not find data to be read, takes to long-range storage
Business device sends the request of the second far call, and the request of the second far call includes the first mark, and the second far call is asked for referring to
Show that remote storage server, according to the first mark, searches data to be read.
Receiving unit 404, is additionally operable to receive the data to be read that remote storage server sends.
Memory cell 402, is additionally operable in the data Cun Chudao local caches to be read for receiving receiving unit 404, and to
Called side returns to data to be read.
Alternatively, the application server can also include:Second searching unit 407.
Determining unit 401, is additionally operable to determine the second mark of data to be deleted.
Second finds unit 407, for the second mark determined according to determining unit 401, is searched from local cache
Data to be deleted, and delete data to be deleted.
Transmitting element 403, is additionally operable to send the request of the 3rd far call to remote storage server, and the 3rd far call please
Ask including the second mark, the 3rd far call asks, for indicating remote storage server according to the second mark, to search and delete
Data to be deleted, determine the communication channel between remote storage server and other application server, and by communication channel to
Other servers send and indicate message, indicate message to be treated for indicating other application server to be deleted from corresponding local cache
Data are deleted, other application server refers to the application clothes set up with remote storage server in application server cluster and be connected
Business device.
The function of each functional module of the embodiment of the present application device, can be by each step of above method embodiment come real
It is existing, therefore, the specific work process of the device that the application is provided is not repeated again herein.
The application server that the embodiment of the present application is provided, determining unit 401 determines data to be written.Memory cell 402 will
In data Cun Chudao local caches to be written.Transmitting element 403 sends the first far call and asks to remote storage server, should
The request of first far call includes data to be written, and the first far call is asked for indicating remote storage server to be written into
In data Cun Chudao remote storage servers.Thus, it is possible to improve the access efficiency of the data of whole application server cluster.
With above-mentioned date storage method accordingly, a kind of remote storage server that the embodiment of the present application is also provided, such as Fig. 5
Shown, the remote storage server includes:
Receiving unit 501, sends out for receiving the first application server after data Cun Chudao local caches are written into
The first far call for sending is asked, and the first application server is for disposing in the application server cluster of same operation system
Any application server, the first far call request includes data to be written.
Memory cell 502, for being asked according to the first far call, stores data to be written.
Alternatively, the first far call request also address including the first application server.
Memory cell 502 specifically for:
According to address, the first application server is searched from control unit;
If finding the first application server, data to be written are stored;
If not finding the first application server, the communication channel with the first application server is set up, be communication channel
Assignment channel is identified, and recording address and the corresponding relation of gap marker in a control unit, stores data to be written.
Alternatively, the remote storage server can also include:First searching unit 503 and transmitting element 504.
Receiving unit 501, is additionally operable to receive the first application server the of the data to be read sent according to called side
One mark, does not find the second far call request sent during data to be read from local cache, and the second far call please
Ask including the first mark.
First searching unit 503, for the first mark received according to receiving unit 501, searches data to be read.
Transmitting element 504, if finding data to be read for the first searching unit 503, to the first application server
Data to be read are returned, for the first application server by data Cun Chudao local caches to be read, and is returned to called side
Return data to be read.
Alternatively, the second far call request also address including the first application server.
First searching unit 503 specifically for:
According to address, the first application server is searched from control unit;
If finding the first application server, according to the first mark, data to be read are searched;
If not finding the first application server, the communication channel with the first application server is set up, be communication channel
Assignment channel is identified, and recording address and the corresponding relation of gap marker in a control unit, is identified according to first, and lookup is continued
Access evidence.
Alternatively, the remote storage server can also include:Second searching unit 505 and acquiring unit 506.
Receiving unit 501, is additionally operable to receive the first application server according to the second of data to be deleted the mark, from local
The 3rd far call request sent after data to be deleted is searched and deleted in caching, and the request of the 3rd far call includes second
Mark.
Second searching unit 505, for the second mark received according to receiving unit 501, searches and deletes number to be deleted
According to.
Acquiring unit 506, for built with remote storage server in the acquisition application server cluster from control unit
The address of the other application server of vertical connection, and obtain the corresponding gap marker in address.
Transmitting element 504, the corresponding communication channel of gap marker for being additionally operable to be obtained by acquiring unit 506 should to other
Sent with server and indicate message, indicate message to be used to indicate other application server to search and delete from corresponding local cache
Except data to be deleted.
The function of each functional module of the embodiment of the present application device, can be by each step of above method embodiment come real
It is existing, therefore, the specific work process of the device that the application is provided is not repeated again herein.
The remote storage server that the embodiment of the present application is provided, receiving unit 501 receives the first application server and will treat
The the first far call request sent after write-in data Cun Chudao local caches, the first application server is same for disposing
Any application server in the application server cluster of operation system, the first far call request includes data to be written.Deposit
Storage unit 502 is asked according to the first far call, stores data to be written.Thus, it is possible to avoid the data focus of prior art
Problem, such that it is able to improve the performance of remote storage server.
Those skilled in the art it will be appreciated that in said one or multiple example, work(described in the invention
Be able to can be realized with hardware, software, firmware or their any combination.When implemented in software, can be by these functions
Storage is transmitted in computer-readable medium or as one or more instructions on computer-readable medium or code.
Above-described specific embodiment, has been carried out further to the purpose of the present invention, technical scheme and beneficial effect
Describe in detail, should be understood that and the foregoing is only specific embodiment of the invention, be not intended to limit the present invention
Protection domain, it is all technical scheme basis on, any modification, equivalent substitution and improvements done etc. all should
It is included within protection scope of the present invention.