Serverless Rust program to run code from clients in micro-vm
Cloude is made up of 5 parts. They are assembled together to create the flow of the project :
initramfs-builderhandles the creation of the initramfs to start with a kernel to have the dependancies for the language we need in the VMvmmis the main crate that is used as a wrapper above KVM to make it easier to use by abstracting virtio support, serial channel handling and so onbackendis a small API that takes HTTP requests with code to execute, starts the VM thanks to vmm crate and send the order to the agent in the VMagenttake care of the execution of the code in the VM, it receives the order from the backend and return the output of the executioncliconstitute the last brick that is the user interface and allow sending requests to backend through HTTP
In a more graphical way this is the architecture of the project :
+------------------+
| CLI |
| User Interface |
| Sends HTTP Req |
+--------+---------+
|
v
+------------------+
| Backend |
| HTTP API |
| Start VM + Send |
| Exec Requests |
+--------+---------+
|
v
+------------------+
| VMM |
| KVM Wrapper |
| |
| VM Management |
+--------+---------+
|
Starts VM |
v
+--------------------------+
| VM |
| |
| +--------------------+ |
| | Agent | |
| | Execute Code | |
| | Return Output | |
| +---------+----------+ |
| |
| +---------+-----------+ |
| | Initramfs | |
| | Kernel + Runtime | |
| | Dependencies | |
| +---------------------+ |
+--------------------------+
↑
|
+----------+-----------+
| Initramfs Builder |
| Build initramfs file |
| Dependencies |
+----------------------+
The initramfs builder handles all the process of creating the image that will be used to start the VM and customize it. It will bring dependancies for languages
Features :
- Generates an initramfs from an OCI (docker) image
- Can generate an image depending of the language given
The VMM is a wrapper to KVM that handles the logic to manage the VM. It brings methods to create VMs, handle virtio device creation, assign IP, manage serial channels.
Features :
- Programs can create VM with resources allocated
- IP can be set to handle program-VM communication
- Serial port receives the output of the commands
The backend is an API that receives HTTP requests with language and code to execute. It will create a VM and send the order of execution before returning the output. Because we can receive multiple requests at the same time we can have multiple VM and so multiple agents to handle at the same time with unique IP for each one.
Features :
- User send requests to the specified route
- A VM is created with a specific IP, resources and image
- The code is sent to the agent inside the VM for execution
- After execution the output is returned
The agent is in charge of receiving code to execute, start it and wait for the complete execution. Each VM has an agent that starts a web server to receive the requests on a specific port. When the backend starts a VM, the agent starts in it and wait for the orders, the backend sends the order through the IP of the VM and the agent receives it.
Features :
- The code to execute is received from the backend
- The instructions are executed in the VM
- After execution the output is sent back to the backend
The CLI is a user-friendly interface to interact with the backend without CURL requests.
Features :
- Commands are executed in the user space
- Requests go to the designed backend
- Code output is received from the backend after execution
A micro-VM is spawned for every request as in serverless architecture. That way the agent only exists for the time of execution while the backend is constantly listening for execution requests.
The CLI is only used when the user needs it.
Below is the sequence diagram illustrating the end-to-end flow of a request in the Cloude system:
This diagram provides a high-level overview of how a job request flows through the system, from submission to execution and result retrieval.
To use this project locally, you can follow the quickstart guide in QUICKSTART.md for a simple end-to-end startup for local development.
The project is distributed under license Apache License 2.0
