惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

爱范儿
爱范儿
H
Help Net Security
Jina AI
Jina AI
T
The Blog of Author Tim Ferriss
宝玉的分享
宝玉的分享
博客园 - 叶小钗
Y
Y Combinator Blog
罗磊的独立博客
大猫的无限游戏
大猫的无限游戏
WordPress大学
WordPress大学
C
Check Point Blog
Recent Announcements
Recent Announcements
IT之家
IT之家
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
美团技术团队
云风的 BLOG
云风的 BLOG
雷峰网
雷峰网
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
SegmentFault 最新的问题
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
B
Blog

Dizzy zone

Pangolin Private Resources With Domain Https About Redis is fast - I'll cache in Postgres n8n and large files Malicious Node install script on Google search Wrapping Go errors with caller info BLAKE2b performance on Apple Silicon State of my Homelab 2025 My homelabs power consumption On Umami ML for related posts on Hugo Probabilistic Early Expiration in Go SQLC & dynamic queries Enums in Go Streaming Netdata metrics from TrueNAS SCALE SQL string constant gotcha Moving from Jenkins to Drone My new server: MSI Cubi 3 Silent My thoughts on Ansible® Profiling gin with pprof How I host this blog, CI and tooling Refactoring Go switch statements OAuth with Gin and Goth I made my own commenting server. Here's why. Why I hate OpenApi(swagger) IDE for GO Jenkins on raspberry pi 3 How I started my professional career Go's defer statement Self-hosted disqus alternative for 5$ a month
Kestrel vs Gin vs Iris vs Express vs Fasthttp on EC2 nano
Vik · 2018-01-24 · via Dizzy zone

Since this post got quite a bit of traction, I decided to update it by rerunning all the benchmarks as well as adding GO’s fasthttp and Node’s express to the comparison.

I came across this blog post on ayende.com. Here Oren Eini tries to see how far he could push a simple ipify style of api on an EC2 by running a synthetic benchmark. He hosts the http server on a T2.nano instance and then uses wrk to benchmark it from a T2.small instance. After reading this, I thought to myself - surely .NET cannot be quicker than GO. I decided to try and make a similar effort and get a little bit of competition going between a .NET implementation with, hopefully, a representative version of Oren’s .NET server made with GO. For GO - I went with 3 candidates gin, fasthttp and iris. I also benchmark Node’s Express. All the tests were performed on the same EC2 instance, with production/release configurations, so variance should be low. I also use the same parameters for wrk as Oren. This is as close as I could get to apples to apples type of comparison.

Kestrel setup

For Kestrel I used the same code that Oren did. I did manage to get to 35000 requests/sec.

The results were as follows:

Kestrel results.

And here’s a snap of TOP somewhere mid run:

Snap of Kestrel's top.

Iris setup

For Iris I went with the code that Gerasimos from the comments below suggested.

Results:

Iris results.

Top:

Snap of Iris's top.

Gin setup

For Gin, I used the built in ClientIP() which does a few more things than just looking at the X-Forwarded-For header. Here’s the code I ended up with.

Results:

Gin results.

Top:

Snap of Gins's top.

FastHttp setup

This is the server I went with for fasthttp.

Results:

Fasthttp results.

Top:

Snap of fasthttp's top.

Express setup

To be fair, I knew Express would not perform too well here but I added it nonetheless. Here’s the Express code.

Results:

Express results.

Top:

Express results.

Conclusion

Server Requests/sec Memory MB
Kestrel 35404 131.0
Iris 21868 26.4
Gin 20856 21.0
FastHttp 37361 14.1
Express 7902 76.3

From this, I drew the following conclusions:

  • I’m pleasantly surpised by Kestrels performance(I mostly code Go).
  • Kestrel(most likely .NET, not Kestrel itself) is way harder on the memory than GO’s equivalents.
  • Nano instance can be quite good at handling not very intensive tasks.
  • Fasthttp outperforms kKstrel, but not by a large margin.
  • Fasthttp uses only 1/10th of Kestrels memory.
  • Gin and Iris are not as fast as Kestrel, which surprised me.
  • Express is nowhere close, as expected.

I also ran the tests on my Mac Pro - every server comfortably went into the 100 000 requests/second. Go seemed to do a tiny bit better than .NET on this one though. Express only managed 16000 requests/s.

Take note that I’m not an expert in benchmarking by any means. Let me know if I made any mistakes in the comments below!