Read the first chapter
The whole of chapter one, free. About 9 min. Turn the pages with the arrows, your keyboard, or a swipe.
Chapter 1
Latency Budgeting and Measurement
What do you actually measure when you say “our feed handler is fast”? If you cannot point to a single end-to-end number tied to a specific trading-critical path, you will keep chasing improvements you cannot verify - and you will eventually ship changes that make fills worse while dashboards still look “healthy.”
Latency budgeting and measurement solve a specific problem: you turn a vague performance goal into a ledger of time spent in each hop of your system, then you validate that the measured end-to-end behavior matches the budget. After this chapter, you will be able to (1) define a latency budget for a chosen critical path, (2) pick metrics that match the decisions your trading system makes, and (3) verify end-to-end measurements with enough rigor to catch instrumentation mistakes.
You will also learn how to use the Latency Budget Ledger to separate “time we think we spend” from “time the market sees,” and how to run a tight measurement loop when you change code, NIC settings, or time synchronization.
Latency Budget Ledger: define the budget, pick the metrics, and lock the path
Start by choosing the trading-critical path you care about. For most firms, the path is not “from market to exchange” but “from market event arrival into your system to the moment your order reaches the exchange matching engine,” plus any decision latency inside your stack. The trap: teams often budget the wrong segment, like application-to-application time, while the real pain lives in kernel queues, serialization, or timestamping.
The Latency Budget Ledger forces you to write down every stage with a concrete unit (usually microseconds) and an explicit measurement method. Use it like a financial ledger: each line item has a measurable quantity and an uncertainty range. If you cannot measure a line item directly, you either add an instrumentation point or you mark it as “unresolved” and bound it using a controlled experiment.
A practical way to define the path: pick one order type and one decision trigger, then write the pipeline in the order you will instrument it. For example, for Nadia’s microstructure strategy (market microstructure quant, 34), the critical path might run from “best bid/offer update reaches the strategy process” to “order request bytes hit the exchange gateway,” because her signal updates must stay synchronized with micro-price changes. She does not budget “strategy compute time” in isolation; she budgets the full path that determines whether the order reflects the intended state.
Use these three rules when you write the ledger:
1. Pick timestamps you can control and interpret. Decide which events produce timestamps: NIC transmit completion, kernel socket send timestamp, application “request built” timestamp, and exchange acknowledgment (or gateway-level receipt). Each timestamp must have a known meaning and known capture point. If you stamp “send” in application code but the OS queues the packet later, you have not measured what matters.
2. Budget in monotonic time, not wall-clock. Use a monotonic clock for internal measurements (for example, clock_gettime(CLOCK_MONOTONIC)), and only use wall-clock for alignment with external systems. Monotonic time prevents jumps during NTP adjustments from poisoning your latency deltas.
3. Track both median and tail with the same path. Don’t pick one without the other. Trading-critical behavior often fails in the tail due to queueing and contention. Record at least a central tendency (median) and a worst-case bound you actually observe (for example, 99th percentile, or “max over a run”), using the same instrumentation.
Once you have the path, choose metrics that map to execution outcomes. For low-latency systems, a good metric set usually includes: end-to-end latency for the critical path, application-to-kernel time (how long your process takes to hand off), kernel-to-wire time (how long the OS and NIC take to push bytes), and a timestamp-consistency check (does your “order built” timestamp align with the “packet sent” timestamp trend). If you only track one number, you will not know whether an improvement came from fewer queue waits or from your instrumentation drifting.
Finally, make the ledger executable. Each line item needs a measurement strategy: direct timestamp capture, packet trace correlation, or a controlled differential test. For direct capture, instrument at the producer and consumer of each stage. For correlation, use stable identifiers (sequence numbers in message payloads) so you can match one “order built” event to one “packet sent” event.
A ledger line item should read like: “Stage: strategy builds order → timestamp at order-build completion; Method: monotonic timestamp in strategy thread right before handoff; Expected: X µs; Uncertainty: Y µs; Validation: compare with packet trace and gateway logs.” If you cannot fill those fields, you do not yet have a usable budget.
Putting it into practice: validate end-to-end measurements and keep the ledger honest
You need a concrete measurement loop, not a one-time dashboard. The goal: confirm that the sum of your ledger line items matches end-to-end measurements within a tolerable error, and that each line item reacts to changes in the way you expect.
Below is a realistic scenario and a workflow you can run on a production-like testbed.
Assume the trading-critical path for Nadia’s strategy looks like this:
• Market event enters the market-data receiver - Strategy updates state and builds an order - The order leaves the process via a socket - The exchange gateway receives it (or you get a gateway-level receipt timestamp)
You will build a Latency Budget Ledger for that path, then validate it.
Step-by-step scenario (with expected outcomes)
1. Define ledger stages and instrumentation points. Add monotonic timestamps at: - T1: end of market-state update inside the strategy (the moment the order decision uses the new data) - T2: end of order-build (right before message encoding is complete and the send call runs) - T3: kernel send completion timestamp (or the earliest socket timestamp you can reliably capture) - T4: gateway receive timestamp from the order acknowledgment stream (or gateway receipt log) Expected outcome: you should be able to compute three deltas from logged events: - D12 = T2 - T1 (decision and build) - D23 = T3 - T2 (handoff/queueing) - D34 = T4 - T3 (network + gateway processing)
2. Pick a message correlation key and enforce it end-to-end. Put a monotonically increasing sequence number into each order message payload. Log it at T2, and ensure it appears in the gateway receive record so you can match T2 to T4.
Expected outcome: you will eliminate “wrong pairing” errors that otherwise look like jitter.
3. Run a controlled load test with a fixed order rate. Example: run 10,000 orders over a short window at a stable rate, and keep CPU frequency policy fixed. If you use thread pinning, keep it fixed too. Expected outcome: the deltas D12, D23, D34 should show stable baselines, not random swings that correlate with unrelated system activity.
4. Compute ledger totals and compare to end-to-end. End-to-end latency D14 = T4 - T1 should equal (within measurement error) D12 + D23 + D34. If you see a consistent gap, you likely have a missing stage (for example, timestamp capture lag) or a correlation mismatch.
Expected outcome: the discrepancy should behave like instrumentation noise, not like a systematic drift.
5. Validate timestamp consistency with a “no-op” experiment. Run the system in a mode where T2 logging still happens, but the order send is disabled (or the socket is blocked) so T3 and T4 do not advance. Expected outcome: you should see T2 logging continue and T3/T4 disappear. If you still get T4, you are not actually disabling the send path.
6. Change one variable at a time and watch which ledger lines move. For example: - Change NIC queueing discipline or interrupt moderation settings. - Re-run the same test. - Compare median and tail of D23 and D34 to the baseline.
Expected outcome: if queueing changes, you should see D23 and/or D34 move, while D12 stays roughly constant.
Quick checklist
• Write down the chosen trading-critical path and list every stage with a timestamp you can interpret. - Use monotonic time for internal deltas. - Add a correlation sequence number and verify it appears in gateway records. - Run a fixed-rate load test and compute D14 and D12 + D23 + D34. - Perform a no-op experiment to confirm your send/receive instrumentation gates work. - Change one system variable at a time and map the delta movement to the ledger line you expect.
To make this operational, store your ledger outputs with run metadata: code version, kernel version, NIC driver version, CPU frequency policy, and time synchronization state. When something regresses, you will need that metadata to decide whether you changed the system or merely updated the data pipeline.
What to watch for: common mistakes and edge cases that break budgets
Even strong teams break latency budgets for predictable reasons. The fix usually involves tightening measurement discipline rather than “tuning the fastest path.”
Clock domains drift and you blame the network If you mix wall-clock timestamps from different machines without proper alignment, you will see phantom latency or negative deltas. The ledger will not balance because you are comparing different time bases.
Do this: Use monotonic deltas inside one host, and only align across hosts using a carefully controlled time synchronization setup. Then validate by checking that D14 stays non-negative and that the ledger sum matches within a small error band during stable runs. Not this: Compare “strategy time” (wall-clock) to “gateway time” (wall-clock) and then try to smooth it with averages. You will hide real bugs and chase non-existent improvements.
Correlation key collisions or missing sequence numbers If your correlation key does not propagate cleanly, you will pair the wrong order-build event with the wrong gateway receipt. This produces artificial tail latency spikes and “ledger gaps” that look like queueing.
Do this: Put a sequence number directly in the order payload, log it at T2, and verify it exists in the gateway receive record for every order. Add a hard assertion in your offline analysis: each T2 must map to exactly one T4 (or a known set if you handle retries). Not this: Match events by “closest timestamp” or “same client order id string” when your system can batch, retry, or reorder at the application layer.
Instrumentation overhead changes the system you measure Adding logging at T2/T3/T4 can perturb scheduling and cache behavior. Your budget then measures the act of measuring, not the system latency.
Do this: Capture timestamps with minimal overhead (pre-allocated buffers, lock-free rings when possible), and perform an A/B run where you disable logging payloads but keep timestamp capture. If D12 shifts materially when you turn on detailed logging, you need a lighter capture path. Not this: Turn on verbose tracing in the hot path during production load and then interpret the results as performance facts. You will end up budgeting your logger.
These failure modes all share a pattern: the ledger stops balancing. When D14 no longer matches D12 + D23 + D34, you do not “assume the difference is network.” You inspect time bases, correlation, and measurement overhead until the ledger reconciles.
Latency budgeting works when you treat it like a verification system, not a spreadsheet. The Latency Budget Ledger gives you that discipline: define the path, attach timestamps that mean something, validate end-to-end reconciliation, and then let changes show up in the specific ledger lines you expect. If you do that reliably, you will spend your time fixing the right bottleneck - and you will stop arguing about which dashboard is “more correct.”
End of chapter one. 7 more chapters in the full book.
Swipe or use the arrows to turn the page
What's inside: 8 chapters
- 1. Latency Budgeting and Measurement
- 2. Network Topologies for Low Latency
- 3. Co-location Design and Tradeoffs
- 4. Time Synchronization with PTP
- 5. Kernel and NIC Tuning for Jitter
- 6. Packet Capture and Latency Forensics
- 7. Switch Configuration and Queue Control
- 8. End-to-End Validation and Regression Testing
About this book
"Latency And Infrastructure" is a finance book by Michael Burney with 8 chapters and approximately 15,712 words. Trading infrastructure, networks, co-location, and time synchronization.
This book was created using Inkfluence AI, an AI-powered book generation platform that helps authors write, design, and publish complete books. It was made with the AI Ebook Generator.
Frequently Asked Questions
What is "Latency And Infrastructure" about?
Trading infrastructure, networks, co-location, and time synchronization
How many chapters are in "Latency And Infrastructure"?
The book contains 8 chapters and approximately 15,712 words. Topics covered include Latency Budgeting and Measurement, Network Topologies for Low Latency, Co-location Design and Tradeoffs, Time Synchronization with PTP, and more.
Who wrote "Latency And Infrastructure"?
This book was written by Michael Burney and created using Inkfluence AI, an AI book generation platform that helps authors write, design, and publish books.
How can I create a similar finance book?
You can create your own finance book using Inkfluence AI. Describe your idea, choose your style, and the AI writes the full book for you. It's free to start.
Write your own finance book with AI
Describe your idea and Inkfluence writes the whole thing. Free to start.
Start writingCreated with Inkfluence AI