Home  >  Article  >  Backend Development  >  nginx learning (1)

nginx learning (1)

WBOY
WBOYOriginal
2016-08-08 09:22:56940browse

I recently started doing CDN-related business. The backend is all nginx-related knowledge. For example, the cache of all websites is built on the nginx server. Various forwarding, proxy, caching, load balancing and other functions are all supported by nginx.

Many access control strategies need to be implemented using nginx embedded lua. In addition, there is a large amount of logic and business related to CDN that need to be customized and developed on nginx, so mastering nginx is the basis for in-depth development of CDN business.

So I plan to spend some time learning and developing business at the same time, and record the overall learning experience, hoping to have a better understanding of nginx.

Currently, the understanding of nginx is limited to the following aspects:

  • 1 nginx is a high-performance WEB server based on event-driven model C/S architecture open sourced by a Russian expert, and mainly supports HTTP Protocols related to email.
  • 2 nginx has the best performance among WEB servers. Although it only ranks second in market share, the first place is of course apache in the Java world.
  • 3 At present, the back-end of mainstream domestic CDN services is almost all based on nginx.
  • 4 nginx is very powerful and supports forward proxy, reverse proxy, caching, load balancing and many other functions.
  • 5 nginx can support lua extension very well, and can load the lua interpreter internally, achieving a perfect fit with the lua language. At present, many functions are completed in Lua scripts.
  • 6 nginx adopts a multi-process management method, with one master manager and 0 to multiple worker processes. All specific tasks are completed by specific workers. The master is only responsible for management and scheduling responsibilities.
  • 7 nginx uses a pipeline to process the message flow. The processing process is divided into 11 stages. Each message is executed stage by stage in order. If the conditions are not met in one of the stages, it will end early. The three most famous stages are rewrite, access, and content. Rewrite is to perform internal processing on the URL, including checking, modifying attributes, redirecting, etc., access is mainly to implement access control, etc., and content is to generate the final content to be sent to the user.
  • 8 There are many data structures inside nginx, including strings, linked lists, hashes, and radix_tree (used before), etc. It is best to master these data structures.
  • 9 There is an open source project called openresty, which contains the core of nginx and commonly used third-party modules. You can refer to it if you want to build it quickly.

The above introduces nginx learning (1), including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn