Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How fast are Java Datagrams?

DZone's Guide to

How fast are Java Datagrams?

· Java Zone
Free Resource

What every Java engineer should know about microservices: Reactive Microservices Architecture.  Brought to you in partnership with Lightbend.

Following my article How fast are Java sockets, this article follows the same tests except for Datagrams which use UDP rather than TCP.

 

 

The timings

The tests are the same except Datagrams don't support busy waiting in Java 6 which hurts the Threaded Ping latency
UDP Pings per second 224 K/s
UDP Pings latency was 1/50/99%tile 4.1/4.2/4.7 us
Threaded UDP Pings per second 131 K/s
Threaded UDP Pings latency was 1/50/99%tile 9.8/11.0/33.2 us

Comparison

Test  Threaded  Throughput Typical latency
Datagram Ping no 224 K/s  4.2 μs
Socket Ping no 170 K/s  5.8 μs
Datagram Ping yes 131 K/s 11.0 μs
Socket Ping yes 235 K/s 8.5 μs

The Code

DatagramPingTest.java

From http://vanillajava.blogspot.com/2011/07/how-fast-are-java-datagrams.html

Microservices for Java, explained. Revitalize your legacy systems (and your career) with Reactive Microservices Architecture, a free O'Reilly book. Brought to you in partnership with Lightbend.

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}