DEV Community

loading...

Fiber vs Echo (a developer point)

andreidascalu profile image Andrei Dascalu ・2 min read

Hi there!

I'm not a Go expert by any means but I grew into really enjoying the language, its opinionated ways, concurrency and sheer performance. While I do frown that it doesn't have the tools for better support of functional patterns, I appreciate the simplicity that makes it easy to get the job done with a reasonable amount of code.

That said, I also like things that make me more productive. Enter frameworks! And Go has so many of them. Minimalist, progressives, swiss-army-knives, you name it!

But until recently, I was (and still am, to a certain extent) a fan of the Echo framework. It's fast enough and has all the features that I look for in a framework:

  • no-nonsense router that supports grouping and middlewares
  • ton of middleware (some microservice must-haves like Prometheus, JWT and Jaeger)
  • a decent logger that defaults to JSON
  • easy way to control CORS (for those situations you're not using an external load balancer)

I was always aware that Echo (while fast, at least fast enough for my use cases) wasn't the top of the bunch in Go-world, but the shortcomings and annoyances I have with Gin and others made me overlook that. Also, all those built-in middlewares are awesome - I can't emphasise enough how important it is to have these to get things rolling (particularly Prometheus and JWT).

Yet recently I gave Fiber a shot and boy, was I impressed! Just by switching to it (surprisingly easy, just a couple of methods to replace, handlers, etc) my API response times lowered by roughly 40%. It's not all rosy though as:

  • Fiber's logger doesn't do JSON, not by configuration at least. I can provide a pattern for it, but I ended up using my own middleware based on zerolog (it's also a bit faster than the built in logger)
  • Fiber doesn't have as many middlewares available. It's a bit annoying to maintain a list of add-ons that belong to third parties, which may go away at any time. I miss Prometheus & Jaeger, for one.
  • Fiber's autorecovery goes through the built-in logger which, as mentioned, doesn't do JSON. It's annoying as hell, when you're using external log aggregators, to have a message out of the blue break the serenity of your ingest patterns.
  • it's not as easy to hook into an extend with customizations. I guess performance comes with a price as Fiber also has its quirks, mostly related to its zero allocations mantra.

I guess good things come with a price, but I'm more than happy to keep Fiber close!

Discussion (0)

pic
Editor guide