Skip to content

ReflxzR/monoio-relay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

monoio-relay

monoio-relay is a high-performance, easy-to-use HTTP server framework written in Rust. Built on the monoio runtime and its io_uring driver, the framework offers minimal overhead for performance-critical applications.

Key Features

Routing

  • Support for all HTTP methods: Handles all 9 standard HTTP methods with ease.
  • Static routes: Efficiently manage predefined routes.
  • Dynamic pattern matching:
    • Utilize a combination of LRU cache and radix trees for pattern matching.
    • Supports placeholders and wildcard patterns.
  • Nested routes: Easily organize and process nested route hierarchies.

Modular Design

  • Layered services architecture:
    • Stack service layers as needed, built with flexible service factories.
    • Unified server configuration simplifies layer management.
  • Thanks to service-async: which enables integration of various service layers.

Server Configuration

  • Fully customizable parameters for server initialization using the hyper builder API.

Additional Capabilities

  • Rate limiting: Control and manage request throughput to ensure system stability.
  • Router state app: Share data across routes with the Router State App (just remember your state type needs to implement Clone!)
  • Secure Communication: TLS is supported via Rustls for secure connections
  • Request Validation: Validate request headers and query parameters
  • Metrics: Track cache performance metrics whichever layer uses a cache (gated behind the 'metrics' feature)

Handler Function Simplicity

Each handler function in monoio-relay takes only two mandatory parameters:

  1. Request: Represents the incoming HTTP request.
  2. State: Access the user-defined application state.
    use monoio_relay::router::AppState;
    // Note: The state application must implement the `Clone` trait. Check examples

    // If you don't want to specify any stateful app
    async fn sample_request_handler(_req: Request<HttpBody>, _state: AppState<()>) -> Response<HyperBody> {
        Response::new(HyperBody::text("Hello from /api/users route"))
    }

    // If you want to provide and use the state
    async fn sample_request_handler(req: Request<HttpBody>, state: AppState<YourStateApp>) -> Response<HyperBody> {
        Response::new(HyperBody::text("Hello from /api/users route")) 
    }

please refer examples for more implementation details

Benchmark Performance

benchmarked using wrk and rewrk against other popular Rust frameworks. A simple "Hello, World!" HTTP server was used for raw performance evaluation.

Planned Features (Work in Progress)

  • Incoming request logging.
  • Request/response compression for improved performance.
  • Authentication mechanisms.

About

An http server framework compatible with monoio runtime

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages