Processing method and device based on distributed application program
By using a unified address space and state machine model, transparent migration and scheduling of distributed applications across different nodes are achieved, solving the problems of insufficient resources and efficiency in existing technologies and improving system performance and flexibility.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-05
- Publication Date
- 2026-04-10
AI Technical Summary
Existing distributed application architectures are insufficient to meet resource and efficiency requirements, lack dynamic adjustment capabilities, and cannot achieve fine-grained program logic, code and state scheduling under a unified view.
It adopts a unified address space and state machine model, using the state machine as the execution and scheduling unit to achieve transparent migration and scheduling across nodes, simplifying distributed program development and supporting on-demand loading and dynamic migration of code and data.
It enables the dynamic migration and scheduling of distributed application functions across different nodes, improving system resource utilization, operational performance, and business flexibility, while reducing development complexity and maintenance costs.
Smart Images

Figure CN121833086A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to a processing method and device based on distributed application. BACKGROUND
[0002] With the development of computer technology, the function provided by the application program is more and more complex, and the resource consumed is more and more, so the distributed application is proposed, which completes the task by distributing the application program on different nodes.
[0003] However, in the existing distributed application, the execution node of each function is usually fixed, such as function A is fixed in node A and function B is fixed in node B, but such architecture is difficult to meet the needs of distributed application in resources, efficiency and other aspects. SUMMARY
[0004] In view of the above problems, a processing method and device based on distributed application are provided to overcome the above problems or at least partially solve the above problems, comprising:
[0005] A processing method based on distributed application, the distributed application is provided with one or more state machines, the method is applied to a first node, comprising:
[0006] In response to a state machine migration event, migrating first data of a first state machine instance running on the first node to a second node to instantiate a target state machine of the distributed application on the second node to obtain a second state machine instance; wherein the first state machine instance is a state machine instance obtained by instantiating a target state machine in the one or more state machines on the first node.
[0007] A processing method based on distributed application, the distributed application is provided with one or more state machines, the method is applied to a second node, comprising:
[0008] In response to a state machine migration event, obtaining first data of a first state machine instance running on a first node, and instantiating a target state machine of the distributed application on the second node to obtain a second state machine instance; wherein the first state machine instance is a state machine instance obtained by instantiating a target state machine in the one or more state machines on the first node.
[0009] A processing system based on distributed application, the distributed application is provided with one or more state machines, the system comprises a first node and a second node;
[0010] The first node is configured to obtain second data of a target state machine of the one or more state machines from a node storage space of the first node or a node storage space of another node through a logical storage address, instantiate the target state machine according to the second data to obtain a first state machine instance, and migrate first data of the first state machine instance running on the first node to the second node in response to a state machine migration event.
[0011] The second node is configured to obtain second data of a target state machine from a node storage space of the second node or a node storage space of another node through the logical storage address in response to the state machine migration event, and instantiate the target state machine according to the second data to obtain a second state machine instance.
[0012] A processing apparatus based on a distributed application, the distributed application being provided with one or more state machines, the apparatus being applied to a first node and configured to:
[0013] migrate first data of a first state machine instance running on the first node to a second node in response to a state machine migration event, so as to instantiate a target state machine of the distributed application on the second node to obtain a second state machine instance, wherein the first state machine instance is a state machine instance obtained by instantiating the target state machine of the one or more state machines on the first node.
[0014] A processing apparatus based on a distributed application, the distributed application being provided with one or more state machines, the apparatus being applied to a second node and configured to:
[0015] obtain first data of a first state machine instance running on a first node in response to a state machine migration event, and instantiate a target state machine of the distributed application on the second node to obtain a second state machine instance, wherein the first state machine instance is a state machine instance obtained by instantiating the target state machine of the one or more state machines on the first node.
[0016] An electronic device, comprising a processor, a memory, and a computer program stored on the memory and capable of running on the processor, wherein the computer program is executed by the processor to implement the method described above.
[0017] A computer readable storage medium, wherein a computer program is stored on the computer readable storage medium, and the computer program is executed by a processor to implement the method described above.
[0018] A computer program product comprising a computer program which, when executed by a processor, implements the method as described above.
[0019] Embodiments of the present application have the following advantages:
[0020] In the embodiments of the present application, by instantiating the target state machine of the distributed application at the first node, a first state machine instance is obtained, and in response to a state machine migration event, the first data of the first state machine instance running at the first node is migrated to the second node to instantiate the target state machine of the distributed application at the second node to obtain a second state machine instance, migration of the state machine execution of the distributed application is realized, and then the function of the distributed application can be migrated to different nodes for execution, meeting the needs of the distributed application in resources, efficiency and the like. BRIEF DESCRIPTION OF DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the present application, the drawings needed to be used in the description of the present application will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained according to these drawings without creative labor for those skilled in the art.
[0022] Figure 1 is a schematic diagram of a scheduling process of CDN and edge computing in the related art provided by some embodiments of the present application;
[0023] Figure 2 is a schematic diagram of an overall framework provided by some embodiments of the present application;
[0024] Figure 3 is a schematic diagram of a unified address space provided by some embodiments of the present application;
[0025] Figure 4 is a schematic diagram of a state machine model provided by some embodiments of the present application;
[0026] Figure 5 is a schematic diagram of transparent state machine scheduling provided by some embodiments of the present application;
[0027] Figure 6 is a step flowchart of a processing method based on a distributed application provided by some embodiments of the present application;
[0028] Figure 7 is a schematic diagram of a user order grabbing flow provided by some embodiments of the present application;
[0029] Figure 8 is a schematic diagram of a video encoding and decoding flow provided by some embodiments of the present application;
[0030] Figure 9 This is a flowchart of a second processing method based on a distributed application provided in some embodiments of the present invention. Detailed Implementation
[0031] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0032] In related technologies, Content Delivery Networks (CDNs) and edge computing have been proposed to improve user access experience and system response speed. For example... Figure 1 CDNs reduce backbone network latency by pre-caching static resources (such as images, videos, and web page content) on edge nodes closer to users. Some CDNs also incorporate "scheduling" capabilities, which can route requests to appropriate edge nodes based on factors such as the user's geographical location and bandwidth availability.
[0033] However, CDNs essentially only support static data replication and routing scheduling, and do not have the ability to fine-grained control and migration of program logic (i.e., code) and state.
[0034] Furthermore, edge computing proposes offloading some computing tasks (such as AI inference and video encoding) from core cloud nodes to edge nodes closer to the data source to reduce latency and alleviate the load on the central processing unit. Although some edge platforms support modular operator deployment and model inference services, they still have the following shortcomings:
[0035] 1. Developers need to pre-design feature deployment locations: It requires explicitly specifying which features will execute on the terminal, local edge, or cloud, lacking the ability to dynamically adjust at runtime. 2. Complex interface negotiation: The server and client need to define interfaces and negotiate deployment plans in advance, lacking flexibility. 3. Lack of complete program semantic scheduling capabilities: The system uses functions, operators, or containers as basic scheduling units, making it difficult to express and manage the consistency of program state, context, and execution logic.
[0036] In summary, although CDN and edge computing systems possess some "scheduling" capabilities, they can only optimize at the resource or request level and cannot achieve dynamic, fine-grained, and unified code and state scheduling under a "program-oriented semantics" view.
[0037] In the embodiments of the present application, a state machine scheduling scheme based on a unified address space is proposed to realize location-independent computing, mainly including the following two aspects:
[0038] 1. Simplifying distributed program development: By introducing a unified address space and a state machine model, developers do not need to care about network location, remote call, deployment strategy and other underlying details, code and data are located in a unified address space, and distributed applications are constructed and run like single-machine programs, which greatly reduces development complexity and maintenance cost. 2. Realizing transparent migration and scheduling optimization of program logic: Taking a state machine as an execution and scheduling unit, the dynamic migration and automatic scheduling of code and states between multiple nodes are realized without affecting the integrity of program logic, and the data accessed by the state machine can also be independently and automatically migrated with the location of the state machine, which can improve system resource utilization, running performance and business flexibility.
[0039] As Figure 2 , the embodiments of the present application are provided with five core levels, specifically as follows:
[0040] 1. State machine layer (State Machine Layer): The modeling unit of application entities, representing different application logic units (such as users, orders, video processing, etc.), is the basis for business modeling of the system.
[0041] 2. Unified address space layer (Unified Address Space Layer): Provides consistent addressing and access capabilities across nodes, supporting on-demand loading of code and data.
[0042] 3. Runtime layer (Runtime Layer): Responsible for managing state machine lifecycle, execution, state storage / loading, security isolation, forming a task unit containing context such as stack and program counter, supporting transparent local or remote call agent, and code / data loading based on event or procedural method.
[0043] 4. Scheduling layer (Schedule Layer): Optimizes state machine execution location within the same scheduling domain (Schedule Domain), realizes module-level scheduling and transparent migration. The scheduling domain refers to a logical resource area within a certain geographical or network range that has unified scheduling control capability and can realize transparent migration of state machines, such as an operator's edge cloud area, a resource pool in a telecom core cloud, a city node cluster in CDN, an edge cluster under the same private cloud, etc.
[0044] 5、Management Plane: the state machine development framework SDK provides an event-driven / procedural programming model for developers, allowing developers to focus on business logic (state, event processing) without handling distributed details (network location, remote call, etc.); the state machine management platform provides application deployment, update, monitoring, management, and other functions for users. SDK (Software Development Kit): refers to a component that can assist developers in developing applications for a unified address space state machine system, including but not limited to documents, development libraries, and interfaces.
[0045] Event-driven programming model: the execution flow of a program is triggered by events, rather than a pre-written sequence. After starting, the program usually enters an "event loop" and waits for various events. Once an event occurs, the processing logic bound to it is called. State machines can be executed locally or remotely, and state machines communicate with each other through messages. For example, when the program receives message A, it calls state machine 1, state machine 1 executes and sends new message B, and when the program receives message B, it calls state machine 2.
[0046] Procedural programming model: the execution flow of a program is driven by procedures and executed step by step according to a pre-written sequence. For example, sequential execution encounters a call to a sub-module, which is a small state machine that can be executed locally or remotely, and finally returns the execution result of the sub-module. That is, the program logic actively calls the sub-module, just like calling a function.
[0047] In an embodiment of the present application, a unified address space is proposed, which is a consistent logical addressing mechanism across nodes, providing a single-machine memory model abstraction for distributed systems, making code and data access independent of physical location.
[0048] Specifically, the unified address space is a memory model that provides a consistent logical view across nodes, allowing code and data access in a distributed system to have the same programming experience as local access.
[0049] As Figure 3 , the core features are as follows:
[0050] 1. Each piece of data and code has a globally unique identifier (such as a linear virtual address or object reference). 2. All accesses (reads / calls) are initiated through logical storage addresses, and the runtime layer automatically determines whether a local cache hit has occurred. 3. If no data / code is found locally when accessing a logical storage address, the system automatically initiates a remote load or remote call, achieving transparent loading and execution on demand. 4. Supports multiple address models (such as linear virtual addresses and object references) and is compatible with multiple languages, such as WASM (WebAssembly, a binary instruction format for stack-based virtual machines) and JVM (Java Virtual Machine).
[0051] In some examples, addresses for most data are pre-reserved during state machine deployment, meaning they are statically allocated. The specific allocation method can be chosen according to needs, such as using the simplest memory allocation strategy, for example, initial adaptation: sort the free memory by address from smallest to largest; when the program needs a block of memory, start searching from the beginning and allocate the first sufficiently large free area; if the free area is larger than needed, allocate a block to the program and leave the remaining space.
[0052] For new data generated at runtime, and this data must not overwrite other data, the same strategy can be used for dynamic allocation. This allocation is synchronized with other nodes at runtime to ensure consistency. Since the unified address space is an abstract address, it is not limited by the storage space of a single node and can be very large (e.g., 2 to the power of 128), so in practical applications it can be considered almost infinite. However, in actual runtime, a single node may only execute a portion of the state machine and only load the necessary data, as long as the node's storage space can hold the data accessed by the state machine executed on that node.
[0053] In some examples, the logical address of the data accessed by each operation is fixed during code development. This is similar to native programming, where the compiler assigns an address to each variable, and new data can be dynamically allocated at runtime.
[0054] By proposing a unified logical storage address space mechanism for multi-node systems, transparent access to data and code across nodes is achieved. Developers can reference remote states or modules through logical storage addresses without explicitly managing network connections, serialization, and deployment locations, greatly simplifying the programming model of distributed systems. Furthermore, this mechanism boasts good compatibility and can be integrated into mainstream runtimes (such as WASM and JVM).
[0055] In this embodiment of the invention, a state machine model is proposed. The state machine model is an abstraction of a program unit. It encapsulates the execution state and execution logic and can be used as the basic unit for running, scheduling, and migration.
[0056] Specifically, the state machine model is a computing model encapsulating execution state and execution logic, for responding to events, driving state transition, and its state and logic can be transparently migrated and executed in a distributed system.
[0057] As Figure 4 The core features are as follows:
[0058] 1. Each state machine represents a logical entity (such as user, order, video processing, etc.), including:
[0059] Execution logic: load execution code (from code segment), read and write execution state during execution, and determine the next state and action according to the current state, the action can be reading and writing data segment, or interacting with other state machines through event triggering or direct calling.
[0060] Execution state (State): records the current state of the state machine during execution, which can include relevant environment information, etc.
[0061] 2. The state machine supports sub-module division, allowing part of the logic and state to be migrated as an independent module.
[0062] 3. Combined with the unified address space, the code and data location are transparent to the logic.
[0063] In the embodiments of the present application, a transparent state machine scheduling (Transparent Scheduling) is proposed, which is a state machine unit combined with a unified address space and runtime support to achieve dynamic migration and scheduling optimization at the sub-module level.
[0064] Specifically, the state machine scheduling (State Machine Schedule) is a task scheduling mechanism taking state machine as an execution unit, supporting dynamic migration and scheduling of the whole state machine or sub-module between different physical nodes. The data accessed by the state machine can be independently scheduled based on the unified address space according to the location of the state machine. Transparent migration (Transparent Migration) refers to that the system automatically completes the cross-node migration of code and data without the intervention of the developer, and the developer does not need to perceive or handle details such as remote calling and data synchronization.
[0065] As Figure 5 The core features are as follows:
[0066] 1. Support overall or submodule migration, flexible scheduling granularity. 2. Scheduling basis includes resource utilization, network state, SLA (Service Level Agreement), user policy, etc. 3. The scheduler can predict the migration state machine in advance (such as judging according to historical information that a user will call a state machine, and then migrating the state machine + data to a node close to the user) or respond to the migration state machine. 4. The entire migration process is completely transparent to developers and business logic.
[0067] By taking the "state machine" as the scheduling basic unit, each state machine encapsulates its state and execution logic, supporting dynamic migration and concurrent running at the module level, and code and data can be independently scheduled. Compared with the traditional virtual machine or container scheduling scheme, the present application has finer granularity migration capability and higher runtime controllability, supporting dynamic adjustment of its running location and strategy in the task life cycle.
[0068] Moreover, through the transparent migration mechanism at the state machine level, during the migration process, the system automatically saves, transfers and restores the running state and dependent resources of the state machine, and is completely transparent to the call chain, control flow and data access. Developers do not need to pay attention to the implementation details of scheduling and migration, and can develop complex distributed applications with a single-machine semantic.
[0069] Through the embodiments of the present application, the following beneficial effects are achieved:
[0070] 1. Development friendly: through the abstracted unified address space and transparent migration capability, developers can use the state machine framework development SDK to build distributed applications with a consistent programming paradigm, without explicitly handling the underlying communication protocol, remote call logic and fault recovery mechanism, greatly reducing the distributed development threshold and learning cost.
[0071] 2. Dynamic flexibility: the system has the ability to intelligently schedule and dynamically scale according to resource load, geographical location, policy constraints and other factors, which can adapt to various application scenarios (such as edge computing, CDN acceleration, low-latency interaction, etc.), improving the flexibility and robustness of the overall system.
[0072] 3. Improve performance and reduce cost: through the near-scheduling and on-demand migration mechanism, execution logic and data can be independently scheduled, which can effectively reduce the latency and bandwidth consumption of remote calls and cross-machine access, while supporting resource hot migration and cold start optimization, improving system throughput and computing density, thereby reducing overall operation and computing power costs.
[0073] 4. Meet the multi-party demand: the system scheduling strategy supports the business logic requirements of the user side and the resource scheduling strategy of the platform side. For example, the quality of service can be guaranteed according to the user priority, and the computing resources can be dynamically integrated from the platform perspective to realize the dual optimization of "service quality and cost control".
[0074] The application will be further described below:
[0075] Referring to Figure 6 , a step flowchart of a processing method based on a distributed application is shown, and the distributed application can be provided with one or more state machines.
[0076] In some examples, the state machine can be a finite state automaton.
[0077] In some examples, the distributed application can have multiple business functions, and each state machine can be a logical execution unit of part of the business functions of the distributed application (each state machine can contain the code of the corresponding business function in the distributed application), such as user, order, video processing, etc. In actual application, developers can develop on the basis of the SDK provided by the distributed application, and abstract the business logic of the distributed application into a state machine.
[0078] In some examples, the state machine of the distributed application includes a large state machine and a small state machine, each large state machine includes one or more small state machines, and each small state machine is a sub-module of the large state machine.
[0079] In some examples, the method can be applied to a first node, and the node can be a computing node in a network, which can include a terminal node, an edge node, and a core cloud node. The first node can be any one of the terminal node, the edge node, and the core cloud node, and the second node can be any one of the edge node and the core cloud node.
[0080] Specifically, the method can include the following steps:
[0081] Step 601, in response to a state machine migration event, migrating first data of a first state machine instance running on the first node to a second node to instantiate a target state machine of the distributed application on the second node to obtain a second state machine instance; wherein the first state machine instance is a state machine instance obtained by instantiating the target state machine in the one or more state machines on the first node.
[0082] The first data can be context data of the first state machine instance, such as a state value, a variable, cache data, an intermediate result, or the like. The context data is data accumulated and relied on by the state machine during execution, and migrating the context data can ensure that the state machine can continue to execute seamlessly on the target node, maintaining consistency and continuity of application logic.
[0083] In some examples, the state machine migration event can include any one or more of the following:
[0084] The resource occupancy of the first node is greater than an occupancy threshold, the task computation cost of the first node is greater than a cost threshold, and the task processing latency of the first node is greater than a latency threshold.
[0085] In actual applications, one or more target state machines of the distributed application program can be instantiated in the first node to obtain a first state machine instance, and then the first state machine instance in the first node can provide services for users. When a state machine migration event is detected, such as excessively high resource occupancy, excessively large task computation cost, or excessively long task processing latency of the first node, a state machine migration mechanism can be triggered, and then the second node can be selected as a target migration node, and the first data of the first state machine instance running in the first node can be migrated to the second node.
[0086] On the second node side, the target state machine of the distributed application program can be instantiated to obtain a second state machine instance, and then the second state machine instance in the second node can provide services for users.
[0087] In some examples, the selection of the second node can be performed by a scheduling layer, which can select the second node according to distances of various nodes from the first node, such as selecting the node closest to the first node as the second node. In some examples, the scheduling layer can also select the second node in combination with a load condition and a network condition of the second node.
[0088] By migrating the first data of the first state machine instance running in the first node to the second node, it can be ensured that the state machine can continue to execute seamlessly on the new node, maintaining consistency and continuity of application logic. This migration process is completely transparent to developers, who only need to focus on development and maintenance of business logic without needing to pay attention to specific implementation details of the migration. Through the state machine migration mechanism of the embodiments of the present application, the system can intelligently adjust the deployment position of the state machine according to actual running conditions, realize optimized configuration and dynamic elastic scaling of resources, and thus improve performance and stability of the overall system.
[0089] In some embodiments of the present application, in response to a state machine migration event, first data of a first state machine instance running on the first node is migrated to a second node to instantiate a target state machine of the distributed application on the second node to obtain a second state machine instance, comprising:
[0090] In response to a state machine migration event, first data of a first state machine instance running on the terminal node is migrated to an edge node to instantiate a target state machine of the distributed application on the edge node to obtain a second state machine instance.
[0091] Alternatively, in response to a state machine migration event, first data of a first state machine instance running on the edge node is migrated to a core cloud node to instantiate a target state machine of the distributed application on the core cloud node to obtain a second state machine instance.
[0092] In some embodiments, the first node is a terminal node, and the second node is an edge node. The target state machine of the distributed application is instantiated on the terminal node to obtain the first state machine instance, and the first state machine instance in the terminal node provides services to users. In response to a state machine migration event, first data of the first state machine instance running on the terminal node can be migrated to the edge node to instantiate the target state machine on the edge node to obtain the second state machine instance, and the second state machine instance in the edge node provides services to users.
[0093] In some embodiments, the first node is an edge node, and the second node is a core cloud node. The target state machine of the distributed application is instantiated on the edge node to obtain the first state machine instance, and the first state machine instance in the terminal node provides services to users. In response to a state machine migration event, first data of the first state machine instance running on the terminal node can be migrated to the core cloud node to instantiate the target state machine on the core cloud node to obtain the second state machine instance, and the second state machine instance in the edge node provides services to users.
[0094] In some embodiments of the present application, before the first data of the first state machine instance running on the first node is migrated to the second node to instantiate the target state machine of the distributed application on the second node to obtain the second state machine instance in response to the state machine migration event, further comprising:
[0095] In response to a trigger event, a target state machine to be run in the first node is determined, and a logical storage address of second data of the target state machine is determined; wherein one logical storage address is mapped to a node storage address in a node storage space of a plurality of nodes; the second data of the target state machine is obtained from the node storage space of the first node or the node storage space of another node through the logical storage address; and the target state machine of the distributed application program is instantiated in the first node according to the second data, to obtain a first state machine instance.
[0096] The second data can be code data and / or user data of the target state machine, for example, the code data can be execution logic, algorithm, processing flow, etc. of the state machine, and the user data can be data to be read or written by the state machine during running.
[0097] In some examples, the trigger event includes a trigger operation of a user on an application function corresponding to the target state machine, such as starting a distributed application program, receiving a user request, a timing task trigger, etc.
[0098] In actual application, when a trigger event occurs, a function to be executed by a distributed application program can be determined, and then a target state machine to be run can be determined according to the function to be executed, and a logical storage address of second data of the target state machine can be obtained. After the logical storage address is obtained, the second data of the target state machine can be obtained from the node storage space of the first node or the node storage space of another node through the logical storage address. Then, the target state machine of the distributed application program is instantiated in the first node according to the obtained second data, to obtain a first state machine instance, so as to provide services for users through the first state machine instance in the first node.
[0099] The logical storage address is an address in a unified address space, and can be mapped to a node storage address in a node storage space of a plurality of nodes. For data required by a distributed application program, such as user data and code data of a state machine, a logical storage address in a unified address space can be allocated to the data, and the logical storage address is a globally unique address, which can be accessed by any node. Since the logical storage address is a virtual address and does not have an actual physical storage space for storing data, the data itself can be stored in a node storage space of any node (one copy of the data can be stored in different nodes and a synchronization mechanism is set between the data), when the data needs to be accessed, the data can be accessed through the unique logical storage address of the data, and then the logical storage address is mapped to a node storage address in a node storage space of a certain node, and then the actual data itself is found.
[0100] In some examples, one distributed application is composed of a set of state machines, and all nodes executing the application jointly maintain a uniform address space, which is included in the code of the distributed application and is the address space accessible by the distributed application. The uniform address has a uniform address identifier recognized by all nodes, and in actual execution, the logical storage addresses in the same uniform address space can be mapped to different physical storage spaces (i.e., node storage addresses) at different nodes. Data can exist in multiple copies, such as two nodes each storing one copy of the data, and synchronization is used to ensure consistency between the two copies.
[0101] In some embodiments of the application, the second data of the target state machine is obtained from the node storage space of the first node or the node storage space of another node through the logical storage address, including: determining whether the logical storage address is mapped with a node storage address in the first node; if the logical storage address is mapped with the node storage address in the first node, obtaining the second data of the target state machine from the node storage space of the first node; and if the logical storage address is not mapped with the node storage address in the first node, determining a node storage address in another node mapped with the logical storage address, and obtaining the second data of the target state machine from the node storage space of the other node.
[0102] Since data itself can be stored in the node storage space of any node, i.e., the same logical storage address can be mapped to node storage addresses in multiple node storage spaces, the priority of the node storage address can be set, and then one node storage address mapped with the same logical storage address is selected according to the priority of the node storage address to obtain data. For example, the node storage address of the currently executing node itself is set as the first priority, and the node storage addresses of other nodes are set as the second priority (the second priority can also be set according to the distance from the currently executing node), and then the node storage address of the first priority is selected to obtain data, and when data is not obtained through the node storage address of the first priority, data is obtained from the node storage address of the second priority.
[0103] Specifically, when it's necessary to retrieve the second data of the target state machine via a logical storage address, we can first determine whether the logical storage address maps to a node storage address in the first node (i.e., the currently executing node). If the logical storage address maps to a node storage address in the first node, it means the required data is stored in the node storage space of the first node, and the second data of the target state machine can be retrieved directly from the node storage space of the first node. If the logical storage address does not map to a node storage address in the first node, it means the required data is not stored in the node storage space of the first node. We can then determine the node storage address mapped to another node and retrieve the second data of the target state machine from the node storage space of that other node. In this way, we can ensure that the required data can be accessed from any node, achieving global data access and sharing.
[0104] In some examples, each node can maintain a local address mapping table, which can record the logical storage address of the data stored in the node's node storage space, and can record the mapping relationship between each logical storage address and the node storage address in the node's node storage space.
[0105] The entire system can maintain a global address mapping table, which can record the logical storage addresses of all data (including code data and user data) in the distributed application, and can also record the mapping relationship between each logical storage address and the node storage address (the node storage address can include the node storage address in the node storage space of multiple nodes).
[0106] When data needs to be accessed on a node, the system first checks the local address mapping table to see if the logical storage address of the data maps to the node storage address of the current node. If a mapping exists in the local address mapping table, it means the required data is stored in the node storage space of the current node, and the data can be retrieved directly from the node storage space. If no mapping exists in the local address mapping table, the system accesses the global address mapping table, searches for the corresponding node storage address based on the logical storage address, and then retrieves the data from the node storage space of the corresponding node. This method ensures that the required data can be quickly accessed from any node, improving data access efficiency.
[0107] In some embodiments of the present application, after determining the node storage address in other nodes mapped by the logical storage address and obtaining the second data of the target state machine from the node storage space of the other nodes, the method further comprises: storing the second data of the target state machine in the node storage space of the first node, and establishing a mapping relationship between the logical storage address and the node storage address in the first node; wherein the second data in all nodes is provided with a data synchronization mechanism.
[0108] After obtaining the second data, the first node can store the second data in the node storage space of the first node, and can establish a mapping relationship between the logical storage address of the second data and the node storage address in the first node, so as to facilitate subsequent data searching. In some examples, the mapping relationship can be recorded in the local address mapping table of the first node, and can be synchronized to the global address mapping table of the system.
[0109] In some embodiments of the present application, the logical storage address is also used for: in the second node, obtaining the second data of the target state machine from the node storage space of the second node or the node storage space of other nodes through the logical storage address, and instantiating the target state machine of the distributed application in the second node according to the second data, to obtain a second state machine instance.
[0110] In some embodiments of the present application, the logical storage address and the node storage address are any of the following:
[0111] Java object reference, linear virtual address.
[0112] The Java object reference can be an object reference in a JVM (Java Virtual Machine). The JVM is realized by simulating various computer functions on an actual computer. It is composed of a set of bytecode instruction sets, a group of registers, a stack, a garbage collection heap, and a storage method area, etc. Only the target code (bytecode) generated on the JVM needs to be run, and it can be run on multiple platforms without modification. The JVM arranges data and code in the form of Java objects in memory.
[0113] The linear virtual address can be a linear virtual address in WASM (WebAssembly, a binary instruction format for stack-based virtual machines). WASM is a binary instruction format for stack-based virtual machines. WASM aims to be a portable compilation target for programming languages, supports client and server applications deployed on the Web, has a sandboxed execution environment and linear virtual memory.
[0114] In some embodiments, the logical storage address is a Java object reference in the uniform address space, the node storage address is a Java object reference in the node storage space, and the data is found in the node storage space through the mapping of the Java object reference in the uniform address space to the Java object reference in the node storage space.
[0115] In some embodiments, the logical storage address is a linear virtual address in the uniform address space, the node storage address is a linear virtual address in the node storage space, and the data is found in the node storage space through the mapping of the linear virtual address in the uniform address space to the linear virtual address in the node storage space. For example, the input is the logical storage address of the uniform address space: [0, 1000], but this program only accesses [0, 100], [500, 600], [800, 900] in it, the linear virtual address of the WASM linear address space: [0, 300], then the mapping relationship is: the logical storage address [0, 100] in the uniform address space -> the linear virtual address [0, 100] in the WASM linear address space, the logical storage address [500, 100] in the uniform address space -> the linear virtual address [100, 200] in the linear address space, the logical storage address [800, 900] in the uniform address space -> the linear virtual address [200, 300] in the linear address space.
[0116] As Figure 7 , for example, in the shopping scenario, the "grab order" task (linear virtual address):
[0117] In this scenario, the shopping user and the order are both modeled as independent state machine entities. Among them, the user state machine is responsible for managing the personal information, behavior state and event response of the user, and the order state machine encapsulates various logics of order life cycle management (such as ordering, payment, grabbing order, etc.). Both of them are located in the uniform address space, and each user and order has a globally unique logical storage address. In order to facilitate cross-platform running, the mapping of the global logical storage address to the linear virtual address in the WASM linear space, the state machine execution logic and the runtime can be implemented in the WASM linear space.
[0118] Suppose a user is shopping using a mobile phone, and the user state machine and the order state machine are both instantiated in the runtime layer of the terminal node. Due to the limited resources of the mobile device, in order to save local memory, the "grab order" submodule (responsible for the order locking and distribution logic in a high-concurrency environment) in the order state machine is not loaded to the local in the initial stage, but is reserved in the edge node.
[0119] When the user initiates the "order grabbing" operation, the runtime layer of the terminal node attempts to access the "order grabbing" submodule through the uniform address space (i.e., access through a logical storage address). Since the submodule is currently not resident in the local running environment, the runtime layer automatically initiates a remote RPC request to the edge node through logical storage address resolution (the RPC service can be implemented in WASM or can be independently run on the host of the runtime), loads the required code and data (i.e., second data) from the edge node, and maps them to the linear virtual address space of the local WASM, realizing transparent loading and calling of the submodule. With the completion of the loading of the "order grabbing" submodule (i.e., instantiation), the runtime layer executes the order grabbing logic locally.
[0120] However, if the computing power and resources of the mobile terminal are gradually strained during the order grabbing process, the runtime layer will send a migration request (i.e., a state machine migration event) to the scheduling layer through the RPC service according to the resource state monitoring mechanism. The scheduling layer decides to migrate the context data (including state data and execution context) of the order grabbing submodule (i.e., first data) to the nearest edge node according to resource utilization, network conditions, and other comprehensive strategies. During the migration process, the runtime layer packages and synchronizes the execution state of the order grabbing submodule (i.e., first data) through the RPC service, the scheduling layer re-instantiates the corresponding state machine task on the edge node, and maintains the mapping relationship with the uniform address space. Thereafter, the order grabbing submodule will continue to execute on the edge node and still be able to load code and data as needed through the uniform address space (i.e., load second data on the edge node).
[0121] When the order grabbing is successful, the edge node sends the order grabbing result to the user terminal through the RPC service through the event notification mechanism, and the user state machine of the terminal node updates the local state and feeds back to the user after receiving the event.
[0122] In the entire process, the developer does not need to care about the physical location change of the code and data, and the user is completely unaware of the dynamic scheduling and migration process of the order grabbing submodule, greatly optimizing resource utilization and terminal experience.
[0123] As can be seen from the example, the uniform address space, state machine model, and transparent scheduling mechanism proposed by the present application effectively shield the complexity of the underlying distributed environment, making the application program have higher flexibility and resource adaptation capability, and enabling efficient dynamic resource scheduling in edge computing and mobile terminal scenarios.
[0124] As Figure 8 Take the video coding task as an example (Java object reference):
[0125] In this scenario, the video coding task is modeled as independent state machine entities, including a video session state machine and a coding task state machine. The video session state machine is responsible for managing the metadata and control logic of the user's video session (such as play, pause, bitrate adjustment, etc.), and the coding task state machine encapsulates the specific video coding process (such as H.265 encoding, AI noise reduction, resolution switching, etc.). Both types of state machines are registered in the system's unified address space and have a globally unique logical storage address. Moreover, this scenario uses the Java object space as the runtime logical storage address model, and through the object reference mechanism in the Java Virtual Machine (JVM), the logical storage address is mapped to the JVM object instance of each node (i.e., the node storage address), achieving unified addressing and transparent access, and using the cross-platform features of JVM to achieve cross-platform application running.
[0126] Suppose a user is using an online video editing application to perform high-definition video editing and real-time preview on a mobile terminal (such as a tablet computer). When the user initiates an editing operation, both the video session state machine and the coding task state machine are instantiated in the JVM environment of the terminal node. Due to the high requirements of high-definition video coding tasks on computing resources and memory bandwidth, the terminal device only loads the "basic coding module" of the coding task state machine, while high-load sub-modules such as "AI noise reduction" and "intelligent resolution switching" are still resident in the edge node or the cloud.
[0127] When the user enables the "AI noise reduction" function, the terminal node attempts to access the AI noise reduction sub-module in the coding task state machine through the unified address space (i.e., through the logical storage address access). Since this module is not currently instantiated in the JVM of the terminal device, the runtime will map the address through RPC service to request the edge node to load the module. The edge node will package the Java bytecode of the AI noise reduction sub-module and the necessary data state (i.e., the second data) according to the request, and transmit it to the terminal device through the network. The runtime layer of the terminal node dynamically loads the classes and object instances of this module into the local JVM object space, achieving transparent mounting and calling of the module, and developers do not need to write any additional remote loading logic.
[0128] As the complexity of the editing project increases, the terminal node resources gradually become tight, and the runtime layer detects the CPU load and memory bandwidth bottleneck of the terminal. At this time, the runtime layer initiates an "AI noise reduction sub-module migration" request (that is, a state machine migration event) to the scheduling layer through the RPC service. The scheduling layer decides to migrate the execution of the AI noise reduction sub-module to the nearest edge node according to the resource state in the domain, network delay and current task priority. During the migration process, the runtime layer serializes the object state (such as buffer data, filter parameters) (that is, the first data) of the AI noise reduction sub-module in the JVM and sends it to the target edge node. After the edge node receives the migration data, it re-instantiates the state machine task of the AI noise reduction sub-module and maintains consistency with the logical storage address in the unified address space of the terminal device. Subsequent AI noise reduction processing will be directly performed on the edge node, the terminal interacts with the remote module through RPC, and the user interface continues to maintain real-time preview experience, completely unaffected by the migration operation.
[0129] In the codec task, part of the sub-modules of the state machine (such as code stream multiplexing and format packaging) are still executed locally on the terminal to ensure the real-time performance of the key control link; while the high-load AI noise reduction and intelligent coding strategy are asynchronously processed on the edge node to realize the collaborative work of cloud, edge and terminal. If the user switches to a more complex video scene (such as 4K video editing), the scheduling layer can further migrate part of the sub-modules to the core cloud resource pool (that is, the core cloud node) according to the resource requirements.
[0130] Through the embodiments of the present application, the system achieves the following effects: simple development experience: developers only need to write Java object space-oriented calling logic, without manually managing module deployment and remote calling details; resource utilization optimization: dynamically adjusting the execution location of the module according to the real-time resource state, realizing the collaborative computing power utilization of terminal, edge and cloud; user experience guarantee: ensuring that high-load codec tasks are automatically migrated when resources are limited, guaranteeing the smooth interaction experience and response speed of the terminal application; transparent migration and elastic expansion: the entire scheduling and migration process is completely transparent to users and developers, with good elasticity and adaptability, suitable for high-concurrency and dynamically changing multimedia application scenarios.
[0131] Reference Figure 9 , shows a step flowchart of another processing method based on a distributed application provided by some embodiments of the present application, and the distributed application can be provided with one or more state machines.
[0132] In some examples, the state machine can be a finite state automaton.
[0133] In some examples, the distributed application can have multiple business functions, each state machine can be a logical execution unit for part of the business functions of the distributed application (each state machine can contain the code of the corresponding business function in the distributed application), such as user, order, video processing, etc. In actual application, developers can develop on the basis of the SDK provided by the distributed application, and abstract the business logic of the distributed application into state machines.
[0134] In some examples, the state machines of the distributed application include large state machines and small state machines, each large state machine includes one or more small state machines, and each small state machine is a sub-module of the large state machine.
[0135] In some examples, the method can be applied to a first node, the node can be a computing node in a network, and the node can include a terminal node, an edge node, and a core cloud node. The first node can be any one of the terminal node, the edge node, and the core cloud node, and the second node can be any one of the edge node and the core cloud node.
[0136] Specifically, the method can include the following steps:
[0137] Step 901, in response to a state machine migration event, obtaining first data of a first state machine instance running on a first node, and instantiating a target state machine of the distributed application on the second node to obtain a second state machine instance; wherein the first state machine instance is a state machine instance obtained by instantiating the target state machine in the one or more state machines on the first node.
[0138] The first data can be context data of the first state machine instance, such as state values, variables, cache data, intermediate results, etc. The context data is data accumulated and relied on by the state machine during execution, and migrating the context data can ensure that the state machine can continue to execute seamlessly on the target node, maintaining the consistency and continuity of the application logic.
[0139] In some examples, the state machine migration event can include any one or more of the following:
[0140] The resource occupancy rate of the first node is greater than an occupancy rate threshold, the task computation cost of the first node is greater than a cost threshold, and the task processing delay of the first node is greater than a delay threshold.
[0141] In actual application, according to actual demand, a target state machine in one or more state machines of the distributed application program can be instantiated in the first node to obtain a first state machine instance, and then the first state machine instance in the first node provides services for users. When a state machine migration event is detected, such as that the resource occupancy of the first node is too high, the task calculation cost is too large, or the task processing time delay is too long, the state machine migration mechanism can be triggered, and then the second node can be selected as a target migration node, and the first data of the first state machine instance running in the first node can be migrated to the second node.
[0142] On the second node side, the target state machine of the distributed application program can be instantiated to obtain a second state machine instance, and then the second state machine instance in the second node provides services for users.
[0143] In some examples, the selection of the second node can be performed by a scheduling layer, which can select the second node according to the distance between each node and the first node, such as selecting the node closest to the first node as the second node. In some examples, the scheduling layer can also select the second node in combination with the load situation, network situation, and the like of the second node.
[0144] By migrating the first data of the first state machine instance running in the first node to the second node, it is ensured that the state machine can continue to execute seamlessly on the new node, maintaining the consistency and continuity of the application logic. This migration process is completely transparent to the developer, who only needs to focus on the development and maintenance of the business logic without needing to pay attention to the specific implementation details of the migration. Through the state machine migration mechanism of the embodiments of the present application, the system can intelligently adjust the deployment position of the state machine according to the actual running status, realize the optimized configuration and dynamic elastic scaling of resources, and thus improve the performance and stability of the overall system.
[0145] In some embodiments of the present application, instantiating the target state machine of the distributed application program in the second node to obtain a second state machine instance includes:
[0146] determining a logical storage address of second data of the target state machine; wherein a same logical storage address is mapped to a node storage space of each node; the second data of the target state machine is obtained from the node storage space of the second node or the node storage space of another node through the logical storage address; and the target state machine of the distributed application program is instantiated in the second node to obtain a second state machine instance according to the second data.
[0147] The second data can be code data and / or user data of the target state machine. The code data can be execution logic, algorithm, processing flow, etc. of the state machine. The user data can be data that needs to be read or written by the state machine during running.
[0148] In actual application, the second node can determine the logical storage address of the second data of the target state machine to be instantiated. After obtaining the logical storage address, the second node obtains the second data of the target state machine from the node storage space of the second node or the node storage space of another node through the logical storage address. Then, the second node instantiates the target state machine of the distributed application according to the obtained second data, to obtain a second state machine instance, so as to provide services for users through the second state machine instance in the second node.
[0149] The logical storage address is an address in a uniform address space, and can be mapped to a node storage address in a node storage space of a plurality of nodes. For data required by a distributed application, such as user data and code data of a state machine, a logical storage address in a uniform address space can be allocated to the data. The logical storage address is a globally unique address, and any node can access the logical storage address. Since the logical storage address is a virtual address and does not have an actual physical storage space for storing data, the data itself can be stored in a node storage space of any node (a copy of the data can be stored in different nodes and a synchronization mechanism is set between the data). When the data needs to be accessed, the data can be accessed through the unique logical storage address of the data, and then the logical storage address is mapped to a node storage address in a node storage space of a certain node, and then the actual data itself is found.
[0150] In some examples, a distributed application is composed of a group of state machines, and all nodes executing the application jointly maintain a uniform address space, which is already included in the code of the distributed application, that is, the address space accessible by the distributed application. The uniform address has a uniform address identifier recognized by all nodes. In actual execution, the logical storage address in the same uniform address space can be mapped to different physical storage spaces (i.e., node storage addresses) in different nodes. The data can exist in multiple copies. For example, two nodes need to access a piece of data, and then the two nodes can each store a copy of the data, and the consistency between the two copies is ensured through synchronization. It should be noted that the process of instantiating the target state machine of the distributed application in the second node can be performed before obtaining the first data, that is, the second data is obtained first to instantiate the second state machine instance, and then the second state machine instance is adjusted according to the obtained first data. Of course, the second state machine instance can also be instantiated according to the first data and the second data after the first data is obtained.
[0151] In some embodiments of the present application, the second data of the target state machine is obtained from the node storage space of the second node or the node storage space of other nodes through the logical storage address, including: judging whether the logical storage address is mapped with a node storage address in the second node; if the logical storage address is mapped with a node storage address in the second node, obtaining the second data of the target state machine from the node storage space of the second node; if the logical storage address is not mapped with a node storage address in the second node, determining a node storage address in other nodes mapped by the logical storage address, and obtaining the second data of the target state machine from the node storage space of other nodes.
[0152] Since the data itself can be stored in the node storage space of any node, that is, the same logical storage address can be mapped to node storage addresses in the node storage spaces of multiple nodes, the priority of the node storage address can be set, and then a node storage address is selected from the multiple node storage addresses mapped by the same logical storage address according to the priority of the node storage address to obtain data. For example, the node storage address of the currently executed node itself is set as the first priority, and the node storage addresses of other nodes are set as the second priority (the second priority can also set the priority according to the distance from the currently executed node), and then the node storage address of the first priority can be selected to obtain data. When the data is not obtained through the node storage address of the first priority, the data is obtained from the node storage address of the second priority.
[0153] Specifically, when the second data of the target state machine needs to be obtained through the logical storage address, it can be judged whether the logical storage address is mapped with a node storage address in the second node (i.e. the currently executed node). If the logical storage address is mapped with a node storage address in the second node, it indicates that the required data is stored in the node storage space of the second node, and the second data of the target state machine can be directly obtained from the node storage space of the second node. If the logical storage address is not mapped with a node storage address in the second node, it indicates that the required data is not stored in the node storage space of the second node, and the node storage address in other nodes mapped by the logical storage address can be determined, and the second data of the target state machine is obtained from the node storage space of other nodes. In this way, it can be ensured that the required data can be accessed at any node, realizing global access and sharing of data.
[0154] In some examples, each node can maintain a local address mapping table, which can record the logical storage addresses of the data stored in the node storage space of the current node, and can record the mapping relationship between each logical storage address and the node storage address in the node storage space of the current node.
[0155] The entire system can maintain a global address mapping table, which can record the logical storage addresses of all data (including code data and user data) of the distributed application and can record the mapping relationship between each logical storage address and the node storage address (which can include the node storage address in the node storage space of multiple nodes).
[0156] When data needs to be accessed at a certain node, the logical storage address of the data can be first searched in the local address mapping table to check whether the logical storage address is mapped with the node storage address of the current node. If the mapping relationship of the logical storage address exists in the local address mapping table, it indicates that the required data is stored in the node storage space of the current node, and the data can be directly obtained from the node storage space of the current node. If the mapping relationship of the logical storage address does not exist in the local address mapping table, the global address mapping table can be accessed to find the corresponding node storage address in the global address mapping table, and then the data can be obtained from the node storage space of the corresponding node. In this way, it can be ensured that the required data can be quickly accessed at any node, and the data access efficiency is improved.
[0157] In some embodiments of the application, if the logical storage address is not mapped with the node storage address in the second node, the node storage address in other nodes mapped by the logical storage address is determined, and the second data of the target state machine is obtained from the node storage space of the other nodes, and then the second data of the target state machine is stored in the node storage space of the second node, and the mapping relationship between the logical storage address and the node storage address in the second node is established; wherein the second data in all nodes is provided with a data synchronization mechanism.
[0158] After obtaining the second data, the second node can store the second data in the node storage space of the second node, and can establish the mapping relationship between the logical storage address of the second data and the node storage address in the second node, so as to facilitate subsequent data searching. In some examples, the mapping relationship can be recorded in the local address mapping table of the second node, and can be synchronized to the global address mapping table of the system.
[0159] In some embodiments of the application, after obtaining the first data of the first state machine instance running in the first node in response to the state machine migration event, and instantiating the target state machine of the distributed application in the second node to obtain the second state machine instance, the method further comprises:
[0160] feeding back the task processing result of the second state machine instance to the user.
[0161] After instantiation, the second node can provide services for the user through the second state machine instance, and the user can be fed back the task processing result of the second state machine instance for preview on the terminal side.
[0162] In some embodiments of the present application, the logical storage address is further used to: in the first node, obtain second data of the target state machine from the node storage space of the first node or the node storage space of other nodes through the logical storage address, and instantiate the target state machine of the distributed application in the first node according to the second data, to obtain the first state machine instance.
[0163] It should be noted that, for the method embodiments, in order to simply describe, they are all described as a series of action combinations, but those skilled in the art should know that the embodiments of the present application are not limited to the order of the actions described, because according to the embodiments of the present application, some steps can be performed in other order or simultaneously. Secondly, those skilled in the art should know that the embodiments described in the specification all belong to preferred embodiments, and the actions involved are not necessarily necessary for the embodiments of the present application.
[0164] Some embodiments of the present application provide a processing system based on a distributed application, the distributed application is provided with one or more state machines, and the system comprises a first node and a second node.
[0165] The first node is configured to obtain second data of a target state machine in the one or more state machines from the node storage space of the first node or the node storage space of other nodes through a logical storage address, instantiate the target state machine according to the second data to obtain a first state machine instance, and migrate first data of the first state machine instance running in the first node to the second node in response to a state machine migration event.
[0166] The second node is configured to obtain the second data of the target state machine from the node storage space of the second node or the node storage space of other nodes through the logical storage address in response to the state machine migration event, and instantiate the target state machine according to the second data to obtain a second state machine instance.
[0167] It should be noted that the process of instantiating the target state machine of the distributed application in the second node can be performed before obtaining the first data, that is, the second data is obtained first to instantiate and obtain the second state machine instance, and then the second state machine instance is adjusted according to the obtained first data. Of course, the first data and the second data can be used to instantiate the second state machine instance after the first data is obtained.
[0168] In some examples, the code data and the user data (i.e., the second data) of the target state machine can be stored in the first node and the second node in advance, and then the instantiation can be performed in the first node and the second node. Of course, the code data and the user data (i.e., the second data) of the target state machine can also be obtained from other nodes for instantiation.
[0169] For the first node:
[0170] Optionally, the second data of the target state machine in the one or more state machines is obtained from the node storage space of the first node or the node storage space of other nodes through the logical storage address, and the target state machine is instantiated according to the second data to obtain the first state machine instance, including:
[0171] In response to a trigger event, the target state machine to be run in the first node is determined, and the logical storage address of the second data of the target state machine is determined; wherein the same logical storage address is mapped to node storage addresses in node storage spaces of multiple nodes.
[0172] The second data of the target state machine is obtained from the node storage space of the first node or the node storage space of other nodes through the logical storage address.
[0173] The target state machine of the distributed application program is instantiated in the first node according to the second data to obtain the first state machine instance.
[0174] Optionally, the logical storage address is also used for:
[0175] In the second node, the second data of the target state machine is obtained from the node storage space of the second node or the node storage space of other nodes through the logical storage address, and the target state machine of the distributed application program is instantiated in the second node according to the second data to obtain the second state machine instance.
[0176] Optionally, the second data of the target state machine is obtained from the node storage space of the first node or the node storage space of other nodes through the logical storage address, including:
[0177] It is judged whether the logical storage address is mapped with the node storage address in the first node;
[0178] If the logical storage address is mapped with the node storage address in the first node, the second data of the target state machine is obtained from the node storage space of the first node;
[0179] If the logical storage address is not mapped with the node storage address in the first node, a node storage address in other node mapped with the logical storage address is determined, and second data of the target state machine is obtained from the node storage space of the other node.
[0180] Optionally, after determining the node storage address in other node mapped with the logical storage address if the logical storage address is not mapped with the node storage address in the first node, and obtaining the second data of the target state machine from the node storage space of the other node, the method further comprises:
[0181] storing the second data of the target state machine in the node storage space of the first node, and establishing a mapping relationship between the logical storage address and the node storage address in the first node; wherein the second data in all nodes is provided with a data synchronization mechanism.
[0182] Optionally, the logical storage address and the node storage address are any one of the following: Java object reference, linear virtual address.
[0183] Optionally, the first data is context data of the first state machine instance, and the second data is code data and / or user data of the target state machine.
[0184] Optionally, the trigger event includes a trigger operation of a user on an application function corresponding to the target state machine.
[0185] Optionally, in response to a state machine migration event, the first data of the first state machine instance running in the first node is migrated to a second node to instantiate the target state machine of the distributed application in the second node to obtain a second state machine instance, comprising:
[0186] In response to a state machine migration event, the first data of the first state machine instance running in the terminal node is migrated to the edge node to instantiate the target state machine of the distributed application in the edge node to obtain a second state machine instance.
[0187] Or, in response to a state machine migration event, the first data of the first state machine instance running in the edge node is migrated to the core cloud node to instantiate the target state machine of the distributed application in the core cloud node to obtain a second state machine instance.
[0188] Optionally, the state machine migration event includes any one or more of the following:
[0189] The resource occupancy of the first node is greater than an occupancy threshold, the task computation cost of the first node is greater than a cost threshold, and the task processing delay of the first node is greater than a delay threshold.
[0190] Optionally, the state machine of the distributed application includes a large state machine and a small state machine, and each large state machine includes one or more small state machines.
[0191] For the second node:
[0192] Optionally, the second data of the target state machine is obtained from the node storage space of the second node or the node storage space of another node through the logical storage address, and the target state machine is instantiated according to the second data to obtain a second state machine instance, including:
[0193] The logical storage address of the second data of the target state machine is determined; wherein the same logical storage address is mapped to node storage addresses in node storage spaces of multiple nodes.
[0194] The second data of the target state machine is obtained from the node storage space of the second node or the node storage space of another node through the logical storage address.
[0195] The target state machine of the distributed application is instantiated in the second node according to the second data to obtain a second state machine instance.
[0196] Optionally, the logical storage address is also used for:
[0197] In the first node, the second data of the target state machine is obtained from the node storage space of the first node or the node storage space of another node through the logical storage address, and the target state machine of the distributed application is instantiated in the first node according to the second data to obtain a first state machine instance.
[0198] Optionally, the second data of the target state machine is obtained from the node storage space of the second node or the node storage space of another node through the logical storage address, including:
[0199] It is judged whether the logical storage address is mapped with a node storage address in the second node;
[0200] If the logical storage address is mapped with the node storage address in the second node, the second data of the target state machine is obtained from the node storage space of the second node;
[0201] If the logical storage address is not mapped with the node storage address in the second node, a node storage address in other node mapped with the logical storage address is determined, and the second data of the target state machine is obtained from the node storage space of the other node.
[0202] Optionally, after the logical storage address is not mapped with the node storage address in the second node, a node storage address in other node mapped with the logical storage address is determined, and the second data of the target state machine is obtained from the node storage space of the other node, the method further comprises:
[0203] The second data of the target state machine is stored in the node storage space of the second node, and a mapping relationship between the logical storage address and the node storage address in the second node is established; wherein the second data in all nodes is provided with a data synchronization mechanism.
[0204] Optionally, after the first data of the first state machine instance running in the first node is obtained in response to the state machine migration event, and the second state machine instance of the target state machine of the distributed application is instantiated in the second node, the method further comprises:
[0205] The task processing result of the second state machine instance is fed back to the user.
[0206] Some embodiments of the application provide a processing device based on a distributed application, the distributed application is provided with one or more state machines, the device is applied to a first node, and is used for:
[0207] In response to a state machine migration event, the first data of the first state machine instance running in the first node is migrated to a second node, so that a second state machine instance of a target state machine of the distributed application is instantiated in the second node; wherein the first state machine instance is a state machine instance obtained by instantiating the target state machine in the one or more state machines in the first node.
[0208] Optionally, before the first data of the first state machine instance running in the first node is migrated to a second node in response to a state machine migration event, so that a second state machine instance of a target state machine of the distributed application is instantiated in the second node, the method further comprises:
[0209] In response to a trigger event, a target state machine to be run in the first node is determined, and a logical storage address of second data of the target state machine is determined; wherein a same logical storage address is mapped to node storage addresses in multiple node storage spaces of nodes.
[0210] acquire, from the node storage space of the first node or a node storage space of another node, second data of the target state machine according to the logical storage address;
[0211] According to the second data, the first node instantiates the target state machine of the distributed application to obtain a first state machine instance.
[0212] Optionally, the logical storage address is also used for:
[0213] In the second node, second data of the target state machine is acquired from a node storage space of the second node or a node storage space of another node according to the logical storage address, and according to the second data, the second node instantiates the target state machine of the distributed application to obtain a second state machine instance.
[0214] Optionally, acquiring, from the node storage space of the first node or a node storage space of another node, second data of the target state machine according to the logical storage address comprises:
[0215] determining whether the logical storage address is mapped with a node storage address in the first node;
[0216] If the logical storage address is mapped with the node storage address in the first node, the second data of the target state machine is acquired from the node storage space of the first node;
[0217] If the logical storage address is not mapped with the node storage address in the first node, a node storage address in another node mapped by the logical storage address is determined, and the second data of the target state machine is acquired from a node storage space of the other node.
[0218] Optionally, after determining, if the logical storage address is not mapped with the node storage address in the first node, a node storage address in another node mapped by the logical storage address and acquiring, from a node storage space of the other node, the second data of the target state machine, the method further comprises:
[0219] storing the second data of the target state machine in the node storage space of the first node, and establishing a mapping relationship between the logical storage address and the node storage address in the first node; wherein the second data in all nodes is provided with a data synchronization mechanism.
[0220] Optionally, the logical storage address and the node storage address are any one of the following: a Java object reference, a linear virtual address.
[0221] Optionally, the first data is context data of the first state machine instance, and the second data is code data and / or user data of the target state machine.
[0222] Optionally, the trigger event includes a trigger operation of a user on an application function corresponding to the target state machine.
[0223] Optionally, in response to a state machine migration event, first data of a first state machine instance running on the first node is migrated to a second node to instantiate a target state machine of the distributed application on the second node to obtain a second state machine instance, including:
[0224] In response to a state machine migration event, first data of a first state machine instance running on a terminal node is migrated to an edge node to instantiate a target state machine of the distributed application on the edge node to obtain a second state machine instance.
[0225] Alternatively, in response to a state machine migration event, first data of a first state machine instance running on an edge node is migrated to a core cloud node to instantiate a target state machine of the distributed application on the core cloud node to obtain a second state machine instance.
[0226] Optionally, the state machine migration event includes any one or more of the following:
[0227] The resource occupancy rate of the first node is greater than an occupancy threshold, the task computation cost of the first node is greater than a cost threshold, and the task processing delay of the first node is greater than a delay threshold.
[0228] Optionally, the state machines of the distributed application include large state machines and small state machines, and each large state machine includes one or more small state machines.
[0229] Some embodiments of the application provide a processing apparatus based on a distributed application, the distributed application being provided with one or more state machines, the apparatus being applied to a second node, and being used for:
[0230] In response to a state machine migration event, first data of a first state machine instance running on a first node is obtained, and a target state machine of the distributed application is instantiated on the second node to obtain a second state machine instance; wherein the first state machine instance is a state machine instance obtained by instantiating a target state machine in the one or more state machines on the first node.
[0231] Optionally, the target state machine of the distributed application is instantiated on the second node to obtain the second state machine instance, including:
[0232] determining a logical storage address of the second data of the target state machine; wherein one logical storage address is mapped to node storage addresses in node storage spaces of multiple nodes;
[0233] obtaining the second data of the target state machine from the node storage space of the second node or the node storage space of another node through the logical storage address;
[0234] instantiating the target state machine of the distributed application in the second node according to the second data to obtain a second state machine instance.
[0235] Optionally, the logical storage address is further used for:
[0236] in the first node, obtaining the second data of the target state machine from the node storage space of the first node or the node storage space of another node through the logical storage address, and instantiating the target state machine of the distributed application in the first node according to the second data to obtain a first state machine instance.
[0237] Optionally, obtaining the second data of the target state machine from the node storage space of the second node or the node storage space of another node through the logical storage address comprises:
[0238] determining whether the logical storage address is mapped to a node storage address in the second node;
[0239] if the logical storage address is mapped to the node storage address in the second node, obtaining the second data of the target state machine from the node storage space of the second node;
[0240] if the logical storage address is not mapped to the node storage address in the second node, determining a node storage address in another node mapped by the logical storage address, and obtaining the second data of the target state machine from the node storage space of the other node.
[0241] Optionally, after determining the node storage address in another node mapped by the logical storage address if the logical storage address is not mapped to the node storage address in the second node, and obtaining the second data of the target state machine from the node storage space of the other node, the method further comprises:
[0242] storing the second data of the target state machine in the node storage space of the second node, and establishing a mapping relationship between the logical storage address and the node storage address in the second node; wherein the second data in all nodes is provided with a data synchronization mechanism.
[0243] Optionally, in response to the state machine migration event, the first data of the first state machine instance running at the first node is acquired, and after the target state machine of the distributed application is instantiated at the second node to obtain a second state machine instance, the method further comprises:
[0244] The user is fed back the task processing result of the second state machine instance.
[0245] Some embodiments of the present application also provide an electronic device, comprising a processor, a memory, and a computer program stored on the memory and capable of running on the processor, the computer program being executed by the processor to implement the method as above.
[0246] Some embodiments of the present application also provide a computer readable storage medium, the computer readable storage medium storing a computer program, the computer program being executed by the processor to implement the method as above.
[0247] Some embodiments of the present application also provide a computer program product, comprising a computer program, the computer program being executed by the processor to implement the method as above.
[0248] For the device embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the related parts refer to the part of the method embodiments.
[0249] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.
[0250] The above provides a kind of based on distributed application processing method and device, has carried out detailed introduction, the principle and implementation mode of the present application are described in this paper by applying specific example, the above example is only for helping to understand the method of the present application and its core idea;For those skilled in the art, according to the idea of the present application, there will be changes in specific implementation mode and application range, and the content of the specification should not be understood as the limitation of the present application.
Claims
1. A processing method based on a distributed application program, characterized by, The distributed application is provided with one or more state machines, and the method is applied to a first node and comprises: In response to a state machine migration event, migrating first data of a first state machine instance running on the first node to a second node to instantiate a target state machine of the distributed application on the second node to obtain a second state machine instance; wherein the first state machine instance is a state machine instance obtained by instantiating the target state machine of the one or more state machines on the first node.
2. The method of claim 1, wherein, Before the first data of the first state machine instance running on the first node is migrated to the second node to instantiate the target state machine of the distributed application on the second node to obtain the second state machine instance in response to the state machine migration event, the method further comprises: In response to a trigger event, determining a target state machine to be run in the first node and determining a logical storage address of second data of the target state machine; wherein a same logical storage address is mapped to node storage addresses in node storage spaces of multiple nodes; Obtaining the second data of the target state machine from the node storage space of the first node or the node storage space of another node through the logical storage address; Instantiating the target state machine of the distributed application on the first node to obtain the first state machine instance according to the second data.
3. The method of claim 2, wherein, The logical storage address is further used for: In the second node, obtaining the second data of the target state machine from the node storage space of the second node or the node storage space of another node through the logical storage address, and instantiating the target state machine of the distributed application on the second node to obtain the second state machine instance according to the second data.
4. The method of claim 2, wherein, Obtaining the second data of the target state machine from the node storage space of the first node or the node storage space of another node through the logical storage address comprises: Determining whether the logical storage address is mapped with a node storage address in the first node; If the logical storage address is mapped with the node storage address in the first node, obtaining the second data of the target state machine from the node storage space of the first node; If the logical storage address is not mapped with the node storage address in the first node, determining a node storage address in another node mapped by the logical storage address, and obtaining the second data of the target state machine from the node storage space of the other node.
5. The method of claim 4, wherein, After determining the node storage address in another node mapped by the logical storage address and obtaining the second data of the target state machine from the node storage space of the other node if the logical storage address is not mapped with the node storage address in the first node, the method further comprises: Storing the second data of the target state machine in the node storage space of the first node, and establishing a mapping relationship between the logical storage address and the node storage address in the first node; wherein the second data in all nodes is provided with a data synchronization mechanism.
6. The method of claim 2, wherein, The logical storage address and the node storage address are any one of a Java object reference and a linear virtual address.
7. The method of claim 2, wherein, The first data is context data of the first state machine instance, and the second data is code data and / or user data of the target state machine.
8. The method of claim 2, wherein, The trigger event includes a trigger operation of a user on an application function corresponding to the target state machine.
9. The method of any one of claims 1-8, wherein, In response to a state machine migration event, migrating first data of a first state machine instance running on the first node to a second node to instantiate the target state machine of the distributed application on the second node to obtain a second state machine instance, includes: In response to a state machine migration event, migrating first data of a first state machine instance running on the terminal node to an edge node to instantiate the target state machine of the distributed application on the edge node to obtain a second state machine instance. Alternatively, in response to a state machine migration event, migrating first data of a first state machine instance running on the edge node to a core cloud node to instantiate the target state machine of the distributed application on the core cloud node to obtain a second state machine instance.
10. The method according to any one of claims 1 to 8, characterized in that, The state machine migration event includes any one or more of: The resource occupancy of the first node is greater than an occupancy threshold, the task computation cost of the first node is greater than a cost threshold, and the task processing latency of the first node is greater than a latency threshold.
11. The method according to any one of claims 1 to 8, characterized in that, The state machines of the distributed application include large state machines and small state machines, and each large state machine includes one or more small state machines.
12. A processing method based on a distributed application program, characterized by, The distributed application is provided with one or more state machines, and the method is applied to a second node, including: In response to a state machine migration event, obtaining first data of a first state machine instance running on a first node, and instantiating a target state machine of the distributed application on the second node to obtain a second state machine instance; wherein the first state machine instance is a state machine instance obtained by instantiating the target state machine of the one or more state machines on the first node.
13. The method of claim 12, wherein, In response to a state machine migration event, obtaining first data of a first state machine instance running on a first node, and instantiating a target state machine of the distributed application on the second node to obtain a second state machine instance; wherein the first state machine instance is a state machine instance obtained by instantiating the target state machine of the one or more state machines on the first node. Determining a logical storage address of second data of the target state machine; wherein a same logical storage address is mapped to node storage addresses in node storage spaces of multiple nodes; Obtaining the second data of the target state machine from a node storage space of the second node or a node storage space of another node through the logical storage address; Instantiating the target state machine of the distributed application on the second node according to the second data to obtain a second state machine instance.
14. The method of claim 13, wherein, The logical storage address is also used for: In the first node, second data of the target state machine is acquired from the node storage space of the first node or the node storage space of other nodes through the logical storage address, and the target state machine of the distributed application is instantiated in the first node according to the second data, to obtain a first state machine instance.
15. The method of claim 13, wherein, The second data of the target state machine is acquired from the node storage space of the second node or the node storage space of other nodes through the logical storage address, including: It is judged whether the logical storage address is mapped with a node storage address in the second node; If the logical storage address is mapped with the node storage address in the second node, the second data of the target state machine is acquired from the node storage space of the second node; If the logical storage address is not mapped with the node storage address in the second node, a node storage address in other nodes mapped by the logical storage address is determined, and the second data of the target state machine is acquired from the node storage space of the other nodes.
16. The method of claim 15, wherein, After the second data of the target state machine is acquired from the node storage space of the second node or the node storage space of other nodes through the logical storage address, the second data of the target state machine is stored in the node storage space of the second node, and a mapping relationship between the logical storage address and the node storage address in the second node is established; wherein the second data in all nodes is provided with a data synchronization mechanism. After the first data of the first state machine instance running in the first node is acquired in response to a state machine migration event, and the target state machine of the distributed application is instantiated in the second node to obtain a second state machine instance, the method further comprises:
17. The method according to any one of claims 12-16, characterized by, The task processing result of the second state machine instance is fed back to a user. The distributed application is provided with one or more state machines, and the system comprises a first node and a second node; 18. A processing system based on distributed applications, characterized by The first node is configured to acquire second data of a target state machine in the one or more state machines from the node storage space of the first node or the node storage space of other nodes through a logical storage address, instantiate the target state machine according to the second data to obtain a first state machine instance, and migrate first data of the first state machine instance running in the first node to the second node in response to a state machine migration event. The second node is configured to acquire the second data of the target state machine from the node storage space of the second node or the node storage space of other nodes through the logical storage address in response to the state machine migration event, and instantiate the target state machine according to the second data to obtain a second state machine instance. The distributed application is provided with one or more state machines, and the apparatus is applied to a first node and configured to:
19. A processing apparatus based on a distributed application, characterized by In response to a state machine migration event, first data of a first state machine instance running on the first node is migrated to the second node to instantiate a target state machine of the distributed application on the second node to obtain a second state machine instance; the first state machine instance is a state machine instance instantiated on the first node from the target state machine of the one or more state machines.
20. A processing device based on a distributed application, characterized by The distributed application is provided with one or more state machines, and the apparatus is applied to a second node and used for: In response to a state machine migration event, first data of a first state machine instance running on the first node is migrated to the second node to instantiate a target state machine of the distributed application on the second node to obtain a second state machine instance; the first state machine instance is a state machine instance instantiated on the first node from the target state machine of the one or more state machines.
21. An electronic device, comprising: A computer program is stored on the computer readable storage medium and is capable of being run on the processor, and the computer program, when executed by the processor, implements the method according to any one of claims 1 to 17.
22. A computer-readable storage medium, characterized in that, A computer program is stored on the computer readable storage medium and is capable of being run on the processor, and the computer program, when executed by the processor, implements the method according to any one of claims 1 to 17.
23. A computer program product, characterised in that, A computer program is stored on the computer readable storage medium and is capable of being run on the processor, and the computer program, when executed by the processor, implements the method according to any one of claims 1 to 17.