Skip to main content

Crate rusty_ssr

Crate rusty_ssr 

Source
Expand description

§Rusty SSR

High-performance Server-Side Rendering engine for Rust with V8 isolate pool and multi-tier CPU-optimized caching.

§Features

  • V8 Isolate Pool: Thread pool with dedicated V8 isolates for parallel SSR
  • Multi-tier Cache: L1/L2 CPU cache (hot) + RAM (cold) with LRU eviction
  • Axum Integration: Ready-to-use middleware for Axum web framework
  • Brotli Compression: Static and dynamic Brotli compression

§Quick Start

use rusty_ssr::prelude::*;

#[tokio::main]
async fn main() {
    // Initialize the SSR engine
    let engine = SsrEngine::builder()
        .bundle_path("ssr-bundle.js")
        .pool_size(num_cpus::get())
        .cache_size(300)
        .build_engine()
        .expect("Failed to create SSR engine");

    // Render a page
    let html = engine.render("/home").await.unwrap();
    println!("{}", html);
}

§Architecture

Request → SSR Cache (L1 hot → L2 cold) → V8 Pool → Response
                 ↑                            ↓
                 └──────── cache result ──────┘

§Performance

  • 73,000+ req/s with caching enabled
  • Sub-millisecond cache hit latency (~0.2ms)
  • 10-15x faster than Node.js SSR solutions

Re-exports§

pub use config::SsrConfig;
pub use config::SsrConfigBuilder;
pub use engine::SsrEngine;
pub use error::SsrError;
pub use error::SsrResult;

Modules§

cache
Multi-tier caching system Multi-tier caching system optimized for CPU cache efficiency
config
Configuration types and builder Configuration for Rusty SSR engine
engine
Main SSR engine Main SSR Engine
error
Error types Error types for Rusty SSR
middleware
Axum middleware (brotli, etc.) Axum middleware for SSR applications
prelude
Prelude module for convenient imports Convenient re-exports for common usage
v8_pool
V8 thread pool for parallel rendering V8 Thread Pool for parallel SSR rendering