A kind of real-time data base ordering system and method
Technical field
The present invention relates to a kind of data processing technique, is ordered more particularly, to the low real-time data base of a kind of efficiency high, cost
Read system and method.
Background technology
In traditional real-time dataBase system, the position number of client request is subscribed to using directly inquiry or entirety more,
By servicing the mode for oneself preserving whole subscription information.Direct search efficiency is low, and does not support to send in change, wastes network flow
Amount;Overall subscription is the method that most of real-time data bases use at present, although supporting to send in change, subscription information amount is larger
When, it is difficult to safeguard subscription information, and when subscription service exception or after restart, client need to subscribe to again, lose time,
And this scheme, in master-slave redundancy, two subscription services are unaware of mutually other side, client is integrally ordered to 2 subscription services
A number is read, judges which data used by client when above sending, wasting space efficiency, adds client cost.
The content of the invention
The present invention mainly solve prior art middle position ordering system exist waste network traffics, wasting space efficiency,
A kind of the problem of increasing cost, there is provided the low real-time data base ordering system of efficiency high, cost.
Present invention also offers a kind of real-time data base method for subscribing.
The above-mentioned technical problem of the present invention is mainly what is be addressed by following technical proposals:A kind of real-time data base is ordered
System, including some clients, master server, cache database are read, the master server includes some real-time data bases, position number
Distribution service module is subscribed to, client is subscribed to distribution service module by system bus with position number and is connected respectively, real-time data base
Distribution service module is subscribed to position number respectively to be connected, position number is subscribed to distribution service module and is connected with cache database;
Client:Request is initiated or unsubscribed, is stored with and subscribes to position number block;
Subscribe to distribution service module in position number:Receive the data sent in real-time data base real-time change and client subscription or take
Disappear subscription request, and foundation has n slot data, for depositing the subscription information of client;
Buffer DB:Foundation has n slot data, for depositing the subscription information of client.The cache database uses
Distributed key-value cache databases, also known as NoSQL(Not only SQL)Database, one kind can quickly access character
Or the index data base of binary data structure, support redundancy and distribution.Subscription information is divided groove to place by present system, carefully
Point subscription information, minimizes every piece of information, the redundancy and storage problem for solving subscription information, though servers off-line or
Delay machine, subscription information is still stored in cache database, under redundancy services, is effectively reduced using groove algorithm is divided because of client
The data volume subscribed to the change of position number and synchronized.Divide the algorithm of groove storage to reduce time complexity, reach service
The subscription visit capacity of million ranks, more centrally stored than existing, the access mode of order traversal improves very big efficiency.
As a kind of preferred scheme, also include some standby servers, standby server includes some real-time data bases, position
Number subscribe to distribution service module, client by system bus respectively with position number subscribe to distribution service module be connected, real time data
Storehouse is subscribed to distribution service module with position number and is connected respectively, and position number is subscribed to distribution service module and is connected with distributed caching database.
Standby server has one or more, the real-time data base that it includes and master server, other for server real-time data base
It is the same, i.e., master server, the position number of some servers subscribe to distribution service and be connected to same real-time data base.This programme
Structure constitutes the hot standby patterns for servicing and depositing more:Client forget it position number subscribe to distribution service module quantity and it
Health status, as long as subscribing to distribution service module can with the presence of position number provides service, improve given in data and
Successful reliability is subscribed to, compared with the neutral gear phase that traditional active-standby switch presence can not service, security further improves.Together
When this programme cause network and amount of calculation load average, when exist 2 or more position number subscribe to distribution service module be distributed in
During different server, delta data can subscribe to distribution service module by different positions number by different server and send to client
End, improves and send efficiency and resource utilization, fully sharp compared with the completely idle idle state of traditional standby server
With existing resource.Further, since subscription information is placed in distributed cache system, add same between active and standby subscription service
Step, and the same time is only had a subscription service and changed data to client, reduce the amount of sending in 50% data,
Directly reduce client cost and network cost.
A kind of real-time data base method for subscribing, including subscription step, unsubscribe step, change on send step;
Subscription step includes:Processing client pulls subscription the slot data number that position number obtains being put into, and will subscribe to position number and visitor
Family client information is written in cache database slot data, finally informs that the real-time data base position number needs to send in change;
Unsubscribing step includes:The processing client position number that pulls subscription obtains slot data number, and checking in local data groove is
It is no to have the position number, associated if there is then deleting with the client-side information, and synchronization caching database data groove;
Step is sent to include in change:Real-time data base is changed in data to the position number having subscribed to and sent, and divides subscribing to
After hair service module receives a number, handle the position number and obtain slot data number, check in cache database slot data whether deposit
In the position number, if there is the positions number, all clients associated by this number are traveled through, send the data to client successively,
Such as it is not present, is then sent in stopping, abandoning data.Subscription information is divided groove to place by the present invention, segments subscription information, makes every piece of letter
Breath minimizes, and solves the redundancy and storage problem of subscription information, even if servers off-line or machine of delaying, subscription information still stores
In cache database, under redundancy services, carried out using dividing groove algorithm effectively to reduce because of the change of client subscription position number
Synchronous data volume.Divide the algorithm of groove storage to reduce time complexity, service has been reached the subscription visit capacity of million ranks,
More centrally stored than existing, the access mode of order traversal improves very big efficiency.
As a kind of preferred scheme, subscription step, unsubscribe and send processing client request in step to order in step and change
The process for readding position number is:Position Hash will be subscribed to, obtains a cryptographic Hash s, an Integer n will be removed more than cryptographic Hash s, obtain integer
Value a, integer value a corresponding data grooves number.Here Integer n is corresponding with the n slot data established.N is according to the network user and band
Wide needs are set.
As a kind of preferred scheme, also include synchronizing process in subscription step, synchronizing process is:
A. after slot data number is obtained, check local data groove and cache database slot data digital signature whether one
Cause;Local data groove refers to server data groove.
If b. consistent, position number and client-side information write-in local data groove will be subscribed to, while recalculate local data
Groove digital signature is simultaneously stored in local data groove, then synchronous local data groove and cache database slot data content;Here it is synchronous
Local data groove and cache database slot data content are that will subscribe to position number and client-side information write-in in above-mentioned subscription step
Into cache database slot data, also digital signature is also written in cache database slot data in addition.
If c. inconsistent, local data groove content is deleted, local data groove is loaded into cache database slot data content, so
Continue step b afterwards.
As a kind of preferred scheme, unsubscribe also includes checking whether the position number also has other clients to close in step
Connection, if any not doing other operations then, by not cache database after preservation, all information of this number are deleted if not, and
Inform that real-time data base stops sending in the change of the position number.
Therefore, it is an advantage of the invention that:1. dividing groove to place subscription information, subscription information is segmented, makes every piece of information most
Smallization, solve the redundancy and storage problem of subscription information, even if servers off-line or machine of delaying, subscription information is still stored in slow
In deposit data storehouse, under redundancy services, synchronized using dividing groove algorithm effectively to reduce because of the change of client subscription position number
Data volume.Divide the algorithm of groove storage to reduce time complexity, service has been reached the subscription visit capacity of million ranks, than existing
What is had is centrally stored, and the access mode of order traversal improves very big efficiency.The hot standby pattern for servicing more and depositing 2., client
Hold position number of forgetting it to subscribe to the quantity and its health status of distribution service module, taken as long as there is a position number to subscribe to distribution
There is can and provide service in business module, improve and successful reliability is sent and subscribed in data, deposited with traditional active-standby switch
Compared in the neutral gear phase that can not be serviced, security further improves.3. network and amount of calculation load average, when exist 2 or with
On position number subscribe to distribution service module when being distributed in different server, delta data can pass through different server by different
Position number is subscribed to distribution service module and sent to client, improves and send efficiency and resource utilization, with traditional standby server
Complete idle idle state is compared, and takes full advantage of existing resource.4. because subscription information is placed on distributed caching system
In system, the synchronization between active and standby subscription service is added, and the same time is only had a subscription service and becomes to client
Change data, reduce the amount of sending in 50% data, directly reduce client cost and network cost.
Brief description of the drawings
Accompanying drawing 1 is a kind of structural framing schematic diagram of present system;
Accompanying drawing 2 is a kind of schematic flow sheet of subscription step in the inventive method;
Accompanying drawing 3 is a kind of schematic flow sheet that step is unsubscribed in the inventive method;
Accompanying drawing 4 is a kind of schematic flow sheet for sending step in the inventive method in change.
1- clients 2- master servers 3- subscribes to distribution service module 6- for server 4- cache database 5- positions number
Real-time data base.
Embodiment
Below by embodiment, and with reference to accompanying drawing, technical scheme is described in further detail.
Embodiment:
A kind of real-time data base ordering system of the present embodiment, as shown in figure 1, including some clients 1, master server 2, delaying
Deposit data storehouse 4 and standby server 2, standby server can have it is multiple, here by taking a standby server as an example, master server and standby
Server all includes position number subscription distribution service module 5, and two positions number are subscribed to distribution service modules and counted in real time with some respectively
It is connected according to storehouse 6, cache database is subscribed to distribution service module with two positions number and is connected respectively, and some clients then pass through
System bus is connected respectively to two positions number and subscribed on distribution service module.
Client is used to initiating or unsubscribing request, is stored with and subscribes to position number.
Subscribe to distribution service module and be used to receive data and the client subscription sent in real-time data base real-time change in position number
Or request is unsubscribed, position number, which is subscribed to distribution service module and established, n slot data, for depositing the subscription information of client.
Buffer DB:Foundation has n slot data, for depositing the subscription information of client.Cache database, which uses, to be divided
Cloth key-value cache databases, also known as NoSQL(Not only SQL)Database, one kind can quickly access character or
The index data base of binary data structure, support redundancy and distribution.
The method for subscribing of real-time data base ordering system include subscription step, unsubscribe step, change on send step.
As shown in Fig. 2 subscription step includes:
Step 11:Client is initiated to subscribe to request, and the position number to pull subscription and customer terminals are sent to master by client
Server or standby server middle position number subscribe to distribution service module;
Step 12:After position number subscription distribution service module receives subscription request, first look in real-time data base and whether deposit
In the position number;
Step 13:As otherwise put back to step 11, if then Hash position number, a cryptographic Hash s is obtained, more than cryptographic Hash s
Except an Integer n, integer value a is obtained, integer a seeks to the slot data number of deposit;Assuming that master server, standby server, slow
10 slot datas are established in deposit data storehouse, as Hash obtains cryptographic Hash 10003, it is remaining remove 10 after obtain integer 3, then obtain slot data number
3。
Step 14:Corresponding data groove location is found according to slot data number, checks local data groove and cache database number
It is whether consistent according to the digital signature of groove;
Step 15:If so, will then subscribe to position number and client-side information write-in local data groove, while recalculate local number
According to groove digital signature, data signature is stored in local data groove, then synchronous local data groove and cache database slot data content,
Finally inform that the real-time data base position number needs to send in change;
Step 16:If it is not, then deleting local data groove content, local data groove is loaded into cache database slot data content,
It is then back to step 15.
As shown in figure 3, unsubscribe step:
Step 21:Client is initiated to unsubscribe request, and client sends the position number to pull subscription and customer terminals
Distribution service module is subscribed to master server or standby server middle position number;
Step 22:Check that local data groove whether there is the position number;
Step 23:If it is not, it can not then unsubscribe, if so, then Hash position number, obtains a cryptographic Hash s, by cryptographic Hash
S is remaining to remove an Integer n, obtains integer value a, and integer a seeks to the slot data number of deposit, finds corresponding local data groove,
Delete associating for this number and the client-side information;
Step 24:Check whether the position number also has and other client associates;
Step 25:If so, do not do other operations then, synchronization caching database after preservation, if it is not, then deleting the institute of this number
There is information, and inform that real-time data base stops sending in the change of the position number.
As shown in figure 4, step is sent to include in change:
Step 31:Sent in real-time data base change, delta data sends to the position number of master server or standby server and subscribed to
Distribute service module;
Step 32:The Hash position number, a cryptographic Hash s is obtained, an Integer n will be removed more than cryptographic Hash s, obtain integer value a,
Integer a seeks to the slot data number of deposit;
Step 33:The slot data number groove is found in cache database, checks that slot data whether there is the position number;
Step 34:If it is not, being sent on stopping, data are abandoned, if so, all clients associated by this number are then traveled through, according to
It is secondary to send the data to client.
Specific embodiment described herein is only to spirit explanation for example of the invention.Technology belonging to the present invention is led
The technical staff in domain can be made various modifications or supplement to described specific embodiment or be replaced using similar mode
Generation, but without departing from the spiritual of the present invention or surmount scope defined in appended claims.
Although client, master server, standby server, cache database, position number has more been used to subscribe to distribution herein
The terms such as service module, but it is not precluded from the possibility using other terms.Using these terms just for the sake of more easily
Describe and explain the essence of the present invention;Being construed as any additional limitation is disagreed with spirit of the present invention
's.