CN110944051B - Method and device for realizing load balance, electronic equipment and storage medium - Google Patents

Method and device for realizing load balance, electronic equipment and storage medium Download PDF

Info

Publication number
CN110944051B
CN110944051B CN201911207342.XA CN201911207342A CN110944051B CN 110944051 B CN110944051 B CN 110944051B CN 201911207342 A CN201911207342 A CN 201911207342A CN 110944051 B CN110944051 B CN 110944051B
Authority
CN
China
Prior art keywords
client
client instance
instance
service
server
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.)
Active
Application number
CN201911207342.XA
Other languages
Chinese (zh)
Other versions
CN110944051A (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.)
Beijing Dajia Internet Information Technology Co Ltd
Original Assignee
Beijing Dajia Internet Information Technology 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 Beijing Dajia Internet Information Technology Co Ltd filed Critical Beijing Dajia Internet Information Technology Co Ltd
Priority to CN201911207342.XA priority Critical patent/CN110944051B/en
Publication of CN110944051A publication Critical patent/CN110944051A/en
Application granted granted Critical
Publication of CN110944051B publication Critical patent/CN110944051B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1008Server selection for load balancing based on parameters of servers, e.g. available memory or workload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1034Reaction to server failures by a load balancer
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/133Protocols for remote procedure calls [RPC]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer Hardware Design (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer And Data Communications (AREA)

Abstract

The disclosure relates to a method, a device, an electronic device and a storage medium for realizing load balancing, wherein a client obtains a plurality of server instances provided by a server and generates corresponding client instances according to the server instances; then, according to the generated client instances, a client instance manager is created, and a service pressure index is created for each client instance; then, when the client needs to call the service provided by the server, selecting the client instance to be called according to the service pressure index value of each client instance through a client instance manager; and finally, calling the corresponding target service provided by the service end through the client instance selected by the client instance manager. The execution of the load balancing strategy does not depend on the server, the function that the client executes the load balancing strategy by itself is realized, if one machine has a problem, the service calling party on the machine can be influenced, the operation of the whole system can not be influenced, and the single-point problem does not exist any more.

Description

Method and device for realizing load balance, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of computer network technologies, and in particular, to a method and an apparatus for implementing load balancing, an electronic device, and a storage medium.
Background
In the age of rapid development of the internet, a large amount of data, high concurrency, and the like are most mentioned by internet websites. How to deal with the system performance problem caused by high concurrency is a good choice to use a load balancing mechanism. Load balancing is to distribute requests to each server in the cluster according to some load policy, so that the whole server cluster processes the requests of the website.
In the related Load balancing implementation method, there is an independent LB (Load Balancer) between the client and the server, and the LB is usually implemented by a dedicated hardware device or based on software. The LB has address mapping tables for all services, which are typically registered by the operation and maintenance configuration. When a client invokes a target service, it sends a request to the LB, which forwards the request to the target service after load balancing by the LB with a policy such as Round-Robin (Round-Robin). All service call flows need to pass through the LB by using the scheme, when the service quantity and the call volume are large, the performance of the LB is easy to become the bottleneck of the system, and particularly, once the LB breaks down, the operation of the whole system is influenced.
Disclosure of Invention
Based on this, it is necessary that the present disclosure provide a method, an apparatus, an electronic device, and a storage medium for implementing load balancing, so as to at least solve the technical problem in the related art that if an LB fails, normal operation of the entire system is affected.
According to a first aspect of the embodiments of the present disclosure, a method for implementing load balancing is provided, which is applied to a client, and includes:
the method comprises the steps of obtaining a plurality of server instances provided by a server, and generating corresponding client instances according to the server instances;
creating a client instance manager according to the generated client instances, and creating service pressure indexes for the client instances;
when a client needs to call the service provided by the server, selecting a client instance to be called according to the service pressure index value of each client instance through the client instance manager;
and the client instance selected by the client instance manager calls a corresponding target service provided by a server.
According to a second aspect of the embodiments of the present disclosure, an apparatus for implementing load balancing is provided, where the apparatus includes:
the client instance generation module is configured to execute the steps of acquiring a plurality of server instances provided by a server and generating corresponding client instances according to the server instances;
the instance manager creating module is configured to create a client instance manager according to the generated client instances and create a service pressure index for each client instance;
the client instance selection module is configured to execute that when a client needs to call the service provided by the server, the client instance manager selects the client instance needing to be called according to the service pressure index value of each client instance;
and the target service determining module is configured to execute the corresponding target service provided by the client instance calling server according to the client instance selected by the client instance manager.
According to a third aspect of embodiments of the present disclosure, an electronic device includes:
a processor;
a memory configured to execute instructions stored in the memory;
wherein the processor is configured to execute the instructions to implement the method for implementing load balancing in the first aspect.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the method for implementing load balancing in the first aspect.
According to a fifth aspect of embodiments of the present disclosure, there is provided a computer program product, which includes one or more instructions that can be executed by a processor of a computer device, so as to implement the method for implementing load balancing described in the first aspect.
The technical scheme provided by the embodiment of the disclosure at least brings the following beneficial effects:
the client side obtains a plurality of server side instances provided by the server side and generates corresponding client side instances according to the server side instances; then according to each generated client instance, a client instance manager is created, and a service pressure index is created for each client instance; then, when the client needs to call the service provided by the server, selecting the client instance to be called according to the service pressure index value of each client instance through the client instance manager; and finally, calling the corresponding target service provided by the service end through the client instance selected by the client instance manager. The execution of the load balancing strategy does not depend on the server, the function that the client executes the load balancing strategy by itself is realized, if one machine has a problem, the service calling party on the machine can be influenced, the operation of the whole system can not be influenced, and the single-point problem does not exist any more.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and, together with the description, serve to explain the principles of the disclosure and are not to be construed as limiting the disclosure.
FIG. 1a is a diagram of an application environment in which a method for load balancing is implemented in one embodiment;
FIG. 1b is a flow diagram illustrating a method for implementing load balancing in accordance with an exemplary embodiment;
FIG. 1c is a diagram illustrating a client instance corresponding to a server instance, in accordance with an illustrative embodiment;
FIG. 2 is a flow diagram illustrating a method for load balancing according to an example embodiment;
FIG. 3 is a flowchart illustrating one possible implementation of step S210, according to an exemplary embodiment;
FIG. 4 is a flow diagram illustrating a method for load balancing according to an example embodiment;
FIG. 5 is a block diagram illustrating an apparatus for implementing load balancing in accordance with an exemplary embodiment;
FIG. 6 is a block diagram illustrating an electronic device in accordance with an example embodiment.
Detailed Description
In order to make the technical solutions of the present disclosure better understood, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings.
It should be noted that the terms "first," "second," and the like in the description and claims of the present disclosure and in the above-described drawings are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the disclosure described herein are capable of operation in other sequences than those illustrated or described herein. The implementations described in the exemplary embodiments below do not represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
Fig. 1a is a diagram of an application environment of a method for implementing load balancing in one embodiment. Referring to fig. 1a, the load balancing implementation method of the present disclosure may be applied to a system including a client 100 and a server 200, where the client 100 is connected to the server 200 through a network. The client 100 refers to a caller initiating a service request, i.e., a service consumer. The service end 200 refers to a called party receiving the service request, namely, a service provider. Among other things, the client 100 may be application software in a computer device, including but not limited to an APP, a browser, an applet, and so on. The computer device may be at least one of a mobile phone, a tablet computer, a notebook computer, a desktop computer, and the like. The server 200 may be implemented as a stand-alone server or as a server cluster comprising a plurality of servers. The representation forms of the client 100 and the server 200 can be selected according to actual situations.
The idea of the load balancing implementation method of the embodiment of the disclosure includes: the server 200 provides a plurality of server instances (such as server instance 1, server instance 2, and server instance 3), and the client obtains the plurality of server instances provided by the server and generates corresponding client instances (such as client instance 1, client instance 2, and client instance 3) according to the plurality of server instances. And the server instances correspond to the generated client instances one to one. The client 100 creates a client instance manager 110 according to the client instance corresponding to the generated server instance, and sets a service pressure index for each client instance. Then, when the client 100 sends a service request to the server 200, the client instance manager 110 selects an appropriate client instance for the service request according to the service pressure index value of each client instance. Because the client instances correspond to the server instances one to one, the client instance selected by the client instance manager can invoke the corresponding target service. By creating the client instance manager 110 and distributing appropriate client instances by using the created client instance manager 110, the client can execute the load balancing policy by itself without relying on the server for executing the load balancing policy. On one hand, in the load balancing implementation method of the embodiment of the present disclosure, a problem occurring in one machine only affects a service invocation party on the machine, and does not affect the operation of the entire system, that is, a single-point problem no longer exists, and on the other hand, no additional invocation link is added between the client 100 and the server 200, so that the performance overhead is reduced.
Fig. 1b is a flowchart illustrating a method for implementing load balancing, which may be applied to a client in the application environment, according to an exemplary embodiment, and as shown in fig. 1b, the method includes the following steps:
in step S110, a plurality of server instances provided by the server are obtained, and a corresponding client instance is generated according to each server instance.
The service end refers to a called party receiving the service request, namely a service provider. The server instance consists of the server address and port number. The client instance consists of the client address and port number. Specifically, the server provides a plurality of configuration addresses, that is, a plurality of server instances, and can store the plurality of server instances provided by the server in a file (such as a JSON file) in advance, and the client acquires the plurality of server instances provided by the server from the file and generates corresponding client instances according to the plurality of server instances.
Exemplarily, as shown in fig. 1c, a service end depends on a GRPC service example with a certain basic function, provides 6 configuration addresses, that is, GRPC service end instances, and a client obtains a GRPC service end instance array formed by the 6 GRPC service end instances and generates a corresponding GRPC client end instance array according to the GRPC service end instance array.
In step S120, a client instance manager is created according to the generated client instances, and a service pressure index is created for each client instance.
Wherein, the client instance manager refers to software for distributing service requests of the client to the available servers. The service pressure index is a pressure index at which a server device that provides a service responds to a service request and performs the service. The generated client instances are in one-to-one correspondence with the server instances, and each time the target service is called, the client instance needs to pass through the client instance, a service pressure index can be set for the client instance, the service pressure index of the server instance is expressed through the service pressure index of the client instance, namely the service pressure index of the client instance is used for expressing the state of the server instance corresponding to the client instance, such as whether the server instance is occupied, the occupied condition or the survival condition. Specifically, in order for the client to complete load balancing by itself, a client instance manager is created and includes the client instance corresponding to the server instance generated in step 110. Further, a service pressure indicator is set for each client instance in the client instance manager.
In step S130, when the client needs to invoke the service provided by the server, the client instance manager selects the client instance that needs to be invoked according to the service pressure index value of each client instance.
Specifically, each time a server instance is called, the service pressure index value of the corresponding client instance changes accordingly. In order to realize load balance, the client instance manager obtains the service pressure index value of each client instance, and selects the client instance to be called in each client instance according to the service pressure index value of each client instance.
In step S140, the client instance selected by the client instance manager invokes a corresponding target service provided by the server.
Specifically, because the client instances correspond to the server instances one to one, after the client instance manager selects a client instance to be called from each client instance, the corresponding server instance can be determined through the selected client instance, so as to call the final target service.
Based on the above description of the embodiments, the client obtains a plurality of server instances provided by the server, and generates a corresponding client instance according to each server instance; then, according to the generated client instances, a client instance manager is created, and a service pressure index is created for each client instance; then, when the client needs to call the service provided by the server, selecting the client instance to be called according to the service pressure index value of each client instance through a client instance manager; and finally, calling the corresponding target service provided by the service end through the client instance selected by the client instance manager. The execution of the load balancing strategy does not depend on the server, the function that the client executes the load balancing strategy by itself is realized, if one machine has a problem, the service calling party on the machine can be influenced, the operation of the whole system cannot be influenced, and the single-point problem does not exist any more.
In an exemplary embodiment, selecting, by a client instance manager, a client instance to be invoked according to a service pressure indicator value of each client instance includes: and comparing the service pressure index values in the client instances through a client instance manager, and selecting the client instance with the minimum service pressure index value as the client instance needing to be called.
Specifically, when the client instance manager sets the service pressure index for the client instance, an initial value may be set for the service pressure index in the client instance, and each time the server instance is called, the service pressure index value of the client instance corresponding to the server instance is increased. Then, in order to implement load balancing, when a client needs to invoke a service provided by a server, a client instance manager obtains a service pressure index value of each client instance, compares the service pressure index values in each client instance, determines a client instance with the minimum service pressure index value in each client instance, and takes the client instance with the minimum service pressure index value as the client instance needing to be invoked.
Based on the above embodiment, when the client needs to invoke the service provided by the server, the client instance with the smallest service pressure index value is selected as the client instance needing to be invoked by the client instance manager, and dynamic allocation of the server instance is realized at the client, so as to invoke the final target service.
Fig. 2 is a flowchart illustrating a method for implementing load balancing according to an exemplary embodiment, where the method further includes the following steps, as shown in fig. 1:
in step S210, when the client invokes the target service, the service pressure index value of the client instance selected by the client instance manager is increased.
In step S220, when the client completes the call to the target service, the service pressure index of the client instance selected for the client instance manager is decreased by the increased value at the time of the call.
Specifically, when the client needs to invoke the service provided by the server, the client instance manager selects a suitable client instance according to the service pressure index value of each client instance, and invokes the corresponding target service provided by the server through the client instance selected by the client instance manager. When the client calls the target service, the target service is in an occupied state, and the service pressure of the target service is correspondingly increased. Because the client instances correspond to the server instances one to one, and the client instances are provided with the service pressure index values, in order to represent the state of the called target service and the current situation that the resources of the target service are occupied, the client instance manager can increase the service pressure index values of the client instances selected by the client instance manager, when the client completes calling the target service, the resources of the target service are released, at the moment, the service pressure index values of the corresponding client instances can be correspondingly reduced, and the reduced service pressure index values can be equal to the increased values of the service pressure indexes when the target service is called.
Illustratively, the GRPC client instance manager sets a service pressure indicator for each GRPC client instance, the initial value may be 0, and the value of the service pressure indicator of a GRPC client instance is increased by 1 each time a GRPC client instance is invoked. Each time a GRPC client instance is completed invoked, the GRPC client instance's service pressure indicator value is accordingly decremented by 1 to represent the release of service resources.
Further, when the client calls the target service, the service pressure index value of the client instance selected by the client instance manager is increased according to the historical average occupied time of the target service and the current concurrency number.
The historical average occupation time length is an average value of time lengths spent by the target service for processing the historical service requests, for example, if the target service has processed N service requests, the historical total time length occupied for processing the N service requests is M, and the historical average occupation time length is M/N. Specifically, when the client invokes the target service, the resource usage of the target service may be evaluated by using the historical average occupancy duration of the target service, and the service pressure index value of the client instance corresponding to the target service may be increased according to the historical average occupancy duration of the target service. It will be appreciated that if the target service currently receives multiple service requests simultaneously, the service pressure indicator value should be equal to the product of the number of concurrencies and the historical average occupancy period.
Fig. 3 is a flowchart illustrating an implementable manner of step S210 according to an exemplary embodiment, where as shown in fig. 3, when the client completes the call to the target service, the service pressure indicator of the client instance selected by the client instance manager decreases by the increased value when the call is made, and the method includes the following steps:
in step S310, when the client completes calling the target service, it is determined whether a parameter of the callback function satisfies a preset condition;
in step S320, if the preset condition is satisfied, the service pressure index of the client instance selected by the client instance manager is decreased by the increased value during the call.
In step S330, if the preset condition is not satisfied, first alarm information is sent to the server corresponding to the target service.
A callback function is a function that is passed into a main function as an argument and is called within the main function to complete some tasks. The first alarm information refers to prompt information sent by the client when the content responded by the server is not in accordance with expectations. The first alarm information may carry a content responded by the server. The first alarm information can also carry error information to prompt the reason for the alarm information.
Specifically, when the client completes calling the target service, the target service returns response content for the service request to the client. In order to ensure the accuracy of the data, the response content of the server needs to be verified. Because the response content is used as the parameter of the callback function, whether the response content of the server side meets the expectation is verified by judging whether the parameter of the callback function meets the preset condition. And if the parameters of the callback function meet the preset conditions, releasing occupied resources of the target service, and reducing the increased numerical value during calling for the service pressure index of the client instance selected by the client instance manager. And if the parameter of the callback function does not meet the preset condition, first alarm information needs to be sent to a server corresponding to the target service.
In an exemplary embodiment, the state of the server instance corresponds to the state of the client instance, which includes an unavailable state. The method for realizing load balancing further comprises the following steps: when the client fails to call the target service, marking the client instance state corresponding to the target service as an unavailable state; and when the client needs to call the service provided by the server again, selecting the client instance with the minimum service pressure index value by the client instance manager in the client instances except the client instance in the unavailable state.
The state of the service end instance comprises an available state and an unavailable state. The available state can ensure that the service instance works normally and can carry out service calling; conversely, the status is an unavailable status, for example, the status of the service instance being offline, the service instance being disabled, the service instance being expired or failed, the service instance being abnormal, etc. can be referred to as an unavailable status. And the client instances generated according to the server instances are in one-to-one correspondence with the server instances, and the states of the client instances are also in correspondence with the states of the server instances. When the state of the server instance is the available state, the state of the client instance is the available state. And when the state of the server instance is the unavailable state, the state of the client instance is the unavailable state.
Specifically, when the client fails to call the target service, it is described that the state of the service instance corresponding to the target service is an unavailable state, and the state of the client instance corresponding to the target service is marked as an unavailable state. Further, second alarm information may also be sent, and the second alarm information may carry specific error information. The next time a client initiates a service request, the client instance manager may automatically select other client instances to attempt invocation, directly skipping the client instance in the unavailable state. The problem that service calling fails because the calling service instance is still called in an unavailable state in the calling process is solved. Preferably, when the client needs to invoke the service provided by the server again, in the client instances except the client instance in the unavailable state, the client instance manager compares the service pressure index values of the client instances, and selects the client instance with the smallest service pressure index value as the client instance needing to be invoked, so as to invoke the corresponding target service provided by the server.
Fig. 4 is a flowchart illustrating a method for implementing load balancing according to an exemplary embodiment, where, as shown in fig. 4, the method includes the following steps:
in step 402, a plurality of server instances provided by a server are obtained, and corresponding client instances are generated according to the server instances;
in step 404, a client instance manager is created according to the generated client instances, and a service pressure index is created for each client instance;
in step 406, the client instance manager compares the service pressure index values in the client instances, and selects the client instance with the smallest service pressure index value as the client instance to be invoked.
In step 408, the client instance selected by the client instance manager invokes the corresponding target service provided by the server.
The state of the server instance corresponds to the state of the client instance, and the state of the client instance comprises an unavailable state;
in step 410, when the client invokes the target service, the service pressure index value of the client instance selected by the client instance manager is increased according to the historical average occupied time of the target service and the current concurrency number.
In step 412, when the client completes the call to the target service, it is determined whether the parameter of the callback function satisfies a preset condition;
in step 414, if the predetermined condition is satisfied, the service pressure indicator of the selected client instance for the client instance manager is decreased by the increased value during the call.
In step 416, if the preset condition is not met, first alarm information is sent to a server corresponding to the target service, where the first alarm information carries a first error message.
In step 418, when the client fails to invoke the target service, marking the client instance state corresponding to the target service as an unavailable state, and sending second alarm information, wherein the second alarm information carries second error information;
in step 420, when the client needs to call the service provided by the server again, in the client instances except the client instance in the unavailable state, the client instance with the minimum service pressure index value is selected by the client instance manager.
Fig. 5 is a block diagram illustrating an apparatus for implementing load balancing according to an example embodiment. Referring to fig. 5, the apparatus includes a client instance generation module 510, an instance manager creation module 520, a client instance selection module 530, and a target service determination module 540.
A client instance generation module 510 configured to execute obtaining a plurality of server instances provided by a server, and generate corresponding client instances according to the server instances;
an instance manager creation module 520 configured to create a client instance manager according to the generated client instances, and create a service pressure indicator for each client instance;
a client instance selection module 530 configured to execute, when the client needs to invoke the service provided by the server, selecting, by the client instance manager, a client instance that needs to be invoked according to the service pressure index value of each client instance;
a target service determination module 540 configured to execute the corresponding target service provided by the server according to the client instance selected by the client instance manager.
In an exemplary embodiment, the client instance selection module is further configured to compare the service pressure index values in the client instances through the client instance manager when the client needs to invoke the service provided by the server, and select the client instance with the smallest service pressure index value as the client instance needing to be invoked.
In an exemplary embodiment, the apparatus further comprises:
the index value increasing module is configured to increase the service pressure index value of the client instance selected by the client instance manager when the client calls the target service;
and the index value reduction module is configured to execute the value increased when the service pressure index of the client instance selected by the client instance manager is reduced and called when the client completes calling the target service.
In an exemplary embodiment, the index value increasing module is further configured to perform, when the client invokes the target service, increasing the service pressure index value of the client instance selected by the client instance manager according to the historical average duration of occupation and the current concurrency number of the target service.
In an exemplary embodiment, the index value reduction module is further configured to determine whether a parameter of the callback function satisfies a preset condition when the client completes the call to the target service; if the preset condition is met, the service pressure index of the client instance selected by the client instance manager is reduced by the increased numerical value during calling.
In an exemplary embodiment, the apparatus further comprises:
and the first alarm module is configured to send first alarm information to a server corresponding to the target service if the preset condition is not met.
In an exemplary embodiment, the state of the server instance corresponds to the state of the client instance, including an unavailable state; the device also includes:
the second alarm module is configured to mark the client instance state corresponding to the target service as an unavailable state and send second alarm information when the client fails to call the target service;
and the client instance selection module is also configured to select the client instance with the minimum service pressure index value through the client instance manager in the client instances except the client instance in the unavailable state when the client needs to call the service provided by the server again.
With regard to the apparatus in the above-described embodiment, the specific manner in which each module performs the operation has been described in detail in the embodiment related to the method, and will not be elaborated here.
FIG. 6 is a block diagram illustrating an electronic device in accordance with an example embodiment. The electronic device includes: a processor; a memory configured to execute stored processor-executable instructions; the processor is configured to execute the instructions to implement the load balancing implementation method. As shown in fig. 6, the electronic apparatus includes a processor, a memory, a network interface, a display screen, and an input device, which are connected through a system bus. Wherein the processor is configured to provide computing and control capabilities; the memory comprises a nonvolatile storage medium and an internal memory, wherein the nonvolatile storage medium stores an operating system and a computer program, and the internal memory provides an environment for the operation of the operating system and the computer program in the nonvolatile storage medium; the network interface is used for connecting and communicating with external equipment through a network; the computer program is executed by a processor to realize the load balancing implementation method; the display screen can be a liquid crystal display screen or an electronic ink display screen; the input device may be a touch layer covered on the display screen, or may be a key, a track ball or a touch pad arranged on the casing of the computer device, or may be an external keyboard, a touch pad or a mouse, etc.
Those skilled in the art will appreciate that the configuration shown in fig. 6 is a block diagram of only a portion of the configuration associated with the disclosed aspects and does not constitute a limitation on the computing devices to which the disclosed aspects apply, as a particular computing device may include more or fewer components than shown, or combine certain components, or have a different arrangement of components.
In an exemplary embodiment, there is also provided an electronic device including: a processor; a memory configured to execute stored processor-executable instructions; the processor is configured to execute the instructions to implement the load balancing implementation method.
In an exemplary embodiment, a storage medium including instructions, such as a memory including instructions, which are executable by a processor of an electronic device to perform the load balancing implementation method is also provided. Alternatively, the storage medium may be a non-transitory computer readable storage medium, which may be, for example, a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice in the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (16)

1. A method for realizing load balancing is applied to a client, and comprises the following steps:
acquiring a plurality of server instances provided by a server, and generating a corresponding client instance according to each server instance;
creating a client instance manager according to the generated client instances, and creating a service pressure index for each client instance, wherein the service pressure index is used for representing at least one of an occupation state, a survival state, a historical average occupation duration and a concurrency number of the server instance corresponding to the client instance;
when a client needs to call the service provided by the server, selecting a client instance to be called according to the service pressure index value of each client instance through the client instance manager;
and calling a target service provided by a server corresponding to the client instance through the client instance selected by the client instance manager.
2. The method according to claim 1, wherein the selecting, by the client instance manager, the client instance to be invoked according to the service pressure indicator value of each client instance comprises:
and comparing the service pressure index values in the client instances through the client instance manager, and selecting the client instance with the minimum service pressure index value as the client instance needing to be called.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
when the client calls the target service, increasing the service pressure index value of the client instance selected by the client instance manager;
and when the client finishes calling the target service, reducing the increased value when calling for the service pressure index of the client instance selected by the client instance manager.
4. The method according to claim 3, wherein the increasing the service pressure indicator value of the client instance selected by the client instance manager when the client invokes the target service comprises:
and when the client calls the target service, increasing the service pressure index value of the client instance selected by the client instance manager according to the historical average occupied time and the current concurrency number of the target service.
5. The method of claim 4, wherein the decreasing the value increased when the client instance's service pressure indicator selected for the client instance manager decreases the call when the client completes the call to the target service comprises:
when the client finishes calling the target service, judging whether the parameter of the callback function meets a preset condition;
and if the preset condition is met, reducing the increased numerical value when the service pressure index of the client instance selected by the client instance manager is called.
6. The method of claim 5, further comprising:
and if the preset condition is not met, sending first alarm information to a server corresponding to the target service.
7. The method of claim 1, wherein the state of the server instance corresponds to the state of the client instance, and wherein the state of the client instance comprises an unavailable state; the method further comprises the following steps:
when the client fails to call the target service, marking the client instance state corresponding to the target service as an unavailable state, and sending second alarm information;
and when the client needs to call the service provided by the server again, selecting the client instance with the minimum service pressure index value through the client instance manager in the client instances except the client instance in the unavailable state.
8. An apparatus for implementing load balancing, the apparatus comprising:
the client instance generation module is configured to execute the steps of acquiring a plurality of server instances provided by a server and generating corresponding client instances according to the server instances;
an instance manager creating module configured to create a client instance manager according to the generated client instances, and create a service pressure indicator for each client instance, where the service pressure indicator is used to characterize at least one of an occupation state, a survival state, a historical average occupation duration and a concurrency number of a server instance corresponding to the client instance;
the client instance selection module is configured to execute that when a client needs to call the service provided by the server, the client instance manager selects a client instance needing to be called according to the service pressure index value of each client instance;
and the target service determination module is configured to execute target service provided by a server corresponding to the client instance according to the client instance selected by the client instance manager.
9. The implementation apparatus of claim 8, wherein the client instance selection module is further configured to, when a client needs to invoke a service provided by the server, compare, by the client instance manager, service pressure indicator values in the client instances, and select a client instance with a smallest service pressure indicator value as the client instance needing to be invoked.
10. The apparatus of claim 8 or 9, wherein the apparatus further comprises:
an index value increasing module configured to perform increasing a service pressure index value of the client instance selected by the client instance manager when the client invokes the target service;
an index value reduction module configured to execute a value increased when the client completes the call to the target service for the service pressure index reduction call of the client instance selected by the client instance manager.
11. The implementation apparatus according to claim 10, wherein the metric value increasing module is further configured to increase the service pressure metric value of the client instance selected by the client instance manager according to the historical average occupied time and the current concurrency number of the target service when the client invokes the target service.
12. The implementation apparatus of claim 11, wherein the index value reduction module is further configured to determine whether a parameter of a callback function satisfies a preset condition when the client completes the call to the target service; and if the preset condition is met, reducing the increased numerical value when the service pressure index of the client instance selected by the client instance manager is called.
13. The apparatus of claim 12, wherein the apparatus further comprises:
and the first alarm module is configured to send first alarm information to a service end corresponding to the target service if the preset condition is not met.
14. The apparatus as claimed in claim 8, wherein the state of the server instance corresponds to the state of the client instance, and the state of the client instance comprises an unavailable state; the device further comprises:
the second alarm module is configured to mark the client instance state corresponding to the target service as an unavailable state when the client fails to call the target service, and send second alarm information;
and the client instance selection module is further configured to execute the selection of the client instance with the minimum service pressure index value through the client instance manager in the client instances except the client instance in the unavailable state when the client needs to call the service provided by the server again.
15. An electronic device, comprising:
a processor;
a memory configured to execute instructions stored in the memory;
wherein the processor is configured to execute the instructions to implement the method of any one of claims 1 to 7.
16. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN201911207342.XA 2019-11-29 2019-11-29 Method and device for realizing load balance, electronic equipment and storage medium Active CN110944051B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911207342.XA CN110944051B (en) 2019-11-29 2019-11-29 Method and device for realizing load balance, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911207342.XA CN110944051B (en) 2019-11-29 2019-11-29 Method and device for realizing load balance, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN110944051A CN110944051A (en) 2020-03-31
CN110944051B true CN110944051B (en) 2023-01-20

Family

ID=69909186

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911207342.XA Active CN110944051B (en) 2019-11-29 2019-11-29 Method and device for realizing load balance, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN110944051B (en)

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7752626B1 (en) * 2003-09-30 2010-07-06 Oracle America, Inc. System and method for RMI-IIOP request load balancing
CN102447624B (en) * 2011-11-23 2014-09-17 华为数字技术(成都)有限公司 Load balancing method in server cluster, as well as node server and cluster
CN103442030B (en) * 2013-07-31 2016-12-28 北京京东尚科信息技术有限公司 Send and process method and system and the client terminal device of service requesting information
CN108512865B (en) * 2017-02-23 2021-04-16 北京宝兰德软件股份有限公司 Data transmission method and device of EJB container system of Java application server
US10951693B2 (en) * 2018-04-02 2021-03-16 T-Mobile Usa, Inc. Data prioritization and scheduling system
CN110377419A (en) * 2019-06-11 2019-10-25 北京达佳互联信息技术有限公司 A kind of server calls method, apparatus and electronic equipment

Also Published As

Publication number Publication date
CN110944051A (en) 2020-03-31

Similar Documents

Publication Publication Date Title
CN108600005A (en) A method of defence micro services avalanche effect
US9384114B2 (en) Group server performance correction via actions to server subset
CN111817974B (en) Interface current limiting method, device and system based on token bucket and readable storage medium
CN110912972B (en) Service processing method, system, electronic equipment and readable storage medium
US20180205593A1 (en) Resource Management for Services
CN109617750A (en) A kind of service method for early warning and gateway
CN111200606A (en) Deep learning model task processing method, system, server and storage medium
CN106375102A (en) Service registration method, application method and correlation apparatus
CN112559173A (en) Resource adjusting method and device, electronic equipment and readable storage medium
CN106506278B (en) Service availability monitoring method and device
EP3672203A1 (en) Distribution method for distributed data computing, device, server and storage medium
CN113905091A (en) Method and device for processing access request
CN110944051B (en) Method and device for realizing load balance, electronic equipment and storage medium
US9405603B2 (en) Naming of nodes in net framework
US11836528B2 (en) Throttling thread resources of service computing platform
CN109274533B (en) Web service fault positioning device and method based on rule engine
CN111522664A (en) Service resource management and control method and device based on distributed service
CN115514665B (en) Service expansion method, device, electronic equipment and storage medium
WO2017131777A1 (en) Application aware cluster monitoring
CN116032932A (en) Cluster management method, system, equipment and medium for edge server
CN113535439A (en) Service request processing method, device, equipment and storage medium
US8549537B2 (en) Middleware bridge system and method
CN109218376B (en) Data processing method, device and equipment
CN115391042B (en) Resource allocation method and device, electronic equipment and storage medium
CN115622988B (en) Call response method and device for web interface, electronic equipment and storage medium

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
GR01 Patent grant
GR01 Patent grant