CN109819055A - Method that is a kind of while supporting Ribbon and Eureka to realize load balancing - Google Patents

Method that is a kind of while supporting Ribbon and Eureka to realize load balancing Download PDF

Info

Publication number
CN109819055A
CN109819055A CN201910197691.1A CN201910197691A CN109819055A CN 109819055 A CN109819055 A CN 109819055A CN 201910197691 A CN201910197691 A CN 201910197691A CN 109819055 A CN109819055 A CN 109819055A
Authority
CN
China
Prior art keywords
client
load balancing
eureka
ribbon
docker container
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.)
Granted
Application number
CN201910197691.1A
Other languages
Chinese (zh)
Other versions
CN109819055B (en
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.)
Sichuan Hongwei Technology Co Ltd
Original Assignee
Sichuan Changhong Electric 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 Sichuan Changhong Electric Co Ltd filed Critical Sichuan Changhong Electric Co Ltd
Priority to CN201910197691.1A priority Critical patent/CN109819055B/en
Publication of CN109819055A publication Critical patent/CN109819055A/en
Application granted granted Critical
Publication of CN109819055B publication Critical patent/CN109819055B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Stored Programmes (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a kind of methods for supporting Ribbon and Eureka to realize load balancing simultaneously, it include: the start command for the content and Docker container that Cloud configuration file is applied in combination, respectively specify that the client that load balancing is realized using Ribbon and realizes load balancing using Eureka, comprising: the mapping relations of client name and Client path are configured in the configuration file of server end;When starting dispatcher server using Docker container, the load balancing implementation of each client is specified by setting.By given client end using the load balancing of Eureka and/or the load balancing of Ribbon, the single or multiple clients that realization accesses the same server end can use different loads balanced way and can be by the context variable values switching load balancing implementation of change docker container.

Description

Method that is a kind of while supporting Ribbon and Eureka to realize load balancing
Technical field
The present invention relates to field of computer technology, specifically, are a kind of while supporting Ribbon and Eureka is realized to bear Carry balanced method.
Background technique
Increasing with number of users, the increasingly increase of user's request amount, the requirement to server also can be increasingly It is high.The performance of stand-alone server easily reaches the limit, it is therefore desirable to the overall performance of website is improved using server cluster. So, since being the server of clustering, it is also required for a server naturally, takes on the responsibility of dispatcher.User is from client All requests for holding browser to issue can all be intercepted by it first and be received, and then dispatcher server is further according to each server Loading condition, it then follows certain strategy process, therefrom select a background server go processing user request.In this mistake Cheng Zhong, it is necessary to guarantee that the performance of each back-end server is all fully played, the overall performance of server cluster system It is optimal.And how dispatcher server reasonably distributes task, the problem of being exactly load balancing.Load balancing is divided into service Device end and client, the load balancing at period of service end most common at present is realized using Nginx.And in the art of this patent The range for relating generally to and being applicable in is client load equilibrium Ribbon.Spring Cloud can be developer as one kind Tool (such as configuration management, service discovery and registration, the open circuit of some common schemas in rapid build distributed system are provided Device, Intelligent routing, control bus) Open Framework, quickly update and develop with gesture with lightning speed.Especially In the API gateway of micro services, irreplaceable important function is played.Using in micro services at present most common is exactly integrated note All services are successively registered on Eureka, uniformly carry out pipe by service register center Eureka by volume service centre Eureka Reason.In this way, the problem of Ribbon load balancing also give Eureka processing, be it is very convenient, it is simple and direct, efficiently.But This configuration mode be not yet it is perfect, due in a micro services project, often not merely only one visitor of docking The service of family end, but multiple services.Two kinds of load balancing implementations that Spring Cloud has been supported so far are all Global configuration, i.e., all clients for accessing the server are unified to use a set of configuration.It uses The realization of load balancing is all transferred to Eureka to handle by ribbon.eureka.enabled=true;It uses The combination of ribbon.eureka.enabled=false and [Client Name] .ribbon.listOfServers configure, will The realization of load balancing all transfers to Ribbon to handle.That is, the multiple client of the same server end is accessed, we Can not be achieved: the load-balancing function of customer end A transfers to registration center Eureka to be handled, the load of client service B Equalization function transfers to Ribbon itself to be handled.But this demand is that we need during actual development, because This, and can it is desirable that there is a kind of customized own load balanced realization of each client that can be allowed under the same server In a manner of switching at any time.
Summary of the invention
The purpose of the present invention is to provide a kind of methods for supporting Ribbon and Eureka to realize load balancing simultaneously, are used for Solve the problems, such as that client load equilibrium cannot support Ribbon and Eureka simultaneously in the prior art.
The present invention is solved the above problems by following technical proposals:
Method that is a kind of while supporting Ribbon and Eureka to realize load balancing, comprising:
The content of Cloud configuration file and the start command of Docker container is applied in combination, respectively specifies that using Ribbon It realizes load balancing and realizes the client of load balancing using Eureka.
Further, the method specifically includes:
Step S100: the mapping relations of client name and Client path are configured in the configuration file of server end;
Step S200: when using Docker container starting dispatcher server, each visitor is specified by setting The load balancing implementation at family end.
Further, the step S100 is specifically included:
The client resource of load balancing using Eureka is registered in service register center;
By the configuration text using the full request address write service device end of the client resource of the load balancing of Ribbon In part.
Further, the step S200 is specifically included:
Step S210: when using Docker container starting dispatcher server, defining EUREKA array and RIBBON array, The client of load balancing using Eureka is added to EUREKA array, it will be using the client of the load balancing of Ribbon It is added to RIBBON array;
Step S220: user sends the request URL that access resource by client browser, and dispatcher server is first right The request URL is intercepted, and then searches the Client path met with request URL in configuration file according to request URL, then Corresponding client name is obtained according to client name and the mapping relations of Client path, and is judged:
If client uses the load balancing of Eureka, Eureka is according to client name by request URL according to distribution plan Slightly divide and is forwarded to back-end services;
If client uses the load balancing of Ribbon, Ribbon is according to the Ribbon Server List in configuration file List is forwarded to back-end services according to allocation strategy.
Further, the method also includes: if there is new client to access dispatcher server, judgement:
If new client realizes load balancing by Eureka, then by the visitor in the start command of docker container Family end name is referred to as new element and is inserted into EUREKA array;
It, only need to should in the start command of docker container if new client realizes load balancing by Ribbon Client name is inserted into RIBBON array as new element.
Further, the method also includes: when needing to switch the load balancing implementation of some client, change Then the context variable values of docker container start command restart container.
Compared with prior art, the present invention have the following advantages that and the utility model has the advantages that
The present invention is connect by given client end using the load balancing of Eureka and/or the load balancing of Ribbon, realization The single or multiple clients for entering the same server end can use different loads balanced way and can pass through change The context variable values switching load balancing implementation of docker container.
Detailed description of the invention
Fig. 1 is flow chart of the invention.
Specific embodiment
The present invention is described in further detail below with reference to embodiment, embodiments of the present invention are not limited thereto.
Embodiment 1:
In conjunction with shown in attached drawing 1, a kind of while method of supporting Ribbon and Eureka to realize load balancing is based on Spring Cloud Open Framework and Docker application container engine are ordered by the content of cloud configuration file and the starting of docker container It enables, respectively specifies that the client that load balancing is realized using Ribbon and realizes load balancing using Eureka, the two combination makes With, the compatibility of realization two kinds of load balancing modes of Ribbon and Eureka shares, it specifically includes:
Step S100: the mapping relations of client name and Client path are configured in the configuration file of server end;
If it is the load balancing using Eureka, need multiple client resource registering in service register center, if Always it not will use Eureka and realize load balancing, then without being registered to registration center.If it is equal using the load of Ribbon Weighing apparatus is needed in the configuration file at the full request address write service device end of multiple client resource, if not will use always Ribbon itself realizes load balancing, then this configuration can be omitted.
Step S200: when using Docker container starting dispatcher server, each visitor is specified by setting The load balancing implementation at family end.
(1) using Docker starting dispatcher server when, by way of environmental variance, the negative of each client is specified It carries balanced realization mode and specifically defines two arrays, one is EUREKA [], and one is RIBBON [], by Ribbon's The client of load balancing is added in RIBBON array, and the client of the load balancing of Eureka is added to EUREKA number Group.That is: " it is negative to indicate that client 1 and client 3 are realized using Eureka to-e by EUREKA [client1, client3]=true " Equalization function is carried ,-e " RIBBON [client2]=true " indicates that client 2 realizes load-balancing function using Ribbon;
(2) user sends request: http by client browser respectively: // 127.0.0.1:8080/app1/xxx with http://127.0.0.1:8080/app2/xxx;Service dispatch person intercepts the request, is looked into configuration file according to request URL Path/app1/** and path/app2/** are looked for, according to the mapping relations of client name and Client path, determination/app1/ Request to be really forwarded to and gone in client1, the request of/app2/ will be really forwarded to goes in client2.
Embodiment 2:
On the basis of embodiment 1, further includes: if having new client access dispatcher server, to be loaded Balanced implementation transfers to Eureka, then the start command related content of docker container is revised as-e " EUREKA [client1, client3, client4]=true ";To the implementation of its load balancing is transferred to Ribbon, then need Its real rear end request address is added in configuration file, then the start command related content of docker container is revised as-e " RIBBON [client2, client4]=true ".
Embodiment 3:
On the basis of embodiment 1 or 2, further includes: when needing to switch the load balancing implementation of some client, It can directly be operated by the start command of docker container, then restarting container can come into force.It avoids at present To change load balancing implementation, it is necessary to the content inside configuration file is modified, is then recompilated, is packaged, deployment Complexity.It realizes under the same service, while Ribbon and Eureka being supported to realize load balancing.It is accessed in the service Each micro services example, load balancing can be realized by different modes.
Although reference be made herein to invention has been described for explanatory embodiment of the invention, and above-described embodiment is only this hair Bright preferable embodiment, embodiment of the present invention are not limited by the above embodiments, it should be appreciated that those skilled in the art Member can be designed that a lot of other modification and implementations, these modifications and implementations will fall in principle disclosed in the present application Within scope and spirit.

Claims (6)

1. a kind of method for supporting Ribbon and Eureka to realize load balancing simultaneously characterized by comprising
The content of Cloud configuration file and the start command of Docker container is applied in combination, respectively specifies that and is realized using Ribbon Load balancing and the client that load balancing is realized using Eureka.
2. a kind of method for supporting Ribbon and Eureka to realize load balancing simultaneously according to claim 1, feature It is, specifically includes:
Step S100: the mapping relations of client name and Client path are configured in the configuration file of server end;
Step S200: when using Docker container starting dispatcher server, each client is specified by setting Load balancing implementation.
3. a kind of method for supporting Ribbon and Eureka to realize load balancing simultaneously according to claim 2, feature It is, the step S100 is specifically included:
The client resource of load balancing using Eureka is registered in service register center;
It will be using in the configuration file at the full request address write service device end of the client resource of the load balancing of Ribbon.
4. a kind of method for supporting Ribbon and Eureka to realize load balancing simultaneously according to claim 2 or 3, special Sign is that the step S200 is specifically included:
Step S210: when using Docker container starting dispatcher server, EUREKA array and RIBBON array is defined, will be adopted It is added to EUREKA array with the client of the load balancing of Eureka, will be added using the client of the load balancing of Ribbon To RIBBON array;
Step S220: user sends the request URL that access resource by client browser, and dispatcher server first asks this It asks URL to be intercepted, then searches the Client path met with request URL in configuration file according to request URL, further according to Client name and the mapping relations of Client path obtain corresponding client name, and judge:
If client uses the load balancing of Eureka, Eureka is according to client name by request URL according to allocation strategy point It is forwarded to back-end services;
If client uses the load balancing of Ribbon, Ribbon is according to the Ribbon Server List list in configuration file Back-end services are forwarded to according to allocation strategy.
5. a kind of method for supporting Ribbon and Eureka to realize load balancing simultaneously according to claim 4, feature It is, further includes: if there is new client access dispatcher server, judgement:
If new client realizes load balancing by Eureka, then by the client in the start command of docker container Name is referred to as new element and is inserted into EUREKA array;
If new client realizes load balancing by Ribbon, only need to be in the start command of docker container by the client End name is referred to as new element and is inserted into RIBBON array.
6. a kind of method for supporting Ribbon and Eureka to realize load balancing simultaneously according to claim 5, feature It is, further includes: when needing to switch the load balancing implementation of some client, change docker container start command Then context variable values restart container.
CN201910197691.1A 2019-03-15 2019-03-15 Method for realizing load balance by simultaneously supporting Ribbon and Eureka Active CN109819055B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910197691.1A CN109819055B (en) 2019-03-15 2019-03-15 Method for realizing load balance by simultaneously supporting Ribbon and Eureka

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910197691.1A CN109819055B (en) 2019-03-15 2019-03-15 Method for realizing load balance by simultaneously supporting Ribbon and Eureka

Publications (2)

Publication Number Publication Date
CN109819055A true CN109819055A (en) 2019-05-28
CN109819055B CN109819055B (en) 2020-07-07

Family

ID=66609076

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910197691.1A Active CN109819055B (en) 2019-03-15 2019-03-15 Method for realizing load balance by simultaneously supporting Ribbon and Eureka

Country Status (1)

Country Link
CN (1) CN109819055B (en)

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110505427A (en) * 2019-08-27 2019-11-26 杭州觅境寻味农业科技有限公司 Electric business shopping platform system and method based on video calling and intelligent electronic-scale
CN112291099A (en) * 2020-11-02 2021-01-29 西南电子技术研究所(中国电子科技集团公司第十研究所) Multi-mode registration center architecture switching method under mobile environment
CN112633664A (en) * 2020-12-17 2021-04-09 苏州莫普迪拉信息科技有限公司 Internet digital operation system
CN113572828A (en) * 2021-07-13 2021-10-29 壹药网科技(上海)股份有限公司 System for improving client load balance based on URL grouping granularity
CN113778653A (en) * 2021-09-22 2021-12-10 苏州莫普迪拉信息科技有限公司 Flat-panel player service end system
CN114726785A (en) * 2022-04-07 2022-07-08 深圳市铱云云计算有限公司 Directional routing debugging mechanism based on request label expression
CN115987547A (en) * 2022-11-02 2023-04-18 四川大学 Multi-platform interconnection cloud connector system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB249716A (en) * 1925-06-24 1926-04-01 Watson Ex Lab Company Improvements in and relating to computing weighing scales
CN107885822A (en) * 2017-11-07 2018-04-06 厦门安胜网络科技有限公司 The generation method and device of a kind of operation code
CN108052640A (en) * 2017-12-21 2018-05-18 泰康保险集团股份有限公司 The interlock method and device of status information change
CN108446111A (en) * 2018-03-26 2018-08-24 国家电网公司客户服务中心 A kind of micro services construction method based on Spring cloud
CN108933832A (en) * 2018-07-17 2018-12-04 河北中科恒运软件科技股份有限公司 A method of realizing that full stage grid is shared

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB249716A (en) * 1925-06-24 1926-04-01 Watson Ex Lab Company Improvements in and relating to computing weighing scales
CN107885822A (en) * 2017-11-07 2018-04-06 厦门安胜网络科技有限公司 The generation method and device of a kind of operation code
CN108052640A (en) * 2017-12-21 2018-05-18 泰康保险集团股份有限公司 The interlock method and device of status information change
CN108446111A (en) * 2018-03-26 2018-08-24 国家电网公司客户服务中心 A kind of micro services construction method based on Spring cloud
CN108933832A (en) * 2018-07-17 2018-12-04 河北中科恒运软件科技股份有限公司 A method of realizing that full stage grid is shared

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
DEFONDS: "Ribbon 和 Eureka 的集成", 《CSDN》 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110505427A (en) * 2019-08-27 2019-11-26 杭州觅境寻味农业科技有限公司 Electric business shopping platform system and method based on video calling and intelligent electronic-scale
CN112291099A (en) * 2020-11-02 2021-01-29 西南电子技术研究所(中国电子科技集团公司第十研究所) Multi-mode registration center architecture switching method under mobile environment
CN112291099B (en) * 2020-11-02 2022-07-29 西南电子技术研究所(中国电子科技集团公司第十研究所) Multi-mode registration center architecture switching method under mobile environment
CN112633664A (en) * 2020-12-17 2021-04-09 苏州莫普迪拉信息科技有限公司 Internet digital operation system
CN113572828A (en) * 2021-07-13 2021-10-29 壹药网科技(上海)股份有限公司 System for improving client load balance based on URL grouping granularity
CN113572828B (en) * 2021-07-13 2024-04-09 壹药网科技(上海)股份有限公司 System for improving client load balance based on URL grouping granularity
CN113778653A (en) * 2021-09-22 2021-12-10 苏州莫普迪拉信息科技有限公司 Flat-panel player service end system
CN114726785A (en) * 2022-04-07 2022-07-08 深圳市铱云云计算有限公司 Directional routing debugging mechanism based on request label expression
CN115987547A (en) * 2022-11-02 2023-04-18 四川大学 Multi-platform interconnection cloud connector system

Also Published As

Publication number Publication date
CN109819055B (en) 2020-07-07

Similar Documents

Publication Publication Date Title
CN109819055A (en) Method that is a kind of while supporting Ribbon and Eureka to realize load balancing
US11159411B2 (en) Distributed testing service
CN107426034B (en) Large-scale container scheduling system and method based on cloud platform
CN110149397A (en) A kind of micro services integration method and device
US8185654B2 (en) Systems and methods for content-aware load balancing
CN103401917B (en) A kind of mixing cloud computing system and its implementation method based on cloud bus
US5740371A (en) Load balancing of connections to parallel servers
CN109547570A (en) Service registration method, apparatus, registration center's management equipment and storage medium
CN107688322A (en) A kind of containerization management system
US20180129495A1 (en) Elastic application framework for deploying software
US10776141B2 (en) Directed placement for request instances
US9459897B2 (en) System and method for providing data analysis service in cloud environment
US11539582B1 (en) Streamlined onboarding of offloading devices for provider network-managed servers
CN106657248A (en) Docker container based network load balancing system and establishment method and operating method thereof
CN103425511A (en) System and method of installing and deploying application software in cloud computing environment
TW200412736A (en) Dynamic binding and fail-over of comparable web service instances in a services grid
CN113094182B (en) Service load balancing processing method and device and cloud server
US20130117290A1 (en) Platform for software as a service and method for provisioning service for supporting multi-tenants using the platform
CN108551488A (en) Distributed container cluster load balancing method based on domestic CPU and OS
WO2014158909A1 (en) Distributed data center technology
CN102170473A (en) Resource sharing system, mobile terminal and resource sharing method
CN110532208A (en) A kind of data processing method, interface conversion structure and equipment
US20220329651A1 (en) Apparatus for container orchestration in geographically distributed multi-cloud environment and method using the same
CN116010027A (en) Method for managing task processing cluster, method for executing task and container cluster
US9984021B1 (en) Location-aware self-configuration of a peripheral device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20200110

Address after: 610000 Chengdu City, Sichuan Province, China (Sichuan) Free Trade Pilot Area, No. 199 Tianfu Fourth Street, Chengdu High-tech Zone, 33 floors

Applicant after: Panovasic Co., Ltd.

Address before: 621000 Mianyang province high tech Zone, East Hing Road, No. 35 cotton

Applicant before: Sichuan Changhong Electrical Appliance Co., Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant