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 Fiber and Express
- Config of test stand
- Benchmark results
- The choice is obvious
- Is it worth to switch to Go?
- Do you like Fiber?
- Your assistance to project
πΏ 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.
- Express β extremely 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.
β Fiber handled 6,162,556 resp./sec with an average latency of 2.0 ms.
β 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.
β Fiber handled 11,846 resp./sec with an average latency of 42.8 ms.
β 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.
β Fiber handled 19,664 resp./sec with an average latency of 25.7 ms.
β 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.
β Fiber handled 368,647 resp./sec with an average latency of 0.7 ms.
β 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.
β Fiber handled 1,146,667 resp./sec with an average latency of 0.4 ms.
β 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
Your assistance to project π
- Add a GitHub Star to project.
- Tweet about Fiber on your Twitter.
- 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 articles (like this) on this blog, then post a comment below and subscribe to me. Thanks! π»
βοΈ You can support me on Boosty, both on a permanent and on a one-time basis. All proceeds from this way will go to support my OSS projects and will energize me to create new products and articles for the community.
And of course, you can help me make developers' lives even better! Just connect to one of my projects as a contributor. It's easy!
My main projects that need your help (and stars) π
- π₯ gowebly: A next-generation CLI tool that makes it easy to create amazing web applications with Go on the backend, using htmx, hyperscript or Alpine.js and the most popular CSS frameworks on the frontend.
- β¨ create-go-app: Create a new production-ready project with Go backend, frontend and deploy automation by running one CLI command.
Top comments (20)
I'd like to say this great article is rather outdated imo.
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.
@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
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! π
What about the single thread part?
Please read Project Information Framework Tests Overview for more understand, how TechEmpower does its benchmarks for each web framework.
Seems like they used 14core(28threads) cpu to prove us that multithreading is the King ;)
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).
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!
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
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?
You can see all frameworks and results here, including Express. I will add some screenshots, might be more convenient! π
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.
Op appears evasive on therding question. It is possible he did not thread node but did on Go Lang. Likely some sort of marketing.
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.
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 π
I'll take a look at it this weekend and do some more bench marking myself against gin.
On the other hands, gnet is very fast in plaintext, could be deserve attention for specific use case.
Here is another benchmark
github.com/the-benchmarker/web-fra...
fasthttp does really well while fiber is average
I might be the fiber implementation
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...