Is Echo is more efficient than Gin? #2143
-
According to Echo README, Echo is faster and more efficient than Gin as of 2020. However, Accord got Gin homepage, Gin is faster and more efficient as of 2022. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 9 replies
-
You should take this with grain of salt. Every library claims that it is the best. Looking from Gin repo its seems that their benchmarks are also quite old (from May 2020 https://github.com/gin-gonic/gin/blob/master/BENCHMARKS.md) NB: these benchmarks hardly ever include middlewares and does not represent real world use cases. I have run same tests with latest Echo and Gin and result is https://github.com/aldas/web-framework-benchmark/actions/runs/2017913749 or from my own machine:
The most notable difference between Gin and Echo is how handler functions look like. func mainEcho() {
e := echo.New()
e.GET("/test", func(c echo.Context) error {
return c.String(http.StatusOK, "OK")
})
}
func mainGin() {
g := gin.New()
g.GET("/test", func(c *gin.Context) {
c.String(http.StatusOK, "OK")
})
} |
Beta Was this translation helpful? Give feedback.
-
Thank you for actually running the benchmark. It is quite helpful. |
Beta Was this translation helpful? Give feedback.
-
Thank you for the advice. |
Beta Was this translation helpful? Give feedback.
-
@aldas thank you for the clear explanation. Few weeks ago i am wondering if gin would be better choice for my next projects since people said it is faster. After reading your explanation, i think i will stick with echo since echo is i think better structured and has neat documentation. The only downside is majority of example in SOF is using gin or native (no framework) |
Beta Was this translation helpful? Give feedback.
-
Thank you for clearly addressing the performance matter. I had the same question. But apart from performance, for me, project structure is very important factor in the choice of a good go library. Just from the looks of it, echo seems to me to be better aligned with golang conventions/guidelines. One step deeper in gin, I see that I used echo for the first time ~5 years ago. Early on, one day I noticed that beego has way more stars on github compared to echo. (gin had almost equal or maybe even less stars than echo at that time). I put some serious time to see how beego works, so I can make a switch if it's necessary. But all I saw then was redundant and bloat code. Today I was put off by gin for the same reasons. They're in my mind examples of 'golang done wrong'. The logic in a large web app can get quite messy and intertwined. Having to go through 20+ similarly named framework methods that do ~similar things will just add to the headache. I extended |
Beta Was this translation helpful? Give feedback.
-
Thanks for the excellent explanations, I got a new question related to framework efficiency. |
Beta Was this translation helpful? Give feedback.
You should take this with grain of salt. Every library claims that it is the best. Looking from Gin repo its seems that their benchmarks are also quite old (from May 2020 https://github.com/gin-gonic/gin/blob/master/BENCHMARKS.md)
NB: these benchmarks hardly ever include middlewares and does not represent real world use cases.
I have run same tests with latest Echo and Gin and result is https://github.com/aldas/web-framework-benchmark/actions/runs/2017913749
or from my own machine: