Private libraries and modules which are included in the subscription of OpenResty XRay
Directory
- lua-resty-tls-session
- lua-resty-jsonb
- lua-cjson-plus
- lua-resty-http-fast
- luajit-plus
- lua-resty-kafka-fast
- lua-resty-redis-fast
- lua-resty-redis-cluster-fast
- lua-resty-mysql-fast
- lua-resty-memcached-fast
- lua-resty-dymetrics
- openresty-minifiers
- lua-resty-dymetrics
- lua-resty-limit-traffic-dynamic
- openresty-minifiers
- dubbo-nginx-module-plus
lua-resty-tls-session
lua-resty-tls-session is a Lua library for the rotation of TLS session ticket keys.
The TLS session ticket key in the Nginx configuration file is used to generate TLS session tickets. The client uses the session ticket to resume the previous session with the server without a new handshake. However, if the ticket key is not changed for a long time and is leaked, there is a security issue. The security requirements can be met by periodically changing the ticket keys in the configuration file and restarting the Nginx process. However, this approach is very cumbersome for operations and maintenance, and restarting causes brief business interruptions, which is unacceptable for services with high SLA levels.
In addition, for multiple Nginx servers in a cluster, the same ticket key must be configured, otherwise, client requests switching between different servers will cause servers to fail to decrypt the session ticket. The session cannot be restored then. In this case, a new SSL/TLS handshake is required, which can result in very high additional CPU overhead.
Using the lua-resty-tls-session library, you can dynamically update the key in Nginx by specifying keys_fetcher to get the latest key at regular intervals and eliminate expired keys without restarting the Nginx process.
We also provide a built-in redis_fetcher. As long as the cluster uses the same redis_fetcher configuration, they can share these ticket keys. The client-side can resume sessions with all servers in the cluster using a valid session ticket which improves session reuse on both the client and server sides.
lua-resty-jsonb
lua-resty-jsonb
is a solution for manipulating and storing JSON data instead of lua-cjson
. It greatly reduces the creation of GC objects by avoiding serialization and deserialization operations without changing existing data structures.
As lua-resty-jsonb does not require deserialization to query JSON data, it is particularly suitable for replacing lua-cjson when frequent deserialization is required or when only a few subobjects of a large object are queried.
For example, you can generate a JSONB object on control plane machines and distribute that JSONB object to all data plane machines. The machines data plane machines can then query data inside the JSONB without deserialization.
lua-cjson-plus
JSON is often used to exchange messages and store configurations because of its easy-to-read format. In practice, there is often a need to encode and decode a large number of JSON objects, and these operations consume a lot of CPU resources.
The JSON encoding/decoding library lua-cjson has been widely used in OpenResty service. Therefore, OpenResty Inc. has fully optimized the lua-cjson software to improve the efficiency of encoding and decoding JSON data.
In many cases, performance can be up to 4
times that of the open-source library.
The installation and usage instructions of the library can be found in this document.
lua-resty-http-fast
This software is a high-performance HTTP client library implemented by OpenResty Inc. with a core implementation in pure C. It ensures 100% non-blocking IO communication, which is much faster than the open-source Lua cosocket API in OpenResty. The interface of this library is consistent with the open source lua-resty-http. Users can easily replace the open-source lua-resty-http.
Compared to lua-resty-http, this library offers significantly higher performance and less memory overhead.
The installation of the library can be found in Installation guide.
The user manual of the library can be found in User manual.
luajit-plus
luajit-plus is the LuaJIT engine optimized by OpenResty Inc.
The software has the following features
- The performance of operations on tables of luajit-plus private library can be improved thousands of times under some scenarios compared to open-source LuaJIT.
- luajit-plus private library also provides more operation symbols, such as +=, -=, %=, etc.
- Support expression-level
do end
statement. - Optimize memory usage and reduce the memory footprint of the LuaJIT memory allocator.
The installation and usage instructions of the library can be found in this document.
lua-resty-kafka-fast
This software is an interface to the Kafka consumer developed by OpenResty Inc. that enables the OpenResty gateway to consume Kafka messages at the Lua level. The interface implemented in this module is also guaranteed to be 100% synchronized and non-blocking, and will not affect the main loop of the OpenResty worker process.
The installation and usage instructions of the library can be found in this document.
lua-resty-redis-fast
This software is a high-performance Redis client library implemented by OpenResty Inc. with a core implementation in pure C. It ensures 100% non-blocking IO communication, which is much faster than the open-source Lua cosocket API in OpenResty. The interface of this library is consistent with the open source lua-resty-redis. Users can easily replace the open-source lua-resty-redis.
The library offers higher performance with less memory overhead than lua-resty-redis. In some cases, performance can be up to 2.5 times that of the open-source library.
lua-resty-redis-cluster-fast
This software is a high-performance Redis client library implemented by OpenResty Inc. using C-based cosocket API which is much faster than the open-source Lua-based cosocket API. It adds support for Redis clustering compared to lua-resty-redis-fast
. The installation and usage instructions of the library can be found in this document.
lua-resty-mysql-fast
This software is a high-performance MySQL client library implemented by OpenResty Inc. with a core implementation in pure C. It ensures 100% non-blocking IO communication, which is much faster than the open-source Lua cosocket API in OpenResty. The interface of this library is consistent with the open source lua-resty-mysql. Users can easily replace the open-source lua-resty-mysql.
Compared to lua-resty-mysql, this library offers significantly higher performance and less memory overhead.
lua-resty-memcached-fast
This is a high-performance memcached client library implemented by OpenResty Inc. with a core implementation in pure C. It ensures 100% non-blocking IO communication, which is much faster than the open-source Lua cosocket API in OpenResty. The library’s interface is aligned with that of the open-source lua-resty-memcached, allowing for easy replacements.
This library offers higher performance and less memory overhead than lua-resty-memcached.
lua-resty-dymetrics
Open source metrics statistics modules such as nginx-module-vts suffer from severe performance degradation in the case of multiple workers, which in turn affects the business and are therefore not suitable for production environments with high traffic.
OpenResty Inc. implements a high-performance metrics module based on lock-free programming, which can output metrics results in JSON format or Prometheus format, and is suitable for docking with various legacy collection systems. The module also has excellent performance in high-traffic situations. The installation and usage instructions of the library can be found in this document.
openresty-minifiers
The openresty-minifiers library is a high-performance minification library implemented by OpenResty Inc. that supports minification of HTML, CSS, and JavaScript files. The library is based on the private library replace-filter-plus
. The installation and usage instructions of the library can be found in this document.
lua-resty-limit-traffic-dymaic
Lua-resty-limit-traffic-dynamic is an advanced module designed to optimize Nginx performance by dynamically managing HTTP request rate-limiting. This intelligent system adapts to real-time server conditions, focusing on maintaining CPU utilization within a specified target range for Nginx worker processes.
The module operates by collecting crucial metrics, including the total size of request responses for various URIs and the CPU usage of Nginx worker processes. Leveraging this data, it calculates and applies new rate-limiting values to incoming requests, ensuring that CPU usage remains within the desired threshold.
Key features of lua-resty-limit-traffic-dynamic include:
- Dynamic adjustment: Automatically modifies rate-limiting values based on current server load and traffic patterns.
- CPU utilization control: Helps prevent CPU usage from exceeding configured targets.
- URI-specific monitoring: Collects statistics on response sizes for different URIs, allowing for more granular traffic management.
- Seamless integration: Designed to work within Nginx’s request processing phases, including init_worker, access, and log phases.
By implementing lua-resty-limit-traffic-dynamic, system administrators and developers can achieve more efficient resource utilization and improved overall performance of their Nginx servers, particularly in high-traffic environments where maintaining optimal CPU usage is critical.
dubbo-nginx-module-plus
dubbo-nginx-module-plus is a private library of the Dubbo gateway deeply optimized by OpenResty Inc. Compared to the open-source Dubbo gateway module, this module is more stable and offers higher performance.