Patent information
IP India · live recordAbstract
Disclosed herein is a method (600) for updating a ruleset of a live rule engine (106). The method includes receiving a versioned ruleset comprising one or more rules, each rule comprising a condition expression and an action expression, from a remote compiler service (104) over a communication channel. The method (600) includes generating a compiled ruleset by translating the condition expression and the action expression into bytecode executable by a virtual machine of the live rule engine (106). The method (600) includes staging the compiled ruleset in an inactive memory buffer (401) distinct from an active memory buffer indicated by an active ruleset pointer (303). The method (600) includes activating the compiled ruleset based on an atomic swap operation, receiving rule-evaluation requests, serving new requests, completing in-flight requests, transitioning the active ruleset (403) to a draining state, and retiring the active ruleset (403).
Applicants
1Inventors
1Specification
Show full textCollapse
Description:FIELD OF INVENTION
[0001] The present disclosure relates to rule engine systems, and more particularly to a system and method for updating a ruleset of a live rule engine.
BACKGROUND
[0002] Business rule engines drive real-time decisions in various industries including telecommunications and electronic commerce. Such rule engines evaluate conditions and execute actions for charging, promotions, discounts, eligibility checks, and policy enforcement. Rulesets within such rule engines change frequently due to flash promotions, seasonal offers, and regulatory updates. Platforms hosting the rule engines operate continuously and demand high availability.
[0003] In some implementations, updated rulesets may be deployed using service restart procedures, runtime reload mechanisms, configuration update techniques, orchestration-based deployment approaches, or other ruleset activation mechanisms.
[0004] Certain deployment approaches may involve one or more operations associated with retrieval, validation, parsing, compilation, loading, activation, or replacement of a ruleset. In continuously operating environments, deployment of an updated ruleset may present considerations relating to request continuity, activation latency, resource utilization, version management, deployment coordination, or rollback handling.
[0005] Accordingly, there exists a need for an updated system and method to address at least one or more of the above-mentioned shortcomings and other related problems in the art.
SUMMARY
[0006] This summary is provided to introduce a selection of concepts in a simplified form that are further described below in the detailed description. This summary is not intended to identify key features or essential features of the claimed subject matter, nor is it intended to be used as an aid in determining the scope of the claimed subject matter.
[0007] The present disclosure provides a system and method for updating a ruleset of a live rule engine.
[0008] In an embodiment, a method for updating a ruleset of a live rule engine is disclosed. The method includes receiving, by a scheduler of the live rule engine, a versioned ruleset from a remote compiler service over a communication channel. The versioned ruleset includes one or more rules. Each rule includes a condition expression and an action expression. The method includes generating a compiled ruleset based on the received versioned ruleset by translating the condition expression and the action expression of each rule into bytecode executable by a virtual machine of the live rule engine. Further, the method includes staging the compiled ruleset in an inactive memory buffer of the live rule engine. The inactive memory buffer is distinct from an active memory buffer indicated by an active ruleset pointer corresponding to an active ruleset that serves requests received by the live rule engine. Further, the method includes activating the compiled ruleset based on an atomic swap operation of the active ruleset pointer from the active memory buffer to the inactive memory buffer. The atomic swap operation corresponds to an indivisible in-memory operation performed upon completion of translating the condition expression and the action expression. The method includes receiving rule-evaluation requests after the atomic swap operation. Each rule-evaluation request comprises at least one of a new request or an in-flight request associated with the live rule engine. Further, the method includes serving the new request based on the activated compiled ruleset and completing the in-flight request based on the active ruleset. The method includes transitioning the active ruleset to a draining state based on a cooperative cancellation of an execution context associated with the active ruleset. The draining state indicates that the active ruleset serves the in-flight request and routes the new request received after the atomic swap operation to the activated compiled ruleset. Additionally, the method includes retiring the active ruleset from the active memory buffer based on completion of the in-flight request, thereby updating the active ruleset of the live rule engine without service interruption.
[0009] In an embodiment, a system for updating a ruleset of a live rule engine is disclosed. The system includes a memory and a processor communicatively coupled with the memory. The processor is configured to receive, by a scheduler of the live rule engine, a versioned ruleset from a remote compiler service over a communication channel. The versioned ruleset includes one or more rules. Each rule includes a condition expression and an action expression. The processor is configured to generate a compiled ruleset based on the received versioned ruleset by translating the condition expression and the action expression of each rule into bytecode executable by a virtual machine of the live rule engine. Further, the processor is configured to stage the compiled ruleset in an inactive memory buffer of the live rule engine. The inactive memory buffer is distinct from an active memory buffer indicated by an active ruleset pointer corresponding to the active ruleset that serves requests received by the live rule engine. The processor is configured to activate the compiled ruleset based on an atomic swap operation of the active ruleset pointer from the active memory buffer to the inactive memory buffer. The atomic swap operation corresponds to an indivisible in-memory operation performed upon completion of translating the condition expression and the action expression. Further, the processor is configured to receive rule-evaluation requests after the atomic swap operation. Each rule-evaluation request includes at least one of a new request or an in-flight request associated with the live rule engine. The processor is configured to serve the new request based on the activated compiled ruleset and complete the in-flight request based on the active ruleset. Further, the processor is configured to transition the active ruleset to a draining state based on a cooperative cancellation of an execution context associated with the active ruleset. The draining state indicates that the active ruleset serves the in-flight request and routes the new request received after the atomic swap operation to the activated compiled ruleset. Additionally, the processor is configured to retire the active ruleset from the active memory buffer based on completion of the in-flight request, thereby updating the active ruleset of the live rule engine without service interruption.
[0010] To further clarify the advantages and features of the present invention, a more particular description of the invention will be rendered by reference to specific embodiments thereof, which are illustrated in the appended drawings. It is appreciated that these drawings depict only typical embodiments of the invention and are therefore not to be considered limiting of its scope. The invention will be described and explained with additional specificity and detail in the accompanying drawings.
BRIEF DESCRIPTION OF FIGURES
[0011] These and other features, aspects, and advantages of the present invention will become better understood when the following detailed description is read with reference to the accompanying drawings in which like characters represent like parts throughout the drawings, wherein:
[0012] Figure 1 illustrates a block diagram of an environment for implementing a system for updating a ruleset of a live rule engine, in accordance with an embodiment of the present disclosure;
[0013] Figure 2 illustrates a block diagram of the system for updating the ruleset of the live rule engine, in accordance with an embodiment of the present disclosure;
[0014] Figure 3 illustrates an example system operation workflow for implementing zero-downtime hot-swap of compiled rulesets, in accordance with an embodiment of the present disclosure;
[0015] Figure 4 illustrates an example ruleset workflow depicting the path of a ruleset version through a hot-swap pipeline, in accordance with an embodiment of the present disclosure;
[0016] Figure 5 illustrates an example live request flow method showing concurrent handling of ruleset transitions during live traffic, in accordance with an embodiment of the present disclosure; and
[0017] Figure 6 illustrates a flowchart for a method for updating the ruleset of the live rule engine, in accordance with an embodiment of the present disclosure.
[0018] Further, skilled artisans will appreciate that elements in the drawings are illustrated for simplicity and may not have necessarily been drawn to scale. For example, the flow charts illustrate the method in terms of the most prominent steps involved to help to improve understanding of aspects of the present invention. Furthermore, in terms of the construction of a device, one or more components of the device may have been represented in the drawings by conventional symbols, the drawings may show only those specific details that are pertinent to understanding the embodiments of the present invention so as not to obscure the drawings with details that will be readily apparent to those of ordinary skill in the art having benefit of the description herein.
DETAILED DESCRIPTION
[0019] For the purpose of promoting an understanding of the principles of the present disclosure, reference will now be made to the various embodiments, and specific language will be used to describe the same. It will nevertheless be understood that no limitation of the scope of the present disclosure is thereby intended, such alterations and further modifications in the illustrated system, and such further applications of the principles of the present disclosure as illustrated therein, are contemplated as would normally occur to one skilled in the art to which the present disclosure relates.
[0020] It will be understood by those skilled in the art that the foregoing general description and the following detailed description are explanatory of the present disclosure and are not intended to be restrictive thereof.
[0021] Whether or not a certain feature or element was limited to being used only once, it may still be referred to as “one or more features,” or “one or more elements,” or “at least one feature,” or “at least one element.” Furthermore, the use of the terms “one or more” or “at least one” feature or element does not preclude there being none of that feature or element, unless otherwise specified by limiting language, including, but not limited to, “there needs to be one or more…” or “one or more elements are required.”
[0022] Reference is made herein to some “embodiments.” It should be understood that an embodiment is an example of a possible implementation of any features and/or elements of the present disclosure. Some embodiments have been described for the purpose of explaining one or more of the potential ways in which the specific features and/or elements of the proposed disclosure fulfil the requirements of uniqueness, utility, and non-obviousness.
[0023] Use of the phrases and/or terms including, but not limited to, “a first embodiment,” “a further embodiment,” “an alternate embodiment,” “one embodiment,” “an embodiment,” “multiple embodiments,” “some embodiments,” “other embodiments,” “further embodiment”, “furthermore embodiment”, “additional embodiment” or other variants thereof do not necessarily refer to the same embodiments. Unless otherwise specified, one or more particular features and/or elements described in connection with one or more embodiments may be found in one embodiment, or may be found in more than one embodiment, or may be found in all embodiments, or may be found in no embodiments. Although one or more features and/or elements may be described herein in the context of only a single embodiment, or in the context of more than one embodiment, or in the context of all embodiments, the features and/or elements may instead be provided separately or in any appropriate combination or not at all. Conversely, any features and/or elements described in the context of separate embodiments may alternatively be realized as existing together in the context of a single embodiment.
[0024] Any particular and all details set forth herein are used in the context of some embodiments and therefore should not necessarily be taken as limiting factors to the proposed disclosure.
[0025] The terms “includes”, “including”, or any other variations thereof, are intended to cover a non-exclusive inclusion, such that a process or method that includes a list of steps does not include only those steps but may include other steps not expressly listed or inherent to such process or method. Similarly, one or more devices or sub-systems or elements or structures or components preceded by “includes... a” does not, without more constraints, preclude the existence of other devices or other sub-systems or other elements or other structures or other components or additional devices or additional sub-systems or additional elements or additional structures or additional components.
[0026] The present disclosure provides a system and method for updating a ruleset of a live rule engine. The system and method address the downtime and swap-time latency problems associated with restart-based or load-time-compilation ruleset updates in conventional rule engines.
[0027] It is an object of the present disclosure to provide streaming delivery of versioned rulesets from a remote compiler service to a live rule engine over a communication channel.
[0028] It is another object of the present disclosure to provide ahead-of-time pre-compilation of rulesets into bytecode executable by a virtual machine, with atomic in-process activation through a pointer swap operation.
[0029] It is another object of the present disclosure to provide cooperative draining of in-flight requests, wherein requests executing against a prior ruleset complete while new requests are served by an activated compiled ruleset.
[0030] Embodiments of the present disclosure are explained in detail in the forthcoming paragraphs with reference to the corresponding figures and examples.
[0031] Figure 1 illustrates an environment 100 for implementing a system for updating a ruleset of a live rule engine, in accordance with an embodiment of the present disclosure. The environment 100 includes an administrator 102, a remote compiler service 104, the live rule engine 106, a scheduler 108, the system 110 for updating the ruleset of the live rule engine 106, an output device 112, and a client device 114.
[0032] In an embodiment, the administrator 102 may correspond to a user or an automated process that authors and publishes ruleset updates. The administrator 102 may be communicatively coupled with the remote compiler service 104. The remote compiler service 104 may correspond to a server or a distributed service that receives ruleset updates from the administrator 102 and compiles the ruleset updates for deployment. In some embodiments, the remote compiler service 104 may store versioned rulesets and make the versioned rulesets available for retrieval by the live rule engine 106. The remote compiler service 104 is communicatively coupled with the live rule engine 106.
[0033] In an embodiment, the live rule engine 106 may correspond to a software component or a set of software components that manage the execution of business rules in real-time. The live rule engine 106 is communicatively coupled with the system 110. In a non-limiting example, the live rule engine 106 may be applied in telecom environments for real-time charging, rating, promotions, discounts, and policy engines. The live rule engine 106 may be applied in e-commerce and retail environments for dynamic pricing, flash promotions, seasonal offers, loyalty rules, and eligibility rules. The live rule engine 106 may be applied in fintech and banking environments for fraud-detection rules, transaction limits, and Know Your Customer/Anti-Money Laundering (KYC/AML) policy updates. The live rule engine 106 may be applied in AdTech environments for real-time bidding and targeting rule updates. The live rule engine 106 may also be applied for feature flags, entitlement and access-control policies, workflow and business process management decisioning, and Internet of Things (IoT) or edge rule evaluation. In an embodiment, the live rule engine 106 may include a plurality of replicated nodes communicatively coupled with the remote compiler service 104. Each replicated node may receive the versioned ruleset from the remote compiler service 104 and perform an atomic swap operation independently of remaining replicated nodes based on completion of staging the compiled ruleset at the respective replicated node. The atomic swap operation indicates an indivisible memory update that replaces a currently active data structure, buffer, or program with a new one in a single step, ensuring that the system never observes a partially updated state. For example, the system 110 may create a new data structure while the current data structure remains in use. When the new data structure is ready, the atomic swap operation allows replacing the current data structure in the single step or operation. The system 110 provides access either to the current data structure (also referred to as the old data structure) or to the new data structure, but never a partially updated version.
[0034] In an implementation, each replicated node maintains its own active ruleset pointer and an inactive memory buffer. Each replicated node transitions to the new ruleset version upon completion of local pre-compilation and staging without coordination with the other replicated nodes.
[0035] In an embodiment, the active ruleset pointer may correspond to one active ruleset pointer of a plurality of active ruleset pointers of the live rule engine 106. Each active ruleset pointer may be associated with at least one tenant of the live rule engine 106. The atomic swap operation may be performed on the one active ruleset pointer independently of remaining active ruleset pointers of the plurality of active ruleset pointers. Further, the live rule engine 106 includes the scheduler 108.
[0036] In an embodiment, the scheduler 108 may correspond to a polling component or an event-driven component that detects new versioned rulesets from the remote compiler service 104 and coordinates the retrieval and staging of compiled rulesets. In some embodiments, the scheduler 108 polls the remote compiler service 104 at a configured time interval. Further, the scheduler 108 may receive publication notifications from the remote compiler service 104 indicating availability of the new versioned ruleset.
[0037] In an embodiment, the scheduler 108 of the live rule engine 106 may receive the versioned ruleset from the remote compiler service 104 over a communication channel. The versioned ruleset includes one or more rules. Each rule of the one or more rules may include a condition expression and an action expression. The condition expression may indicate a logical condition to be evaluated against input data. The action expression may indicate an operation to be performed when the condition expression evaluates to true.
[0038] In an embodiment, the communication channel between the scheduler 108 and the remote compiler service 104 may be implemented using gRPC (Google Remote Procedure Call) streaming protocol for efficient versioned ruleset delivery. In some embodiments, the communication channel may alternatively be implemented using message queues, for example, the Apache Kafka message queue, for ruleset delivery between the remote compiler service 104 and the live rule engine 106. In a non-limiting example, the communication channel may be implemented using object-storage polling for the ruleset delivery or using push-based webhooks for the ruleset delivery.
[0039] In an embodiment, a rule format for the one or more rules may include JavaScript Object Notation (JSON) condition and action rules for defining the ruleset. In some embodiments, the rule format may alternatively include Yet Another Markup Language (YAML) rules for defining the ruleset. In an embodiment, the rule format may include a domain-specific language for defining the ruleset.
[0040] In an embodiment, the system 110 may correspond to a central processing component that interfaces with external devices and processes rule-evaluation requests. The system 110 is communicatively coupled with the client device 114. In a non-limiting example, the client device 114 may correspond to a computing device, a mobile device, or an application that sends requests to be processed according to an active ruleset. The system 110 is also communicatively coupled with the output device 112. In a non-limiting example, the output device 112 may correspond to a display, a printer, a storage device, or another computing device that receives processed results and outputs from the system 110.
[0041] In an embodiment, the environment 100 may enable continuous rule deployment by allowing the administrator 102 to push ruleset updates through the remote compiler service 104. The scheduler 108 within the live rule engine 106 may retrieve the ruleset updates and apply the ruleset updates to the system 110 without requiring service restarts or dropping in-flight requests from the client device 114.
[0042] Figure 2 illustrates a block diagram of the system 110 for updating the ruleset of the live rule engine 106, in accordance with an embodiment of the present disclosure.
[0043] In an embodiment, the system 110 may include a processor 202, a memory 204, modules 206, and a communication interface 222. The processor 202 is communicatively coupled with the memory 204. The processor 202 may be configured to execute instructions stored in the memory 204 to perform operations associated with updating the ruleset of the live rule engine 106. The memory 204 may store data and instructions that are accessible by the processor 202 for executing the various functions of the system 110.
[0044] In an embodiment, the processor 202 is configured to execute instructions stored in the memory 204 to perform operations associated with the system 110. As an example, the processor 202 may be a single processing unit or a number of units, all of which could include multiple computing units. The processor 202 may be implemented as one or more microprocessors, microcomputers, microcontrollers, digital signal processors, central processing units, state machines, logic circuitries, and/or any devices that manipulate signals based on operational instructions. Among other capabilities, the processor 202 is configured to fetch and execute computer-readable instructions and data stored in the memory. The processor 202 may include one or a plurality of processors. At this time, one or a plurality of processors 202 may be a general-purpose processor, such as a central processing unit (CPU), an application processor (AP), or the like, a graphics-only processing unit such as a graphics processing unit (GPU), a visual processing unit (VPU), and/or an AI-dedicated processor such as a neural processing unit (NPU). The one or a plurality of processors 202 may control the processing of the input data in accordance with predefined operating rules or artificial intelligence (AI) models stored in the non-volatile memory and the volatile memory, i.e., memory 204. The predefined operating rules or artificial intelligence models are provided through training or learning.
[0045] In an embodiment, the memory 204 may include any non-transitory computer-readable medium known in the art, including, for example, volatile memory, such as static random access memory (SRAM) and dynamic random-access memory (DRAM), and/or non-volatile memory, such as read-only memory (ROM), erasable programmable ROM, flash memories, hard disks, optical disks, and magnetic tapes.
[0046] In an embodiment, the modules 206 may include one or more distinct functional units or functional components implemented in hardware, software, firmware, or any combination thereof, configured to perform one or more specific operations within the system. The modules 206 may include executable instructions stored in the memory 204, logic circuitry within the processor 202, dedicated hardware blocks, or a combination thereof. The modules 206 may be implemented as a standalone component or as part of an integrated subsystem. The term “module” is not limited to any particular physical form and may include distributed components that collectively perform the stated function. The expression “plurality of modules” refers to two or more modules, each of which may perform distinct functions or may collectively cooperate to achieve a composite system-level function. The modules 206 may reside within a single device, for example, within the memory or processing subsystem, or distributed across multiple devices connected through the communication interface 222. Each module 206 may interact with the processor(s) 202, the memory 204, and the communication interface 222. The modules 206, among other things, include routines, programs, objects, components, data structures, etc., which perform particular tasks or implement data types. The modules 206 may also be implemented as signal processor(s), state machine(s), logic circuitries, and/or any other device or component for processing the received signals and detecting the symbol boundaries. The modules 206 may include a receiving module 208, a generating module 210, a staging module 212, an activating module 214, a serving module 216, a transitioning module 218, and a retiring module 220.
[0047] In an embodiment, the receiving module 208 may be configured to receive the versioned ruleset from the remote compiler service 104 over a communication channel, using the scheduler 108 of the live rule engine 106. The versioned ruleset includes one or more rules. Each rule may include the condition expression and the action expression. In an embodiment, the receiving module 208 may be configured to poll the remote compiler service 104 by the scheduler 108 at a configured time interval over the communication channel. The scheduler 108 may be implemented using gocron for polling on the configurable interval. The receiving module 208 may receive the versioned ruleset based on a difference between a version identifier associated with the versioned ruleset and a subsequent version identifier associated with the active ruleset. In some embodiments, the scheduler 108 may be configured to compare the version identifier of the versioned ruleset available at the remote compiler service 104 with the version identifier of the active ruleset. The scheduler 108 may further retrieve the versioned ruleset when the version identifiers differ. Further, the scheduler 108 may detect a changed versioned ruleset based on a comparison of a timestamp associated with the versioned ruleset at the remote compiler service 104 with a timestamp associated with the active ruleset. The scheduler 108 may receive the versioned ruleset when the timestamps differ.
[0048] In an embodiment, the receiving module 208 may alternatively be configured to detect the publication notification transmitted by the remote compiler service 104 over the communication channel. The publication notification indicates availability of the version identifier of the versioned ruleset. The receiving module 208 may receive the versioned ruleset based on the publication notification. In some embodiments, the scheduler 108 may use event-driven triggers on new-version publication instead of polling to receive the versioned ruleset from the remote compiler service 104.
[0049] In an embodiment, the receiving module 208 may be configured to receive a compressed archive of a plurality of rule definitions in a structured data format over the communication channel. For example, the compressed archive may include a ZIP archive, and the plurality of rule definitions may correspond to the JSON rule definitions. The receiving module 208 may deserialize each rule definition of the plurality of rule definitions prior to translating the condition expression and the action expression. In some embodiments, the versioned ruleset is delivered as the ZIP archive containing the JSON rule definitions that are extracted and deserialized before compilation. In yet another embodiment, the receiving module 208 may receive a subsequent versioned ruleset from the remote compiler service 104.
[0050] In an embodiment, the generating module 210 may be configured to generate a compiled ruleset based on the received versioned ruleset. The generating module 210 may translate the condition expression and the action expression of each rule into bytecode executable by a virtual machine (VM) of the live rule engine 106. The compiled ruleset may also be referred to as a pre-compiled ruleset, indicating that the ruleset is compiled ahead of activation. The generating module 210 may be configured to parse each of the condition expression and the action expression of each rule of the one or more rules into a respective syntax tree. The syntax tree may correspond to an abstract syntax tree (AST) representing the structure of the condition expression and the action expression. The generating module 210 may translate the respective syntax tree into a condition program and an action program of the bytecode prior to activation of the bytecode. The condition program and the action program are associated with the rule in the inactive memory buffer. The generating module 210 may generate the compiled ruleset based on the translation.
[0051] In an embodiment, the bytecode compilation target may be a virtual machine (VM) bytecode generated via an expression library. The expression library may produce per-rule ConditionProgram and ActionProgram bytecode corresponding to the condition program and the action program. The ruleset may include a RuleDefinition schema with ConditionProgram and ActionProgram fields for storing the compiled bytecode associated with each rule. In some embodiments, the compilation target may alternatively be another bytecode or intermediate representation format. For example, the compilation target may be just-in-time (JIT) compiled native code instead of the VM bytecode. For example, the compilation target may be natively compiled code emitted as a shared object (.so) library. The shared object library is generated at the live rule engine 106 side from rule definitions received over the communication channel and dynamically loaded into the inactive memory buffer prior to the atomic swap operation.
[0052] In an embodiment, the system 110 may be configured to validate the rulesets during compilation such that the ruleset failing to compile is rejected without affecting the live ruleset. The generating module 210 may reject the subsequent versioned ruleset received from the remote compiler service 104 via the receiving module 208, based on a failure in translating at least one of the condition expression and the action expression of the subsequent versioned ruleset into the bytecode. The generating module 210 may discard the rejected subsequent versioned ruleset from the inactive memory buffer. The system 110 may retain the active ruleset pointer in the active memory buffer. In some embodiments, validation completing before activation allows a non-compiling ruleset to be rejected without affecting the live ruleset, and the active ruleset continues to serve requests without interruption.
[0053] In an embodiment, the staging module 212 may be configured to stage the compiled ruleset in an inactive memory buffer of the live rule engine 106. The inactive memory buffer is distinct from an active memory buffer indicated by an active ruleset pointer corresponding to an active ruleset that serves requests received by the live rule engine 106. The staging module 212 may place the compiled bytecode into the inactive memory buffer while the active ruleset continues to serve requests.
[0054] In an embodiment, the activating module 214 is configured to activate the compiled ruleset based on the atomic swap operation of the active ruleset pointer from the active memory buffer to the inactive memory buffer. The atomic swap operation corresponds to an indivisible in-memory operation performed upon completion of translating the condition expression and the action expression. The activating module 214 may perform the atomic swap operation to replace the active ruleset with the staged compiled ruleset in a single indivisible operation.
[0055] In an embodiment, the activating module 214 may be configured to identify a previously compiled ruleset based on the version identifier associated with the previously compiled ruleset. The activating module 214 may restore the previously compiled ruleset of the live rule engine 106 based on the subsequent atomic swap operation of the active ruleset pointer to the memory buffer holding the previously compiled ruleset. The version tags associated with the compiled rulesets enable instant rollback to the previously compiled ruleset when a new ruleset fails validation or when operational conditions warrant reverting to a prior version. In some embodiments, the system 110 may retain the one or more previously compiled rulesets in the memory buffer to facilitate rapid rollback without requiring recompilation.
[0056] In an embodiment, the serving module 216 may be configured to receive rule-evaluation requests after the atomic swap operation. Each rule-evaluation request includes at least one of a new request or an in-flight request associated with the live rule engine 106. The serving module 216 may be configured to serve the new request based on the activated compiled ruleset and complete the in-flight request based on the active ruleset. The serving module 216 may route the new requests to the activated compiled ruleset while allowing the in-flight requests to complete against the prior active ruleset.
[0057] In an embodiment, the transitioning module 218 may be configured to transition the active ruleset to a draining state based on a cooperative cancellation of an execution context associated with the active ruleset. The cooperative cancellation indicates a cancellation mechanism in which a running task is requested to stop, rather than being forcibly terminated. The task periodically checks for a cancellation signal and, upon detecting the signal, completes any necessary cleanup and exits gracefully. This approach helps avoid incomplete operations, resource leaks, and inconsistent states.
[0058] Further, the draining state indicates that the active ruleset serves the in-flight request and routes the new request received after the atomic swap operation to the activated compiled ruleset. The transitioning module 218 may manage the transition of the rulesets through various states, including the draining state where the in-flight requests complete against the prior ruleset. The transitioning module 218 may manage the cooperative cancellation of the execution context to transition the active ruleset through the draining state before retirement.
[0059] In some embodiments, the cooperative cancellation mechanism operates on a goroutine execution context for draining the active ruleset. The goroutine execution context is the runtime state associated with a goroutine, including its stack, scheduling information, and any context data used during execution. The goroutine indicates a lightweight execution thread managed by the Go runtime for concurrent execution of one or more functions. For example, the cooperative cancellation mechanism may operate on thread pools or on actor runtimes in other programming languages. The cooperative cancellation may further allow the in-flight requests to complete against the prior ruleset before the execution context is terminated and the memory resources are released.
[0060] In an embodiment, the retiring module 220 may be configured to retire the active ruleset from the active memory buffer based on completion of the in-flight request. The retiring module 220 may be configured to retire the active ruleset by completing the in-flight request served in the draining state and terminating the execution context associated with the active ruleset. The retiring module 220 may be configured to release a memory region occupied by the active ruleset based on the completion and the termination. The retiring module 220 may then update the active ruleset of the live rule engine 106 without service interruption. The retiring module 220 may release the memory resources associated with the retired ruleset after completion of the in-flight requests.
[0061] In an embodiment, the communication interface 222 facilitates communication between the system 110 and external components such as the remote compiler service 104, the scheduler 108, and client devices 114. The communication interface 222 may enable the system 110 to receive ruleset updates via streaming delivery over the communication channel and to serve requests from the client devices 114.
[0062] In an implementation, deployment topology may include a single in-process engine performing hot-swap operations. The hot-swap operation indicates the replacement or update of the software component, configuration, or executable module while the system remains operational, without requiring a shutdown or restart. In the deployment topology, the system 110 may operate as a single instance that receives the versioned rulesets from the remote compiler service 104 and performs atomic swap operations to update the active ruleset.
[0063] In another implementation, including a multi-tenant deployment topology, the system 110 maintains per-tenant active-ruleset pointers, and each tenant may receive ruleset updates and undergo the atomic swap operations independently of other tenants. The per-tenant active-ruleset pointers enable tenant-specific ruleset versioning and rollback without affecting the other tenants of the live rule engine 106.
[0064] Figure 3 illustrates an example system operation workflow 300 for implementing zero-downtime hot-swap of the compiled rulesets, in accordance with an embodiment of the present disclosure.
[0065] In an exemplary embodiment, consider the rule engine that is currently evaluating requests using a first compiled ruleset. While the first compiled ruleset remains active, a second version of the ruleset is received, validated, and compiled in the inactive memory buffer. The atomic swap operation then activates the second compiled ruleset. The requests that were already being processed before the atomic swap operation continue to be evaluated using the first compiled ruleset until completion, whereas the requests received after the atomic swap operation are evaluated using the second compiled ruleset. As a result, the transition between the first compiled ruleset and the second compiled ruleset occurs without interrupting request processing, thereby providing zero-downtime hot-swap of the compiled ruleset.
[0066] The zero-downtime hot-swap of the compiled ruleset may be further explained in reference to the workflow 300 illustrated in Figure 3. The example system operation workflow 300 depicts the interaction between the remote compiler service 104 and the scheduler 108, along with the lifecycle states of the rulesets during the hot-swap operation.
[0067] In an embodiment, at operation 302, the workflow 300 may include establishing a streaming connection between the remote compiler service 104 and the scheduler 108 for ruleset delivery. The streaming connection may enable the scheduler 108 to receive the versioned rulesets from the remote compiler service 104 over the communication channel.
[0068] In an embodiment, a pre-compilation engine 301 may receive the rulesets and perform ahead-of-time compilation. The pre-compilation engine 301 may parse the JSON rules into the abstract syntax tree and produce the virtual machine bytecode before activating the bytecode.
[0069] In an embodiment, at operation 304, the workflow 300 may indicate a compilation status associated with the pre-compilation engine 301. The compilation status may indicate whether the pre-compilation process is incomplete or completed ahead of time before activation of the bytecode.
[0070] In an embodiment, the 300 may illustrate the state transitions of a first ruleset, for example, ruleset v41, through multiple operations. At operation 306, the workflow 300 may include the ruleset v41 in an active state, serving requests with the active ruleset pointer 303 pointing to the ruleset v41. At operation 308, the workflow 300 may include the ruleset v41 transitioning to the draining state, where the in-flight requests are completing. At operation 310, the workflow 300 may include the ruleset v41 in a retired state, where the goroutine is stopped through the context cancellation.
[0071] In an embodiment, the workflow 300 may concurrently illustrate the state transitions of a second ruleset, for example, ruleset v42, through multiple operations. At operation 312, the workflow 300 may include the ruleset v42 in a building state, where a pre-compiled bytecode resides in the inactive buffer. At operation 314, the workflow 300 may include the ruleset v42 in a staged state, where the pre-compiled bytecode is ready in the inactive buffer. At operation 316, the workflow 300 may include the ruleset v42 transitioning to the active state, serving the requests with the active ruleset pointer 303 now pointing to the ruleset v42.
[0072] In an embodiment, at operation 318, the workflow 300 may include receiving incoming gRPC requests entering the system 110. At operation 320, the workflow 300 may include the atomic swap operation that transitions the active ruleset from the ruleset v41 to the ruleset v42. The active ruleset pointer 303 may facilitate the atomic swap operation, enabling instantaneous activation of the new ruleset. At operation 322, the workflow 300 may include continuation of the atomic swap operation. At operation 324, the workflow 300 may include completion of the atomic swap operation where the new ruleset, for example, the ruleset v42, becomes fully active.
[0073] Figure 4 illustrates an example ruleset workflow 400 depicting the path of the ruleset version through the hot-swap pipeline, in accordance with an embodiment of the present disclosure. The example ruleset workflow 400 traces the progression of the versioned ruleset from the remote compiler service 104 through the staging and the atomic activation.
[0074] In an embodiment, at operation 402, the workflow 400 may include the remote compiler service 104 outputting a versioned ruleset package. The versioned ruleset package may include the compressed archive containing the rule definitions in the structured data format. In one embodiment, the compressed archive file, for example, a v42 file, may be a .zip file.
[0075] In an embodiment, at operation 404, the workflow 400 may include the scheduler 108 receiving the versioned ruleset package from the remote compiler service 104. The scheduler 108 may extract the rule definitions from the versioned ruleset package and forward the rule definitions in the structured data format to the pre-compilation engine 301. In one embodiment, the rule definitions may be the JSON rule definitions.
[0076] In an embodiment, at operation 406, the workflow 400 may include the pre-compilation engine 301 compiling the rule definitions into the bytecode. The pre-compilation engine 301 may parse each rule definition into the syntax tree and translate the syntax tree into the bytecode executable by the virtual machine of the live rule engine 106.
[0077] In an embodiment, the workflow 400 may include placement of the compiled bytecode in the inactive memory buffer 401 (also referred to as a staged ruleset buffer). The inactive memory buffer 401 may correspond to the inactive memory buffer that holds the compiled bytecode prior to activation. The inactive memory buffer 401 remains distinct from the memory buffer holding the active ruleset 403 that serves the requests.
[0078] In an embodiment, at operation 408, the workflow 400 may include the atomic swap operation that transitions the staged ruleset from the inactive memory buffer 401 to become the active ruleset 403. The active ruleset pointer 303 may facilitate the atomic swap operation, enabling the compiled bytecode in the inactive memory buffer 401 to replace the prior active ruleset 403 in the single indivisible operation. The workflow 400 demonstrates the sequential progression from the remote compilation through scheduling, pre-compilation, staging, and atomic activation.
[0079] Figure 5 illustrates an example live request flow method 500 showing concurrent handling of the ruleset transitions during live traffic, in accordance with an embodiment of the present disclosure.
[0080] In an embodiment, the method 500 depicts gRPC clients 501 connected to the active ruleset pointer 303, which routes requests to the appropriate ruleset version. The active ruleset pointer 303 enables seamless transition between the ruleset versions, allowing the new requests to be served by the new ruleset v42 503 while existing requests against the old ruleset v41 505 complete without interruption.
[0081] In an embodiment, the method 500 depicts the lifecycle of an old ruleset v41 505 (corresponding to the first ruleset) through multiple operations. At operation 512, the old ruleset v41 505 is in the active state, serving the requests received by the live rule engine 106. At operation 514, the old ruleset v41 505 transitions to the draining state, where the in-flight requests complete against the old ruleset v41 505. At operation 516, the old ruleset v41 505 reaches the retired state, where resources associated with the old ruleset v41 505 are released.
[0082] In an embodiment, the method 500 concurrently depicts the lifecycle of a new ruleset v42 503 (corresponding to the second ruleset) through multiple operations. At operation 502, the scheduler 108 polls the remote compiler service 104 for the new ruleset v42 503. At operation 504, the scheduler 108 receives the new ruleset v42 503 via streaming from the remote compiler service 104. At operation 506, the pre-compilation engine 301 compiles the new ruleset v42 503 into the bytecode. At operation 508, the compiled bytecode is staged in the inactive memory buffer. At operation 510, the new ruleset v42 503 becomes active.
[0083] Figure 6 illustrates a flowchart for a method 600 for updating the ruleset of the live rule engine 106, in accordance with an embodiment of the present disclosure. The method 600 may be performed by the system 110.
[0084] In an embodiment, at step 602, the method 600 may include receiving, by the scheduler 108 of the live rule engine 106, the versioned ruleset from the remote compiler service 104 over the communication channel. The versioned ruleset may include the one or more rules. Each rule includes the condition expression and the action expression. The scheduler may poll the remote compiler service at the configured time interval or may receive the publication notification indicating availability of the versioned ruleset.
[0085] In an embodiment, at step 604, the method 600 may include generating the compiled ruleset based on the received versioned ruleset by translating the condition expression and the action expression of each rule into the bytecode executable by the virtual machine of the live rule engine 106. The method 600 may include parsing the condition expression and the action expression of each rule into the respective syntax tree and translating the respective syntax tree into the condition program and the action program of the bytecode.
[0086] In an embodiment, at step 606, the method 600 may include staging the compiled ruleset in the inactive memory buffer of the live rule engine 106. The inactive memory buffer may be distinct from the active memory buffer indicated by the active ruleset pointer 303 corresponding to the active ruleset that serves the requests received by the live rule engine 106. The compiled bytecode may be placed into the inactive memory buffer while the active ruleset continues to serve the requests.
[0087] In an embodiment, at step 608, the method 600 may include activating the compiled ruleset based on the atomic swap operation of the active ruleset pointer 303 from the active memory buffer to the inactive memory buffer. The atomic swap operation may correspond to the indivisible in-memory operation performed upon completion of translating the condition expression and the action expression. The step 608 may include replacing the active ruleset with the staged compiled ruleset in a single indivisible operation.
[0088] In an embodiment, at step 610, the method 600 may include receiving the rule-evaluation requests after the atomic swap operation. Each rule-evaluation request may include at least one of the new request or the in-flight request associated with the live rule engine 106.
[0089] In an embodiment, at step 612, the method 600 may include serving the new request based on the activated compiled ruleset and completing the in-flight request based on the active ruleset. The step 612 may include routing the new requests to the activated compiled ruleset while allowing the in-flight requests to complete against the prior active ruleset.
[0090] In an embodiment, at step 614, the method 600 may include transitioning the active ruleset to the draining state based on the cooperative cancellation of the execution context associated with the active ruleset. The draining state may indicate that the active ruleset serves the in-flight request and routes the new request received after the atomic swap operation to the activated compiled ruleset.
[0091] In an embodiment, at step 616, the method 600 may include retiring the active ruleset from the active memory buffer based on completion of the in-flight request. The step 616 may include completing the in-flight request served in the draining state, terminating the execution context associated with the active ruleset, and releasing the memory region occupied by the active ruleset. The method 600 thereby updates the active ruleset of the live rule engine 106 without the service interruption.
[0092] In some embodiments, the method 600 may include receiving the subsequent versioned ruleset and rejecting the subsequent versioned ruleset based on the failure in translating at least one of the condition expression and the action expression into the bytecode. The method 600 may further include discarding the rejected subsequent versioned ruleset from the inactive memory buffer, and retaining the active ruleset pointer 303 at the active memory buffer. In some embodiments, the method 600 may include identifying the previously compiled ruleset based on the version identifier. The method 600 may further include restoring the previously compiled ruleset based on the subsequent atomic swap operation of the active ruleset pointer 303 to the memory buffer holding the previously compiled ruleset.
[0093] In some advantageous embodiments, the present disclosure provides significant advantages as described in the forthcoming paragraphs.
[0094] The present disclosure provides continuous rule deployment without service restarts or dropping the in-flight requests.
[0095] The present disclosure facilitates activation that adds no parsing or compilation cost because the ruleset is pre-compiled to bytecode and validated while inactive in a staging buffer.
[0096] The present disclosure provides correctness and safety through the draining and retired lifecycle states. The cooperative cancellation mechanism prevents resource leaks and races on concurrent ruleset access; requests executing against the prior ruleset complete normally while the new requests route to the activated compiled ruleset, and the ruleset that fails to compile is rejected without affecting the live ruleset.
[0097] The present disclosure facilitates traceability and rollback through version-tagged rulesets that enable instant rollback to the prior compiled ruleset without requiring recompilation or off-hours change windows.
[0098] The present disclosure provides the in-process swap that avoids the approximately thirty to one hundred twenty second propagation delay per update associated with external orchestration such as process-level container replacement.
[0099] While specific language has been used to describe the present subject matter, any limitations arising on account thereof are not intended. As would be apparent to a person in the art, various working modifications may be made to the method in order to implement the inventive concept as taught herein. The drawings and the foregoing description give examples of embodiments. Those skilled in the art will appreciate that one or more of the described elements may well be combined into a single functional element. Alternatively, certain elements may be split into multiple functional elements. Elements from one embodiment may be added to another embodiment. , Claims:1. A method (600) for updating a ruleset of a live rule engine (106), the method comprising: receiving (602), by a scheduler (108) of the live rule engine (106), a versioned ruleset from a remote compiler service (104) over a communication channel, wherein the versioned ruleset comprises one or more rules, wherein each rule comprises a condition expression and an action expression; generating (604) a compiled ruleset based on the received versioned ruleset by translating the condition expression and the action expression of the each rule into bytecode executable by a virtual machine of the live rule engine; staging (606) the compiled ruleset in an inactive memory buffer (401) of the live rule engine (106), wherein the inactive memory buffer (401) is distinct from an active memory buffer indicated by an active ruleset pointer (303) corresponding to an active ruleset (403) that serves requests received by the live rule engine (106); activating (608) the compiled ruleset based on an atomic swap operation of the active ruleset pointer (303) from the active memory buffer to the inactive memory buffer (401), wherein the atomic swap operation corresponds to an indivisible in-memory operation performed upon completion of translating the condition expression and the action expression; receiving (610) rule-evaluation requests after the atomic swap operation, wherein each rule-evaluation request comprises at least one of a new request or an in-flight request associated with the live rule engine; serving (612) the new request based on the activated compiled ruleset and completing the in-flight request based on the active ruleset (403); transitioning (614) the active ruleset (403) to a draining state based on a cooperative cancellation of an execution context associated with the active ruleset (403), wherein the draining state indicates that the active ruleset (403) serves the in-flight request and routes the new request received after the atomic swap operation to the activated compiled ruleset; and retiring (616) the active ruleset (403) from the active memory buffer based on completion of the in-flight request, thereby updating the active ruleset (403) of the live rule engine (106).
2. The method (600) as claimed in claim 1, wherein receiving the versioned ruleset comprises: polling the remote compiler service (104) by the scheduler (108) at a configured time interval over the communication channel; and receiving the versioned ruleset, based on a difference between a version identifier associated with the versioned ruleset and a subsequent version identifier associated with the active ruleset (403).
3. The method (600) as claimed in claim 1, wherein receiving the versioned ruleset comprises: detecting a publication notification transmitted by the remote compiler service (104) over the communication channel, wherein the publication notification indicates availability of the version identifier of the versioned ruleset; and receiving the versioned ruleset based on the publication notification.
4. The method (600) as claimed in claim 1, wherein receiving the versioned ruleset comprises: receiving a compressed archive of a plurality of rule definitions in a structured data format over the communication channel; and deserializing each rule definition of the plurality of rule definitions prior to translating the condition expression and the action expression.
5. The method (600) as claimed in claim 4, wherein the compressed archive comprises a ZIP archive, and wherein the plurality of rule definitions correspond to JavaScript Object Notation (JSON) rule definitions.
6. The method (600) as claimed in claim 1, wherein generating the compiled ruleset further comprises: parsing the condition expression and the action expression of the each rule of the one or more rules into a respective syntax tree; translating the respective syntax tree into a condition program and an action program of the bytecode, wherein the condition program and the action program are associated with the rule in the inactive memory buffer (401); and generating the compiled ruleset based on the translation.
7. The method (600) as claimed in claim 1, further comprising: receiving a subsequent versioned ruleset from the remote compiler service (104); rejecting the subsequent versioned ruleset based on a failure in translating at least one of the condition expression and the action expression of the subsequent versioned ruleset into the bytecode; discarding the rejected subsequent versioned ruleset from the inactive memory buffer (401); and retaining the active ruleset pointer (303) at the active memory buffer.
8. The method (600) as claimed in claim 1, further comprising: identifying a previously compiled ruleset based on a version identifier associated with the previously compiled ruleset; and restoring the previously compiled ruleset of the live rule engine (106) based on a subsequent atomic swap operation of the active ruleset pointer (303) to a memory buffer holding the previously compiled ruleset.
9. The method (600) as claimed in claim 1, wherein retiring the active ruleset (403) comprises: completing the in-flight request served in the draining state; terminating the execution context associated with the active ruleset (403); and releasing a memory region occupied by the active ruleset (403) based on the completing and the terminating.
10. The method (600) as claimed in claim 1, wherein the active ruleset pointer (303) corresponds to one active ruleset pointer (303) of a plurality of active ruleset pointers of the live rule engine (106), wherein each active ruleset pointer (303) is associated with at least one tenant of the live rule engine (106), and wherein the atomic swap operation is performed on the one active ruleset pointer (303) independently of remaining active ruleset pointers of the plurality of active ruleset pointers.
11. The method (600) as claimed in claim 1, wherein the live rule engine (106) comprises a plurality of replicated nodes communicatively coupled with the remote compiler service (104), wherein each replicated node comprises: receiving the versioned ruleset from the remote compiler service (104); and performing the atomic swap operation independently of remaining replicated nodes based on completion of staging the compiled ruleset at the respective replicated node.
12. A system (110) for updating a ruleset of a live rule engine (106), the system (110) comprising: a memory (204); and a processor (202) communicatively coupled with the memory (204), wherein the processor (202) is configured to: receive, by a scheduler (108) of the live rule engine (106), a versioned ruleset from a remote compiler service (104) over a communication channel, wherein the versioned ruleset comprises one or more rules, wherein each rule comprises a condition expression and an action expression; generate a compiled ruleset based on the received versioned ruleset by translating the condition expression and the action expression of the each rule into bytecode executable by a virtual machine of the live rule engine; stage the compiled ruleset in an inactive memory buffer (401) of the live rule engine (106), wherein the inactive memory buffer (401) is distinct from an active memory buffer indicated by an active ruleset pointer (303) corresponding to the active ruleset (403) that serves requests received by the live rule engine (106); activate the compiled ruleset based on an atomic swap operation of the active ruleset pointer (303) from the active memory buffer to the inactive memory buffer (401), wherein the atomic swap operation corresponds to an indivisible in-memory operation performed upon completion of translating the condition expression and the action expression; receive rule-evaluation requests after the atomic swap operation, wherein each rule-evaluation request comprises at least one of a new request or an in-flight request associated with the live rule engine; serve the new request based on the activated compiled ruleset and complete the in-flight request based on the active ruleset (403); transition the active ruleset (403) to a draining state based on a cooperative cancellation of an execution context associated with the active ruleset (403), wherein the draining state indicates that the active ruleset (403) serves the in-flight request and routes the new request received after the atomic swap operation to the activated compiled ruleset; and retire the active ruleset (403) from the active memory buffer based on completion of the in-flight request, thereby updating the active ruleset (403) of the live rule engine (106).