A cloud computing system for multi-threaded execution with resource security sharing for serverless computing
By adopting a multi-threaded resource-sharing parallel secure execution model, the problems of cold start latency and low memory utilization in serverless computing are solved, achieving efficient and secure resource management and data protection, and improving system performance and security.
Patent Information
- Application Number
- CN202411440822.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2044-10-15
AI Technical Summary
Serverless computing suffers from cold start latency, low memory resource utilization, and insufficient security, which particularly impacts user experience and data security under high concurrency loads.
A multi-threaded resource-sharing parallel secure execution model is adopted. Through thread-level resource management and MPK protection mechanisms, multi-threaded parallel execution and memory isolation are achieved. ptrace is used for system call injection and resource recovery to ensure the security of sensitive data.
Significantly reduces cold start latency, improves memory resource utilization and system processing power, enhances data security, reduces data contention issues, and increases system throughput and compatibility.
Smart Images

Figure CN119396548B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of serverless computing, and particularly relates to a cloud computing system for multi-thread execution and resource security sharing in serverless computing. BACKGROUND
[0002] Serverless computing is a cloud computing model where users can write and run code without managing the underlying server infrastructure. In the serverless model, applications are typically deployed in containers that can run in any computing environment and can be automatically started on demand. After developers upload their code to a cloud platform, the cloud service provider takes care of configuration, scaling, and server resource management. Serverless applications are event-driven, responding to specific events or triggers such as web requests, database updates, or queue messages. When these events occur, the serverless platform automatically allocates resources for the code to execute, and immediately releases resources after execution. In this model, server management, scaling, and maintenance are automatically handled by cloud service providers (such as AWS, Alibaba Cloud). Serverless computing automatically scales on demand, charging based on actual resource usage rather than fixed capacity paid in advance.
[0003] Serverless computing platforms are currently in a rapid development stage. AWS Lambda is one of Amazon's serverless computing platforms. Lambda functions can be triggered by various events such as API Gateway, S3 file uploads, DynamoDB database changes, etc. Lambda supports multiple programming languages, including Python, Node.js, Go, Java, etc. AWS Lambda supports concurrent execution of multiple requests. It provides the function of reserving concurrency to ensure that specific Lambda functions can reserve resources for burst loads. In addition, AWS Lambda can handle high concurrency requests through automatic scaling, allowing thousands of requests to be processed simultaneously. Alibaba Cloud's serverless computing platform is called Function Compute. It allows users to write code and run functions triggered by HTTP requests, object storage (OSS), message services, etc., supporting multiple programming languages (Python, Node.js, Java, PHP, etc.). Alibaba Cloud Function Compute also supports high concurrency. Function Compute automatically scales according to the number of requests and allocates corresponding resources. Through configuration, multiple function instances can be ensured to run simultaneously, handling a large number of concurrent requests.
[0004] Serverless computing also faces challenges. On one hand, serverless computing faces the problem of container cold start. Usually, when a certain serverless function is not invoked for a period of time, the provider will shut it down to save energy and avoid over-provisioning. The next time a user runs an application that calls the function, the serverless provider will have to restart and start hosting the function again. This startup time adds significant latency, called "cold start". Once the function is started and running, it will get faster service speed in subsequent requests (warm start), but if it is not requested again for a period of time, it will go back to sleep. This means that the next user requesting the function will experience a cold start. When a cold start occurs, the serverless platform needs to perform a series of operations such as instance scheduling, image distribution, instance creation, resource configuration, runtime initialization, and code loading. The latency caused by this process can be several times the actual execution time of the request, resulting in a negative impact on user experience, especially in applications that rely on low latency. Secondly, the parallel execution of serverless functions still has the problem of low memory resource utilization. If a serverless function needs to handle multiple events or requests from users at the same time, the platform may need to allocate independent resources for each event. For example, when a cloud service provider processes multiple execution requests for machine learning inference tasks from different users, multiple containers will be enabled to execute. In order to execute the same function, call the same code and use the same environment, each container will load the libraries, models and other required libraries for this machine learning inference task during initialization. These preloaded libraries cannot be shared between container invocations, which leads to low memory resource utilization.
[0005] On the other hand, serverless computing also has security problems. Although container technology brings many advantages in providing lightweight and portable application deployment environments, compared with virtual machines, containers also face some unique security problems. Since containers share the operating system kernel on the same host, this can result in weaker isolation compared to virtual machines. If an attacker can successfully cross the container boundary, they may be able to affect other containers and applications running on the host, which is one of the security risks. Serverless computing adopts a multi-tenant mode, and functions in serverless services are usually running on shared infrastructure that runs code for multiple customers, which may lead to the possibility of sensitive data leakage between users when sensitive data is involved. At the same time, cloud service providers may retain users' sensitive data for commercial purposes, making it impossible to protect sensitive data. Images are the basic building blocks of containers, which contain all the file system layers of an application and its dependencies. If unverified or outdated images are used, there may be potential vulnerabilities, introducing security risks.
[0006] Therefore, the person skilled in the art is committed to developing a multi-threaded resource sharing parallel safe execution model, which is a multi-threaded parallel execution architecture, utilizes the multi-threaded execution performance of functions, improves parallelism, reduces response time, ensures that computing resources can still be effectively utilized under high concurrent load, and improves the throughput of the system. It is composed of a multi-threaded efficient parallel execution module and a multi-threaded resource safe sharing module. SUMMARY
[0007] In view of the above defects of the prior art, the technical problem to be solved by the present application is how to efficiently and safely execute.
[0008] To achieve the above-mentioned purpose, the present application provides a multi-threaded execution and resource safe sharing cloud computing system for serverless computing, characterized in that the present application proposes a multi-threaded resource sharing parallel safe execution model composed of a multi-threaded efficient parallel execution module and a multi-threaded resource safe sharing module; the multi-threaded efficient parallel execution proposes a thread-level resource management mechanism for function single instance, allowing accurate control of resource allocation for each thread, and designs a sequential execution mechanism within the container; in the multi-threaded resource safe sharing module, the MPK protection mechanism is the core component of thread memory safety, and the MPK provides per-thread memory protection, allowing the creation of memory isolation areas between different threads, thereby enhancing data security.
[0009] Further, the multi-threaded efficient parallel execution utilizes the lightweight characteristics of threads, so that multiple threads can be run in parallel in the same process, and each thread is responsible for processing a part of the task.
[0010] Further, the thread-level resource management mechanism intercepts the system calls of the processes within the container through ptrace to realize system call injection, i.e., systeminject, so that after the task is executed, the container environment is restored to ensure that the new task can return to the state after the container initialization when it starts.
[0011] Further, the implementation of the thread-level resource management mechanism includes the following steps:
[0012] Step 1, use the PTRACE_ATTACH command of ptrace to attach to the target process;
[0013] Step 2, use the PTRACE_SYSCALL command to pause the process before and after each system call in order to intervene;
[0014] Step 3, after the task is executed, use the read and write memory and register capabilities provided by ptrace to restore the container environment to the initialized state, preparing for the execution of the next task.
[0015] Further, the thread-level resource management mechanism can be executed in multiple threads.
[0016] Further, in the multi-thread resource safe sharing mode, a user sends a request through an http trigger, the request is received by an API server, then enters a corresponding container and starts a corresponding thread for processing.
[0017] Further, the multi-thread resource safe sharing mode involves thread management, CPU resource scheduling and virtual memory management.
[0018] Further, the thread management needs to ensure the correctness and reliability of shared resources when the function instance is executed in multiple threads in parallel, protect sensitive data of the user from being leaked between threads, and the application adopts an MPK protection mode to protect thread safety.
[0019] Further, the virtual memory management parses the code through a cppparser and generates a corresponding abstract syntax tree, determines the dependency relationship between variables, protects the private variables of each thread, and shares the shared variables as shared resources between functions, effectively improving the memory utilization and saving the memory resources.
[0020] Further, the relationship of each variable in the abstract syntax tree is expressed in the form of a graph, the data transmission is taken as the starting point, the graph traversal algorithm is used for traversal, all variables related to the input are found as the private state for protection, the content irrelevant to the user input is shared by multiple threads as the shared state, and after automatic classification, the MPK is used to isolate and protect the private state of each parallel thread.
[0021] The application has the following technical effects:
[0022] 1. Technical advantage: the strategy of instance multi-thread parallel execution solves the cold start, the MPK provides memory protection for each thread, sets access permissions in the page table entry, realizes fine-grained memory access control, enhances data security and reduces potential data competition problems. At the same time, the efficiency of MPK switching permission is high, only about 20 CPU instruction cycles are needed, which helps to maintain the high performance of the system.
[0023] 2. Performance indicators: Multi-threaded parallel execution can significantly reduce latency. Parallel execution can improve the processing capacity of the system, allowing more requests to be processed in a unit of time. By distinguishing between shared memory areas and private memory areas, the system can more efficiently utilize memory resources, reducing redundant memory allocation and release. By utilizing multi-threaded processing within already started containers to handle concurrent requests, the cold start triggered by each request is avoided. Each request can share the resources of the same container, avoiding the duplication of loading the same resources for each request, improving the utilization of memory and CPU resources. Reducing memory consumption by 30% to 98% for each function call, while reducing overall memory utilization by 25% and reducing the total number of cold starts by 62%
[0024] 3. Production implementation: The design of function multi-threaded resource sharing and parallel safe execution makes it have good scalability and compatibility, which can be easily deployed on various serverless computing platforms. Multi-threaded parallel execution can significantly reduce latency. Parallel execution can improve the processing capacity of the system, allowing more requests to be processed in a unit of time.
[0025] The concept, specific structure and technical effects of the present application will be further described below in conjunction with the drawings, so as to fully understand the purpose, features and effects of the present application. BRIEF DESCRIPTION OF DRAWINGS
[0026] Figure 1 is a multi-threaded resource sharing and parallel safe execution model system architecture diagram of a preferred embodiment of the present application. DETAILED DESCRIPTION
[0027] The following describes the preferred embodiments of the present application with reference to the drawings, making the technical content of the present application clearer and easier to understand. The present application can be embodied in many different forms, and the scope of protection of the present application is not limited to the embodiments described herein.
[0028] In the drawings, components of the same structure are denoted by the same reference numerals, and components having similar structures or functions are denoted by similar reference numerals. The size and thickness of each component shown in the drawings are arbitrarily shown, and the present application is not limited to the size and thickness of each component. In order to make the drawing clearer, the thickness of some components is appropriately exaggerated in some places.
[0029] The present patent proposes a multi-threaded efficient parallel execution and resource safe sharing cloud computing system for serverless computing, which utilizes the multi-threaded execution performance of functions, improves parallelism, reduces response time, and ensures that computing resources can still be effectively utilized under high concurrent load, improves the throughput of the system, and mainly consists of a multi-threaded efficient parallel execution architecture and a multi-threaded resource safe sharing. The workflow of the system is as follows Figure 1The user will send a request through the http trigger, which will be received by the API server, and then enter the corresponding container and start the corresponding thread for processing. The main functions involved here are thread management, CPU resource scheduling, and virtual memory management. For thread management, it is necessary to ensure the correctness and reliability of shared resources when multiple threads are executed in parallel, and to protect sensitive user data from being leaked between threads. We use the mpk protection mode to protect thread safety. For virtual memory management, we use the cppparser to parse the code and generate the corresponding abstract syntax tree to determine the dependency between variables, and protect the private variables of each thread. Shared variables are shared as shared resources between functions, effectively improving memory utilization and saving memory resources. In terms of sequential execution, we use Ptrace to complete the system inject to restore the thread in the container, so that when a new task is executed after a task is completed, it can be restored to the environment after the container is initialized. This allows one process (tracer) to control another process (tracee). Through Ptrace, we can achieve fine control over thread execution in the container, ensuring that tasks are executed in a specific order while effectively recovering and sharing resources between tasks. The following is a specific example:
[0030] Embodiment 1: Multi-thread efficient parallel execution architecture
[0031] In a serverless computing-oriented multi-thread efficient parallel execution and resource security sharing cloud computing system, a function single instance multi-thread parallel execution strategy is innovatively designed, and a thread-level resource management mechanism for function single instances is proposed, allowing precise control of resource allocation for each thread to improve resource utilization. In terms of sequential execution, system inject is performed through Ptrace to complete the Restore of the thread in the container, so that when a new task is executed after a task is completed, it can be restored to the environment after the container is initialized. This allows one process (tracer) to control another process (tracee). Through ptrace, we can achieve fine control over thread execution in the container, ensuring that tasks are executed in a specific order while effectively recovering and sharing resources between tasks. Specifically, our solution uses ptrace to intercept system calls of processes in the container, implements system call injection (system inject), and restores the container environment after task execution, ensuring that the new task can start in the state after the container is initialized. This mechanism not only ensures the sequential nature of task execution, but also improves the efficiency and resource utilization of the container through resource recovery and sharing.
[0032] In implementation, we first attach to the target process using the PTRACE_ATTACH command of ptrace, and then let the process pause before and after each system call through the PTRACE_SYSCALL command, so that we can intervene. After the end of task execution, we use the read and write memory and register capabilities provided by ptrace to restore the container environment to the initialization state, preparing for the execution of the next task. In addition, our solution also considers the need for safe parallel execution. By executing function instances in parallel in multiple threads, we can more effectively utilize computing resources and speed up task processing. This parallel execution mechanism, combined with the sequential control capabilities of ptrace, enables the system to maintain good performance and stability when handling a large number of short-lived, high-concurrency requests.
[0033] Embodiment 2: Multi-threaded resource safe sharing mode
[0034] The multi-threaded resource safe sharing mode is a core component of the thread memory safety, and the MPK provides per-thread memory protection, allowing the creation of memory isolation areas between different threads, thereby enhancing data security and reducing potential data race issues.
[0035] First, the user sends a request through the http trigger, which is received by the API server, and then enters the corresponding container and starts the corresponding thread for processing. The functions mainly involved here are thread management, CPU resource scheduling, and virtual memory management. For thread management, it is necessary to ensure the correctness and reliability of shared resources when function instances are executed in parallel, and to protect sensitive user data from being leaked between threads. We use the protection mode of mpk to protect thread safety. MPK provides independent memory access permission management for each core, grouping memory into a maximum of 16 groups. The binary numbers 0b0000~0b1111 of these 16 groups are called protection keys. Each core of the CPU has a 32-bit register (PKRU) to store the access permission of the current core for each group. The PKRU register contains 16 pairs of bits, corresponding to 16 page groups. Each pair contains two bits, representing R / W permissions. The value of each pair corresponds to three possible permissions (0, 0): read / write, (1, 0): read-only, (x, 1): no access. Compared with the system mprotect call, updating PKRU does not require a system call, which is much faster than mprotect (MPK requires a system call when marking pages). The protection of MPK is thread-local, and the access permissions of different threads may not be consistent, related to the corresponding PKRU, while mprotect affects the entire process. For each thread started, we assign the thread a corresponding protection key. The thread gets this protection and can get access to each memory, achieving the function of protecting the thread's memory.
[0036] For many high concurrency tasks, if we completely isolate the memory for all threads, it may cause a waste of resources. For example, the following common scenario: when the user sends a lot of the same task request to the cloud platform to batch process pictures, where these pictures are processed using the same machine learning inference model for each thread task. The machine learning model is equivalent for each user, and there is no possibility of data privacy leakage. If we protect this part of the model memory through mpk for each thread, it will cause a waste of memory resources. In order to solve this problem and improve the utilization of memory resources in the container, by distinguishing between private variables and public variables in the thread, for the part that all threads can share, as a shared region for all threads to access. For the part of the private variable related to user data privacy and security, this part is stored as a private region, so as to complete the distinction between private and shared memory, and realize the high utilization of container memory. In order to realize the distinction of variable privacy, we design cppparser, which can obtain the AST arranged in tree structure by static scanning of the code, support the parsing of multi-file programs, and have minimal dependencies. The relationship between each variable in the abstract syntax tree is expressed in the form of a graph. Taking the data input as the starting point, the graph traversal algorithm (DFS, BFS) is used to traverse, find all the variables related to Input, and protect them as private state. The content unrelated to user input is shared by multiple threads as shared state. After automatic classification, the private state of each parallel thread is isolated and protected by mpk.
[0037] The foregoing detailed description of the preferred embodiments of the application has been presented. It is understood that modifications and changes can be made to the preferred embodiments of the present application by those skilled in the art without departing from the spirit and scope of the present application. Therefore, the technical solutions obtained by those skilled in the art on the basis of the concept of the present application through logical analysis, reasoning or limited experiments, should be within the scope of protection determined by the claims.
Claims
1. A cloud computing system for serverless computing oriented multithreaded execution and resource security sharing, characterized in that, The application provides a multi-thread resource sharing parallel safety execution model, which is composed of a multi-thread efficient parallel execution and a multi-thread resource safety sharing module; the multi-thread efficient parallel execution provides a thread level resource management mechanism for a function single instance, allows accurate control of resource allocation of each thread, and designs an in-container sequential execution mechanism; in the multi-thread resource safety sharing module, an MPK protection mechanism is a core component of thread memory safety, the MPK provides per-thread memory protection, allows creation of a memory isolation area between different threads, and thus enhances data safety; The thread level resource management mechanism intercepts system calls of a process in a container through ptrace, realizes system call injection, i.e. system inject, and thus restores the container environment after task execution, so that the new task can return to the state after container initialization when starting; The multi-thread resource safety sharing module involves thread management, CPU resource scheduling and virtual memory management; The virtual memory management analyzes code through a cppparser and generates a corresponding abstract syntax tree, determines the dependency relationship between variables, protects private variables of each thread, and shares variables as shared resources between functions, so as to effectively improve memory utilization and save memory resources; The relationship of each variable in the abstract syntax tree is expressed in the form of a graph, the data transmission is taken as a starting point, all variables related to Input are found through graph traversal algorithm, and are protected as private state; Contents unrelated to user input are shared by multiple threads as shared state, and after automatic classification, the private state of each parallel thread is isolated and protected by mpk.
2. The serverless-compute oriented multi-threaded execution and resource-secure shared cloud computing system of claim 1, wherein, The multi-thread efficient parallel execution utilizes the lightweight characteristics of threads, so that multiple threads can be run in parallel in the same process, and each thread is responsible for processing a part of the task.
3. The serverless-compute oriented multi-threaded execution and resource-secure shared cloud computing system of claim 2, wherein, The thread level resource management mechanism includes the following steps: Step 1: use the PTRACE_ATTACH command of ptrace to attach to the target process; Step 2: pause the process before and after each system call through the PTRACE_SYSCALL command to intervene; Step 3: after the end of task execution, the container environment is restored to the initialization state by using the read-write memory and register capabilities provided by ptrace, so as to prepare for the execution of the next task.
4. The serverless-compute oriented multi-threaded execution and resource-secure shared cloud computing system of claim 3, wherein, The thread level resource management mechanism can be executed in multiple threads.
5. The serverless-compute oriented multi-threaded execution and resource-secure shared cloud computing system of claim 4, wherein, In the multi-thread resource safety sharing module, a user sends a request through an http trigger, which is received by an API server, then enters a corresponding container and starts a corresponding thread for processing.
6. The serverless-compute oriented multi-threaded execution and resource-secure shared cloud computing system of claim 5, wherein, The thread management needs to ensure the correctness and reliability of shared resources when the function instance is executed in multiple threads, and protect sensitive data of the user from being leaked between threads, and the application adopts the protection mode of mpk to protect thread safety.
Citation Information
Patent Citations
Multi-thread program memory security dynamic analysis method
CN117009977A
Method and system for isolating server-side resources of operating system under microkernel architecture
CN118585286A