While Internet applications are developing rapidly,software architectures and related technologies are also evolving.Microservices architecture stands out from other software architectures with its excellent design concept and has gradually become the mainstream software architecture today.Microservice architecture can build a highly available,highly scalable and low-coupling application system,which can effectively improve the service quality of the application system.However,the difference in load capacity of each server in a microservice cluster often leads to unbalanced load distribution among service nodes in a highly concurrent environment,resulting in a scenario where system resources are overloaded or idle in time segments and localities,and even causing some service nodes to be at risk of downtime due to high load,which seriously affects the quality of system services.In this paper,we optimize and improve the multilayer polling load balancing strategy commonly used in microservice architecture,and adopt an asynchronous nonblocking load balancing strategy at the resource invocation layer between microservices,and design an optimized multilayer load balancing architecture strategy technique to relieve the load pressure of each service node,improve the concurrent processing capability of the system,and improve its service quality.The main work of this paper is divided into the following sections:First,the first layer access portal uses Open Resty as the load balancing component,and provides a new load balancing strategy for Open Resty server by using Lua scripting language.the core idea of this strategy is to calculate the weight of various factors affecting the server load capacity by means of linear weighted sum,and get the load balancing weight value of each server.By dividing the weight value of each server into regions,a random number smaller than the total weight value is randomly generated,and the random number will be served by whichever server falls in the divided region,and the requests will be distributed to the Layer 2 routing gateway cluster in a more balanced way by this load balancing policy.Secondly,the second layer load balancing component uses the asynchronous non blocking gateway component gateway newly provided by spring cloud as the routing gateway layer.By integrating the open source load balancing component ribbon,it completes the dynamic load balancing service and completes the request forwarding to the downstream service cluster by using its excellent load balancing capability.Then,for the resource invocation and effective utilization among the third layer services,the traditional polling strategy of this layer is optimized and improved by using the asynchronous non-blocking Web Client technology as the load distribution model.The core idea of this strategy is to use a linear weighted sum approach to calculate the load balancing weight values of the factors affecting the load capacity of each server,and each scheduling cycle will iterate through all servers in the cluster,and decide the number of scheduling times according to the weight ratio of each server,in order to give full play to the performance of each server,the request tasks are assigned to each node in a smoother way in each scheduling cycle,so that the whole micro In order to fully utilize the performance of each server,the request tasks are assigned to each node in a smoother way in each scheduling cycle,so that the whole microservice cluster works more efficiently and balanced.Finally,the optimized multilayer load balancing scheme is applied to a real engineering system and tested for different levels of concurrent accesses.The experimental test results show that the optimized strategy outperforms the traditional polling strategy in terms of both concurrency handling and request response time. |