loading...
Cover image for Is switching from Express to Fiber worth it? 🤔

Is switching from Express to Fiber worth it? 🤔

koddr profile image Vic Shóstak Updated on ・5 min read

Introduction

Good news, everyone! 😉 We did it! Fiber version 1.8.43 scored awesome benchmark results! Now we hold a strong third place on TechEmpower as a full fledged Golang HTTP framework!

❗️ This post is not about if Fiber is faster than Express, this is obvious since Node.js is an interpreted language, while Golang is a compiled language.

☝️ We mainly focus on testing Fiber versus other Go frameworks with the following disciplines: plaintext, data updates, multiple queries, single query and of course, JSON serialization! 😎

Table of contents

🍿 A few words about Express and Fiber

First of all, me and all Fiber authors love Express so much and made a lot of projects with it! But, Fiber is different.

  • Expressextremely popular Node.js web framework. And still the best choice for JavaScript developers on backend.
  • Fiber — web framework, written in Golang with exactly the same API, like Expressjs. Focused on JavaScript developers and new gophers, who want to easily switch to Go on the backend.

⚙️ Config of test stand

  • CPU Intel Xeon Gold 5120 @2,20 GHz
  • MEM 32 GB
  • GO go1.13.6 linux/amd64
  • OS Linux
  • DISK Enterprise SSD
  • NET Dedicated Cisco 10-gigabit Ethernet switch

See Project Information Framework Tests Overview for more info.

🤖 Benchmark results

Plaintext

The Plaintext test is an exercise of the request-routing fundamentals only, designed to demonstrate the capacity of high-performance platforms in particular.

  • Requests will be sent using HTTP pipelining.
  • The response payload is still small, meaning good performance is still necessary in order to saturate the gigabit Ethernet of the test environment.

Plaintext

✅ Fiber handled 6,162,556 resp./sec with an average latency of 2.0 ms.

Plaintext

✅ Express handled 367,069 resp./sec with an average latency of 354.1 ms.

Data Updates

The Database Updates test is a variation of the Multiple database queries that exercises the ORM's persistence of objects and the database driver's performance at running UPDATE statements or similar.

The spirit of this test is to exercise a variable number of read-then-write style database operations.

Data Updates

✅ Fiber handled 11,846 resp./sec with an average latency of 42.8 ms.

Data Updates

✅ Express handled 2,066 resp./sec with an average latency of 390.44 ms.

Multiple Queries

The Multiple Database Queries test is a variation of Single Database Query test and also uses the World table. Multiple rows are fetched to more dramatically punish the database driver and connection pool.

At the highest queries-per-request tested (20), this test demonstrates all frameworks' convergence toward zero requests-per-second as database activity increases.

Multiple Queries

✅ Fiber handled 19,664 resp./sec with an average latency of 25.7 ms.

Multiple Queries

✅ Express handled 4,302 resp./sec with an average latency of 117.2 ms.

Single Query

The Single Database Query test exercises the framework's object-relational mapper (ORM), random number generator, database driver, and database connection pool.

Single Query

✅ Fiber handled 368,647 resp./sec with an average latency of 0.7 ms.

Single Query

✅ Express handled 57,880 resp./sec with an average latency of 4.4 ms.

JSON Serialization

The JSON Serialization test exercises the framework fundamentals including keep-alive support, request routing, request header parsing, object instantiation, JSON serialization, response header generation, and request count throughput.

JSON Serialization

✅ Fiber handled 1,146,667 resp./sec with an average latency of 0.4 ms.

JSON Serialization

✅ Express handled 244,847 resp./sec with an average latency of 1.1 ms.

⚠️ The choice is obvious

If you haven't tried running your web projects in Go, Fiber might be the right framework for you!

❓ Is it worth to switch to Go?

It really depends on the use case. But it might benefit, if you need more performance.

💬 Do you like Fiber? Tell about it!

Fiber authors are always listening to its users in issues and all over the Internet. Therefore, it would be great, if you could share your opinion or/and experience with Fiber to authors in GitHub repository!

[...] because it's only right way to create a fast, flexible and friendly Go web framework for any tasks, deadlines and developer skills!

— Fiber Authors

Do you like Fiber?

Your assistance to project 👍

  1. Add a GitHub Star to project.
  2. Tweet about Fiber on your Twitter.
  3. Help to translate README and API Docs to another language (at this moment, Fiber was translated to 10 languages).

Photo by

[Title] Sonic from the Google Pictures
[1] Ashley McNamara https://github.com/ashleymcnamara/gophers

P.S.

If you want more — write a comment below & follow me. Thx! 😘

Discussion

pic
Editor guide
Collapse
sirajulm profile image
Sirajul Muneer

Does Fiber achieve this performance with a single thread, like Express does? If not then Fibre is not qualified to be compared with Express yet.
Also you miss express from the test results entirely, which should not happen when you compare them.

Collapse
koddr profile image
Vic Shóstak Author

You can see on TechEmpower site all results, included Express: link was on top of article... but okay, I add some screenshots to article, no problem! 😉

Collapse
abdulmannan3 profile image
abdulmannan3

What about the single thread part?

Thread Thread
koddr profile image
Vic Shóstak Author

Please read Project Information Framework Tests Overview for more understand, how TechEmpower does its benchmarks for each web framework.

Collapse
fenny profile image
Fenny

@abdulmannan3 , both Fiber & Express used all cores in the benchmark, see source:
github.com/TechEmpower/FrameworkBe...
github.com/TechEmpower/FrameworkBe...

@Sirajul, you can filter the results by displaying Fiber & Express only:
techempower.com/benchmarks/#sectio...

I uploaded the comparison on our wiki: fiber.wiki/benchmarks

Collapse
alx77 profile image
Alexey Furmanov

Seems like they used 14core(28threads) cpu to prove us that multithreading is the King ;)

Collapse
skarthikdurai profile image
skarthikdurai

We are seriously considering to switch from Java(spring cloud) to some go Framework. Would you compare it with Spring cloud? we are looking features like Service discovery, orchestration etc and support to gRPC(important).

Collapse
fenny profile image
Fenny

Fiber does not have HTTP/2 support unless you use a reverse proxy like cloudflare, nginx, f5, incapsula etc. I don't have much experience with the Spring cloud framework, but I don't think making the switch is worth it if your application relies on gRPC. However, HTTP/2 is being worked on github.com/valyala/fasthttp/issues... and when this is ready, the gRPC protocol could follow!

Collapse
skarthikdurai profile image
skarthikdurai

Thank you. We are still running in Http 1.1 and not going to grpc for some time now.
However I'm looking for complete framework support for microservices architecture like service discovery, orchestration, tracing, health monitor as we are not using kubernate

Collapse
entrptaher profile image
Md. Abu Taher 👨‍💻

I don't see express in any of the screenshots but only in the text. 🤔 Am I missing something or the images are not loading properly?

Collapse
koddr profile image
Vic Shóstak Author

You can see all frameworks and results here, including Express. I will add some screenshots, might be more convenient! 😉

Collapse
entrptaher profile image
Md. Abu Taher 👨‍💻

I was reading from mobile and the link just doesn't load properly in mobile, so I just got disappointed.

Thanks for sharing anyway. Appreciate it. Will take a look from desktop.

Collapse
cekvenich profile image
cekvenich

Op appears evasive on therding question. It is possible he did not thread node but did on Go Lang. Likely some sort of marketing.

Collapse
josephsintum profile image
Joseph Sintum

Here is another benchmark
github.com/the-benchmarker/web-fra...

fasthttp does really well while fiber is average
I might be the fiber implementation

Collapse
fenny profile image
Fenny

Hi Joseph, we are aware of the results of those benchmarks. We had contact with the owner and he confirmed that those are invalid results and therefore it's not production-ready yet.

Rank 28 - 41 are all limited to the benchmarked machine, I suggest checking out a more stable benchmark project like TechEmpower techempower.com/benchmarks/#sectio...

Collapse
freedom profile image
Freedom

On the other hands, gnet is very fast in plaintext, could be deserve attention for specific use case.

Collapse
akayami profile image
Tomasz Rakowski

How about you compare yourself to gin ? Doing a speed comparaison to a node framework is cheap. Any golang framework should beat any js framework unless the golang dev is particularly incompetent.

Collapse
koddr profile image
Vic Shóstak Author

Hi Tomasz, as you can see in the benchmarks we do compare Fiber with all web frameworks in any language (including gin). Since Fiber is heavily based on the Express API, I think it does no harm to include the results. Regarding the overwhelming results, it has nothing to do with Express but rather with Nodejs.

You can filter specific frameworks in the benchmark results, here I only enabled Fiber & Gin here 👍

Collapse
akayami profile image
Tomasz Rakowski

I'll take a look at it this weekend and do some more bench marking myself against gin.