I recently decided to compare 2 frameworks for building micro services, one of them is the popular Spring framework which recently launched the Web Flux module that allows you to write reactive MVC applications. It uses Reactor under the hood and can be deployed on light weight run times like Netty and Undertow. The other framework I chose was Vertx which promises to be a light weight framework to build micro services.
The focus of this post is on performance measured in terms of throughput and CPU utilization. For the comparison, my code ran on EC2 instances that connected to a Cassandra database hosted within our VPC which itself ran on EC2 instances. All instances were in the same region and availability zones and the load tests were done through Jmeter which was also executed from an EC2 instance in the same VPC. I used t2 instances for this exercise and ran several tests with the same configuration.
About the code: There was just 1 GET end point that looked up a record from a table in Cassandra. The Cassandra table also had just 2-3 records and the table itself was simple to have a primary key with which we were looking up.
About the Tests: I ran tests with 3 frameworks with the above functionality
Spring Web Flux
Both Spring MVC & Spring Web Flux performed nearly the same. At about 4000 requests per second I started getting errors and the error rates increased as I increased the threads to achieve about 5000 requests/second. Throughout the tests the CPU appeared to be pegged at around 100%
With Vertx however, I observed that I could go up to 6000 requests/second without getting any errors. The CPU continued to remain at 30-40%