In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the advantages and disadvantages of Nginx_lua". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what are the advantages and disadvantages of Nginx_lua.
First, let's take a look at the design guidelines of Nginx_lua:
1. Rapidly develop high-performance and high-concurrency network services based on Nginx.
2. Provide a "synchronous non-blocking" Icano access interface to simplify the development of business logic in the Icano multiplexing system.
The main body of ■ "synchronization" is the timing relationship between the user code and the processing process of the Imax O request initiated by it, which means that the user code will hang until the processing of the Imax O request is completed.
The subject of ■ "non-blocking" is the service process, which means that the processing of the Imax O request does not cause the service process to block waiting, but rather the user logic that can continue to process other requests.
Nginx is characterized by less memory and strong concurrency ability. In fact, the concurrency ability of nginx does perform better in the same type of web server. At present, Chinese mainland uses nginx website users: Sina, NetEase, Tencent, and the well-known microblog Plurk also uses Nginx.
Selection of Nginx server and Lua version
1) selection of Nginx high-performance open source WEB server
Qingwu first came into contact with Nginx servers in 2008, when high-performance open source WEB servers also included lighttpd, so why did Qingwu, a technical expert in Yitao, choose Nginx? Which aspect does Nginx have its advantages? Qing Wu said that in the comparison between lighttpd and Nginx, there is an obvious disadvantage that the module mechanism of lighttpd is poorly designed. The module mechanism of lighttpd combines too much request processing logic of the module itself with the handling of underlying network events, so it is not as clear as the module structure of Nginx. Of course, the module design of Nginx draws lessons from the module design of Apache to a large extent, so this piece has an inherent advantage. At that time, in fact, he first came into contact with lighttpd, and then after Nginx came out, after comparing the differences in their module structure, he felt that Nginx seemed to have more advantages. According to the actual measurement, for our network Imax O-intensive applications, as long as you do not implement this logic, there is not much difference between lighttpd or Nginx.
In the process of comparison and selection, first of all, starting from the architecture, if there is a problem, no matter how you implement it, there is a problem, so my comparison is first of all in the construction of the architecture, the service model of each connection or single-thread single process per request is brushed out directly, and it is certainly impossible to achieve high service capability. The rest are all based on the RO multiplex architecture, so on this system we go to test. In fact, we take an IPP request to test the quality of its implementation. Generally speaking, once this part of the architecture is decided, the actual performance difference is not particularly large, unless one feature is implemented and the other is not implemented. The differences we measure usually fluctuate around 10% and 20%.
2) selection of Lua version
In the communication between Xiaobian and Qingwu, I learned that the current version of lua used by Yitao is 5.1.2. When the editor asks whether the higher the version, the stronger the performance, Qingwu thinks it is not right. For lua, the change in each version means that it will add new syntax elements or change some of the internal implementation. Strictly speaking, it does not mean that its performance is good, for example, for 5.2 and 5.1, it is strictly a new language for the modification of the environment table or other mechanisms. So for now, the obstacle to migrating to 5.2 is actually a change in the concept of the underlying interface in 5.2. Because 5.1 has done a lot of work on some aspects, and then use its global table plus environment table mechanism. But 5.2 completely cancels the concept of global table, and also cancels a series of interfaces for environment table operation at CU level. For us, it certainly cannot be smoothly migrated to 5.2. if there is a need, we can do it, but we have not seen this requirement yet. Another problem that hinders us from upgrading the version number is that the performance of Lua JIT,lua JIT is much higher than the standard lua, so deep inside we usually use JIT, but luaJIT's support for lua5.2 is not so tight, it is still mainly 5.1, so it is impossible for me to follow in the footsteps of luaJIT for a long time.
In the application of Yitao, Qingwu said that Nginx_lua is mainly used in two places, one is the traditional quantum statistics store of Yitao database, and the data interface part is done entirely with Nginx_lua. The other is that part of the data interface of Yitao's advertising department also uses Nginx_lua.
Performance Test and comparison of Nginx_lua
In fact, there are a lot of people still use Nginx_php this combination, where is the advantage of Nginx_lua combination? Qingwu said that there should be inter-process communication between Nginx+php, so the basic performance overhead is very high. Lua is embedded inside the Nginx process, so it doesn't need two sets of processes working independently there. So this piece has a decisive advantage in terms of structure. In addition, the communication between threads requires a lot of deserialization and serialization work, and then the extra situation brought by the two sets of processes is more processes and more switching overhead, so the Nginx_php on a stand-alone machine is much lower than Nginx_lua. But relatively speaking, we still have to go back to what we do, because the current disadvantage of Nginx_lua is that the surrounding modules are quite unsound, and we need a lot of time to accumulate these modules. Php has accumulated for more than ten years, if your performance requirements are not so high, my concurrency is dozens, then you use php is the most appropriate. However, if it is like a data interface for data, the number of machines is only a little bit, because a lot of my cost is on the MySQL cluster, which is the main force in this area, then I want to reduce the cost of the external data interface as much as possible, and the number of concurrency is very large, and php is definitely not good, then we have to choose Nginx_lua. But the disadvantage of this piece to the module does not seem to be so great, because its logic is relatively fixed, we can bear the cost, and we go to customize some modules for this logic.
From the above two performance test charts, we summarize the applicable scenarios of Nginx_lua:
Network applications whose blocking time is much higher than that of CPU computing and upstream resources are non-bottleneck (scalable), such as high-performance network middle layer, HTTP REST interface service, etc.
A Web site that expects to simplify the system architecture and homogenize services to Nginx
Advantages and disadvantages of Nginx_lua
As for the disadvantages of Nginx_lua, Qingwu also introduced a problem that the surrounding modules are not perfect and not sound when comparing with Nginx_php. If you use this thing is more complex when the productivity may not go up, the most suitable person for Nginx_lua is the data interface layer, as well as all the network middle layer, you need the most concurrent, high-performance network middle layer. Because its own logic is relatively simple, or it can be realized entirely in lua itself, the ratio of effectiveness to effectiveness is *. So if you currently want to be a complex WEB access station, there are a lot of templates to set, a lot of complex logic embedded in it, and then you want to access mail to access other services, I think it is still php or other more mature languages. The same is true for our current applications, the middle layer will use a lot of lua, but the front-end presentation layer will either be moved to the browser and implemented in the form of JS+ template, or it will be done with PHP.
Another disadvantage is that there are not too many debugging aids, because advanced php programmers tend to use XDebug or other debugging tools, which can be debugged step by step and online. Compared with php, there is still a lack of such a mechanism. At that time, we will emulate XDebug to implement DPT V2 protocol, we implement a mechanism that is compatible with DPT V2 and connect to Nginx_lua, so that Nginx_lua can also be debugged step by step. We will share it with you then.
* Let's summarize several advantages and disadvantages of Qingwu:
Advantages:
The form of synchronous non-blocking isign O is intuitive and easy to understand, and its concurrent service ability is strong.
Low running cost of CPU and memory
High degree of bonding with Nginx, convenient for bonding existing Nginx module functions
Disadvantages:
It is a new technology solution. Lua is more widely used than PHP, Ruby and other widely used development.
Language, the surrounding ancillary facilities are not sound enough, it takes time to accumulate
Requirements of Nginx_lua and pursuit of performance
In terms of demand, Qing does not think that this part of the data interface in Yitao can be fully met, as for other needs, we need to find a specific solution. Because there is no such thing as eating everything in the computer industry.
So as a technician, is the pursuit of performance suitable or endless? Qingwu said that this depends on whether we are doing business or personal matters. If it is in a company, such as in specific matters, and then in the case of teamwork, then blindly pursuing the limit of performance is an inappropriate behavior, because your pursuit is to pay the corresponding costs and expenses, which is often intolerable in an enterprise environment. The most appropriate architecture is often the one that aims at you to solve the problem, rather than the one that pursues efficiency. Therefore, when we specifically do projects in the enterprise, it is obvious that enough is enough. If you cover the needs of your user, you don't have to pay more energy to do it, because there are many other problems, and you don't need to stay on the issue of performance, which is just one of them. there is no need to put much effort into a problem. However, from the developer's personal point of view, pursuing the performance limit is a good idea and behavior, because the developer's own pursuit of the performance limit reflects the pursuit of *. The pursuit of * means that it can focus on research from the top to the bottom, and research is the most effective driving force to improve personal quality. So look at this issue separately.
Thank you for your reading, the above is the content of "what are the advantages and disadvantages of Nginx_lua". After the study of this article, I believe you have a deeper understanding of the advantages and disadvantages of Nginx_lua, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.