Building Modern Serverless Runtimes

Discover how modern serverless runtimes built with Rust and V8 isolates outperform Node.js in performance and security, delivering faster execution times and enhanced memory safety through memory-safe architecture.

Guilherme Oliveira - Dev Writer

The rise of serverless computing has revolutionized how developers build and deploy applications, prioritizing scalability and ease of use. However, the ever-increasing demand for faster performance, robust security, and optimized resource utilization calls for innovative approaches to runtime environments. These environments must not only handle workloads with precision but also ensure seamless integration with the dynamic requirements of edge computing.

By combining Rust’s unparalleled safety features with the versatility of the V8 engine, modern runtime architectures are redefining edge computing possibilities. Rust offers memory safety without a garbage collector, while V8 provides high-performance JavaScript execution. Together, they create a secure, efficient platform for handling complex edge workloads.

Why choose Rust for runtime development

Building next-generation serverless platforms demands a programming language that balances memory safety with top-tier performance. Rust stands out as the ideal candidate, offering unmatched safety and efficiency. Its robust design ensures that developers can create runtime environments that are secure, fast, and reliable, even under the most demanding workloads. Rust’s key strengths make it uniquely suited for runtime development:

  • Memory safety guarantees without runtime overhead.
  • Zero-cost abstractions for optimal performance.
  • Predictable performance characteristics.
  • Thread safety by design.
  • Compile-time error checking.

In modern serverless runtimes, Rust is often combined with the V8 engine to create efficient and secure execution environments. Rust’s memory safety and performance align well with V8’s lightweight isolates, enabling the development of scalable and responsive serverless platforms. This synergy allows for the execution of untrusted code with minimal overhead, making it ideal for edge computing scenarios.

Core runtime environment

The core runtime environment serves as the backbone of the serverless platform, managing the execution of code within isolated contexts to ensure security and efficiency. The V8 engine’s Isolate feature represents an isolated instance that provides a separate environment for executing JavaScript code. Each Isolate offers a sandboxed context with its own global variables and functions. This design ensures that each function runs in a secure, isolated environment, preventing unintended interactions between different executions.

V8 engine integration

V8 engine integration in Rust-based serverless runtimes enhances performance and flexibility. Google’s V8 engine employs just-in-time (JIT) compilation to transform JavaScript into optimized machine code, achieving native-like execution speeds. Through Rust bindings like Rusty V8, developers can execute JavaScript within Rust environments, enabling custom runtimes that combine the strengths of both technologies for efficient, scalable serverless platforms.

Memory management

The runtime leverages Rust’s ownership model for enhanced memory efficiency in its core components. While Rust ensures single ownership and prevents data races in the native code, the V8 JavaScript runtime employs its proven garbage collection system for managing JavaScript objects. A well-structured interaction between Rust and V8 combines the best of both worlds: Rust’s robust memory safety guarantees with V8’s sophisticated memory management.

The synergy between Rust’s compile-time checks and V8’s mature garbage collection system creates a robust foundation for memory management. When properly implemented, the Rust-V8 interface provides optimal memory handling in production environments, offering significant advantages over traditional approaches.

Security layer

The security layer is crucial in maintaining the integrity and safety of the serverless environment. It employs several mechanisms to ensure that code execution remains secure and isolated:

  • Process-level isolation through V8 isolates: V8 isolates provide lightweight isolation by running code in separate instances, enabling rapid context switching and efficient handling of concurrent functions.
  • Memory space separation between executions: each V8 isolate maintains its own memory space, preventing functions from accessing each other’s memory and maintaining data privacy in multi-tenant environments.

By integrating these features, the runtime architecture achieves a balance between performance and security, providing a robust foundation for executing serverless functions at the edge.

Performance benefits

When comparing traditional serverless platforms to modern edge runtimes, the performance improvements are striking. These advancements stem from architectural innovations prioritizing lightweight execution and resource efficiency. The table below highlights key metrics showcasing the differences between traditional serverless solutions and edge runtimes built with Rust and V8. Each metric reflects improvements in speed, memory consumption, and operational efficiency, critical for high-performance applications at scale.

MetricTraditional serverlessModern edge runtime
Cold start100ms - 1+s~5-20ms
Memory usage128MB+~10MB
InitializationContainer spin-upSandbox activation

Edge runtime’s superior performance stems from V8 isolates, which separate just the runtime context instead of entire containers, enabling quick startup times and high performance. This architecture, combined with Rust’s efficiency, delivers consistently lower latency and better resource utilization compared to traditional serverless approaches.

Why not Node.js

By using v8 and Rust, it’s possible to address some of the inherent flaws in Node.js since its inception. Ryan Dahl, the original creator of Node.js, has discussed these issues extensively, citing module management as one of its biggest design flaws. However, the most significant drawback of Node.js is its lack of built-in support for multi-tenancy, which can only be achieved through containerization, leading to cold starts. Additionally, Node.js was built with C++, a language that lacks memory safety and is generally less stable than Rust. By building a solution with Rust and V8 isolates, you get a more stable and secure application.

Multi-tenancy is essential for serverless computing because it allows multiple users or functions to share the same infrastructure efficiently, reducing costs and resource waste. Since Node.js wasn’t designed with multi-tenancy in mind, each function execution requires isolation to prevent conflicts or security risks between different workloads. Containerization provides this isolation by encapsulating each function in a separate environment with its own dependencies and runtime. While this approach effectively enforces multi-tenancy, it comes with a trade-off: the overhead of initializing and running containers contributes to slow startup times, commonly known as cold starts.

The process of containerization involves multiple steps that accumulate significant latency. First, the container runtime must pull the required image, which may include a full operating system, libraries, and dependencies. Then, the container must be instantiated, requiring resource allocation, filesystem setup, and sometimes even network configuration. Finally, the runtime loads the application code and executes it. These sequential steps introduce unavoidable delays. In contrast, V8 isolates offer a much lighter approach. Instead of spinning up separate containers, V8 isolates create lightweight execution contexts within the same process, providing rapid function execution without the need for system-level virtualization. This drastically reduces cold start time, making V8-based solutions ideal for high-performance serverless environments.

Real-world impact

Azion Cells is a runtime that demonstrates the benefits of modern edge runtime environments built with Rust. By focusing on lightweight execution, it avoids container overhead and significantly reduces cold starts while maintaining multi-tenant isolation. With startup times and memory consumption orders of magnitude lower than container-based solutions, Edge Cells sets a new standard for serverless computing at the edge.

Unlike AWS Lambda’s container-based approach, Azion’s architecture eliminates container initialization overhead, reducing startup times, memory consumption, and costs. Running closer to users and executing functions from NVMe storage, it ensures minimal latency for modern applications.

Key features of Azion’s runtime architecture

  • Secure multi-tenant isolation: Azion Cells use sandboxed environments to isolate functions, ensuring secure execution without the overhead of full containers. This approach enhances both performance and security, making it ideal for multi-tenant applications.
  • Rapid startup times: functions execute significantly faster due to lightweight runtime architecture, effectively minimizing cold starts and ensuring reliable performance even during sudden traffic surges.
  • Efficient resource utilization: by leveraging Rust’s memory safety and low-overhead abstractions, Azion optimizes resource use, reducing costs and improving scalability.
  • Latency reduction: Azion Cells operate directly at the network’s edge, dramatically reducing latency by processing requests closer to users. This strategic positioning, with the runtime’s rapid startup times and efficient code execution, creates a powerful synergy that delivers exceptional responsiveness for real-time applications. The architecture ensures consistently low latency from the initial request to the final response.

Azion’s innovative approach challenges the dominance of traditional solutions like AWS Lambda, making edge computing a viable and cost-effective option for next-generation applications. The combination of Rust’s power, V8 integration, and a forward-thinking architecture ensures that Azion Cells meet the demanding requirements of modern serverless platforms.

stay up to date

Subscribe to our Newsletter

Get the latest product updates, event highlights, and tech industry insights delivered to your inbox.