Performance Benchmarks

Comprehensive performance analysis and benchmarks for PivotPHP

Performance in Every Strand

PivotPHP delivers exceptional performance through intelligent architecture and optimizations. Our comprehensive benchmarks demonstrate real-world performance across various scenarios.

Executive Summary

13,374
requests/second
Peak throughput
0.07ms
avg latency
Simple endpoints
0-2MB
memory usage
Under load

Performance by Request Type

Our benchmarks test three types of endpoints to represent real-world scenarios:

Request Type Description Throughput Avg Latency
Simple Minimal processing, status checks 13,374 req/s 0.07ms
JSON Typical API responses with data 2,059 req/s 0.48ms
Complex CPU-intensive calculations 2,213 req/s 0.44ms

Concurrency Performance

PivotPHP maintains excellent performance under various concurrent load levels:

Stress Test Results

100 Requests

PivotPHP Core 9,059 req/s
PivotPHP ORM 9,059 req/s
Slim 4 2,641 req/s
Lumen 2,182 req/s

1,000 Requests

PivotPHP Core 5,661 req/s
PivotPHP ORM 5,661 req/s
Slim 4 4,782 req/s
Lumen 2,313 req/s

10,000 Requests

PivotPHP Core 13,374 req/s
PivotPHP ORM 8,893 req/s
Slim 4 4,562 req/s
Lumen 2,912 req/s

Component Performance

Individual framework components demonstrate excellent efficiency:

🚀 Routing

4,785 ops/sec
Simple route resolution

⚡ Middleware

3,392 ops/sec
Single middleware execution

🔄 Pipeline

4,482 ops/sec
10 middleware layers

📦 JSON

519 ops/sec
JSON processing

Latency Distribution

PivotPHP maintains consistent low latency across percentiles:

Endpoint Type P50 P95 P99
Simple 0.13ms 0.22ms 0.44ms
Data 0.30ms 0.47ms 0.81ms
POST 0.40ms 0.61ms 2.38ms
Compute 0.15ms 0.22ms 0.42ms

Comparison with Other Frameworks

PivotPHP significantly outperforms established microframeworks:

Stress Test Results (10,000 requests)

Framework Simple Route JSON API Complex Avg Latency
PivotPHP Core 13,374 req/s 2,059 req/s 2,213 req/s 0.07ms
PivotPHP ORM 8,893 req/s 876 req/s 2,252 req/s 0.11ms
Slim 4 4,562 req/s 4,826 req/s 1,192 req/s 0.22ms
Lumen 2,912 req/s 2,708 req/s - 0.34ms
Flight - - - Timeout

PivotPHP is 2.9x faster than Slim 4 and 4.6x faster than Lumen!

Concurrent Performance Testing

PivotPHP excels at handling concurrent requests with minimal performance degradation:

Concurrent Request Handling

Connections Simple API Data API Heavy Processing Efficiency
1 3,931 req/s 1,229 req/s 2,647 req/s 100%
10 3,325 req/s 129 req/s - Excellent
50 3,033 req/s 1,163 req/s 1,447 req/s Good
100 3,991 req/s 1,057 req/s 1,508 req/s Excellent

Scaling Behavior

PivotPHP demonstrates excellent scaling characteristics:

  • Synchronous: Maintains 13,374 req/s even at 10,000 requests
  • Concurrent: Scales to 3,991 req/s with 100 connections
  • Memory Efficient: Only 0-2MB usage under heavy load

Real-World Performance

API Response Times

// Light endpoint - 0.11ms average
$app->get('/status', fn($req, $res) => $res->json(['ok' => true]));

// Normal endpoint - 0.20ms average
$app->get('/users', function($req, $res) {
    $users = User::paginate(10);
    return $res->json($users);
});

// Heavy endpoint - 2.28ms average
$app->post('/analyze', function($req, $res) {
    $result = ComplexCalculation::process($req->body());
    return $res->json($result);
});

Optimization Tips

1. Use Appropriate Endpoints

  • Reserve heavy processing for dedicated endpoints
  • Implement caching for computationally expensive operations
  • Use lightweight responses for health checks

2. Leverage Middleware Efficiently

// Good: Conditional middleware
$app->group('/api', function($app) {
    $app->use(new RateLimitMiddleware());
    $app->use(new AuthMiddleware());
    // Routes here
});

// Avoid: Global heavy middleware
$app->use(new ExpensiveMiddleware()); // Applied to all routes

3. Optimize Database Queries

// Use eager loading
$users = User::with('posts', 'comments')->get();

// Use query builder for complex queries
$stats = DB::table('orders')
    ->select(DB::raw('DATE(created_at) as date'), DB::raw('SUM(total) as revenue'))
    ->groupBy('date')
    ->get();

Benchmark Methodology

All benchmarks were conducted with:

  • Environment: Isolated Docker containers
  • Resources: 2 CPUs, 1GB RAM per container
  • PHP Version: 8.4.8 with OPcache+JIT enabled
  • Warmup: 100-1000 iterations before measurement
  • Duration: 10+ seconds per test
  • Metrics: Throughput, latency percentiles, memory usage

Running Your Own Benchmarks

Test PivotPHP performance in your environment:

# Clone the benchmark suite
git clone https://github.com/pivotphp/benchmarks.git
cd benchmarks

# Run all benchmarks
make benchmark-all

# Run specific framework benchmarks
make benchmark-pivotphp

# Generate reports
make report

Conclusion

PivotPHP delivers:

  • Ultra-low latency: Sub-millisecond response times
  • High throughput: Up to 8,673 requests/second
  • Memory efficiency: 5.7MB consistent footprint
  • Excellent scaling: Maintains performance under load

Perfect for high-performance APIs, microservices, and real-time applications.