System and method for integrating APISIX with Sentinel and readable storage medium

By integrating the Sentinel plug -in, the APISIX streaming plug -in lack of multi -dimensional current and downgrade strategies, realized dynamic rules management and real -time effect, provided rich monitoring indicators, and improved the stability and reliability of the system.

CN119363663APending Publication Date: 2025-01-24SHANGHAI SHOUQIANBA INTERNET TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411478852.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

APISIX's current limit plug-in lacks multi-dimensional current limit and downgrade strategies. It depends on API configuration and has weak dynamic management capabilities. Each change of rules requires re-release of routes, and there is no corresponding monitoring indicator.

Method used

Integrate Sentinel plug -in, provide regular configuration components and storage components, support multi -dimensional current limit and downgrade strategies, realize dynamic rules management and real -time effect, and provide rich monitoring indicators.

Benefits of technology

The support of multi -dimensional current restrictions and downgrading strategies, dynamic rules management and real -time effect, provide rich monitoring indicators, and improve the stability and reliability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119363663A_ABST
    Figure CN119363663A_ABST
Patent Text Reader

Abstract

According to the APISIX integrated Sentinel system and method and the readable storage medium, by integrating Sentinel, the system can support multi-dimensional current limiting and degradation strategies, and the degradation strategies of Sentinel allow the system to automatically degrade part of non-core functions when detecting abnormity or pressure, so that the overall stability of the system is protected. The Sentinel provides the capabilities of dynamic configuration and real-time effectiveness, which means that the traffic management rule can be updated without restarting the APISIX gateway. The rule configuration component and the storage component are introduced, so that management and storage of the rules are more centralized and flexible, and operation and maintenance personnel can conveniently monitor and adjust the rules in real time. In addition, the Sentinel also provides abundant monitoring indexes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of traffic management, and in particular to a system, method and readable storage medium for integrating APISIX with Sentinel. Background Art

[0002] APISIX is a dynamic, real-time, high-performance cloud-native gateway. It is built on the technical foundation of nginx+ngx_Lua, making full use of the powerful performance provided by LuaJIT. On the one hand, it provides important basic functions such as route matching, load balancing, service discovery, and API management. On the other hand, based on its powerful and flexible plug-ins, users can customize API processing logic and implement flexible authentication, observability, traffic management, and multi-protocol access at the plug-in level. The open source version of APISIX supports interface current limiting and fuse in the form of plug-ins.

[0003] The APISIX current limiting plug-in is relatively basic, mainly providing current limiting based on request rate and concurrency, and lacks multi-dimensional current limiting and degradation strategies like Sentinel (such as hotspot parameter current limiting, system adaptive protection, etc.). In addition, the APISIX current limiting plug-in relies on API configuration, and its dynamic management capabilities are weak. Each time the rules are changed, the route needs to be republished. The APISIX open source plug-in also does not have corresponding monitoring indicators. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a system, method and readable storage medium for integrating Sentinel with APISIX, so as to solve the problems that the APISIX current limiting plug-in lacks multi-dimensional current limiting and degradation strategies, relies on API configuration, has weak dynamic management capabilities, requires re-publishing routes every time the rules are changed, and has no corresponding monitoring indicators.

[0005] An APISIX-integrated Sentinel system provided in an embodiment of the present application includes: a rule configuration component, a storage component, an APISIX management component, and at least one APISIX gateway loaded with a Sentinel plug-in;

[0006] APISIX management component is used to manage and enable / disable the Sentinel plug-in corresponding to the APISIX gateway;

[0007] A rule configuration component is used to: configure traffic management rules and store the traffic management rules in a storage component; wherein the traffic management rules include flow limiting rules and / or fuse rules and / or degradation rules;

[0008] Sentinel plug-in, used to: obtain traffic management rules in storage components;

[0009] APISIX gateway is used to: use the Sentinel plug-in to execute traffic management rules and control traffic.

[0010] In the above technical solution, by integrating Sentinel, the system can support multi-dimensional flow control and degradation strategies. Sentinel's degradation strategy allows the system to automatically downgrade some non-core functions when anomalies or pressure are detected, thereby protecting the overall stability of the system. Sentinel provides dynamic configuration and real-time effectiveness capabilities, which means that traffic management rules can be updated without restarting the APISIX gateway. The introduction of rule configuration components and storage components makes the management and storage of rules more centralized and flexible, making it easier for operation and maintenance personnel to monitor and adjust rules in real time. Sentinel provides a wealth of monitoring indicators, such as request success rate, response time, number of anomalies, etc. These indicators can help operation and maintenance personnel better understand system performance and bottlenecks.

[0011] In some optional implementations, the method further includes: at least one visualization data module; while executing the traffic management rules using the Sentinel plug-in, the Sentinel plug-in records relevant monitoring indicators;

[0012] The visualization data module is used to regularly pull the monitoring indicators of the Sentinel plug-in and use these monitoring indicators to display the system's flow control and circuit breaking conditions.

[0013] In the above technical solution, the visualization data module can regularly pull monitoring indicators recorded by the Sentinel plug-in, such as request volume, current limiting times, response time, error rate, etc., and display these data in the form of charts, dashboards, etc. This allows operation and maintenance personnel to intuitively understand the system's flow control and fuse conditions and promptly discover potential performance bottlenecks or anomalies.

[0014] In some optional implementations, the storage component is used to store the latest version of the traffic management rules, and the Sentinel plug-in is used to monitor changes in the traffic management rules in the storage component.

[0015] In the above technical solution, the Sentinel plug-in can monitor the changes in the traffic management rules in the storage component in real time, ensuring that once new rules are released or updated, the plug-in can immediately obtain and apply these rules, avoiding the failure or misjudgment of traffic control due to untimely rule updates, and improving the response speed and accuracy of the system. By centrally storing the latest version of traffic management rules, the storage component ensures that all APISIX gateways can access consistent and up-to-date rule information, avoiding traffic control confusion or conflicts caused by inconsistent rules, and improving the stability and reliability of the system.

[0016] In some optional embodiments, the storage component includes a distributed storage component.

[0017] The distributed storage component can be Apollo. Apollo is a distributed configuration center developed by Ctrip's framework department. It can centrally manage the configuration of different application environments and clusters. After the configuration is modified, it can be pushed to the application end in real time. It also has standardized permissions, process governance and other features, which is suitable for microservice configuration management scenarios. Apollo provides two parts: the server and the client. The server is developed based on SpringBoot and SpringCloud, and the client can run in all Java runtime environments.

[0018] In some optional implementations, the Sentinel plug-in includes: an open source Sentinel plug-in in Rust language version; and a cross-language call between the Lua of the APISIX gateway and the Rust of the Sentinel plug-in is implemented through the Lua C API.

[0019] The above technical solution takes advantage of the performance and memory security of the Rust language, and also implements cross-language calls between the Lua script of the APISIX gateway and the Rust code of the Sentinel plug-in through the Lua C API.

[0020] In some optional implementations, including: implementing cross-language calls between Lua of the APISIX gateway and Rust of the Sentinel plugin through the Lua C API, including:

[0021] Use Rust to call the Lua C API provided by Lua. Rust directly operates the Lua virtual machine and registers functions in Rust as callable functions of Lua.

[0022] In the above technical solution, by using Lua C API instead of FFI, WASM, ext-plugin and other technologies provided by APISIX, the ability to efficiently call Rust functions in Lua is guaranteed, thereby improving the performance of the overall system.

[0023] In some optional implementations, Lua's memory management mechanism is garbage collection, and Rust's memory management mechanism is managing memory using ownership and borrowing rules;

[0024] Through Lua C API, cross-language calls between Lua of APISIX gateway and Rust of Sentinel plugin are implemented, including:

[0025] Use Lua newuserdata to allocate memory on the Lua stack. This memory is bound to C / C++ objects. At the same time, when registering these C / C++ objects, a method for actively releasing memory is actively registered for them.

[0026] In the above technical solution, Lua and Rust adopt different strategies for memory management. Lua uses a garbage collection mechanism to automatically manage memory, while Rust manually manages memory through ownership and borrowing rules to avoid memory leaks and unsafe operations. When implementing cross-language calls between Lua of the APISIX gateway and Rust of the Sentinel plug-in through the Lua C API, special attention should be paid to memory management issues. In this embodiment, Lua_newuserdata is used to allocate memory to the Lua stack, and the memory is bound to C / C++ objects. At the same time, when registering these C / C++ objects, a __gc metamethod is actively registered for them, and the Lua language can actively release the memory when needed by calling this method. In this way, the differences in memory management mechanisms between the Lua language and the Rust language are smoothed, and the memory recovery of C objects is handed over to Lua for judgment, avoiding memory leaks and dangling pointer problems.

[0027] In some optional implementations, cross-language calls between Lua of the APISIX gateway and Rust of the Sentinel plugin are implemented through the Lua C API, including:

[0028] Register the Sentinel API of the Sentinel plugin to userdata, provide the function name, function parameters, and function return of the Sentinel API, and implement the encapsulation of the Rust language data structure as the Lua userdata type; when Lua calls the Sentinel API in Rust, Rust converts the userdata type in Lua to the corresponding Rust object.

[0029] In the above technical solution, a mapping relationship between the data type on the Rust side and the Lua userdata is designed. The complex data structures in Rust (such as Entry and Rule of Sentinel) are encapsulated as Lua userdata types through the Lua_newuserdata mechanism, so that Lua can directly operate these Rust data, thereby realizing the communication and conversion of cross-language data structures.

[0030] An embodiment of the present application provides a method for integrating Sentinel with APISIX, including:

[0031] Utilize the rule configuration component to configure the traffic management rules, and store the traffic management rules in the storage component; wherein the traffic management rules include flow limiting rules and / or fuse rules and / or degradation rules;

[0032] Use the APISIX management component to enable the Sentinel plug-in corresponding to the APISIX gateway;

[0033] After the Sentinel plug-in is enabled, the Sentinel plug-in obtains the traffic management rules in the storage component;

[0034] When traffic enters the APISIX gateway, the Sentinel plug-in is used to execute traffic management rules and control the traffic.

[0035] A computer program product provided in an embodiment of the present application includes a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned method of integrating Sentinel with APISIX. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0037] Figure 1 A system functional module diagram of APISIX integrated with Sentinel provided in an embodiment of the present application;

[0038] Figure 2 A flowchart of the method steps for integrating Sentinel with APISIX provided in an embodiment of the present application;

[0039] Figure 3 A system structure diagram of APISIX integrated with Sentinel provided for a specific embodiment of the present application;

[0040] Figure 4 A schematic diagram of a cross-language call provided in an embodiment of the present application. DETAILED DESCRIPTION

[0041] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0042] APISIX is a dynamic, real-time, high-performance cloud-native gateway. It is built on the technical foundation of nginx+ngx_Lua, making full use of the powerful performance provided by LuaJIT. On the one hand, it provides important basic functions such as route matching, load balancing, service discovery, and API management. On the other hand, based on its powerful and flexible plug-ins, users can customize API processing logic and implement flexible authentication, observability, traffic management, and multi-protocol access at the plug-in level. The open source version of APISIX supports interface current limiting and fuse in the form of plug-ins.

[0043] Sentinel is a traffic management component for distributed, multi-language heterogeneous service architectures. It mainly uses traffic as the entry point to help users ensure the stability of microservices from multiple dimensions such as traffic control, traffic routing, circuit breaking and degradation, and system adaptive protection.

[0044] The applicant's research found that:

[0045] The current limiting and fuse plug-in functions provided by the open source version of APISIX are not as rich as those of Sentinel. Sentinel is a library designed specifically for flow control, fuse and degradation. It is very functional and supports a variety of current limiting and fuse rules as well as fine-grained configuration. The current limiting plug-in functions of APISIX are relatively basic, mainly providing current limiting based on request rate and concurrency, but lacking multi-dimensional current limiting and degradation strategies like Sentinel (such as hotspot parameter current limiting, system adaptive protection, etc.).

[0046] Secondly, the open source version of APISIX current limiting and fuse plug-in cannot implement dynamic rule management. Sentinel provides a wealth of dynamic rule management functions, and can modify and view rules in real time through the Dashboard. However, the APISIX current limiting plug-in relies on API configuration, has weak dynamic management capabilities, and each rule change requires re-publishing the route.

[0047] Again, the open source version of APISIX current limiting and circuit breaking plug-in does not have corresponding monitoring and alarming. Sentinel comes with detailed monitoring indicators and can be integrated with Prometheus and Grafana to provide real-time traffic statistics, rule triggering, degradation and other information. The open source plug-in of APISIX does not have corresponding monitoring indicators and needs to be redeveloped.

[0048] Again, the open source version of APISIX only provides a flow-limiting and circuit-breaking plug-in, and does not have the ability to downgrade services. Sentinel focuses on flow control and also provides circuit-breaking and downgrade capabilities. It can automatically trigger circuit-breaking according to predefined rules to protect system stability. The flow-limiting plug-in of APISIX mainly limits flow and circuit-breaking, and its support for the downgrade mechanism is not perfect.

[0049] Therefore, one or more embodiments of the present application provide a system, method and readable storage medium for APISIX integrated Sentinel to solve the above technical problems.

[0050] Please refer to Figure 1 , Figure 1 A system functional module diagram of APISIX integrated with Sentinel provided in an embodiment of the present application, the system includes: a rule configuration component, a storage component, an APISIX management component, and at least one APISIX gateway loaded with a Sentinel plug-in.

[0051] The APISIX management component is used to manage and enable / disable the Sentinel plug-in corresponding to the APISIX gateway. The rule configuration component is used to configure traffic management rules and store the traffic management rules in the storage component; the traffic management rules include flow limiting rules and / or circuit breaker rules and / or degradation rules. The Sentinel plug-in is used to obtain the traffic management rules in the storage component. The APISIX gateway is used to use the Sentinel plug-in to execute the traffic management rules and control the traffic.

[0052] Sentinel can be an open source sentinel component in java, go, c++, or Rust. APISIX and Sentinel need to make cross-language calls, which can be achieved through FFI, WASM, ext-plugin, and Lua CAPI.

[0053] In the embodiment of the present application, by integrating Sentinel, the system can support richer flow limiting strategies, including but not limited to flow limiting based on multiple dimensions such as QPS (query rate per second), number of concurrency, hot spot parameters, system load, etc. Sentinel's downgrade strategy allows the system to automatically downgrade some non-core functions when anomalies or pressure are detected, thereby protecting the overall stability of the system. Sentinel provides dynamic configuration and real-time effectiveness capabilities, which means that traffic management rules can be updated without restarting the APISIX gateway. The introduction of rule configuration components and storage components makes the management and storage of rules more centralized and flexible, making it easier for operation and maintenance personnel to monitor and adjust rules in real time. Sentinel provides a wealth of monitoring indicators, such as request success rate, response time, number of exceptions, etc. These indicators can help operation and maintenance personnel better understand system performance and bottlenecks.

[0054] In some optional implementations, the method further includes: at least one visualization data module; while executing the traffic management rules using the Sentinel plug-in, the Sentinel plug-in records relevant monitoring indicators;

[0055] The visualization data module is used to pull the monitoring indicators of the Sentinel plug-in and use these monitoring indicators to display the system's flow control and fuse status.

[0056] In the embodiment of the present application, the visualization data module can regularly pull (or pull when a trigger condition is triggered) the monitoring indicators recorded by the Sentinel plug-in, such as the number of requests, the number of flow limits, the response time, the error rate, etc., and display these data in the form of charts, dashboards, etc. This allows operation and maintenance personnel to intuitively understand the system's flow control and fuse conditions, and promptly discover potential performance bottlenecks or anomalies.

[0057] In some optional implementations, the storage component is used to store the latest version of the traffic management rules, and the Sentinel plug-in is used to monitor changes in the traffic management rules in the storage component.

[0058] In the embodiment of the present application, the Sentinel plug-in can monitor the changes in the traffic management rules in the storage component in real time, ensuring that once new rules are released or updated, the plug-in can immediately obtain and apply these rules, avoiding the failure or misjudgment of traffic control due to untimely rule updates, and improving the response speed and accuracy of the system. By centrally storing the latest version of the traffic management rules, the storage component ensures that all APISIX gateways can access consistent and up-to-date rule information, avoiding traffic control confusion or conflicts due to inconsistent rules, and improving the stability and reliability of the system.

[0059] In some optional embodiments, the storage component includes a distributed storage component.

[0060] The distributed storage component can be Apollo. Apollo is a distributed configuration center developed by Ctrip's framework department. It can centrally manage the configuration of different application environments and clusters. After the configuration is modified, it can be pushed to the application end in real time. It also has standardized permissions, process governance and other features, which is suitable for microservice configuration management scenarios. Apollo provides two parts: the server and the client. The server is developed based on SpringBoot and SpringCloud, and the client can run in all Java runtime environments.

[0061] In some optional implementations, the Sentinel plug-in includes: an open source Sentinel plug-in in Rust language version; and a cross-language call between the Lua of the APISIX gateway and the Rust of the Sentinel plug-in is implemented through the Lua C API.

[0062] In the embodiment of the present application, the performance advantages and memory safety of the Rust language are utilized, and cross-language calls between the Lua script of the APISIX gateway and the Rust code of the Sentinel plug-in are implemented through the Lua C API.

[0063] In some optional implementations, including: implementing cross-language calls between Lua of the APISIX gateway and Rust of the Sentinel plugin through the Lua C API, including:

[0064] Use Rust to call the Lua C API provided by Lua. Rust directly operates the Lua virtual machine and registers functions in Rust as callable functions of Lua.

[0065] In the embodiments of the present application, by using Lua C API instead of FFI, WASM, ext-plugin and other technologies provided by APISIX, the ability to efficiently call Rust functions in Lua is guaranteed, thereby improving the performance of the overall system.

[0066] In some optional implementations, Lua's memory management mechanism is garbage collection, and Rust's memory management mechanism is managing memory using ownership and borrowing rules;

[0067] Through Lua C API, cross-language calls between Lua of APISIX gateway and Rust of Sentinel plugin are implemented, including:

[0068] Use Lua newuserdata to allocate memory on the Lua stack. This memory is bound to C / C++ objects. At the same time, when registering these C / C++ objects, a method for actively releasing memory is actively registered for them.

[0069] In the embodiments of the present application, Lua and Rust adopt different strategies in memory management. Lua uses a garbage collection mechanism to automatically manage memory, while Rust manually manages memory through ownership and borrowing rules to avoid memory leaks and unsafe operations. When implementing cross-language calls between Lua of the APISIX gateway and Rust of the Sentinel plug-in through the Lua C API, special attention should be paid to memory management issues. In this embodiment, memory is allocated to the Lua stack by using Lua_newuserdata, and the memory is bound to C / C++ objects. At the same time, when registering these C / C++ objects, a __gc metamethod is actively registered for them, and the Lua language can actively release the memory when needed by calling this method. In this way, the difference in memory management mechanisms between the Lua language and the Rust language is smoothed, and the memory recovery of the C object is handed over to Lua for judgment, avoiding memory leaks and dangling pointer problems.

[0070] In some optional implementations, cross-language calls between Lua of the APISIX gateway and Rust of the Sentinel plugin are implemented through the Lua C API, including:

[0071] Register the Sentinel API of the Sentinel plugin to userdata, provide the function name, function parameters, and function return of the Sentinel API, and implement the encapsulation of the Rust language data structure as the Lua userdata type; when Lua calls the Sentinel API in Rust, Rust converts the userdata type in Lua to the corresponding Rust object.

[0072] In the embodiments of the present application, a mapping relationship between the data types on the Rust side and the Lua userdata is designed. The complex data structures in Rust (such as Entry and Rule of Sentinel) are encapsulated as Lua userdata types through the Lua_newuserdata mechanism, so that Lua can directly operate these Rust data, thereby realizing the communication and conversion of cross-language data structures.

[0073] Please refer to Figure 2 , Figure 2 A flowchart of a method step for integrating Sentinel with APISIX provided in an embodiment of the present application includes:

[0074] Step 100: Utilize the rule configuration component to configure the traffic management rules, and store the traffic management rules in the storage component; wherein the traffic management rules include flow limiting rules and / or fuse rules and / or degradation rules;

[0075] Step 200: Use the APISIX management component to enable the Sentinel plug-in corresponding to the APISIX gateway;

[0076] Step 300: After the Sentinel plug-in is enabled, the Sentinel plug-in obtains the traffic management rules in the storage component;

[0077] Step 400: When traffic enters the APISIX gateway, the Sentinel plug-in is used to execute traffic management rules to control the traffic.

[0078] Please refer to Figure 3 , Figure 3 The APISIX system integrated with Sentinel is provided as a specific embodiment of the present application. The following is a detailed description of each module in the system:

[0079] The APISIX control plane is responsible for managing and enabling / disabling the Sentinel current limiting and fuse plug-in. When developers need to enable current limiting, fuse, or degradation functions for specific routes, they can configure them through the APISIX control plane. Only routes with the Sentinel plug-in enabled can have these functions. The APISIX control plane module ensures that the routes have the ability to limit current, fuse, and degrade, maintaining the stability of the entire system.

[0080] The rule configuration component is the control plane of the system, which is used to configure specific Sentinel current limiting, circuit breaking, and downgrade rules. Developers configure these rules through the rule configuration component, and these rules are eventually stored in Apollo. The rule configuration component provides a centralized management platform that allows developers to flexibly configure and manage Sentinel rules and distribute the rules to the system.

[0081] Apollo is a distributed storage component used to store Sentinel rules. It only stores the latest version of Sentinel rules to ensure that the system configuration and execution are always based on the latest rules. Apollo is the core component of rule storage. APISIX monitors the changes of rules in Apollo to ensure that the rules used for each request processing are the latest.

[0082] APISIX acts as an API gateway, loads the Sentinel plug-in, and determines whether current limiting, fuse or downgrading the current route is required based on the result returned by the plug-in at each request. APISIX monitors Apollo's configuration changes in real time and dynamically adjusts the flow control strategy accordingly. The sentinel plug-in of this embodiment is based on Lua C API and Sentinel Rust version SDK, involving core technologies such as cross-language calls. Rust directly operates the Lua virtual machine through Lua C API, and the communication between Lua and Rust is implemented based on Lua C API, ensuring that the data instances generated using Sentinel API can be managed by Lua across languages. APISIX is the core component of rule execution, responsible for applying the configured rules to actual flow control, and ensuring the stability of the system under high concurrency and abnormal flow.

[0083] The Sentinel plugin is a Sentinel module written in Rust, which is responsible for listening to the Apollo configuration and obtaining the latest Sentinel rules. It also calculates the relevant Metric data so that Prometheus can pull data. The Rust language calls the CAPI provided by the Lua language, and uses data structures such as SentinelEntry as Lua userdata for Lua, solving the cross-language call problem between Lua and Rust. It is also responsible for listening to the Apollo configuration to ensure that the latest rules can be obtained. The Sentinel plugin is the basic module for rule execution, which is directly integrated with APISIX and decides whether to control the traffic by executing Sentinel rules.

[0084] Prometheus is responsible for regularly pulling the monitoring metrics of the Sentinel plug-in, which can show the flow control and fuse status of the current system. Prometheus provides a visual monitoring capability for the system operation status, helping operators and developers understand the operation status of the Sentinel plug-in and make necessary adjustments and optimizations.

[0085] In this embodiment, in order to ensure the stability of the production environment service and the robustness of the entire system, the APISIX gateway needs to perform traffic peak control, service stability protection, and real-time monitoring and adjustment. Among them, traffic peak control: ensure that the backend service is not overwhelmed during burst traffic or traffic peak. Service stability protection: when some services are abnormal or performance degrades, it can automatically downgrade or fuse traffic to prevent the spread of faults. Real-time monitoring and adjustment: by monitoring the operation of the system, timely adjust the current limiting and fuse strategies to optimize system performance.

[0086] The workflow of the system in this embodiment is as follows:

[0087] 1. Configure Sentinel rules (in the rule configuration component):

[0088] Developers configure Sentinel's current limiting, circuit breaking, and degradation rules in the rule configuration component. These rules are customized according to business needs and system load conditions, such as configuring different current limiting thresholds and circuit breaking conditions for different routes.

[0089] Once configured, these rules will be automatically stored in Apollo to ensure centralized management and distribution of rules.

[0090] 2. Enable the Sentinel plugin (in the APISIX control plane):

[0091] Administrators use the APISIX control plane tool to enable the Sentinel plug-in for specific routes in APISIX. Only routes with the plug-in enabled can apply the configured current limiting, circuit breaking, and degradation rules.

[0092] After enabling the plugin, APISIX will start monitoring rule changes in Apollo and apply the latest rules in real time.

[0093] 3. Execution rules (in APISIX):

[0094] When traffic enters APISIX, APISIX will determine in real time whether the request needs to be limited, circuit-broken, or downgraded based on the enabled Sentinel plug-in. This judgment is based on the latest rules stored in Apollo.

[0095] For example, when traffic surges, if the configured current limiting threshold is reached, APISIX will trigger current limiting measures to prevent too many requests from flooding into the backend service.

[0096] 4. Monitoring and adjustment (in Prometheus and Sentinel plugins):

[0097] While APISIX is executing rules, the Sentinel plug-in continuously calculates and records relevant monitoring indicators (such as the number of current limiting times, the number of circuit breakers, etc.).

[0098] Prometheus regularly pulls these indicator data and displays them on the monitoring dashboard, making it convenient for operation and maintenance personnel to monitor the operating status of the system in real time.

[0099] If performance bottlenecks or anomalies are found in the system, developers can readjust the Sentinel rules in the rule configuration component based on the monitoring data, and then publish the new rules to Apollo to quickly respond to changes.

[0100] Please refer to Figure 4 In this embodiment, a Sentinel plug-in is written for APISIX in Lua language through cross-language calling technology, which specifically includes the following contents:

[0101] 1. Implementation of cross-language calls:

[0102] This example uses the Rust language to write the Sentinel plug-in, and uses the Lua C API to implement cross-language calls between Lua and Rust.

[0103] Specifically, the Lua language natively supports mutual calls between Lua and C / C++ languages. The Lua language supports cross-language calls through the stack model of the virtual machine. Lua provides header files such as Lua.h, Lualib.h, and lauxlib.h. C / C++ can interact with the Lua virtual machine by using the functions in these header files. The Lua virtual machine maintains a stack for data transfer between C / C++ and Lua. When C calls a Lua function, the parameters are pushed into the stack, and the return value is taken out of the stack after the call ends. When Lua calls a C function, the stack is also used to pass parameters and process return values.

[0104] Lua can register C / C++ functions so that they can be called like Lua functions. Registered C functions can be called directly in Lua scripts, including:

[0105] 1. C function registration: C functions are registered in the Lua virtual machine through Lua_register() or Lua_pushcfunction() and mapped as Lua functions.

[0106] 2. C function parameter passing: When Lua calls a C function, it pushes the parameters into the stack, and the C function reads the parameters in the stack through the Lua C API.

[0107] 3. Return value transfer: The C function pushes the return value into the stack and returns it to the Lua runtime. The Lua runtime then obtains this data through the Lua stack, thus completing cross-language data interaction.

[0108] Current mainstream programming languages ​​all support compiling codes into .so dynamic link libraries based on CABI (Application Binary Interface), so that the Lua language can load dynamic link libraries of any language to achieve cross-language calls.

[0109] In this embodiment, through the Lua C API, Rust can directly operate the Lua virtual machine and register the functions in Rust as Lua callable functions. By using the Lua C API, the ability to efficiently call Rust functions in Lua is guaranteed, thereby improving the performance of the overall system.

[0110] 2. Challenges and solutions of memory management:

[0111] In the cross-language calling process, Lua and Rust have their own independent memory management mechanisms. Lua uses a garbage collection mechanism, while Rust manages memory through ownership and borrowing mechanisms. Therefore, this cross-language memory coordination and management is one of the core technical difficulties of this embodiment.

[0112] This embodiment ensures the allocation and management of the life cycle of Rust objects in the Lua virtual machine through interfaces such as Lua_newuserdata of the Lua C API. When the Rust plug-in creates or uses objects in Lua, the life cycle of these objects is closely integrated with the garbage collection mechanism of the Lua environment, thereby avoiding memory leaks and illegal access problems.

[0113] Through intelligent management of memory references, this embodiment ensures that data shared by Lua and Rust can be safely released under high concurrency conditions, avoiding potential memory leaks or memory inconsistency problems.

[0114] Specifically, Lua and Rust have their own memory management systems: Lua relies on garbage collection (GC), while Rust manages memory using ownership and borrowing rules. These two different memory management mechanisms may lead to memory leaks or dangling pointer problems. For example:

[0115] 1. Dangling pointer: If you hold a pointer in Lua in Rust, and Lua's GC reclaims the object, Rust may access an invalid memory area, resulting in a dangling pointer problem.

[0116] 2. Memory leak: If Rust allocates memory outside the life cycle of Lua, Lua's GC cannot reclaim this memory, resulting in a memory leak.

[0117] The present invention mainly allocates memory on the Lua stack by using Lua_newuserdata, and the memory is bound to C / C++ objects. At the same time, when registering these C / C++ objects, a __gc metamethod is actively registered for them, and the Lua language can actively release the memory when needed by calling this method. In this way, the difference in memory management mechanism between the Lua language and the Rust language is smoothed, and the memory recovery of the C object is handed over to Lua for judgment, avoiding memory leaks and dangling pointer problems.

[0118] 3. Communication and conversion of cross-language data structures:

[0119] Since Lua and Rust use different data representations, this embodiment implements the conversion of data structures between the two languages ​​through the Lua C API. Specifically, complex data structures in Rust (such as Sentinel's Entry and Rule) are encapsulated as Lua's userdata type through the Lua_newuserdata mechanism, so that Lua can directly operate these Rust data.

[0120] In the data conversion process, this embodiment specifically designs the mapping relationship between the data type on the Rust side and the Lua userdata. The mapping management includes: registering the Sentinel API to the userdata, providing the function name, function parameters, and function return of the Sentinel API. In this way, Lua can directly call these methods bound to the userdata.

[0121] The registration method involved can be directly implemented through the Lua_register function of the Lua C API. The function of Lua_register is to register a C function as a Lua function, including:

[0122] 1. Lua_pushcfunction(L,f): Push the C function f into the Lua stack. Lua treats it as a callable function.

[0123] 2. Lua_setglobal(L,n): Assign the value at the top of the stack (C function) to the global variable n. n is the name used when calling the function in the Lua script.

[0124] Through this macro, you can bind the C function as a global function of Lua, and then call it directly in the Lua script, which actually executes the C function.

[0125] In addition, this embodiment also solves the data synchronization problem in cross-language calls. When Lua and Rust share data through Lua CAPI, data consistency and thread safety in a multi-process environment are ensured.

[0126] When Lua calls the Sentinel API in Rust, the Rust plugin converts the userdata type in Lua to the corresponding Rust object, thus achieving seamless data transfer between Lua and Rust.

[0127] In summary, this embodiment can bring the following beneficial effects:

[0128] Not only does it take advantage of the efficient execution capabilities of the Rust language, but it also reduces communication overhead by properly designing the interface between Lua and Rust. For example, when performing flow control and circuit breaker judgment, Lua can allow Rust to complete the calculation through very few interface calls, avoiding performance loss caused by frequent language switching.

[0129] The Sentinel plug-in is based on Rust's multi-threaded model, which can effectively and concurrently process traffic monitoring and circuit breaking logic under high load, and at the same time achieves tight integration with the APISIX main process through the Lua C API. This architectural design fully utilizes Rust's advantages in concurrent processing and ensures the simplicity and maintainability of Lua code.

[0130] The Lua C API provides powerful expansion capabilities. In the future, more Sentinel functions can be extended to APISIX through the same cross-language calling mechanism. For example, more complex traffic limiting rules or dynamic circuit breaking strategies can be supported.

[0131] Through the modular design of Lua and Rust, developers can dynamically adjust Sentinel rules according to business needs without having to worry about the complexity of the underlying cross-language communication. This architectural design makes the system highly maintainable and scalable while reducing maintenance costs.

[0132] Through the Sentinel plug-in, the system can implement refined current limiting and circuit breaking strategies to ensure the stability of services in high-concurrency scenarios and prevent sudden traffic from causing backend service overload.

[0133] Apollo is used for centralized rule storage and management, so that current limiting, circuit breaking, and downgrade rules can be dynamically updated according to business needs. APISIX monitors rule changes in real time to ensure that the latest rules are in effect, thereby quickly responding to changes in system load.

[0134] Through the automated circuit breaker and degradation mechanism, when service anomalies or performance degradation occur, the propagation of problems can be cut off in a timely manner, thus protecting the stability of the overall system and reducing the impact on user experience.

[0135] Prometheus monitors and visualizes the indicators of the Sentinel plug-in, providing comprehensive system operation status monitoring capabilities, helping operations and developers to identify problems in a timely manner and make corresponding adjustments.

[0136] Each module of the system has clear responsibilities and is loosely coupled, making the system easy to expand. Developers can easily configure and adjust rules in the rule configuration component without directly modifying the code of APISIX or Sentinel plug-ins, making maintenance and management convenient.

[0137] Through real-time traffic monitoring and dynamic adjustment of rules, the system can be optimized according to actual traffic conditions, avoiding resource waste and improving overall system performance.

[0138] A computer program product provided in an embodiment of the present application includes a computer program / instruction, which, when executed by a processor, implements the steps of the above-mentioned method of integrating Sentinel with APISIX.

[0139] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the devices or units can be electrical, mechanical or other forms.

[0140] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0141] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.

[0142] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0143] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. An APISIX integrated Sentinel system, characterized in that: include: Rule configuration component, storage component, APISIX management component, and at least one APISIX gateway with the Sentinel plug-in loaded; The APISIX management component is used to manage and enable / disable the Sentinel plug-in corresponding to the APISIX gateway; The rule configuration component is used to: configure traffic management rules and store the traffic management rules in the storage component; wherein the traffic management rules include flow limiting rules and / or fuse rules and / or degradation rules; The Sentinel plug-in is used to: obtain the traffic management rules in the storage component; The APISIX gateway is used to: use the Sentinel plug-in to execute traffic management rules and control traffic.

2. The system according to claim 1, characterized in that Also includes: At least one visualization data module; while the Sentinel plug-in is used to execute the traffic management rules, the Sentinel plug-in records the relevant monitoring indicators; The visualization data module is used to pull the monitoring indicators of the Sentinel plug-in and use these monitoring indicators to display the flow control and fuse status of the system.

3. The system according to claim 1, characterized in that The storage component is used to store the latest version of the traffic management rules, and the Sentinel plug-in is used to monitor the changes of the traffic management rules in the storage component.

4. The system according to claim 1, characterized in that The storage component includes a distributed storage component.

5. The system according to claim 1, wherein: The Sentinel plug-in includes: an open source Sentinel plug-in in Rust language version; and a cross-language call between the Lua of the APISIX gateway and the Rust of the Sentinel plug-in is implemented through the Lua C API.

6. The system according to claim 5, characterized in that include: The cross-language call between the Lua of the APISIX gateway and the Rust of the Sentinel plug-in is implemented through the Lua C API, including: Use Rust to call the Lua C API provided by Lua. Rust directly operates the Lua virtual machine and registers functions in Rust as callable functions of Lua.

7. The system according to claim 5, characterized in that Lua's memory management mechanism is garbage collection, while Rust's memory management mechanism manages memory using ownership and borrowing rules; The cross-language call between the Lua of the APISIX gateway and the Rust of the Sentinel plug-in is implemented through the Lua C API, including: Use Lua newuserdata to allocate memory on the Lua stack. This memory is bound to C / C++ objects. At the same time, when registering these C / C++ objects, a method for actively releasing memory is actively registered for them.

8. The system according to claim 5, characterized in that include: The cross-language call between the Lua of the APISIX gateway and the Rust of the Sentinel plug-in is implemented through the Lua C API, including: Register the SentinelAPI of the Sentinel plug-in to the userdata, provide the function name, function parameters and function return of the SentinelAPI, and implement the encapsulation of the data structure of the Rust language as the userdata type of Lua; when Lua calls the SentinelAPI in Rust, Rust converts the userdata type in Lua into the corresponding Rust object.

9. A method for integrating Sentinel with APISIX, characterized in that: include: Utilize the rule configuration component to configure the traffic management rules, and store the traffic management rules in the storage component; wherein the traffic management rules include flow limiting rules and / or fuse rules and / or degradation rules; Use the APISIX management component to enable the Sentinel plug-in corresponding to the APISIX gateway; After the Sentinel plug-in is enabled, the Sentinel plug-in obtains the traffic management rules in the storage component; When traffic enters the APISIX gateway, the Sentinel plug-in is used to execute traffic management rules and control the traffic.

10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the method according to claim 9 are implemented.