VOOZH about

URL: https://thenewstack.io/p99-conf-3-ways-to-squash-application-latency/

⇱ P99 Conf: 3 Ways to Squash Application Latency - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-11-22 13:02:49
P99 Conf: 3 Ways to Squash Application Latency
Data / Networking / Operations

P99 Conf: 3 Ways to Squash Application Latency

"Latency lurks everywhere," warned Pekka Enberg in his P99Conf talk, offering three ways users can minimize slow performance on their systems.
Nov 22nd, 2024 1:02pm by Joab Jackson
👁 Featued image for: P99 Conf: 3 Ways to Squash Application Latency
Feature image via Pixabay.

We’ve all been frustrated by latency, either as users of an application,  or as developers building such apps.

At ScyllaDB‘s annual P99 virtual conference for system performance management, Pekka Enberg, founder and CTO of Turso Database, shared his favorite tips for spotting and removing latency from systems.

“Latency lurks everywhere,” said Enberg, who also has authored a book on latency, as well as worked fine-tuning the Linux kernel. “Every part of your stack will have some component will have some variance in latency.”

Each customer-facing app has a latency budget, which can be gobbled up by one bad component.

Latency is a distribution number: The 99th percentile is less than one failure for 100 successful operations. That may sound like a solid goal, but there is a compounding effect here, Enberg said. For an app with ten components, being in the 99th percentile still results in nine percent of users getting unsatisfactory performance.

And it can add up. Amazon once estimated that it loses 1% of sales for every 100ms of latency.

👁 Image

Screenshot

Enberg has thought plenty about ways of reducing latency and has boiled down his solutions into three different approaches:

  • Reduce data movement
  • Avoid work
  • Avoid waiting

#1 Reduce Data Movement

Moving the data needed to an application is always slow. In the best-case scenario, data can move only at the speed of light, and the network probably can’t even offer that theoretical throughput.

A network round trip from New York to London will be at least 57ms. Within the data center, it can take hundreds of microseconds to move between network cards of different servers, and within the server itself, accessing the server cache can still take nanoseconds.

To reduce latency, minimize data movement as much as possible, Enberg advised. Put the data as close as possible to where it is being used, either by co-location, replication or caching.

Moving the database to the same server that runs the application eliminates any network roundtrip latency. This is a favorite technique for high-frequency trading shops.

If you can’t move the data closer, you can at least copy the data to a closer location via caching and replication.

#2 Avoid Computational Work

Latency can also be lowered by avoiding unnecessary work. Although some processing will always be necessary, there is no reason to get the data entangled in more work than necessary.

This can be done in several ways, Enberg explained:

  • Reducing algorithmic complexity
  • Controlling memory management
  • Optimizing code
  • Avoiding CPU-intensive computation.

How many steps does your program or algorithm take once data is ingested? One that is too complex will slow things.

👁 screenshot.

Simple algorithms work with simpler data structures, such as arrays, and stacks, queues and hash tables. Linked lists and graphs, on the other hand, do not mesh well with low-latency systems

Although it may save in system resources, memory management can be a burden as well. “There’s actually a lot of things it has to do,” he said. If you use garbage collection, it should run without pause rather than in herky-jerky start-and-top mode.

And don’t even think about using virtual memory, which basically runs at disk speed, since, in fact, it runs on disks and takes up a lot of other CPU resources besides.

Optimizing code is the most obvious way to reduce latency. Look for ways to reduce CPU cycles and cache misses. Find bottlenecks with an optimizer, and then repeat the process.

Also, keep in mind that not all reductions in work result in better performance. Batching, for instance, simplifies the workload for the CPU but actually increases latency.

One long-running process could be split into parallel processes, reducing CPU-intensive computation. One long-running process monopolizes the CPU, and creates longer wait times for other related processes.

#3 Avoid Waiting

Any component waiting around for another incurs latency, Enberg notes. So, avoid designing a system where waiting occurs anywhere.

Synchronization, in general, is always going to be an issue for low-latency systems.

“Synchronization with mutual exclusion means threats have to wait,” he said.

It should not be used, and if it has to be deployed, then use “wait-free” synchronization. Try using partitions to eliminate the need for synchronization, and use read-only shared data structures wherever possible.

If you have to use synchronization, keep the critical bits that must be synchronized as short as possible.

Another tip: Don’t wait for the operating system. Avoid context switching, where the OS switches between multiple applications. “Don’t create too many threads and be easy on system calls,” he said.

Also, to this end, use non-blocking I/O, busy polling (where your system polls for an event rather than waits for it), and kernel by-pass techniques such as XDP and DPDK wherever possible.

Likewise, you don’t want your application to wait for the network.

One trick Enberg pointed out was to disable congestion control (“Nagle’s Algorithm“) in the TCP stack by using the TCP_NODELAY flag.

And while you are at it, disable head-of-line blocking, which means the large processes at the head of the queue will not hold up the rest of the processes behind them.

Enberg goes on to discuss ways of hiding latency (by paralyzing the workloads and other techniques), and how to fine tune a system for maximum performance.

👁 screenshot

His talk and other talks from the events can be viewed, with free registration, on the P99Conf site.

TRENDING STORIES
Joab Jackson is a senior editor for The New Stack, covering cloud native computing and system operations. He has reported on IT infrastructure and development for over 30 years, including stints at IDG and Government Computer News. Before that, he...
Read more from Joab Jackson
SHARE THIS STORY
TRENDING STORIES
Amazon Web Services and ScyllaDB are sponsors of The New Stack. 
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.