REST vs Json-Rpc

Posted by Riomhaire Research on Saturday, October 21, 2017

Introduction

We in Riomhaire have been using Googles Go-Lang for a year or so now and we love its simplicity and cleaness - especially in regards to concurrency. We have recently implemented two demo systems for authentication via JWT and bearer tokens. One system used Go and JSON-RPC called ‘LightAuth’; The other using Go and REST.

Before we start we are not pro-REST or pro-RPC and neither are we anti-REST or anti-RPC. Each has its strengths and weaknesses, and it depends on a number of factors for which each should be used for in a particular scenario. It depends on many factors: the domain, the company, the existing infrastructure and ways of doing things to name a few.

The Experiment

This short blog is about what we noticed after performance testing the two projects within the same cluster and using the same test equipment. We have an instance of each JSON-RPC and REST version of the Authenticate API running on each of the six nodes within the Raspberry PI cluster we called ‘Theign’ which is connected to a gigabit switch. The results after running jmeter are as follows:

JSON-RPC

RPC Call Samples Avg STD Dev Error % Throughput Avg Bytes
Authenticate 50000 120 19.82 0.0 137.53 465.0
Verify 1000000 11 10.58 0.0 2750.75 251.0
TOTAL 1050000 17 25.78 0.0 2887.05 261.19

REST

RPC Call Samples Avg STD Dev Error % Throughput Avg Bytes
Authenticate 50000 119 21.05 0.0 139.01 424.0
Verify 1000000 11 10.22 0.0 2780.49 204.0
TOTAL 1050000 16 25.51 0.0 2918.38 214.0

Conclusion

There is a marginal performance difference between JSON-RPC and REST in the latters favour. This is mainly due to the ‘wordiness’ in the payloads of the JSON-RPC over its REST alternative as can be seen from the ‘avg’ bytes size - some 47 bytes. There is little variation in the individual call times as seen by the ‘avg’ and ‘STD Dev’ fields, so the calls themselves are pretty similar. For JSON-RPC some fore thought for an implementator needs to be done regarding the data structures to minimize the overhead of the JSON-RPC protocol.