The content of the invention
In view of the above problems, it is proposed that the present invention so as to provide one kind overcome the problems referred to above or at least in part solve on
State server method of attachment and the server system of problem.
According to one aspect of the present invention, there is provided a kind of server method of attachment, after WEB server is connected to
End server, the method includes:Whether Web server inspection is locally cached with back-end server cluster-list;If not caching
The back-end server cluster-list, then the Web server back-end server collection series is obtained by configuration server
Table simultaneously carries out local cache;If being cached with the back-end server cluster-list, the Web server obtains the rear end of caching
Server set group-list simultaneously selects to specify back-end server from the back-end server cluster-list of the caching;The Web clothes
Business device is directly connected to the specified back-end server.
Alternatively, methods described also includes:The Web server sends data processing request to the specified back-end services
Device, and wait the result of the specified back-end server return.
Alternatively, when the back-end server cluster-list changes, the Web server is by the configuration service
Server set group-list after device more new change simultaneously updates local cache.
Alternatively, the configuration server is obtained by transferring the application programming interface of the back-end server cluster
The back-end server cluster-list.
Alternatively, the configuration server reads at set time intervals the application programming interface to judge
Whether the back-end server cluster-list changes, and updates the rear end clothes of its acquisition according to situation of change if changing
Business device cluster-list.
Alternatively, the Web server selects the method for given server to adopt from the back-end server cluster-list
With random selection.
Alternatively, the Web server selects the method for given server to adopt from the back-end server cluster-list
Use load-balancing method.
Alternatively, the load-balancing method includes:The Web server calculates the back-end server by formula below
The load value of each back-end server in cluster-list:The load value of back-end server=k1*cpu usage amount+k2* processors
Performance+k3* internal memory surplus+k4* bandwidth resources;Wherein, the k1 is the weights corresponding to cpu usage amounts, and the k2 is process
Weights corresponding to device performance, the k3 is the weights corresponding to internal memory surplus, and the k4 is the weights corresponding to bandwidth resources;
The Web server selects the minimum back-end server of load value as specified back-end server.
According to a further aspect in the invention, there is provided a kind of server system, the system includes Web server and configuration clothes
Business device:The configuration server, for obtaining back-end server cluster-list;The Web server, for check it is local whether
It is cached with back-end server cluster-list;If the back-end server cluster-list is not cached, from the configuration server
Obtain the back-end server cluster-list and carry out local cache;If being cached with the back-end server cluster-list, obtain
Take the back-end server cluster-list of caching and therefrom select to specify back-end server, be directly connected to the specified back-end services
Device.
Optionally, the Web server includes that list acquisition module, list cache module, server choose module kimonos
Business device link block:The list acquisition module, for checking whether the Web server is locally cached with back-end server collection
Group-list, if not caching the back-end server cluster-list, by the configuration server back-end services is obtained
Device cluster-list;The list cache module, for by the back-end server cluster acquired in the list acquisition module
List carries out local cache;The server chooses module, for the back-end server cached from the list cache module
Select to specify back-end server in cluster-list;The server-connection module, for connecting the specified back-end server.
Alternatively, the Web server also includes data processing module, and the data processing module is used to send at data
Reason request waits the specified back-end server process to terminate to the specified back-end server, and result is back to
The data processing module.
Alternatively, the configuration server is obtained by transferring the application programming interface of the back-end server cluster
The back-end server cluster-list.
Alternatively, the configuration server reads at set time intervals the application programming interface to judge
Whether the back-end server cluster-list changes, and updates the rear end clothes of its acquisition according to situation of change if changing
Business device cluster-list.
A kind of server method of attachment according to embodiments of the present invention can be seen that company of the disclosure based on configuration server
The method of connecing eliminates the connection processing procedure of LVS, thereby reduces the network service time in request process is processed, and solves
The problem that Web server is waited as long for after LVS breaks in prior art.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention,
And can be practiced according to the content of description, and in order to allow the above and other objects of the present invention, feature and advantage can
Become apparent, below especially exemplified by the specific embodiment of the present invention.
Specific embodiment
The exemplary embodiment of the disclosure is more fully described below with reference to accompanying drawings.Although showing the disclosure in accompanying drawing
Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure and should not be by embodiments set forth here
Limited.On the contrary, there is provided these embodiments are able to be best understood from the disclosure, and can be by the scope of the present disclosure
Complete conveys to those skilled in the art.
As shown in Fig. 2 when Web server needs and back-end server, such as the 2nd in certain data-base cluster data base
When entering row data communication, first have to check locally whether be cached with back-end server cluster-list, if not finding local cache
Back-end server cluster-list, then obtain back-end server cluster-list by configuration server from back-end server cluster,
And be buffered in the list locally;When Web server obtains back-end server cluster-list from local cache, according to certain plan
The data base 2 of back-end server, Web server is slightly selected to be directly connected to the data base 2 for choosing, being sent to data processing please
Ask, and wait pending end.It is, for example, zookeeper configuration servers based on the configuration server used by the principle,
Zookeeper is mono- realization increased income of Chubby of Google, is high effective and reliable cooperative operation system, at one point
In the environment of cloth, need a Master example or store some configuration informations, it is ensured that concordance of file write etc..
Zookeeper is one distributed, the distributed application program coordination service of open source code, comprising a simple primitive
Collection, is the significant components of Hadoop and Hbase.Distributed Application can use it to realize such as:Uniform Name service, configuration
The functions such as management, distributed lock service, cluster management.Each node in Zookeeper is called znode, and it has one
Individual unique ID of trace route path, znode be one with the similar node in Unix file system path, can toward the storage of this node or
Obtain data.If create znode when Flag be set to EPHEMERAL, then when create this znode node and
Zookeeper is lost after connection, and this znode there would not be in Zookeeper.Zookeeper is discovered using Watcher
Event information, when client receives event information, such as connects time-out, and node data changes, and child node changes, and can call
Corresponding behavior carrys out processing data.The basic operating flow process of ZooKeeper is:1. Leader is elected;2. synchrodata;3. elect
There is much algorithm, but the election criterion to be reached is consistent during Leader;4. Leader will have highest zxid;⑤
The Leader that most machine meets with a response and follow is selected in cluster.
Load-balancing algorithm can be adopted suitable for the policy selection of the principle of the invention, it is commonly used in load-balancing algorithm
Have a stochastic selection algorithm, stochastic selection algorithm be with load-balancing method it is random load is assigned to each available server
On, a server is chosen by Generating Random Number, then give it linkup transmit;Also commonly used can be that poll is calculated
Method, polling algorithm distributes to next server each new connection request in order, and finally all requests are divided equally to institute
Some servers, it is good that polling algorithm in most of the cases all works, but if the equipment of load balancing is processing speed
The aspects such as degree, connection speed and internal memory are not complete equalizations, then effect can be more preferable, certainly, further, it is possible to use be related to
Weight proportion distribution receives the Weighted Round Robin of connection quantity, it is also possible to using persistently monitoring to weighted value and constantly update
Dynamic polling algorithm;Also commonly used is minimum join algorithm, and system distributes to the minimum clothes of current linking number new connection
Business device.The algorithm is highly effective in the environment of each server operation ability basic simlarity.For example, current system has individual 20
Search engine server, 1 director server, 1 standby director server and a web server, wherein, each search engine clothes
Business device is responsible for a part of search mission in general index, and director server is responsible for sending to search for this 20 search engine servers asking
Ask and amalgamation result collection, standby director server is responsible for replacing director server automatically when director server delays machine.When web server
CGI (Common Gateway Interface) to director server send searching request when, it is assumed that in search engine server
15 servers there is presently provided search service, and 5 search engine servers are being generated index, can protected using Zookeeper
How many provides the server of search engine and sends searching request to these servers card director server automatic sensing, this 20
Search engine server Jing will often allow the server stopping offer service for providing search service to start to generate index, or generate
The server of index completes index generation to may search for offer to service.
Fig. 3 show one embodiment of the present of invention, and its principle is consistent with shown in Fig. 2, specifically, a kind of server connection
Method, for WEB server to be connected to back-end server, the method includes:
Whether step S110, Web server inspection is locally cached with back-end server cluster-list, if not caching,
Execution step S120, if there is caching, execution step S130;
Step S120, Web server obtains back-end server cluster by configuration server from back-end server cluster
List simultaneously carries out local cache, and the configuration server is based on the configuration server of zookeeper, by transferring back-end server
The application programming interface (API, Application Programming Interface) of cluster obtains back-end server collection
Group-list, configuration server reads at set time intervals application programming interface (API) to judge back-end server
Whether cluster-list changes, and updates the back-end server cluster-list of its acquisition according to situation of change if changing,
And be buffered in the back-end server cluster-list after renewal locally, certainly, configuration server can also be by manager to it
It is manually entered or updates back-end server cluster-list;
Step S130, Web server obtains the back-end server cluster-list of caching and from the back-end services of the caching
Select to specify back-end server in device cluster-list, this system of selection can be using random selection, it would however also be possible to employ load is equal
The method of accounting is selected, and load-balancing algorithm can be that Web server is by formula below computational back-end server set group-list
Each back-end server load value:
The load value of back-end server=k1*cpu usage amount+k2* processor performance+k3* internal memory surplus+k4* bandwidth money
Source;
Wherein, weights of the k1 corresponding to cpu usage amounts, weights of the k2 corresponding to processor performance, institute
The weights that k3 is stated corresponding to internal memory surplus, the k4 is the weights corresponding to bandwidth resources, and these weights all can be basis
What needs were manually set;Web server selects the minimum back-end server of load value as specified back-end server;Such as backstage
There are 3 data bases in server set group-list, the load value=0.5+0.8+ of data base 1 after each parameter uses normalized
0.6+0.7=2.6;Load value=the 0.6+0.8+0.7+0.7=2.8 of data base 2;Load value=the 0.8+0.7+ of data base 3
0.3+0.7=2.5, then the minimum data base 3 of Web server selection load value is used as specified back-end server;
Step S140, Web server is directly connected to specify back-end server;
Step S150, Web server sends data processing request to the specified back-end server, and waits rear end to be specified to take
The result that business device is returned.
By the present embodiment it is found that when Web server and back-end server need to carry out data processing to exchange, not having
In the case of having back-end server cluster-list, back-end server cluster-list can be obtained by zookeeper configuration servers,
So that Web server directly can be connected with back-end server makes requests on process, network processes link has been lacked one, has been not required to
Will through intermediate link Web server can with back-end server Direct Communication, hence it is evident that improve treatment effeciency.In addition, rear
In the case that end server process is not over, Web server can wait the process of back-end server, without there is connection
Broken situation about but not perceiving.Using zookeeper configuration servers, another benefit is, when back-end server collection series
When table changes, zookeeper configuration servers can in time obtain update content and notify that Web server is locally delayed
The renewal deposited.
Fig. 4 show an alternative embodiment of the invention, is based on a kind of server system of Fig. 2 principles, the system bag
Configuration server 310 and Web server 320 are included, wherein, configuration server 310 is used to obtain back-end server cluster-list;
Web server 320 locally whether be cached with back-end server cluster-list for checking;If not caching back-end server cluster
List, then obtain back-end server cluster-list and carry out local cache from configuration server 310;If being cached with back-end server
Cluster-list, then obtain the back-end server cluster-list of caching and therefrom select to specify back-end server, is directly connected to this and refers to
Determine back-end server and enter row data communication.Configuration server 310 is connect by transferring the application programming of back-end server cluster
Mouth (API) obtains back-end server cluster-list, and application programming interface (API) is read at set time intervals to sentence
Whether end server set group-list of having no progeny changes, and updates the back-end services of its acquisition according to situation of change if changing
Device cluster-list.
Further, Web server includes that list acquisition module 321, list cache module 322, server choose module
323rd, server-connection module 324 and data processing module 325, wherein, list acquisition module 321 is used to check Web server
Whether 320 be locally cached with back-end server cluster-list, if not caching back-end server cluster-list, by configuring clothes
Business device 310 obtains back-end server cluster-list;List cache module 322 is used for after acquired in list acquisition module 321
End server set group-list carries out local cache;Server chooses module 323 for after being cached from list cache module 322
Select to specify back-end server in the server set group-list of end;Server-connection module 324 is used to connect specified back-end server;
Data processing module 325 is used to send data processing request to specified back-end server, and waits back-end server to be specified to process
Terminate, result is back to into data processing module.
It should be noted that algorithm provided in an embodiment of the present invention and show not with any certain computer, virtual system
Or miscellaneous equipment is inherently related.Various general-purpose systems can also be used together based on teaching in this.Retouched according to above
State, the structure constructed required by this kind of system is obvious.Additionally, the present invention is also not for any certain programmed language.
It is understood that, it is possible to use various programming languages realize the content of invention described herein, and above to language-specific institute
The description done is to disclose the preferred forms of the present invention.
In description mentioned herein, a large amount of details are illustrated.It is to be appreciated, however, that the enforcement of the present invention
Example can be put into practice in the case of without these details.In some instances, known method, structure is not been shown in detail
And technology, so as not to obscure the understanding of this description.
Similarly, it will be appreciated that in order to simplify the disclosure and help understand one or more in each inventive aspect, exist
Above in the description of the exemplary embodiment of the present invention, each feature of the present invention is grouped together into single enforcement sometimes
In example, figure or descriptions thereof.However, the method for the disclosure should be construed to reflect following intention:I.e. required guarantor
The more features of feature that the application claims ratio of shield is expressly recited in each claim.More precisely, such as following
Claims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore,
Thus the claims for following specific embodiment are expressly incorporated in the specific embodiment, wherein each claim itself
All as the separate embodiments of the present invention.
Those skilled in the art are appreciated that can be carried out adaptively to the module in the equipment in embodiment
Change and they are arranged in one or more equipment different from the embodiment.Can be the module or list in embodiment
Unit or component are combined into a module or unit or component, and can be divided in addition multiple submodule or subelement or
Sub-component.In addition at least some in such feature and/or process or unit is excluded each other, can adopt any
Combine to all features disclosed in this specification (including adjoint claim, summary and accompanying drawing) and so disclosed
Where all processes or unit of method or equipment are combined.Unless expressly stated otherwise, this specification is (including adjoint power
Profit is required, summary and accompanying drawing) disclosed in each feature can it is identical by offers, be equal to or the alternative features of similar purpose carry out generation
Replace.
It should be noted that above-described embodiment the present invention will be described rather than limits the invention, and ability
Field technique personnel can design without departing from the scope of the appended claims alternative embodiment.In the claims,
Any reference markss between bracket should not be configured to limitations on claims.Word "comprising" is not excluded the presence of not
Element listed in the claims or step.Word "a" or "an" before element does not exclude the presence of multiple such
Element.The present invention can come real by means of the hardware for including some different elements and by means of properly programmed computer
It is existing.If in the unit claim for listing equipment for drying, several in these devices can be by same hardware branch
To embody.The use of word first, second, and third does not indicate that any order.These words can be explained and be run after fame
Claim.