Spring vs Vert.x vs Ktor vs Play Framework — The performance battle for a JVM Based API Gateway

LEON DE SILVA
3 min readDec 11, 2023

What are we trying to find?

The best performing JVM based framework to build an API Gateway.

Options

  • Spring cloud gateway
  • Vert.x (using reactive handler and a custom coroutines handler)
  • Ktor (running with netty server and CIO server)
  • Play Framework

How was the performance measured?

I built 6 applications based on the above options and variations of the options which has the capability of mapping and routing requests as an API gateway. Once the gateway receives a request it calls an underlying service according to the mapping. All applications were built on Java 21 and was running on a 4 core machine with a minimum heap of 256 MB and max heap of 1GB.

The tool wrk was used to benchmark the frameworks.
Initial load was a 30s warmup load, then a 30s load and finally a 60s load was put on each gateway to measure their performance.

Performance Test Results Summary

Startup Time Comparison of each framework

Total Requests Handled by Each Framework

Average Request per second for each Framework

CPU / Memory Consumption on the 60s Load

Max CPU consumption of each Framework

Conclusion

According to the performance tests vert.x was the best performing tool with less resource consumption. However we could also see that the 2nd best at handling more requests was the ktor. But its resource usage was high. But the 2nd best option with the lesser resource usage was spring cloud gateway.

References

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

LEON DE SILVA
LEON DE SILVA

Written by LEON DE SILVA

A Technologist, Engineer, Technical leader and Mentor

Responses (1)

Write a response