Monolake is a framework for developing high-performance network services like proxies and gateways in Rust. It is built from the ground up as a blank slate design, starting with a async runtime called Monoio that has first-class support for io_uring .
While the most widely used Rust async runtime is Tokio, which is an excellent and high-performance epoll/kqueue-based runtime, Monolake takes a different approach. The monoio runtime developed by Bytedance is designed with a thread-per-core model in mind, allowing Monolake to extract maximum performance from io_uring's highly efficient asynchronous I/O operations.
By building Monolake on this novel runtime foundation, the team was able to incorporate new first-class support for io_uring throughout the ecosystem. This includes io_uring specific IO traits and a unique service architecture that differs from the popular Tower implementation. Monolake also includes io_uring optimized implementations for Thrift and HTTP.
The Monolake framework has been used to build various high-performance proxies and gateways, and it is actively deployed in production at ByteDance. Its use cases are wide-ranging and include:
- Application Gateways: For protocol conversion, such as HTTP to Thrift
- Security Gateways: Providing pseudonymization for gRPC and Thrift RPCs
Monolake Proxy is a reference implementation that leverages the various components within the Monolake framework to build a high-performance HTTP and Thrift proxy. This project serves as a showcase for the unique features and capabilities of the Monolake ecosystem. By utilizing the efficient networking capabilities of the monoio-transports crate, the modular service composition of service-async, and the type-safe context management provided by certain-map, Monolake Proxy demonstrates the practical application of the Monolake framework. Additionally, this reference implementation allows for the collection of benchmarks, enabling comparisons against other popular proxy solutions like Nginx and Envoy.
-
io_uring-based Async Runtime (Monoio): Monolake is built on top of the Monoio runtime, which leverages the advanced capabilities of the io_uring Linux kernel feature to provide a highly efficient and performant asynchronous I/O foundation.
-
Thread-per-Core Model: Monoio, the async runtime used by Monolake, follows a thread-per-core architecture, which simplifies concurrent programming and avoids the complexities associated with shared data across multiple threads.
-
Improved Service Trait and Lifecycle Management: Monolake introduces an enhanced
Service
trait with improved borrowing semantics and a sophisticated service lifecycle management system, enabling seamless service versioning, rolling updates, and state preservation. -
Modular and Composable Connector Architecture: The
monoio-transports
crate provides a flexible and composable connector system, allowing developers to easily build complex network communication solutions by stacking various connectors (e.g., TCP, TLS, HTTP) on top of each other. -
Context Management with
certain_map
: Monolake utilizes thecertain_map
crate to provide a typed and compile-time guaranteed context management system, simplifying the handling of indirect data dependencies between services. -
Optimized Protocol Implementations: The Monolake framework includes io_uring-optimized implementations for protocols like HTTP and Thrift, taking full advantage of the underlying runtime's capabilities.
-
Modular and Extensible Design: The Monolake framework is designed to be modular and extensible, allowing developers to easily integrate custom components or adapt existing ones to their specific needs.
- AWS instance: c6a.8xlarge
- CPU: AMD EPYC 7R13 Processo, 16 cores, 32 threads
- Memory: 64GB
- OS: 6.1.94-99.176.amzn2023.x86_64, Amazon Linux 2023.5.20240805
- Nginx: 1.24.0
Crate | Description |
---|---|
monoio-transports | A foundational crate that provides high-performance, modular networking capabilities, including connectors and utilities for efficient network communications |
service-async | A foundational crate that introduces a refined Service trait with efficient borrowing and zero-cost abstractions, as well as utilities for service composition and state management |
certain-map | A foundational crate that provides a typed map data structure, ensuring the existence of specific items at compile-time, useful for managing data dependencies between services |
monoio-thrift | Monoio native, io_uring compatible thrift implementation |
monoio-http | Monoio native, io_uring compatible HTTP/1.1 and HTTP/2 implementation |
monoio-nativetls | The native-tls implementation compatible with monoio |
monoio-rustls | The rustls implementation compatible with monoio |
Contributor guide: Contributing.
Monolake is licensed under the MIT license or Apache license.
- Email: conduct@cloudwego.io
- How to become a member: COMMUNITY MEMBERSHIP
- Issues: Issues
- Discord: Join community with Discord Channel.
CloudWeGo enriches the CNCF CLOUD NATIVE Landscape.