Font Size: a A A

Source Code Research And Systematic Module Encapsulation Based On Nginx

Posted on:2021-04-14Degree:MasterType:Thesis
Country:ChinaCandidate:Y X ZhangFull Text:PDF
GTID:2428330614963696Subject:Electronic and communication engineering
Abstract/Summary:PDF Full Text Request
With the wide spread of the Internet,people's life style and living standard have changed greatly.From the era of PC to the era of mobile Internet and then to the era of 5G,the exponential growth of the number of users and the diversification of requests have led to a large number of concurrent visits and the complexity of business processing.Traditional server architecture has been difficult to deal with massive concurrent requests.Instant messaging,online video,real-time interaction and other forms make the backstage system of the website face millions of users' access,which brings huge pressure and severe test to the performance of the server.As a lightweight web server,nginx not only has high performance,high stability and high scalability due to its excellent architecture design,but also has strong concurrent processing capability.In practice,nginx is usually used as a reverse proxy server to realize the load balancing function of server cluster.Consequently,it is of great meaning to study the operation mechanism,reverse agent and load balancing of nginx framework and develop and optimize it.By studying the source code of nginx,this paper analyzes the whole architecture from four aspects: modular design,event driven,process model,memory pool design,and studies the signal mechanism,excellent reverse proxy function and load balancing technology in nginx.Upstream mechanism is the foundation of nginx to realize load balancing,which enables nginx to break through the limitation of single machine and forward the load to the back-end server cluster.Therefore,this paper also studies the HTTP processing framework of nginx and the upstream mechanism of load forwarding.On the basis of source code research,this paper improves the load forwarding of nginx by using the language features of C++,standard library and template programming.First of all,we start to encapsulate the array,linked list,cache area and other customized basic data structures in nginx.We regard each module as a small system,and systematically encapsulate it in an object-oriented way to provide a more easy-to-use interface.Secondly,the core components of the HTTP framework processing flow are encapsulated.Split the huge and complex request structure to abstract the request class and response class of HTTP framework;optimize the registration of request processing function to make the processing function of the module more convenient to join the processing engine;and reorganize and encapsulate the upstream framework.Finally,based on the systematic encapsulation,a new load forwarding module is developed to intervene in the nginx workflow,which can enhance the load balance of nginx,and make the scalability and maintainability of nginx better under the encapsulation of C++.Then use the testing tools to test the improved nginx.The experiment shows that the improved nginx can distribute the load better and the performance is better than the original nginx.
Keywords/Search Tags:Nginx, Web serever, reverse proxy, Load forwarding
PDF Full Text Request
Related items