Specific embodiment
Performance indicator of the TPS as an expression system processing capacity is generally also write with it come the data of measure database
Enter ability, the data writing capability of different types of database is different.Such as the TPS of single machine oracle is 10,000 or so.
In Third-party payment, with increasing for number of users, Third-party payment real-time deal magnitude increasingly increases, especially
At the time of specific, real-time deal magnitude increases severely, and bottleneck, example has occurred in traditional mode that data are written in real time in the database
The TPS of single machine oracle as stated above is 10,000 or so, it is clear that is unable to satisfy the demand that real-time deal magnitude increasingly increases.
And to solve the above-mentioned problems, the mode generallyd use at present is: increasing on the basis of original storage server
More storage servers, such as increase by three storage servers, it is respectively configured in increased storage server and legacy data
The consistent database of library type, such as the database configured on original storage server A is oracle, then in storage server
B, oracle database is respectively configured on storage server C, storage server D, service server in Third-party payment is generated
Data split, such as data a is split into data a1, data a2, data a3, data a4, data a1 is written and is stored
Storage server B is written in server A, data a2, and storage server C is written in data a3, and storage server D is written in data a4,
Connection schematic diagram is as shown in Figure 1.In this way, will increase hardware cost accordingly, while also adding additional storage server
Maintenance cost.
Technical solution provided by this specification embodiment is pre-configured with and number under the premise of the configuration of original server
According to the corresponding data buffer storage in library, during data write-in, by judging the load state of database, to determine number to be written
According to database is write direct, still store to data buffer storage, it is subsequent that number is written into the data to be written in data buffer storage in idle
According to library.In this way, still can satisfy the demand that real-time deal magnitude increasingly increases in the case where not increasing cost.
Specifically, the technical solution that this specification embodiment provides is as follows:
Be pre-configured with data buffer storage corresponding with database, and configuration work independently from each other the first process, second into
Journey;
First process receives the write data requests that service server issues;It is carried in parsing write data request to be written
Enter data;Whether the load for judging database is more than preset threshold value;If so, storing the data to be written to the data
Caching;Second process determines the load state of database;In the case where determining that the load of database is less than preset threshold value,
The data to be written in the data buffer storage are read, database is written into read data to be written.
In order to make those skilled in the art more fully understand the technical solution in this specification embodiment, below in conjunction with this
Attached drawing in specification embodiment is described in detail the technical solution in this specification embodiment, it is clear that described
Embodiment is only a part of the embodiment of this specification, instead of all the embodiments.The embodiment of base in this manual,
Those of ordinary skill in the art's every other embodiment obtained, all should belong to the range of protection.
Before executing the technical solution that this specification embodiment provides, it is slow to be pre-configured with data corresponding with database
It deposits, and the first process, the second process that configuration works independently from each other;
Generally in the use process of database, in order to sufficiently use some database, generally all a point library can be selected to divide table,
Such as oracle database, multiple points of libraries can be generally established, each there are different tables of data in point library, such as are established
Divide library be DB_1, DB_2 ... DB_N.In the above scenario, it is pre-configured with data buffer storage corresponding with database, as in advance
First configuration divides library corresponding data buffer storage with database, wherein the data buffer storage established can be Cache memory headroom, it can also
To be data buffer storage file, this specification embodiment is not construed as limiting this.By taking data buffer storage file as an example, it is pre-configured with and data
Library divides library corresponding data buffer storage file, i.e. File_1, File_2 ... File_N, and database divides library and data buffer storage file
Corresponding relationship is as shown in Figure 2.
In addition, the first process and the second process that configuration works independently from each other, wherein the first process and the second process
The step of execution, is as follows:
As shown in figure 3, the flow diagram of the method for writing data provided for this specification embodiment, this method can wrap
Include following steps:
S301, the first process receive the write data requests that service server issues;
In the case where original service server and storage server are attached, such as service server and storage server
In the case where A connection, the first process receives the write data requests that service server issues, wherein in synchronization, the first process
Multiple write data requests can be received simultaneously, such as receive 20,000 write data requests.
S302 parses the data to be written carried in write data request;
For the received write data requests of institute in S301, the data to be written carried in write data requests are parsed.Generally write
Request of data has fixed format, and position of the data to be written in write data requests is fixed, it is meant that write data requests
Sender and recipient make an appointment stitching position of the data to be written in write data requests, and the sender of write data requests will
Data to be written splice the designated position into write data requests, the spelling that the recipient of subsequent write data requests arranges according to both sides
Position is connect, parses data to be written from the designated position in write data requests.For example, in the case where paying scene, data to be written
It can be transaction data, transaction data can be transaction journal number, beneficiary ID, beneficiary account, paying party ID, paying party account
Family, spending amount etc..
S303 judges whether the load of database is more than preset threshold value;
Generally with TPS come the data writing capability of measure database, it is meant that there are upper for the every second data writing of database
Limit, for example, the TPS for clicking oracle is 10,000 or so, if the every second data writing of database is more than the upper limit, database is super negative
Lotus operation, may cause database corruption, can not provide data write-in or reading service, it is therefore desirable to determine the load of database
Situation judges whether the load of database is more than preset threshold value.
The TPS of different types of database is different, and threshold value can be set with reference to the type of the database of actual use
It sets, such as by taking oracle database as an example, the TPS of oracle database is 10000, and threshold value then can be the write-in upper limit per second
10000 (threshold value being generally arranged can be slightly less than the TPS of database, such as 9500), accordingly judge database load whether
More than preset threshold value, it can be and judge whether the every second data writing of current database is more than the preset write-in upper limit per second
10000, such as database is oracle, the current every second data writing of oracle database is 9000, oracle database
TPS is 10000, it is evident that the load of database is less than preset threshold value.
S304, if so, storing the data to be written to the data buffer storage;
For the judging result in S303, if the load of database is more than preset threshold value, then it represents that database may be
Overload operation needs the data to be written that script will be written to database temporarily to store to data buffer storage.
During wherein data to be written are temporarily stored to data buffer storage, such as database point library DB_1 to be written originally
Data to be written, temporarily store to data buffer storage file File_1 corresponding with database point library DB_1, number to be written originally
The data to be written for dividing library DB_2 according to library are temporarily stored to data buffer storage file File_2 corresponding with database point library DB_2,
And so on.
It wherein stores to before data buffer storage being written into data, determines the corresponding type of service of write data requests, sentence
Whether the disconnected corresponding type of service of write data requests meets default rule, if the load of database is more than preset threshold value and writes
The corresponding type of service of request of data meets default rule, is written into data and temporarily stores to data buffer storage.Wherein it is worth
It is noted that whether the load for judging database is more than preset threshold value and determines the corresponding type of service of write data requests,
Judge whether the corresponding type of service of write data requests meets default rule, the two does not have strict sequence, can also be with
It is to first carry out the former, then executes the latter, or first carry out the latter, then executes the former, or both and be performed simultaneously, this explanation
Book is not construed as limiting this.
For the business of certain particular traffic types, can according to real-time (real-time indicate be business generate to
Write-in data whether need that database is written in real time) divided rank, for the business of certain particular traffic types, generation it is to be written
Enter data and need write-in database in real time, which can be divided into the first estate (highest priority), for certain
The data to be written of the business of particular traffic type, generation do not have higher demand for real-time, can be by the type of service
It is divided into the second grade (weak priority), and so on, it can divided rank according to actual needs.Therefore data are write in above-mentioned judgement
Request whether corresponding type of service meets default rule, can be judge the corresponding type of service of write data requests whether
The first estate or the second grade.
Database load be more than preset threshold value and data to be written without write-in database in real time in the case where,
Data can be written into temporarily to store to data buffer storage.
In addition, indicating that database operates normally if the load of database is less than preset threshold value, then can be written into
Data write direct database, it is not necessary to consider the factor of above-mentioned real-time.
S305, the second process determine the load state of database;
For the data to be written in data buffer storage, database can be written in idle, i.e. the load of database is less than
Be written database in the case where preset threshold value, thus the second process it needs to be determined that database load state, it is specific to determine
There are following manner for the load state of database:
One: the second process of mode judges whether the load of database is more than preset threshold value according to the preset period, with true
Determine the load state of database.Such as second process it is primary every the judgement of 6 hours, to determine the load state of database.
Two: the second process of mode receives whether the load for database that the first process is sent is more than sentencing for preset threshold
It is disconnected as a result, according to the first process judge database load whether be more than preset threshold as a result, load shape to determine database
Condition.Such as first process judge that the load of database is less than preset threshold value, this result is sent to the second process, second into
Journey receives judging result, determines that the load of database is less than preset threshold value.
S306 is read in the data buffer storage in the case where determining that the load of database is less than preset threshold value
Database is written in read data to be written by data to be written.
For the load state of database identified in S305, preset threshold value is less than in the load for determining database
In the case where, the data to be written in data buffer storage are read, it will be in the data to be written write-in database of reading.
Wherein during database is written in the data to be written that will read, such as from database caches file File_1
Data to be written are read, database corresponding with database caches file File_1 is written into the data to be written of reading and divides library
DB_1 reads data to be written from database caches file File_2, data to be written write-in and database caches by reading
The corresponding database of file File_2 divides library DB_2, and so on.
By the description of the above-mentioned technical solution provided this specification, under the premise of the configuration of original server, in advance
Data buffer storage corresponding with database is configured, during data write-in, by judging the load state of database and sentencing
Whether the disconnected corresponding type of service of write data requests meets default rule, to determine that data to be written write direct database,
Still temporarily store to data buffer storage, it is subsequent in idle (in the case that the load of database is less than preset threshold value) by data
Database is written in data to be written in caching.In this way, still can satisfy real-time friendship in the case where not increasing cost
The demand that easy magnitude increasingly increases.
Relative to the technical solution of above-mentioned offer, this specification embodiment provides another technical solution, and the second process can
To receive the data buffer storage data read command of user's input, i.e., triggered by artificial mode to be written in reading data buffer storage
Enter data, database is written in the data to be written of reading by subsequent second process, slow as data corresponding with database are configured
It deposits, the operation for configuring the first process and the execution of the first process is similar with above-mentioned technical proposal, and this is no longer going to repeat them.
Relative to above method embodiment, this specification embodiment also provides a kind of data transfer apparatus, as shown in figure 4,
It may include: request receiving module 410, request analysis module 420, judgment module 430, data memory module 440, determining module
450, data read module 460, Data write. module 470.
Request receiving module 410 receives the write data requests that service server issues for the first process;
Request analysis module 420, for parsing the data to be written carried in write data request;
Judgment module 430, for judging whether the load of database is more than preset threshold value;
Data memory module 440, for if so, storing the data to be written to the data buffer storage;
Determining module 450 determines the load state of database for the second process;
Data read module 460, for reading institute in the case where determining that the load of database is less than preset threshold value
State the data to be written in data buffer storage;
Data write. module 470, for database to be written in read data to be written.
According to a kind of specific embodiment that this specification provides, the data memory module 440 is specifically used for:
Determine that write data request corresponding type of service;
Judge that write data request whether corresponding type of service meets default rule;
If the load of database is more than that request corresponding type of service to meet preset for preset threshold value and write data
Rule stores the data to be written to the data buffer storage.
According to a kind of specific embodiment that this specification provides, described device further include:
Writing module 480 directly writes the data to be written if the load for database is less than preset threshold value
Enter database.
According to a kind of specific embodiment that this specification provides, the determining module 450 is specifically used for:
Second process judges whether the load of database is more than preset threshold value according to the preset period, to determine database
Load state.
According to a kind of specific embodiment that this specification provides, the determining module 450 is specifically used for:
Second process receive the first process send for database load whether be more than preset threshold judging result,
To determine the load state of database.
The function of modules and the realization process of effect are specifically detailed in the above method and correspond to step in above-mentioned apparatus
Realization process, details are not described herein.
By the description of the above-mentioned technical solution provided this specification, under the premise of the configuration of original server, in advance
Data buffer storage corresponding with database is configured, during data write-in, by judging the load state of database and sentencing
Whether the disconnected corresponding type of service of write data requests meets default rule, to determine that data to be written write direct database,
Still temporarily store to data buffer storage, it is subsequent in idle (in the case that the load of database is less than preset threshold value) by data
Database is written in data to be written in caching.In this way, still can satisfy real-time friendship in the case where not increasing cost
The demand that easy magnitude increasingly increases.
This specification embodiment also provides a kind of computer equipment, as shown in figure 5, the equipment may include: processor
510, memory 520, input/output interface 530, communication interface 540 and bus 550.Wherein processor 510, memory 520,
Input/output interface 530 and communication interface 540 pass through the communication connection between the realization of bus 550 inside equipment.
Processor 510 can use general CPU (Central Processing Unit, central processing unit), micro process
Device, application specific integrated circuit (Application Specific Integrated Circuit, ASIC) or one or
The modes such as multiple integrated circuits are realized, for executing relative program, to realize technical solution provided by this specification embodiment.
Memory 520 can use ROM (Read Only Memory, read-only memory), RAM (Random Access
Memory, random access memory), static storage device, the forms such as dynamic memory realize.Memory 520 can store
Operating system and other applications are realizing technical solution provided by this specification embodiment by software or firmware
When, relevant program code is stored in memory 520, and execution is called by processor 510.
Input/output interface 530 is for connecting input/output module, to realize information input and output.Input and output/
Module can be used as component Configuration (not shown) in a device, can also be external in equipment to provide corresponding function.Wherein
Input equipment may include keyboard, mouse, touch screen, microphone, various kinds of sensors etc., output equipment may include display,
Loudspeaker, vibrator, indicator light etc..
Communication interface 540 is used for connection communication module (not shown), to realize the communication of this equipment and other equipment
Interaction.Wherein communication module can be realized by wired mode (such as USB, cable etc.) and be communicated, can also be wirelessly
(such as mobile network, WIFI, bluetooth etc.) realizes communication.
Bus 550 includes an access, in various components (such as the processor 510, memory 520, input/output of equipment
Interface 530 and communication interface 540) between transmit information.
It should be noted that although above equipment illustrates only processor 510, memory 520, input/output interface
530, communication interface 540 and bus 550, but in the specific implementation process, which can also include realizing to operate normally
Necessary other assemblies.In addition, it will be appreciated by those skilled in the art that, it can also be only comprising realizing in above equipment
Component necessary to this specification example scheme, without including all components shown in figure.
This specification embodiment also provides a kind of computer readable storage medium, is stored thereon with computer program, the journey
Method for writing data above-mentioned is realized when sequence is executed by processor.This method includes at least:
A kind of method for writing data is pre-configured with data buffer storage corresponding with database, and configuration works independently from each other
The first process, the second process, this method comprises:
First process receives the write data requests that service server issues;
The data to be written carried in parsing write data request;
Whether the load for judging database is more than preset threshold value;
If so, storing the data to be written to the data buffer storage;
Second process determines the load state of database;
In the case where determining that the load of database is less than preset threshold value, read to be written in the data buffer storage
Database is written in read data to be written by data.
Computer-readable medium includes permanent and non-permanent, removable and non-removable media can be by any method
Or technology come realize information store.Information can be computer readable instructions, data structure, the module of program or other data.
The example of the storage medium of computer includes, but are not limited to phase change memory (PRAM), static random access memory (SRAM), moves
State random access memory (DRAM), other kinds of random access memory (RAM), read-only memory (ROM), electric erasable
Programmable read only memory (EEPROM), flash memory or other memory techniques, read-only disc read only memory (CD-ROM) (CD-ROM),
Digital versatile disc (DVD) or other optical storage, magnetic cassettes, tape magnetic disk storage or other magnetic storage devices
Or any other non-transmission medium, can be used for storage can be accessed by a computing device information.As defined in this article, it calculates
Machine readable medium does not include temporary computer readable media (transitory media), such as the data-signal and carrier wave of modulation.
As seen through the above description of the embodiments, those skilled in the art can be understood that this specification
Embodiment can be realized by means of software and necessary general hardware platform.Based on this understanding, this specification is implemented
Substantially the part that contributes to existing technology can be embodied in the form of software products the technical solution of example in other words,
The computer software product can store in storage medium, such as ROM/RAM, magnetic disk, CD, including some instructions are to make
It is each to obtain computer equipment (can be personal computer, server or the network equipment etc.) execution this specification embodiment
Method described in certain parts of a embodiment or embodiment.
System, device, module or the unit that above-described embodiment illustrates can specifically realize by computer chip or entity,
Or it is realized by the product with certain function.A kind of typically to realize that equipment is computer, the concrete form of computer can
To be personal computer, laptop computer, cellular phone, camera phone, smart phone, personal digital assistant, media play
In device, navigation equipment, E-mail receiver/send equipment, game console, tablet computer, wearable device or these equipment
The combination of any several equipment.
All the embodiments in this specification are described in a progressive manner, same and similar portion between each embodiment
Dividing may refer to each other, and each embodiment focuses on the differences from other embodiments.Especially for device reality
For applying example, since it is substantially similar to the method embodiment, so describing fairly simple, related place is referring to embodiment of the method
Part explanation.The apparatus embodiments described above are merely exemplary, wherein described be used as separate part description
Module may or may not be physically separated, can be each module when implementing this specification example scheme
Function realize in the same or multiple software and or hardware.Can also select according to the actual needs part therein or
Person's whole module achieves the purpose of the solution of this embodiment.Those of ordinary skill in the art are not the case where making the creative labor
Under, it can it understands and implements.
The above is only the specific embodiment of this specification embodiment, it is noted that for the general of the art
For logical technical staff, under the premise of not departing from this specification embodiment principle, several improvements and modifications can also be made, this
A little improvements and modifications also should be regarded as the protection scope of this specification embodiment.