Tech Tonic

Articles on popular things like Node.js, Deno, Bun, etc.

Follow publication

Go — Gin vs Fiber vs Echo: How much performance difference is really there for a real-world use case?

Mayank C
Tech Tonic
Published in
4 min readMay 20, 2024

--

Let’s say we’re writing a new web application in Go. There are three popular frameworks to choose from:

  • Gin
  • Fiber
  • Echo

Each one claims that they are the fastest (of course). But how much of the difference is really there? Especially for a ‘real-world’ case like:

  • Getting HTTP request
  • Decoding JSON request body and taking a parameter (email) out
  • Making Postgres database query
  • Return the user record in the HTTP response

Let’s find out how much performance benefits they bring over each other? Is it even worth considering them solely for performance reasons?

Test setup

All tests are executed on MacBook M2 with 16G RAM & 8+4 CPU cores. The software versions are:

  • Go version is 1.22.3
  • Gin framework version is 1.10.0
  • Fiber framework version is 2.52.4
  • Echo framework version is 4.12.0

The load tester is a modified version of Bombardier, that sends a random email in each HTTP request.

The Postgres database is preloaded with 100K user records:

# \d users
Table "public.users"
Column | Type | Collation | Nullable | Default
--------+------------------------+-----------+----------+---------
email | character varying(255) | | not null |
first | character varying(255) | | not null |
last | character varying(255) | | not null |
city | character varying(255) | | not null |
county | character varying(255) | | not null |
age | integer | | not null |
Indexes:
"users_pkey" PRIMARY KEY, btree (email)

# select count(*) from users;
count
-------
99999

# select * from users limit 1;
email | first | last | city | county | age
-----------------+----------------------+----------------------+----------------------+----------------------+-----
ongbj@clb1a.com | 2f63ac8f31590d716243 | aed71a8d1868ac6eb032 | 836ddca891d3c46e24fe | bd53f8e8da17cededead | 25

The application code is as follows. The db.go file is common. We’ve used Bun ORM for working with Postgres database.

Results

Each test of 100 & 300 concurrent connections is executed for 5M requests. The readings are collected for RPS, time taken, latencies, CPU, and memory usage.

The results in chart form are as follows:

Analysis

At a glance, there is a difference, but not as significant as we expected. The Fiber framework wins this battle by providing more performance at a lower cost (CPU and memory). However, the winning margin is quite negligible. Fiber offers 36k requests per second (RPS), while the other two offer approximately 34K. The median latency for Fiber is 2.8 milliseconds, while the other two offer around 3 milliseconds. Additionally, Fiber’s CPU and memory usage is lower, but not substantially different from the other two.

So, does it matter to choose a framework solely based on performance? Perhaps not.

Winner: Fiber

Thanks for reading this article!

--

--

Tech Tonic
Tech Tonic

Published in Tech Tonic

Articles on popular things like Node.js, Deno, Bun, etc.

Mayank C
Mayank C

Responses (1)

Write a response