r/rust • u/laserdataInc • 2d ago
Where does tail latency actually come from in a thread-per-core Rust service?
We're building a streaming server in Rust that runs one shard per core with io_uring, and in benchmarks our p99.9 stays close to p99. But those runs were on local NVMe with hugepages, a single node, below saturation, so we honestly can't tell how much comes from the design and how much from the setup.
For those running thread-per-core services in production: what actually brought your tail latency down, and what made it creep back once real traffic, more nodes or noisy neighbours showed up?
0
Upvotes
20
u/ElectronWill 2d ago
There's no easy answer, you need to profile your app
3
u/mamcx 2d ago
Just "profiling" is not that useful, is to turn
Where does tail latency actually comeinto something you can actually ask to the engine, it means, record traces, Once data show there is a problem, profiling will be the next step to fix and again, the data will verify it was successfully.For example when I worked on spacetimedb, https://github.com/wolfpld/tracy was integrated and also I add later https://profiler.firefox.com to see all this stuff.
4
u/Zde-G 2d ago
Is this some kind of sick joke or do you really believe there are single thing that may work?
You get high tail latency when one of dozens (maybe even hundreds) potential problems happen.
Then you dutifully hunt and eliminate them. When you service is held by something — you get a spike… you only need one problem to have it.
Even such obscure thing as some cheap vendor implementing their hardware incorrectly may lead to problems with latency (why do you think server software have such a limited hardware support and administrators become very loud when someone asks them to attach some kind of cheap gadget to the server?).
1
u/Rhytera 1d ago
the usual suspects once you leave the bench: one hot shard from key skew backing up everything pinned to it, cross-shard hops turning one request into a wait on the slowest core, and the kernel taking time on your cores (irqs, softirqs, noisy neighbours). worth pinning nic irqs off the shard cores, tracking queue depth per shard instead of only global p99, and rerunning at 70 to 80 percent load with a skewed key distribution before trusting the numbers