Skip to content

rari-build/benchmarks

Repository files navigation

rari

Runtime Accelerated Rendering Infrastructure

npm version License: MIT Discord

rari vs Next.js Benchmark Suite

This benchmark suite provides a comprehensive comparison between rari (Rust-powered React Server Components) and Next.js.

Benchmark Objectives

Performance Metrics

  • Server-side rendering speed - Time to render all components on server
  • Time to First Byte (TTFB) - Server response latency (P50, P95, P99)
  • Bundle size comparison - Client-side JavaScript payload
  • Build times - Production build speeds
  • Concurrent request handling - Throughput under load (requests/sec)
  • Memory usage - Runtime memory consumption under load

What's Being Tested

The benchmark suite tests a single comprehensive homepage route (/) that includes:

  • 8 Server Components - Counter, TestComponent, ShoppingList, WhatsHot, EnvTestComponent, FetchExample, ServerWithClient, and Markdown
  • Static rendering - All components rendered server-side
  • Real-world complexity - Mix of simple and complex components with various rendering patterns

Quick Start

Prerequisites

  • Node.js 22+
  • pnpm (install with corepack enable)
  • Rust and Cargo
  • just - Command runner (install with cargo install just)

Setup

# One-command setup (installs all dependencies and tools)
just setup

# Or complete initialization (setup + build + compile)
just init

Run Benchmarks

# Build both apps for production
just build

# Run complete benchmark suite
just benchmark-all

# Run specific benchmarks
just buildtest
just benchmark
just loadtest

# Quick tests with oha
just quick-test-rari
just quick-test-nextjs

Test Scenarios

1. Performance Benchmark

Tests server-side rendering performance with sequential requests:

  • Warmup phase - 50 requests to warm up the server
  • Test phase - 20 measured requests
  • Metrics collected - Min, max, avg, P50, P95, P99 response times, response size, error rate

2. Load Test

Tests concurrent request handling using oha:

  • Duration - 30 seconds (configurable)
  • Concurrent connections - 50 (configurable)
  • Metrics collected - Throughput (req/sec), latency percentiles, error rates, timeouts

3. Build Time Test

Compares production build performance:

  • Build command - pnpm run build for both frameworks
  • Metrics collected - Build duration, bundle size, chunk count, warnings, errors

Metrics Collection

Performance Benchmark Metrics

  • Response times - Min, max, avg, P50, P95, P99 (in milliseconds)
  • Response size - Average payload size in bytes
  • Success rate - Percentage of successful requests
  • Error count - Number of failed requests

Load Test Metrics

  • Throughput - Requests per second (avg, min, max)
  • Latency - Response time percentiles (P50, P90, P95, P99) in milliseconds
  • Errors - Failed requests and timeouts
  • Duration - Total test duration

Build Metrics

  • Build time - Total production build duration
  • Bundle size - Total size of client-side JavaScript and CSS
  • Chunk count - Number of generated files
  • Warnings/Errors - Build output analysis

Configuration

Both applications are configured to be as equivalent as possible:

Shared Features

  • App Router with file-based routing
  • Single homepage route (/) with 8 server components
  • Server components by default
  • TypeScript throughout
  • Tailwind CSS for styling
  • Identical component implementations

rari App

  • Rust-powered React Server Components runtime
  • Vite-based build system
  • Production server on port 3000

Next.js App

  • Node.js-based React framework
  • Turbopack build system
  • Production server on port 3001

Actual Results

Based on the latest benchmark run (March 26, 2026):

Build Performance

Metric rari Next.js Improvement
Build Time 1.26s 3.69s 65.8% faster
Client Bundle 280.66 KB (6 files) 633.51 KB (8 files) 55.7% smaller

Performance Benchmark

Metric rari Next.js Improvement
Average Response Time 0.08ms 0.78ms 89.2% faster
P95 Latency 0.12ms 0.86ms 86.0% faster
Response Size 856 bytes 88,292 bytes 99.0% smaller

Load Test Performance (30s duration, 50 concurrent connections)

Metric rari Next.js Improvement
Throughput 71,404.48 req/sec 1,496.61 req/sec 4,671.1% higher
Average Latency 0.70ms 33.42ms 97.9% faster
P95 Latency 1.19ms 41.90ms 97.2% faster
Total Requests 2,142,557 44,903 4,671.1% more
Errors 0 0 100% success rate
Timeouts 0 0 100% success rate

Running Individual Tests

Starting Servers

# Start Rari production server (port 3000)
just start-rari

# Start Next.js production server (port 3001)
just start-nextjs

# Check if servers are running
just check-servers

Performance Testing

# Run performance benchmark (requires servers to be running)
just benchmark

Load Testing

# Run load test (requires servers to be running)
just loadtest

# Quick load tests with custom parameters
just quick-test-rari 30s 100
just quick-test-nextjs 30s 100

Build Time Testing

# Run build time comparison
just buildtest

Viewing Results

# View latest results
just results

# View specific result types
just results-build
just results-perf
just results-load

Development Commands

# Clean build artifacts
just clean

# Clean and rebuild
just rebuild

# Format and check code
just fmt
just check

# Compile benchmark tools
just compile

Available Commands

Run just to see all available commands, or just --list for a detailed list.

Common Workflows

First-time setup:

just init

Running benchmarks:

# 1. Build the apps
just build

# 2. Start servers (in separate terminals)
just start-rari
just start-nextjs

# 3. Run benchmarks
just benchmark-all

Quick iteration:

just rebuild
just buildtest
just check-servers

Contributing

When adding new benchmark scenarios:

  1. Ensure parity - Both apps should have equivalent functionality
  2. Update both apps - Add components/routes to both rari and nextjs
  3. Update benchmark tools - Modify the Rust benchmark tools in tools/benchmark/src/
  4. Document changes - Update this README with new test scenarios
  5. Run all tests - Verify with just benchmark-all

License

MIT License - see LICENSE for details.

About

Comprehensive performance benchmarks comparing rari (Rust-powered RSC) vs Next.js across build times, rendering speed, TTFB, bundle size, and concurrent load handling.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors