Unify accept and network threads into io threads

This commit is contained in:
2025-08-20 16:50:54 -04:00
parent 7e28e6503d
commit 130ff2062a
10 changed files with 157 additions and 216 deletions

View File

@@ -21,10 +21,9 @@ Controls server networking, threading, and request handling behavior.
| `bind_address` | string | `"127.0.0.1"` | IP address to bind the server to |
| `port` | integer | `8080` | Port number to listen on |
| `max_request_size_bytes` | integer | `1048576` (1MB) | Maximum size for incoming requests. Requests exceeding this limit receive a `413 Content Too Large` response |
| `accept_threads` | integer | `1` | Number of dedicated threads for accepting incoming connections |
| `network_threads` | integer | `1` | Number of threads for epoll-based network I/O processing |
| `io_threads` | integer | `1` | Number of I/O threads for handling connections and network events |
| `event_batch_size` | integer | `32` | Number of events to process in each epoll batch |
| `max_connections` | integer | `1000` | Maximum number of concurrent connections (0 = unlimited) |
| `max_connections` | integer | `50000` | Maximum number of concurrent connections (0 = unlimited). Note: Due to race conditions between connection acceptance and cleanup, it's possible to trip this limit without actually having that many concurrent connections, especially under high connection churn. |
### Commit Configuration (`[commit]`)
@@ -54,10 +53,9 @@ Controls behavior of the `/v1/subscribe` endpoint and SSE streaming.
bind_address = "0.0.0.0"
port = 8080
max_request_size_bytes = 2097152 # 2MB
accept_threads = 2
network_threads = 8
io_threads = 8
event_batch_size = 64
max_connections = 10000
max_connections = 50000
[commit]
min_request_id_length = 32
@@ -84,8 +82,7 @@ WeaselDB uses the `toml11` library for configuration parsing with robust error h
These configuration parameters directly affect server and API behavior:
**Server Performance:**
- **`accept_threads`**: Controls parallelism for accepting new connections. More threads can handle higher connection rates
- **`network_threads`**: Controls I/O processing parallelism. Should typically match CPU core count for optimal performance
- **`io_threads`**: Controls parallelism for both accepting new connections and I/O processing. Should typically match CPU core count for optimal performance
- **`event_batch_size`**: Larger batches reduce syscall overhead but may increase latency under light load
- **`max_connections`**: Prevents resource exhaustion by limiting concurrent connections
@@ -107,8 +104,7 @@ The configuration system includes comprehensive validation with specific bounds
### Server Configuration Limits
- **`port`**: Must be between 1 and 65535
- **`max_request_size_bytes`**: Must be > 0 and ≤ 100MB
- **`accept_threads`**: Must be between 1 and 100
- **`network_threads`**: Must be between 1 and 1000
- **`io_threads`**: Must be between 1 and 1000
- **`event_batch_size`**: Must be between 1 and 10000
- **`max_connections`**: Must be between 0 and 100000 (0 = unlimited)