DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • HTTP for Inter-Service Communication?

Trending

  • Run Gemma 4 on Your Laptop: A Hands-On Guide to Google's Latest Open Multimodal LLM
  • Agentic Testing: Moving Quality From Checkpoint to Control Layer
  • Ujorm3: A New Lightweight ORM for JavaBeans and Records
  • The ORM Is Over: AI-Written SQL Is the New Data Access Layer

RSocket vs. gRPC Benchmark

These two go head-to-head in a performance battle based on latency, CPU consumption, QPS, and scalability.

By 
Andy Shi user avatar
Andy Shi
·
Jun. 03, 19 · Tutorial
Likes (24)
Comment
Save
Tweet
Share
51.5K Views

Join the DZone community and get the full member experience.

Join For Free

Almost every time I present RSocket to an audience, there will be someone asking the question: "How does RSocket compare to gRPC?"

Today we are going to find out.

Setting the Stage

RSocket

RSocket implements the reactive semantics on application networks. It is a networking protocol that enforces back pressure and other reactive streams concepts end-to-end.

gRPC

gRPC is designed to solve the problem of polyglot RPC. It has two parts: the protobuf IDL and HTTP/2 networking protocol.

Apple to Apple?

From the design and components, we know the apple to apple comparison should be RSocket vs. HTTP/2.

However, how would you compare two protocols effectively? One approach is to benchmark them with the same application. To make applications run on the protocols, we need an RPC SDK. 

RSocket is quite agnostic on the encoders. It supports JSON, protobuf and other definitions.  In this benchmark, we’ll use RSocket with protobuf,  Java RPC and Messagepack. For gRPC, we'll only use protobuf since it is proven to be the best-performing encoder for gRPC already.

Context

Before the benchmark test, let’s compare the use cases of the two protocols first. Basically, RSocket is designed for application communication, HTTP/2 is still designed to handle web traffic.

But what does “designed to handle web traffic” mean? Well, it means there is a clear distinction between client and server. And the conversation style is mostly request/response, with the possibility of stream. Remember TCP does not stress on that client/server distinction. When we are using the HTTP/2 protocol, it’s hard for the server to make reverse requests to the client, let alone using the same socket connection to do that.

Application-to-application communication, on the other hand, is quite different. Applications are peers having conversations. There is no hard line between who is the server and who is the client, especially in microservices architecture.

To cover most conversation scenarios, RSocket implements four types of communication models :

  • Request/response (stream of 1)
  • Request/stream (finite stream of many)
  • Fire-and-forget (no response)
  • Channel (bi-directional streams)

Not only is RSocket multiplexed, but the sender and receiver can switch roles while retaining the same socket connection.

Benchmark test

Setup

  • Two servers, each with 4-core Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz + 8G

JVM Configuration

 -Xmx2g -Xms2g -XX:+AlwaysPreTouch -XX:+UseStringDeduplication

gRPC Configuration

  • gRPC windowupdate = 1 *1024*1024 *1024

Sampling Rule

  • The best result out of 10 tries

Tool

The package we use is a comparison tool developed by Netifi. It's a Java stack.

Heap vs. Direct

In some of the results, we'll see heap vs. direct comparison. It is mostly meant for Java applications at high loads. On the charts, we will show heap (with _h  tag) and non-heap (with _d tag) results.

Results:

The two meaningful benchmarks are throughput (QPS) and Latency. Here are the results in different loads:

100,000-request_32-concurrency_16-conns_16bytes-repsonse

Latency:

Image title


QPS:

Image title


10,000,000-request_512-concurrency_16-conns_16bytes-repsonse

Latency:

Image title


QPS:

Image title


2,000-request_16-concurrency_16-conns_131072bytes-repsonse

Latency:

Image title


QPS:

Image title


CPU

We also tested CPU usage against the 10,000,000-request_512-concurrency_16-conns_16bytes-repsonse test. Using Java profiling tool, we get the following results:

Image title


Conclusion

It’s pretty obvious that in the Java version, the RSocket SDK wins hands down against gRPC. From QPS, latency, CPU consumption, and scalability, RSocket performs better than gRPC in each and every category.

Reactive gRPC?

The last question we should ask is: "What happens when gRPC goes reactive?" To answer this question, I recommend the book Hands-On Reactive Programming in Spring 5 by Oleh Dokuka and Igor Lozynskyi. Oleh Dokuka is one of the main contributors to the reactive gRPC project. In the book, there is a chapter comparing reactive gRPC vs. RSocket. And I quote: “With the only difference being that it supports the flow control with a higher granularity. Since gRPC is built on top of HTTP/2, the framework employs HTTP/2 flow control as the building block for providing a fine-grained backpressure control. Nevertheless, the flow control still relies on the sliding window size in bytes, so the backpressure control on the logical elements' level granularity is left uncovered.”

So basically, HTTP/2 cannot be “truely” reactive, even though with the reactive implementation, gRPC’s performance may improve a lot.

RSocket

Opinions expressed by DZone contributors are their own.

Related

  • HTTP for Inter-Service Communication?

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook