Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

OpenResty- Enterprise Theory and practice

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

OpenResty background

Nginx has many features and benefits, but it has always been a difficult problem to develop on Nginx. Nginx modules need to be developed in C, and must comply with a series of complex rules. The most important module developed in C must be familiar with the source code of Nginx, which makes developers afraid of it.

OpenResty (also known as ngx_openresty, hereinafter referred to as OR) is a core based on Nginx. By extending third-party functional modules (such as MySQL, PostgreSQL,Memcached,Redis, etc.), we can use lua (scripting language) to develop the business of Nginx core and three-party extension modules.

OpenResty advantage

Core

Based on the Nginx core, it runs completely inside the Nginx service.

Stable operation, lightweight, low memory consumption.

Event-driven model and non-blocking Iamp O

Using the asynchronous non-blocking event driver of Nginx itself to carry out the communication of iUniverse O

Using the efficient multiplexing model of Nginx itself (epoll/linux, kqueue/freebsd, eventport/solaris)

Note: not only the network communication with HTTP clients is non-blocking, but the network communication with many remote backends such as MySQL, PostgreSQL, Memcached and Redis is also non-blocking.

Lua

Compared with nginx module (C) development, lua itself has the characteristics of simple syntax, weak type, and its own GC (no manual memory management), which greatly reduces the difficulty of development.

Performance

Quickly construct a high-performance Web application system capable of concurrent connection of a single machine above 10K or even 1000K.

OpenResty principle

Nginx uses the master-worker model, one master process manages multiple worker processes, the basic event handling is placed in woker, and master is responsible for some global initialization and worker management.

In OpenResty, each woker uses a LuaVM, and when a request is assigned to a woker, a coroutine (co-program) is created in this LuaVM, and data is isolated between the co-programs.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report