Is Gorilla/Mux bad to use?

I don’t want to repeat my Jquery experience, keep learning in something that I think it’s useful and will make my life easier to find out after weeks of hard-working that it is useless and even harming my website by slowing it down. So should I use Gorilla/Mux for my URLs instead of net/http? will it affect my website performance/speed? can things done in Gorilla/mux be done in -vanilla- Golang net/http package?

The mux implementation is based on a for loop, and its performance is not as good as httprouter.

1 Like

Ok thanks, how can I achieve the URL mux give me with the HTTP router? like How is this mux URL page/{pagename}/{id} done with HTTP router?

/page/:name/:oid in httprouter, https://github.com/julienschmidt/httprouter#usage.

1 Like

I would start with the standard library’s default router, and play around with it,
and then move to gorrilla/mux if you need more fancy matching.
They are both solid, reliable, performant and widely used.

Mux is more than 100 times slower than httprouter, mux is implemented using for, and httprouter is implemented using radix.

“Mux is more than 100 times slower than httprouter”

What does this mean in microseconds?

I would stand by my earlier statement that both are fast enough, and that the contribution of the router to http latency in a real world app is insignificant compared to network and DB delays, template expansion, json serialisation etc.

And both are blinding fast compared to frameworks written in python, ruby, etc.

I agree that the router consumes a small proportion of time, but after the mux performance gap is 100 times, it may consume almost the same resources as writing logs(logrus、zap).

Performance test I read the data of other people, the difference between the two is 128 times. For example, the performance multiples of other routers in chi are the same as my own tests.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.