Load balancing method and device based on logistic regression, electronic equipment and medium
Through the load balancing method based on logistic regression, the polling algorithm and feature acquisition training model are used to solve the problems of low load balancing efficiency and poor interpretability in complex environments in the existing technology, and a more efficient and reasonable load balancing strategy is achieved.
Patent Information
- Application Number
- CN202411200668.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-29
- Publication Date
- 2025-01-10
AI Technical Summary
Existing load balancing algorithms are difficult to apply in complex environments. Traditional algorithms are inefficient and deep learning algorithms are not interpretable, so they cannot effectively improve processing efficiency and system stability.
Using a load balancing method based on logistic regression, the gateway node list is obtained through the polling algorithm, the hardware static features, hardware dynamic features, request packet features and response packet features are collected to generate training samples, the logistic regression model is trained, and the target gateway node is determined to execute the request , realize the reasonable allocation of load balancing strategies.
It improves load balancing processing efficiency and interpretability, is suitable for complex scenarios, fully considers load node resources, and forms a reasonable load balancing strategy.
Smart Images

Figure CN119299382A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of load balancing, and in particular to a load balancing method and device based on logistic regression, an electronic device and a medium. Background Art
[0002] In related technologies, load balancing is a strategy that distributes network traffic, data transmission or requests to multiple servers or resources to improve response speed, availability and fault tolerance. The goal of load balancing is to optimize resource utilization, maximize throughput, minimize response time, and avoid overload at any single point, thereby improving the stability and performance of the entire system. Load balancing algorithms are mainly divided into two categories: traditional algorithms and deep learning algorithms. The strategies generated by traditional algorithms for load balancing in complex environments cannot be effectively applied to corresponding scenarios, and deep learning algorithms are inefficient and not very interpretable.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a load balancing method and device based on logistic regression, an electronic device and a medium, which can be applicable to complex scenarios and improve processing efficiency and interpretability.
[0005] To achieve the above object, an embodiment of the present application provides a load balancing method based on logistic regression, the method comprising the following steps:
[0006] Use polling algorithm to obtain the gateway node list;
[0007] Collecting first feature information of each gateway node in the gateway node list, and generating training samples according to the first feature information, wherein the first feature information includes hardware static features, hardware dynamic features, request packet features, and response packet features;
[0008] Training the to-be-processed logistic regression model according to the training samples to obtain a target logistic regression model;
[0009] The target logistic regression model is used to determine a target gateway node of the current request packet from multiple nodes, so as to execute the request corresponding to the current request packet through the target gateway node.
[0010] In some embodiments, the step of acquiring the gateway node list by using a polling algorithm includes:
[0011] Initialize the gateway node list and set index information;
[0012] Circularly read the request information according to the index information;
[0013] When the first request information is read, a gateway node identifier is obtained through a polling algorithm;
[0014] The gateway node list is updated with the gateway node identifier.
[0015] In some embodiments, collecting first feature information of each gateway node in the gateway node list and generating training samples according to the first feature information includes:
[0016] Initialize a timing state collector and set the timing duration of the timing state collector, wherein the features collected by the timing state collector include hardware static features, hardware dynamic features, request packet features, and response packet features;
[0017] Looping to read the second request information;
[0018] Determine that the second request information is read, and update the request packet characteristics and the response packet characteristics in the timing status collector;
[0019] When the collection duration is equal to the timing duration, the hardware dynamic features, request packet features and response packet features in the timing state collector are calculated to obtain the training sample
[0020] Writing the training sample into a distributed message queue;
[0021] Reset the timing status collector.
[0022] In some embodiments, the step of training the to-be-processed logistic regression model according to the training sample to obtain a target logistic regression model includes:
[0023] Circularly reading the training samples in the distributed message queue;
[0024] When the reading process meets the first preset condition, preprocessing the read training samples to obtain a training sample set;
[0025] The training sample set is input into the logistic regression model to be processed to update the feature weights of the logistic regression model to be processed, and the target logistic regression model corresponding to each feature weight is obtained.
[0026] In some embodiments, when the reading process satisfies the first preset condition, preprocessing the read training samples to obtain a training sample set includes:
[0027] When the reading time reaches a time threshold or the number of reads reaches a number threshold, the read training samples are preprocessed to obtain a training sample set.
[0028] In some embodiments, preprocessing the read training samples to obtain a training sample set includes:
[0029] Aggregate the read training samples according to the time information to obtain aggregated samples;
[0030] Performing feature engineering processing on the aggregated samples to obtain engineering samples;
[0031] The label of the feature information in each of the engineering samples is calculated to obtain the training sample set.
[0032] In some embodiments, performing feature engineering on the aggregated sample to obtain an engineered sample includes:
[0033] The identifier and text features in the aggregated sample are encoded using a one-hot encoding method, and the numerical features in the aggregated sample are binned to obtain the engineering sample.
[0034] To achieve the above object, another aspect of the embodiment of the present application provides a load balancing device based on logistic regression, the device comprising:
[0035] The first module is used to obtain a gateway node list using a polling algorithm;
[0036] The second module is used to collect first feature information of each gateway node in the gateway node list, and generate training samples according to the first feature information, where the first feature information includes hardware static features, hardware dynamic features, request packet features, and response packet features;
[0037] The third module is used to train the to-be-processed logistic regression model according to the training samples to obtain a target logistic regression model;
[0038] The fourth module is used to determine the target gateway node of the current request packet from multiple nodes through the target logistic regression model, so as to execute the request corresponding to the current request packet through the target gateway node.
[0039] To achieve the above object, another aspect of an embodiment of the present application provides an electronic device, including:
[0040] at least one processor;
[0041] at least one memory for storing at least one program;
[0042] When the at least one program is executed by the at least one processor, the at least one processor implements the above method.
[0043] To achieve the above objective, another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program implements the above method when executed by a processor.
[0044] The embodiments of the present application include at least the following beneficial effects: The present application provides a load balancing method and device based on logistic regression, an electronic device and a medium. After the scheme obtains the gateway node list by adopting a polling algorithm, the first feature information including hardware static features, hardware dynamic features, request packet features and response packet features of each gateway node in the gateway node list is collected, and a training sample is generated according to the first feature information. The logistic regression model to be processed is trained according to the training sample to obtain a target logistic regression model, and then the target logistic regression model is used to determine the target gateway node of the current request packet from multiple nodes, so as to execute the request corresponding to the current request packet through the target gateway node, so that the load node resources can be fully considered for request allocation, making the load balancing strategy more reasonable, and then it can be applied to the load balancing process of complex scenarios, and the logistic regression model is used for load balancing processing, which can effectively improve the processing efficiency and has strong interpretability. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a flow chart of a load balancing method based on logistic regression provided in an embodiment of the present application;
[0046] Figure 2 The embodiment of this application provides Figure 1 Flow chart of step S110;
[0047] Figure 3 The embodiment of this application provides Figure 1 Flow chart of step S120;
[0048] Figure 4 The embodiment of this application provides Figure 1 Flow chart of step S130;
[0049] Figure 5 It is a structural diagram of a load balancing device based on logistic regression provided in an embodiment of the present application;
[0050] Figure 6 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application, they are only examples of devices and methods consistent with some aspects of the embodiments of the present application.
[0052] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0053] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0055] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations:
[0056] Load balancing: Load balancing is a strategy for distributing network traffic, data transfers, or requests across multiple servers or resources to improve responsiveness, availability, and fault tolerance.
[0057] Logistic function: Logistic function, which is a common S-type function, is in the form of Where x0 is the value of x in the S-curve; L is the maximum value of the curve, and k is the growth rate of the logistic function or the steepness of the curve. However, when x approaches positive infinity, the value of f(x) approaches L, and when x approaches negative infinity, the value of f(x) approaches 0.
[0058] Logistic regression algorithm: Logistic regression algorithm is a machine learning algorithm that measures the relationship between dependent variables (labels) and independent variables (features) by estimating probabilities through logistic functions.
[0059] Polling algorithm: distributes requests to the backend servers in sequence. It treats each backend server evenly without caring about the actual number of connections on the server and the current system load.
[0060] In the related technologies, load balancing algorithms are mainly divided into two categories: traditional algorithms and deep learning algorithms. Traditional algorithms have the advantages of simple variation rules and high distribution efficiency, but they fail to consider features such as hardware resources, request packages, and return packages, making it difficult to cope with load balancing scenarios in complex environments. Although deep learning algorithms take hardware resources and request packages into consideration, their efficiency cannot be guaranteed and their interpretability is not strong.
[0061] In view of this, a load balancing method and device based on logistic regression, an electronic device and a medium are provided in an embodiment of the present application. After obtaining a list of gateway nodes by adopting a polling algorithm, the embodiment of the present application collects first feature information including hardware static features, hardware dynamic features, request packet features and response packet features from each gateway node in the gateway node list, and generates training samples according to the first feature information. The logistic regression model to be processed is trained according to the training samples to obtain a target logistic regression model, and then the target logistic regression model is used to determine the target gateway node of the current request packet from multiple nodes, so as to execute the request corresponding to the current request packet through the target gateway node, so that the load node resources can be fully considered for request allocation, making the load balancing strategy more reasonable, and then it can be applied to the load balancing process of complex scenarios, and the logistic regression model is used for load balancing processing, which can effectively improve the processing efficiency and has strong interpretability.
[0062] The load balancing method based on logistic regression provided in the embodiment of the present application relates to the field of load balancing technology. The load balancing method based on logistic regression provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms and other basic cloud computing services. The server can also be a node server in a blockchain network; the software can be an application that implements a load balancing method based on logistic regression, etc., but is not limited to the above forms.
[0063] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0064] Figure 1 is an optional flow chart of a load balancing method based on logistic regression provided in an embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S106.
[0065] Step S110: using a polling algorithm to obtain a gateway node list;
[0066] Step S120, collecting first feature information of each gateway node in the gateway node list, and generating training samples according to the first feature information, wherein the first feature information includes hardware static features, hardware dynamic features, request packet features, and response packet features;
[0067] Step S130, training the to-be-processed logistic regression model according to the training samples to obtain a target logistic regression model;
[0068] Step S140: determine the target gateway node of the current request packet from multiple nodes through the target logistic regression model, so as to execute the request corresponding to the current request packet through the target gateway node.
[0069] In the embodiments of the present application, Figure 2 As shown, the process of obtaining the gateway node list by using the polling algorithm includes but is not limited to steps S210 to S240:
[0070] Step S210: Initialize the gateway node list and set index information;
[0071] Step S220, cyclically reading request information according to index information;
[0072] Step S230: When the first request information is read, a gateway node identifier is obtained through a polling algorithm, and the gateway node identifier is updated to the gateway node list.
[0073] It can be understood that in this embodiment, the gateway node list can be initialized by the load balancing control node, wherein the list length can be set to n, the gateway node list is represented as srv_list = [S1, S2, ..., Sn], and the index information i = 0 is set. Then the first request information is read according to the index information. If the first request information is not read, the first request information is read in a loop; if the first request information is read, the gateway node identifier (id) is obtained through the polling algorithm, and the gateway node identifier is forwarded to the corresponding gateway node list. Specifically, the first request information of this embodiment can represent the request information of load balancing. When the load balancing control node reads the request information, it can automatically trigger the subsequent acquisition judgment process. Specifically, the polling algorithm of this embodiment can be expressed as i = i%n; Si = srv_list[i]; i = i+1. Among them, Si represents the gateway node that needs to be distributed.
[0074] In the embodiment of the present application, after obtaining the updated gateway node list srv_list, the characteristic information of all gateway nodes in the gateway node list srv_list is collected as the first characteristic information, and a training sample is generated according to the first characteristic information. It can be understood that, if Figure 3 As shown, the process of this implementation includes but is not limited to
[0075] Step S310, initializing a timing state collector and setting a timing duration of the timing state collector, wherein the features collected by the timing state collector include hardware static features, hardware dynamic features, request packet features, and response packet features;
[0076] Step S320, looping and reading the second request information;
[0077] Step S330: Determine that the second request information is read, and update the request packet characteristics and the response packet characteristics in the timing status collector;
[0078] Step S340: When the collection duration is equal to the timing duration, the hardware dynamic features, request packet features and response packet features in the timing state collector are calculated to obtain training samples.
[0079] Step S350: writing the training sample into the distributed message queue;
[0080] Step S360: reset the timing status collector.
[0081] It is understandable that the timing duration of the timing status collector can be set to 10 seconds, or other values can be set according to actual conditions. The hardware static features include CPU model, total number of CPU cores, CPU main frequency, memory size, memory main frequency, network card model and network bandwidth. They can be obtained through the command line or hardware configuration table initially, and are recorded as Hstat = (cpubrand, cpucores, cpufreq, memgb, memfreq, networkbrand, networkbw); the hardware dynamic features include CPU usage, memory usage, network utilization and network response delay. The corresponding usage is recorded initially, and are recorded as Hdynstart = (usagecpu, usagemem, usagenetwork, usagenrsp); the request packet features include the number of request packet bytes and the number of request packets, and are recorded as Reqstat = (Reqbyte, Reqtotal), which are initially set to 0; the response packet features include the response packet IP or domain name as the primary key, and the number of response packet bytes and the number of response packets are mapped values, and are recorded as Rspstat = Rsphost->(Rspbyte, Rsptotal), which are initially empty.
[0082] After completing the initialization, the second request is read in a loop. When the second request is read, the request packet features and response packet features are updated. The update process of the request packet features is to accumulate the number of bytes and add 1 to the number of packets. The update operation of the response packet features is to first extract the IP or domain name, and update the number of bytes and packets under the IP or domain name. Assuming that the request packet size is n bytes, the request packet feature Reqstat = (Reqbyte + n, Reqtotal + 1) is updated; assuming that the response packet is https: / / ip:port / test, the IP is extracted here, and the response packet size is m bytes, then the response packet feature Rspstat = ip-> (Rspbyte + m, Rsptotal + 1) is updated.
[0083] It is understandable that when the collection duration is equal to the timing duration, the hardware dynamic feature Hdyn is calculated. end =(usage cpu ,usage mem ,usage network ,usage nrsp ) and calculate Hdyn start =(Hdyn start +Hdyn end ) / 2, calculate the request packet feature Req stat =Req stat / s and calculate the response packet characteristics Rsp stat =Rsp stat / s. After completing the corresponding calculation process, the obtained training samples are written into a distributed message queue, such as a kafka or rocketmq queue. The writing format is: "time period, node id, hardware static features, hardware dynamic features, request packet features, response packet features", formally expressed as: record = (Ts, Nodeid, Hstat, Hdyn end ,Req stat ,Rsp stat ). After the writing operation is completed, the timing state collector is reset. The hardware static characteristics remain unchanged during the reset process, the hardware dynamic characteristics remain as the value of step S203, the request packet characteristics are reset to 0, and the return characteristics are reset to 0.
[0084] After obtaining the training samples, the processing logistic regression model can be trained with the training samples to obtain the target logistic regression model. Figure 4 As shown, the model training process includes but is not limited to steps S410 to S430:
[0085] Step S410, cyclically reading training samples in the distributed message queue;
[0086] Step S420: When the reading process meets the first preset condition, preprocess the read training samples to obtain a training sample set;
[0087] Step S430: input the training sample set into the logistic regression model to be processed to update the feature weights of the logistic regression model to be processed, and obtain a target logistic regression model corresponding to each feature weight.
[0088] In the embodiment of the present application, satisfying the first preset condition means that the reading time reaches the time threshold or the number of reads reaches the number threshold. The preprocessing process can be to aggregate the read training samples according to the time information to obtain the aggregated samples, then perform feature engineering on the aggregated samples to obtain the engineering samples, and then calculate the labels of the feature information in each engineering sample to obtain the training sample set. It can be understood that the aggregation process can be to aggregate the read training samples according to the time period Ts. The feature engineering process includes feature encoding and feature discretization. The specific process is to encode the identifier (id) and text features in the aggregated samples using a unique hot encoding method, and to perform binning operations on the numerical features in the aggregated samples. Among them, the binning operations mainly include equal width binning, equal frequency binning, and binning based on business logic. Equal width binning is to divide the feature value range into several intervals and mark them with interval ids. For example, if the CPU usage rate is 100%, it will be divided into 10 intervals, each interval 10%. Equal frequency binning is that each interval contains the same number of samples. This method can ensure that the samples of each age group are evenly distributed. Based on business logic binning, we count the n quantiles (such as quartiles) of the features within the period and encode them. Under this principle: the gateway node ID and hardware static features are encoded using one-hot encoding, while the hardware dynamic features are binned using equal width. After removing the IP or domain name from the request packet features and response packet features, we use binning based on business logic.
[0089] It is understandable that the way to calculate the label of the feature information can be to set the sample label (Label) based on the indicator of business concern. For example, if you pay attention to the CPU usage, then calculate the average CPU usage of all gateway nodes in the time period. And set the fault tolerance coefficient ε, when abs(usage cpui -Avg cpu )<ε, the label is set to 1, indicating that the allocation is reasonable, otherwise it is set to 0, indicating that the allocation is unreasonable. The final sample is formally expressed as (X Hstat ,X Hdyn ,X Reqstat ,X Rspstat , Label), where X represents the standardized feature set, which will be represented by x1, x2, …, x m In addition, to ensure the generalization ability of the model, feature crossover can be performed, such as crossing CPU brand with the number of requests, crossing memory main frequency with the number of responses, etc.
[0090] After obtaining the labels of the sample features, the sample data in the training sample set is input into the logistic regression model to be processed, and the logistic regression algorithm is used to update the feature weights. It can be understood that the method for updating the feature weights is as follows:
[0091] 1) Initialize the value of w, corresponding to x;
[0092] 2) Calculation Calculate the logistic function Where hw(x) is the model prediction value;
[0093] 3) Calculate the loss function: Where Loss(w) is the loss function, y i is the label value, p is the number of training samples;
[0094] 4) Update the gradient w: Where η represents the learning rate, is the gradient of the loss function with respect to the parameter w.
[0095] Repeat steps 2)-4) until the preset number of iterations is reached and the loss function no longer decreases significantly, then stop the iteration and obtain the feature weight w.
[0096] In the embodiment of the present application, after the training of the logistic regression model is completed, whenever a new request packet comes, the hardware static features, dynamic features, request packet features and response packet features are feature engineered, and the features after feature engineering are input into the logistic regression model, and the probability value is calculated and sorted. The maximum value is the optimal gateway node of the current request packet, and the optimal gateway node is used as the target gateway node to execute the request process corresponding to the current request packet. It can be understood that after obtaining a new request packet, the response packet needs to extract the IP or domain name, and then query the number of bytes and the number of response packets.
[0097] In the embodiments of the present application, the complete implementation process of the method provided in the embodiments of the present application includes but is not limited to the following steps:
[0098] Step 1: Initialize the logistic regression model to be processed;
[0099] Step 2: Use polling algorithm to obtain the gateway node list;
[0100] Step 3: Collect first feature information of each gateway node in the gateway node list, and generate training samples according to the first feature information, wherein the first feature information includes hardware static features, hardware dynamic features, request packet features, and response packet features;
[0101] Step 4: Train the logistic regression model to be processed according to the training samples to obtain the target logistic regression model corresponding to the initial feature weights;
[0102] Step 5: Determine the target gateway node of the current request packet from multiple nodes through the target logistic regression model, so as to execute the request corresponding to the current request packet through the target gateway node;
[0103] Step 6: Determine whether the number of times the gateway node executes the request reaches a preset number or the recall rate of the logistic regression model reaches the recall rate threshold, and return to execute step 3.
[0104] In summary, the embodiment of the present application regularly collects hardware static features (CPU model, number of CPU cores, main frequency, memory main frequency, network card model and network bandwidth), and dynamically collects hardware dynamic features (CPU utilization, memory utilization, network utilization and network response delay), request packet features (number of request packets, number of bytes of request packets) and response packet features (number of return packets and number of bytes of return packets), and forms training samples, and regularly trains the samples through the logistic regression algorithm, adjusts the feature weights, and the updated model is used for a new round of load balancing decisions, thereby forming a closed loop, and by fully considering the characteristics of various load balancing indicators, combined with the logistic regression algorithm, the model is more reasonable when making load balancing strategies. In addition, compared with deep learning, the logistic regression algorithm in this embodiment is efficient, highly interpretable, and the feature weights of the training are clearly visible.
[0105] Reference Figure 5 , an embodiment of the present application provides a load balancing device based on logistic regression, the device comprising:
[0106] The first module 510 is used to obtain a gateway node list using a polling algorithm;
[0107] The second module 520 is used to collect first feature information of each gateway node in the gateway node list, and generate training samples according to the first feature information, wherein the first feature information includes hardware static features, hardware dynamic features, request packet features, and response packet features;
[0108] The third module 530 is used to train the logistic regression model to be processed according to the training samples to obtain a target logistic regression model;
[0109] The fourth module 540 is used to determine the target gateway node of the current request packet from multiple nodes through the target logistic regression model, so as to execute the request corresponding to the current request packet through the target gateway node.
[0110] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0111] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the load balancing method based on logistic regression when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0112] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0113] See also Figure 6 , Figure 6 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0114] The processor 610 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0115] The memory 620 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 620 can store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 620, and the processor 610 calls and executes the load balancing method based on logistic regression in the embodiment of this application;
[0116] Input / output interface 630, used to implement information input and output;
[0117] Communication interface 640, used to realize communication interaction between the device and other devices, which can be realized through wired mode (such as USB, network cable, etc.) or wireless mode (such as mobile network, WIFI, Bluetooth, etc.);
[0118] bus 650 , which transmits information between the various components of the device (e.g., processor 610 , memory 620 , input / output interface 630 , and communication interface 640 );
[0119] The processor 610 , the memory 620 , the input / output interface 630 , and the communication interface 640 are connected to each other in communication within the device via a bus 650 .
[0120] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the load balancing method based on logistic regression is implemented.
[0121] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0122] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0123] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0124] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0125] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0126] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0127] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0128] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0129] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0130] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0131] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0132] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0133] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A load balancing method based on logistic regression, characterized in that: The method comprises the following steps: Use polling algorithm to obtain gateway node list; Collecting first feature information of each gateway node in the gateway node list, and generating training samples according to the first feature information, wherein the first feature information includes hardware static features, hardware dynamic features, request packet features, and response packet features; Training the to-be-processed logistic regression model according to the training samples to obtain a target logistic regression model; The target logistic regression model is used to determine a target gateway node of the current request packet from multiple nodes, so as to execute the request corresponding to the current request packet through the target gateway node.
2. The method according to claim 1, characterized in that: The method of using a polling algorithm to obtain a gateway node list includes: Initialize the gateway node list and set index information; Circularly read the request information according to the index information; When the first request information is read, a gateway node identifier is obtained through a polling algorithm; The gateway node list is updated with the gateway node identifier.
3. The method according to claim 1, characterized in that The collecting first feature information of each gateway node in the gateway node list and generating a training sample according to the first feature information includes: Initialize a timing state collector and set the timing duration of the timing state collector, wherein the features collected by the timing state collector include hardware static features, hardware dynamic features, request packet features, and response packet features; Looping to read the second request information; Determine that the second request information is read, and update the request packet characteristics and the response packet characteristics in the timing status collector; When the collection duration is equal to the timing duration, the hardware dynamic features, request packet features and response packet features in the timing state collector are calculated to obtain the training sample Writing the training sample into a distributed message queue; Reset the timing status collector.
4. The method according to claim 1, characterized in that: The step of training the to-be-processed logistic regression model according to the training samples to obtain a target logistic regression model comprises: Circularly reading the training samples in the distributed message queue; When the reading process meets the first preset condition, preprocessing the read training samples to obtain a training sample set; The training sample set is input into the logistic regression model to be processed to update the feature weights of the logistic regression model to be processed, and the target logistic regression model corresponding to each feature weight is obtained.
5. The method according to claim 4, characterized in that When the reading process satisfies the first preset condition, preprocessing the read training samples to obtain a training sample set includes: When the reading time reaches a time threshold or the number of reads reaches a number threshold, the read training samples are preprocessed to obtain a training sample set.
6. The method according to claim 5, characterized in that The preprocessing of the read training samples to obtain a training sample set includes: Aggregate the read training samples according to the time information to obtain aggregated samples; Performing feature engineering processing on the aggregated samples to obtain engineering samples; The label of the feature information in each of the engineering samples is calculated to obtain the training sample set.
7. The method according to claim 6, characterized in that The performing feature engineering processing on the aggregated samples to obtain engineering samples includes: The identifier and text features in the aggregated sample are encoded using a one-hot encoding method, and the numerical features in the aggregated sample are binned to obtain the engineering sample.
8. A load balancing device based on logistic regression, characterized in that: The device comprises: The first module is used to obtain a gateway node list using a polling algorithm; The second module is used to collect first feature information of each gateway node in the gateway node list, and generate training samples according to the first feature information, where the first feature information includes hardware static features, hardware dynamic features, request packet features, and response packet features; The third module is used to train the to-be-processed logistic regression model according to the training samples to obtain a target logistic regression model; The fourth module is used to determine the target gateway node of the current request packet from multiple nodes through the target logistic regression model, so as to execute the request corresponding to the current request packet through the target gateway node.
9. An electronic device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.