Skip to content

Commit f90345c

Browse files
authored
Merge pull request #152 from Tuntii/Production-baseline
Production baseline
2 parents d7f8877 + 9fd7e9e commit f90345c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+7722
-497
lines changed

.env

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Placeholder environment variables for local documentation/examples
2+
# Replace with real values before running database-backed samples.
3+
DATABASE_URL=postgres://postgres:postgres@localhost:5432/rustapi_dev
4+
REDIS_URL=redis://127.0.0.1:6379
5+
OAUTH_CLIENT_ID=replace-me
6+
OAUTH_CLIENT_SECRET=replace-me
7+
OAUTH_REDIRECT_URI=http://127.0.0.1:3000/auth/callback
8+
OIDC_ISSUER_URL=https://accounts.google.com

.github/workflows/benchmark.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@ jobs:
2828
- name: Run Benchmarks
2929
run: cargo bench --workspace | tee benchmark_results.txt
3030

31+
- name: Run Performance Snapshot
32+
run: cargo run -p rustapi-core --example perf_snapshot --release | tee perf_snapshot.txt
33+
3134
- name: Upload Benchmark Results
3235
uses: actions/upload-artifact@v4
3336
with:
3437
name: benchmark-results
35-
path: benchmark_results.txt
38+
path: |
39+
benchmark_results.txt
40+
perf_snapshot.txt

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,11 @@ assets/b9c93c1cd427d8f50e68dbd11ed2b000.jpg
1212

1313
docs/cookbook/book/
1414
build_rs_cov.profraw
15+
answer.md
16+
docs/PRODUCTION_BASELINE.md
17+
docs/PRODUCTION_CHECKLIST.md
18+
/.github/instructions
19+
/.github/prompts
20+
/.github/skills
21+
*.md
22+
tasks.md

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
140140

141141
This release delivers a **12x performance improvement**, bringing RustAPI from ~8K req/s to **~92K req/s**.
142142

143+
> Note: the numbers below are preserved as a **historical release snapshot**. Current benchmark methodology and canonical public performance claims are maintained in `docs/PERFORMANCE_BENCHMARKS.md`.
144+
143145
#### Benchmark Results
144146

145147
| Framework | Requests/sec | Latency (avg) |

Cargo.lock

Lines changed: 53 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 63 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ RustAPI ships circuit breaker and retry middleware as first-class features, not
5757
- **Retry** with exponential backoff
5858
- **Rate Limiting** (IP-based, per-route)
5959
- **Body Limit** with configurable max size (default 1 MB)
60+
- **Health Probes** via `.health_endpoints()` for `/health`, `/ready`, and `/live`
6061

6162
### Environment-Aware Error Masking
6263

@@ -67,21 +68,32 @@ All error responses include a unique `error_id` (`err_{uuid}`) for log correlati
6768
Record and replay HTTP request/response pairs for production debugging:
6869

6970
```rust
71+
use rustapi_rs::extras::replay::{ReplayConfig, ReplayLayer};
72+
use rustapi_rs::prelude::*;
73+
7074
RustApi::new()
71-
.layer(ReplayLayer::new(store, config))
72-
.run("0.0.0.0:8080").await;
75+
.layer(
76+
ReplayLayer::new(
77+
ReplayConfig::new()
78+
.enabled(true)
79+
.admin_token("local-replay-token"),
80+
),
81+
)
82+
.run("0.0.0.0:8080")
83+
.await?;
7384
```
7485

7586
```sh
76-
cargo rustapi replay list
77-
cargo rustapi replay run <id> --target http://localhost:8080
78-
cargo rustapi replay diff <id> --target http://staging
87+
cargo rustapi replay list -t local-replay-token
88+
cargo rustapi replay run <id> -t local-replay-token --target http://localhost:8080
89+
cargo rustapi replay diff <id> -t local-replay-token --target http://staging
7990
```
8091

8192
- Middleware-based recording; no application code changes
8293
- Sensitive header redaction; disabled by default
8394
- In-memory (dev) or filesystem (production) storage with TTL
8495
- `ReplayClient` for programmatic test automation
96+
- Full incident workflow: [`docs/cookbook/src/recipes/replay.md`](docs/cookbook/src/recipes/replay.md)
8597

8698
### Dual-Stack HTTP/1.1 + HTTP/3
8799

@@ -121,7 +133,7 @@ Run HTTP/1.1 (TCP) and HTTP/3 (QUIC/UDP) simultaneously on the same server. Enab
121133

122134
| Feature | RustAPI | Actix-web | Axum | FastAPI (Python) |
123135
|:--------|:-------:|:---------:|:----:|:----------------:|
124-
| Performance | ~92k req/s | ~105k | ~100k | ~12k |
136+
| Performance | See benchmark source | Workload-dependent | Workload-dependent | Workload-dependent |
125137
| Ergonomics | High | Low | Medium | High |
126138
| AI/LLM native format (TOON) | Yes | No | No | No |
127139
| Request replay / time-travel debug | Built-in | No | No | 3rd-party |
@@ -132,6 +144,8 @@ Run HTTP/1.1 (TCP) and HTTP/3 (QUIC/UDP) simultaneously on the same server. Enab
132144
| Background jobs | Built-in | 3rd-party | 3rd-party | 3rd-party |
133145
| API stability model | Facade + CI contract | Direct | Direct | Stable |
134146

147+
Current benchmark methodology and canonical published performance claims live in [`docs/PERFORMANCE_BENCHMARKS.md`](docs/PERFORMANCE_BENCHMARKS.md). Historical point-in-time numbers in older release notes should not be treated as the current baseline unless they are linked from that document.
148+
135149
## Quick Start
136150

137151
```rust
@@ -146,13 +160,52 @@ async fn hello(Path(name): Path<String>) -> Json<Message> {
146160
}
147161

148162
#[rustapi_rs::main]
149-
async fn main() {
150-
RustApi::auto().run("127.0.0.1:8080").await
163+
async fn main() -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> {
164+
RustApi::auto().run("127.0.0.1:8080").await
151165
}
152166
```
153167

154168
`RustApi::auto()` collects all macro-annotated handlers, generates OpenAPI documentation (served at `/docs`), and starts a multi-threaded tokio runtime.
155169

170+
For production deployments, you can enable standard probe endpoints without writing handlers manually:
171+
172+
```rust
173+
use rustapi_rs::prelude::*;
174+
175+
#[rustapi_rs::main]
176+
async fn main() -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> {
177+
let health = HealthCheckBuilder::new(true)
178+
.add_check("database", || async { HealthStatus::healthy() })
179+
.build();
180+
181+
RustApi::auto()
182+
.with_health_check(health)
183+
.run("127.0.0.1:8080")
184+
.await
185+
}
186+
```
187+
188+
This registers:
189+
- `/health` — aggregate dependency health
190+
- `/ready` — readiness probe (`503` when dependencies are unhealthy)
191+
- `/live` — lightweight liveness probe
192+
193+
Or use a single production baseline preset:
194+
195+
```rust
196+
use rustapi_rs::prelude::*;
197+
198+
#[rustapi_rs::main]
199+
async fn main() -> std::result::Result<(), Box<dyn std::error::Error + Send + Sync>> {
200+
RustApi::auto()
201+
.production_defaults("users-api")
202+
.run("127.0.0.1:8080")
203+
.await
204+
}
205+
```
206+
207+
`production_defaults()` enables request IDs, tracing spans, and standard probe endpoints in one call.
208+
156209
You can shorten the macro prefix by renaming the crate:
157210

158211
```toml
@@ -202,6 +255,8 @@ Detailed architecture, recipes, and guides are in the [Cookbook](docs/cookbook/s
202255
- [System Architecture](docs/cookbook/src/architecture/system_overview.md)
203256
- [Performance Benchmarks](docs/cookbook/src/concepts/performance.md)
204257
- [gRPC Integration Guide](docs/cookbook/src/crates/rustapi_grpc.md)
258+
- [Recommended Production Baseline](docs/PRODUCTION_BASELINE.md)
259+
- [Production Checklist](docs/PRODUCTION_CHECKLIST.md)
205260
- [Examples](crates/rustapi-rs/examples/)
206261

207262
---

RELEASES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
**Release Date**: February 26, 2026
44
**Full Changelog**: https://github.com/Tuntii/RustAPI/compare/v0.1.335...v0.1.397
55

6+
**Benchmark Source of Truth**: Current benchmark methodology and canonical performance claims live in `docs/PERFORMANCE_BENCHMARKS.md`. Historical release-specific benchmark notes should be treated as point-in-time snapshots unless they are linked from that document.
7+
68
---
79

810
## 🎯 Highlights

0 commit comments

Comments
 (0)