CN101534321A - Load-balancing session-keeping algorithm based on cookie - Google Patents

Load-balancing session-keeping algorithm based on cookie Download PDF

Info

Publication number
CN101534321A
CN101534321A CN200910014677A CN200910014677A CN101534321A CN 101534321 A CN101534321 A CN 101534321A CN 200910014677 A CN200910014677 A CN 200910014677A CN 200910014677 A CN200910014677 A CN 200910014677A CN 101534321 A CN101534321 A CN 101534321A
Authority
CN
China
Prior art keywords
cookie
load
session
balancing
algorithm
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN200910014677A
Other languages
Chinese (zh)
Inventor
苑鸿剑
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Electronic Information Industry Co Ltd
Original Assignee
Langchao Electronic Information Industry Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Langchao Electronic Information Industry Co Ltd filed Critical Langchao Electronic Information Industry Co Ltd
Priority to CN200910014677A priority Critical patent/CN101534321A/en
Publication of CN101534321A publication Critical patent/CN101534321A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Computer And Data Communications (AREA)

Abstract

The invention relates to a load-balancing session-keeping algorithm based on cookie. Aiming at the situation that a source address session-keeping algorithm commonly adopted at present is easy to cause unbalanced load, the algorithm is generated; the load-balancing session-keeping algorithm based on the cookie can distribute a cookie value to each remote accessing client, set an expiry date of the cookie, and avoid that mass intranet users utilize one external IP address to access service so as to cause the occurrence of situation that total intranet users intensively access one server; and after the cookie is invalid, the load-balancing session-keeping algorithm based on the cookie can distribute new cookie to the client so as to ensure the continuity of application.

Description

A kind of load-balancing session-keeping algorithm based on cookie
Technical field
The present invention relates to a kind of network communications technology, specifically a kind of load-balancing session-keeping algorithm based on cookie.
Background technology
Internet user's severe increase and Internet flow explosion type ground increase.The develop rapidly of Internet brings great challenge for the network bandwidth and server.From development of internet technology, the growth of the network bandwidth is far above the growth of processor speed and internal storage access speed, the demand of, high available network services scalable at height, provided at present load balance scheduling solution based on IP layer and content-based request distribution, and in linux kernel, realized these methods, one group of server is constituted realization is telescopic, the virtual server of high available network services.One group of server interconnects by the local area network (LAN) at a high speed or the wide area network of geographical distribution, at their front end a load dispatch device (LoAd BAlAncer) is arranged.The load dispatch device can seamlessly be dispatched to network requests on the real server, thereby makes that the structure of server cluster is transparent to the client, and the network service that the client access group system provides is just as high-performance of visit, high available server.
But the source address session-keeping algorithm that generally adopts easily causes the unbalanced situation of load to produce at present, be Intranet user because have many consumers now, they utilize same external IP to carry out and extraneous getting in touch, so concerning the service of outer net, if according to the source address algorithm, these clients are exactly same client, and load equalizer will send to same station server to these users' request, will certainly cause the separate unit server stress excessive.
Along with Internet development cookie has been used for a lot of web services, the arbitrariness that server can utilize Cookies to comprise information is screened and regular these information of safeguarding, to judge the state in the HTTP transmission.Whether the most typical application of Cookies is to judge registered user's Website login, and the user may obtain prompting, whether keeps user profile so that simplify the login formality when entering this website next time, and these all are the functions of Cookies.
The present invention is both combinations, and has given new function to them.
Summary of the invention
The purpose of this invention is to provide a kind of load-balancing session-keeping algorithm based on cookie.
Purpose algorithm of the present invention is realized in the following manner, utilizes cookie to keep the continuity of load balancing service, and its course of work is whether load equalizer inspection request includes a special load balancing cookie.If can not find this cookie, select a server by a distributed algorithm (for example poll, minimum connection etc.), a load-balancing session cookie is added in the response of returning.When browser obtains this session cookie, in the internal memory, closing this cookie of back at browser will not exist during this cookie will preserve temporarily.Browser can join this cookie in ensuing all requests in session, and request is sent to load equalizer then.By with associated server as the cookie value, that judges which server will be responsible for handling (browser session in) request load equalizer.
In order to guarantee the fail safe of cookie, can utilize MD5 that it is encrypted, and in the cookie value, add source address information, guarantee that the fail safe of cookie in transmission needs.
The invention has the beneficial effects as follows: can avoid a large amount of Intranet users to utilize an outside ip address access services, thereby cause the generation of the situation of whole Intranet user central access one station servers, and after cookie lost efficacy, load-balancing session-keeping algorithm based on cookie can distribute new cookie for client, with the continuity that guarantees to use.
Description of drawings
Accompanying drawing 1 is the load-balancing session-keeping algorithm workflow diagram based on cookie.
5, execution mode
Explain below with reference to Figure of description algorithm of the present invention being done.
Load-balancing session-keeping algorithm based on cookie of the present invention is based on the jAvA program of the load-balancing session-keeping algorithm of cookie.Specific procedure is as follows:
clAss?CookieBAsedLoAdBAlAncerHAndler?implements?IHttpRequestHAndler,
ILifeCycle?{
privAte?finAl?List<InetSocketAddress>?servers=new
ArrAyList<InetSocketAddress>();
privAte?int?serverIdx=0;
privAte?HttpClient?httpClient;
/*
*this?clAss?does?not?implement?server?monitoring?or?heAlthiness?checks
*/
Publ?ic?CookieBAsedLoAdBAlAncerHAndler(InetSocketAddress...reAlServers){
servers.AddAl?l(ArrAys.AsLi?st(reAlServers));
}
public?void?onInit(){
httpClient=new?HttpClient();
httpClient.setAutoHAndleCookies(fAlse);
}
public?void?onDestroy()throws?IOException{
httpClient.close();
}
public?void?onRequest(finAlIHttpExchAnge?exchAnge)throws?IOException{
IHttpRequest?request=exchAnge.getRequest();
IHttpResponseHAndler?respHdl=null;
InetSocketAddress?serverAddr=nul?l;
//check?if?the?request?contAins?the?LB_SLOT?cookie
cl:for(String?cookieHeAder:request.getHeAderList(″Cookie″)){
for(String?cookie:cookieHeAder.split(″;″)){
String[]kvp=cookie.split(″=″);
if(kvp[0].stArtsWith(″LB_SLOT″)){
int?slot=Integer.pArseInt(kvp[1]);
serverAddr=servers.get(slot);
breAk?cl;
}
}
}
//request?does?not?contAins?the?LB_SLOT->select?A?server
if(serverAddr==null){
finAl?int?slot=nextServerSlot();
serverAddr=servers.get(slot);
respHdl=new?IHttpResponseHAndler(){
@Execution(Execution.NONTHREADED)
public?void?onResponse(IHttpResponse?response)throws?IOException
{
//set?the?LB_SLOT?cookie
response.setHeAder(″Set-Cookie″,″LB_SLOT=″+slot+
″;PAth=/″);
exchAnge.send(response);
}
@Execution(Execution.NONTHREADED)
public?void?onException(IOException?ioe)throws?IOException{
exchAnge.sendError(ioe);
}
};
}else{
respHdl=new?IHttpResponseHAndler(){
@Execution(Execution.NONTHREADED)
public?void?onResponse(IHttpResponse?response)throws?IOException
{
exchAnge.send(response);
}
@Execution(Execution.NONTHREADED)
public?void?onException(IOException?ioe)throws?IOException{
exchAnge.sendError(ioe);
}
};
}
//updAte?the?Request-URL?of?the?request
URL?url=request.getRequestUrl();
URLnewUrl=newURL(url.getProtocol(),serverAddr.getHostNAme(),
serverAddr.getPort(),url.getFile());
request.setRequestUrl(newUrl);
//proxy?heAder?hAndl?ing(remove?hop-by-hop?heAders,...)//...
//forwArd?the?request
httpCl?ient.send(request,respHdl);
}
//get?the?next?slot?by?using?the?using?round-robin?ApproAch
privAte?synchronized?int?nextServerSlot(){
serverIdx++;
if(serverIdx>=servers.size()){
serverIdx=0;
}
return?serverIdx;
}
}
clAss?LoAdBAlAncer{
public?stAtic?void?mAin(String[]Args)throws?Exception{
InetSocketAddress[]srvs=new?InetSocketAddress[]{new
InetSocketAddress(″srvl″,8030),new?InetSocketAddress(″srv2″,8030)};
CookieBAsedLoAdBAlAncerHAndler?hdl=new
CookieBAsedLoAdBAlAncerHAndler(srvs);
HttpServer?loAdBAlAncer=new?HttpServer(8080,hdl);
loAdBAlAncer.run();
}
}。

Claims (6)

1, a kind of load-balancing session-keeping algorithm based on cookie, it is characterized in that utilizing cookie to keep the continuity of load balancing service, whether load equalizer inspection request includes a special load balancing cookie, can not find this cookie, by a distributed algorithm, select a server, a load-balancing session cookie is added in the response of returning, when browser obtains this session cookie, during this cookie will preserve temporarily in the internal memory, in session, browser can join this cookie in ensuing all requests, request is sent to load equalizer then, by with associated server as the cookie value, that server that load equalizer is selected will be responsible for handling the request in the browser session.
2, algorithm according to claim 1 is characterized in that distributed algorithm comprises poll, the minimum connection.
3, method according to claim 1 is characterized in that after browser cut out, cookie disappeared automatically.
4, algorithm according to claim 1 is characterized in that method is only applicable to the HTTP service.
5, algorithm according to claim 1 is characterized in that client browser enables the balanced session cookie of cookie service back working load, client browser forbidding cookie service, and then algorithm changes other algorithms automatically into.
6, algorithm according to claim 1 is characterized in that cookie utilizes MD5 that it is encrypted, and add source address information in the cookie value, guarantees that the fail safe of cookie in transmission needs.
CN200910014677A 2009-03-09 2009-03-09 Load-balancing session-keeping algorithm based on cookie Pending CN101534321A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200910014677A CN101534321A (en) 2009-03-09 2009-03-09 Load-balancing session-keeping algorithm based on cookie

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200910014677A CN101534321A (en) 2009-03-09 2009-03-09 Load-balancing session-keeping algorithm based on cookie

Publications (1)

Publication Number Publication Date
CN101534321A true CN101534321A (en) 2009-09-16

Family

ID=41104708

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200910014677A Pending CN101534321A (en) 2009-03-09 2009-03-09 Load-balancing session-keeping algorithm based on cookie

Country Status (1)

Country Link
CN (1) CN101534321A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101783771A (en) * 2010-03-24 2010-07-21 杭州华三通信技术有限公司 Method and equipment for realizing load balance continuity
CN103152270A (en) * 2013-03-11 2013-06-12 华为技术有限公司 Method for forwarding packets, and router
CN103957207A (en) * 2014-04-29 2014-07-30 北京太一星晨信息技术有限公司 Conversation keeping method and device
CN106815059A (en) * 2016-12-31 2017-06-09 广州勤加缘科技实业有限公司 Linux virtual server LVS automates O&M method and operational system
CN108322524A (en) * 2018-01-22 2018-07-24 杭州迪普科技股份有限公司 A kind of load-balancing device session keeps test method and device
CN108881430A (en) * 2018-06-14 2018-11-23 平安科技(深圳)有限公司 Session keeping method, device, computer equipment and storage medium
CN109451068A (en) * 2018-12-28 2019-03-08 杭州迪普科技股份有限公司 The insertion method and device of Set-Cookie value
CN112929440A (en) * 2021-02-09 2021-06-08 上海弘积信息科技有限公司 Method for keeping double stack connection by cookie
CN114866442A (en) * 2022-05-31 2022-08-05 杭州迪普科技股份有限公司 8583 protocol-based cross-virtual service session holding test method and device

Cited By (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101783771A (en) * 2010-03-24 2010-07-21 杭州华三通信技术有限公司 Method and equipment for realizing load balance continuity
CN103152270A (en) * 2013-03-11 2013-06-12 华为技术有限公司 Method for forwarding packets, and router
CN103957207A (en) * 2014-04-29 2014-07-30 北京太一星晨信息技术有限公司 Conversation keeping method and device
CN103957207B (en) * 2014-04-29 2017-11-28 北京太一星晨信息技术有限公司 A kind of session keeping method and device
CN106815059A (en) * 2016-12-31 2017-06-09 广州勤加缘科技实业有限公司 Linux virtual server LVS automates O&M method and operational system
CN108322524A (en) * 2018-01-22 2018-07-24 杭州迪普科技股份有限公司 A kind of load-balancing device session keeps test method and device
CN108881430A (en) * 2018-06-14 2018-11-23 平安科技(深圳)有限公司 Session keeping method, device, computer equipment and storage medium
WO2019237594A1 (en) * 2018-06-14 2019-12-19 平安科技(深圳)有限公司 Session persistence method and apparatus, and computer device and storage medium
CN109451068A (en) * 2018-12-28 2019-03-08 杭州迪普科技股份有限公司 The insertion method and device of Set-Cookie value
CN109451068B (en) * 2018-12-28 2021-11-23 杭州迪普科技股份有限公司 Method and device for inserting Set-Cookie value
CN112929440A (en) * 2021-02-09 2021-06-08 上海弘积信息科技有限公司 Method for keeping double stack connection by cookie
CN114866442A (en) * 2022-05-31 2022-08-05 杭州迪普科技股份有限公司 8583 protocol-based cross-virtual service session holding test method and device
CN114866442B (en) * 2022-05-31 2023-05-26 杭州迪普科技股份有限公司 8583 protocol-based cross-virtual service session maintenance test method and device

Similar Documents

Publication Publication Date Title
CN101534321A (en) Load-balancing session-keeping algorithm based on cookie
US11316786B2 (en) Systems and methods for directly responding to distributed network traffic
US7904345B2 (en) Providing website hosting overage protection by transference to an overflow server
CN101370035B (en) Method and system for dynamic client/server network management using proxy servers
US9577892B2 (en) Systems and methods for providing monitoring in a cluster system
US8706864B1 (en) Behavior monitoring and compliance for multi-tenant resources
US9338192B1 (en) Connection management using connection request transfer protocol
JP5485993B2 (en) Service load balancing
US20080243536A1 (en) Providing website hosting overage protection by storage on an independent data server
CN101605092A (en) A kind of content-based SiteServer LBS
JP2017517064A5 (en)
CN106412063A (en) CDN node detection and resource scheduling system and method in education network
CN103701928B (en) It is applied to the method that load equalizer improves server and SSL gateway operational efficiency
CN111935312B (en) Industrial Internet container cloud platform and flow access control method thereof
CN103401799A (en) Method and device for realizing load balance
WO2023151976A2 (en) Internet proxy system
Chen et al. PacketCloud: A cloudlet-based open platform for in-network services
WO2017097092A1 (en) Method and system for processing cache cluster service
US9973580B2 (en) State-based intercept of interactive communications network connections for provision of targeted, status-based messaging
CN104283957A (en) CDN cache method based on continuous connectionism
Kadhim et al. Hybrid load-balancing algorithm for distributed fog computing in internet of things environment
US9912757B2 (en) Correlation identity generation method for cloud environment
Shen et al. Freeweb: P2p-assisted collaborative censorship-resistant web browsing
Ponciano et al. Load balancing in modern network infrastructures—A simulation model
Han et al. A Solution for Instant Response of Cloud Platform Based on Nginx+ Keepalived

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Open date: 20090916