With the rapid development and wide popularization of the Internet,the explosive growth of access demand has brought huge load pressure to the server.The single server architecture is prone to performance bottlenecks when facing such high concurrent access requirements,and cannot respond to client requests in a timely manner.At present,the effective solution to this problem is to build a server cluster system.As the core technology of the cluster system,the performance of load balancing will directly affect the overall performance of the system.As a representative of excellent load balancer,Nginx is widely used with the advantages of simple configuration,high concurrency,strong scalability and low resource consumption.Therefore,the research of load balancing technology based on Nginx is of great significance.This thesis first studies the event-driven model,process working model,and reverse proxy mechanism of Nginx,and summarizes the advantages and disadvantages of its built-in and thirdparty extension algorithms.It analyzes that Nginx’s built-in algorithm is limited in dynamically adjusting the request distribution ratio based on the actual load status of the cluster in highconcurrency scenarios.Then,aiming at the above shortcomings,this thesis improves the weighted round robin algorithm based on the dynamic feedback mechanism and proposes a load balancing algorithm with dynamically adjusted weights.This algorithm periodically collects the load evaluation indicators of each node in the server cluster and calculates the dynamic weights of the nodes based on the weight model designed in this thesis.At the same time,it collects the average response time of the last five requests to classify the cluster into two states: light load and heavy load.In the process of selecting nodes in the weighted round robin algorithm,the dynamic weight of the nodes in the light load state is combined with their effective_weight value in the weighted round robin algorithm to improve the algorithm.This allows Nginx to allocate requests reasonably according to the real-time load status of the cluster,thereby improving the resource utilization of the cluster system.Finally,this thesis implements the proposed algorithm by analyzing Nginx’s core data structure,source code modules,and process of processing HTTP requests.Finally,this thesis builds a server cluster system based on Nginx and Tomcat,and compares the performance of Nginx weighted round robin algorithm,the third-party fair algorithm and the algorithm proposed in this thesis by using the performance testing tool Siege.The experimental results show that when the actual number of concurrent connections reaches the peak,the algorithm proposed in this thesis is improved by 6.7% compared with the third-party fair algorithm and by 23.8% compared with the weighted round robin algorithm.When the actual number of concurrent connections reaches saturation,the algorithm proposed in this thesis is improved by 6.9% compared with the third-party fair algorithm and by 26.5% compared with the weighted round robin algorithm.In addition,the algorithm proposed in this thesis is also superior to the other two algorithms in response time,throughput and cluster balance,thus verifying that the algorithm proposed in this thesis is feasible and has certain practical application value. |