๐ Comprehensive CRUD Performance Report
Tested on 1,000 pre-seeded SQLite database rows using identical schemas, Pydantic data models, and persistent concurrent HTTP connections.
๐ 1. Python Surface Routes (Tier 1/2) โ Pure FastAPI Compatibility
| Test Case & Operation | FastAPI (Python Stack) | RustAPI Tier 1/2 (Optimized Engine) | RustAPI Speedup Advantage |
|---|---|---|---|
GET List (1,000 Rows) (GET /books) |
17.11 req/s (1,752.9ms) | 121.89 req/s (246.1ms) | ๐ 7.12x FASTER |
GET Single Row (GET /books/1) |
1,131.25 req/s (26.5ms) | 3,580.27 req/s (8.3ms) | ๐ 3.16x FASTER |
POST Create Record (POST /books) |
293.33 req/s (102.2ms) | 1,753.78 req/s (17.1ms) | ๐ 5.98x FASTER |
PUT Update Record (PUT /books/1) |
316.85 req/s (94.6ms) | 2,944.72 req/s (10.1ms) | ๐ 9.29x FASTER |
DELETE Book Record (DELETE /books/1) |
402.06 req/s (74.6ms) | 4,422.77 req/s (6.7ms) | ๐ 11.00x FASTER |
โก Tier 3 Native Rust Fast-Path Routes (app.add_native_route)
Tier 3 routes execute 100% inside compiled machine code inside Tokio/Hyper, completely bypassing Python's CPython interpreter, GIL, and object allocation.
| Endpoint & Fast-Path Method | RustAPI Tier 3 Native Throughput | Avg Latency | Comparison vs FastAPI |
|---|---|---|---|
GET Single Row Fast-Path (GET /tier3/books/1) |
6,218.75 req/sec | 4.82 ms | ๐ 5.50x FASTER than FastAPI |
POST Write Fast-Path (POST /tier3/books) |
3,441.10 req/sec | 8.72 ms | ๐ 11.73x FASTER than FastAPI |
Static Health Check Fast-Path (/tier3/health) |
47,034.00 req/sec | 2.00 ms | โก Ultimate C-Speed Fast Path |
๐ Visual Throughput Comparison (Req/Sec)
๐ฌ Detailed Analysis of Core Write-Path Optimizations
1. Async GIL Semaphore Pre-Acquisition
Replaced try_acquire() with non-blocking async acquire_owned().await before Tokio worker thread dispatch. Prevents worker threads from contending simultaneously on CPython GIL.
2. SQLite WAL Mode Connection Pool
Configured SqliteConnectOptions with journal_mode=WAL, synchronous=NORMAL, and busy_timeout=10s. Eliminates database file locking bottlenecks.
3. Tokio Handle Reuse (try_current)
Directly reuses the server's primary Tokio runtime handle (Handle::try_current()) inside db.execute(), eliminating secondary runtime context switching.
4. Rust Native JSON Parsing
Implemented serde_to_pyobject in Rust to parse JSON directly into PyObjects via serde_json, bypassing Python's standard json.loads() FFI dispatch.