diff --git a/api.md b/api.md index 26a8b86..1771264 100644 --- a/api.md +++ b/api.md @@ -257,6 +257,16 @@ Removes a retention policy, which may allow the log to be truncated. ----- +## `GET /ok` + +Simple health check endpoint. + +### Response + +Returns `200 OK` with minimal content for basic health monitoring. + +----- + ## `GET /metrics` Retrieves server metrics for monitoring. diff --git a/config.md b/config.md index 5ed5946..d74d41c 100644 --- a/config.md +++ b/config.md @@ -18,9 +18,7 @@ Controls server networking, threading, and request handling behavior. | Parameter | Type | Default | Description | |-----------|------|---------|-------------| -| `bind_address` | string | `"127.0.0.1"` | IP address to bind the server to | -| `port` | integer | `8080` | Port number to listen on | -| `unix_socket_path` | string | `""` (empty) | Unix domain socket path. If specified, takes precedence over TCP | +| `interfaces` | array of objects | TCP on 127.0.0.1:8080 | Network interfaces to listen on. Each interface can be TCP or Unix socket | | `max_request_size_bytes` | integer | `1048576` (1MB) | Maximum size for incoming requests. Requests exceeding this limit receive a `413 Content Too Large` response | | `io_threads` | integer | `1` | Number of I/O threads for handling connections and network events | | `epoll_instances` | integer | `io_threads` | Number of epoll instances to reduce kernel contention (max: io_threads). Lower values allow multiple threads per epoll for better load balancing, higher values reduce contention | @@ -47,16 +45,25 @@ Controls behavior of the `/v1/subscribe` endpoint and SSE streaming. | `max_buffer_size_bytes` | integer | `10485760` (10MB) | Maximum amount of unconsumed data to buffer for slow subscribers. Connections are closed if this limit is exceeded | | `keepalive_interval_seconds` | integer | `30` | Interval between keepalive comments in the Server-Sent Events stream to prevent idle timeouts on network proxies | +### Benchmark Configuration (`[benchmark]`) + +Controls benchmarking and health check behavior. + +| Parameter | Type | Default | Description | +|-----------|------|---------|-------------| +| `ok_resolve_iterations` | integer | `7000` | CPU-intensive loop iterations for `/ok` requests in resolve stage. 0 = health check only, 7000 = default benchmark load (~650ns, 1M req/s) | + ## Example Configuration ```toml # WeaselDB Configuration File [server] -# Network configuration -bind_address = "0.0.0.0" -port = 8080 -# unix_socket_path = "weaseldb.sock" # Alternative to TCP +# Network interfaces - can specify multiple TCP and/or Unix socket interfaces +interfaces = [ + { type = "tcp", address = "0.0.0.0", port = 8080 }, + # { type = "unix", path = "weaseldb.sock" }, # Alternative Unix socket +] # Performance tuning max_request_size_bytes = 2097152 # 2MB @@ -74,6 +81,9 @@ request_id_retention_versions = 50000 [subscription] max_buffer_size_bytes = 52428800 # 50MB keepalive_interval_seconds = 15 + +[benchmark] +ok_resolve_iterations = 10000 # Higher load for performance testing ``` ## Configuration Loading diff --git a/design.md b/design.md index e2cb097..cfabf27 100644 --- a/design.md +++ b/design.md @@ -50,11 +50,18 @@ ninja test # or ctest **Individual targets:** - `./test_arena_allocator` - Arena allocator unit tests - `./test_commit_request` - JSON parsing and validation tests +- `./test_http_handler` - HTTP protocol handling tests +- `./test_metric` - Metrics system tests +- `./test_api_url_parser` - API URL parsing tests +- `./test_server_connection_return` - Connection lifecycle tests **Benchmarking:** - `./bench_arena_allocator` - Memory allocation performance - `./bench_commit_request` - JSON parsing performance - `./bench_parser_comparison` - Compare vs nlohmann::json and RapidJSON +- `./bench_metric` - Metrics system performance +- `./bench_thread_pipeline` - Lock-free pipeline performance +- `./bench_format_comparison` - String formatting performance **Debug tools:** - `./debug_arena` - Analyze arena allocator behavior @@ -73,6 +80,9 @@ ninja test # or ctest - **toml11** - TOML configuration parsing - **doctest** - Testing framework - **nanobench** - Benchmarking library +- **nlohmann/json** - JSON library (used in benchmarks) +- **RapidJSON** - High-performance JSON library (used in benchmarks) +- **llhttp** - Fast HTTP parser --- @@ -119,7 +129,7 @@ Ultra-fast memory allocator optimized for request/response patterns: - **Streaming data processing** with partial message handling - **Connection lifecycle hooks** for initialization and cleanup -#### **Thread Pipeline** (`src/ThreadPipeline.h`) +#### **Thread Pipeline** (`src/thread_pipeline.hpp`) A high-performance, multi-stage, lock-free pipeline for inter-thread communication. diff --git a/todo.md b/todo.md index bf3456b..57a0a0f 100644 --- a/todo.md +++ b/todo.md @@ -25,6 +25,7 @@ ### Infrastructure & Tooling - [x] Implement thread-safe Prometheus metrics library and serve `GET /metrics` endpoint - [ ] Implement gperf-based HTTP routing for efficient request dispatching +- [ ] Replace nlohmann/json with simdjson DOM API in parser comparison benchmarks - [ ] Implement HTTP client for S3 interactions - [ ] Design `HttpClient` class following WeaselDB patterns (factory creation, arena allocation, RAII) - [ ] Implement connection pool with configurable limits (max connections, idle timeout)