Highly durable simple queue service scalable to millions of operations per second
Highly durable simple queue service scalable to millions of operations per second
Fast zero-configuration single-binary simple queue service.
Ensure you have Rust installed.
cargo install queuedqueued --data-dir /var/lib/queued…With a single Intel Alder Lake CPU core and NVMe SSD, queued manages around 300,000 operations (push, poll, update, or delete) per second with 4,096 concurrent clients and a batch size of 64. There is minimal memory usage; only metadata of each message is stored in memory.
As every operation is durably persisted to the underlying storage, the storage I/O performance can quickly become a bottleneck. Consider using RAID 0 and tuning the write latency for better performance.
At the API layer, only a successful response (i.e. 2xx) means that the request has been successfully persisted (fdatasync) to disk. Assume any interrupted or failed requests did not safely get stored, and retry as appropriate. Changes are immediately visible to all other callers.
It's recommended to use error-correcting durable storage when running in production, like any other stateful workload.
Performing backups can be done by stopping the process and taking a copy of the contents of the file/device.
GET /queues lists all queues. Returns:
{
"queues": [
{ "name": "my-q" },
{ "name": "another-q" }
]
}POST /queue/:queue/suspend can suspend specific API endpoints for a queue, useful for temporary debugging or emergency intervention without stopping the server. It takes a request body like:
{
"delete": true,
"poll": false,
"push": false,
"update": true
}Set a property to true to disable that endpoint, and false to re-enable it. Disabled endpoints will return 503 Service Unavailable. Use GET /queue/:queue/suspend to get the currently suspended endpoints.
POST /queue/:queue/throttle will configure poll throttling for a queue, useful for flow control and rate limiting. It takes a request body like:
{
"throttle": {
"max_polls_per_time_window": 100,
"time_window_sec": 60
}
}This will rate limit poll requests to 100 every 60 seconds. No other endpoint is throttled. Throttled requests will return 429 Too Many Requests. Use GET /queue/:queue/throttle to get the current throttle setting. To disable throttling:
{
"throttle": null
}GET /healthz returns the current build version.
GET /queue/:queue/metrics returns metrics in the Prometheus or JSON (Accept: application/json) format:
…Clients in example-client can help with running synthetic workloads for stress testing, performance tuning, and profiling.
As I/O becomes the main attention for optimisation, keep in mind:
write won't affect any data outside of the target range.write syscall data is immediately visible to all read syscalls in all threads and processes.write syscalls can be reordered, unless fdatasync/fsync is used, which acts as both a barrier and cache-flusher. This means that a fast sequence of write (1: create) -> read (2: inspect) -> write (3: update) can actually cause 1 to clobber 3. Ideally there would be two different APIs for creating a barrier and flushing the cache.No open issues yet, or sync has not completed.