oscarmlage oscarmlage

Benchmarking with Siege

Written by oscarmlage on

If you ask me, I enjoy starting a new project, that fresh feeling during the first steps is usually becoming into a not-so-fresh thing with time. Life is so :).

In this concrete case, we’re talking about an API, I needed to research and make some benchmarking work to take the best decision possible for the stack. It needs to be as fast as we can, so we can take advantage of some tools like ab or siege to measure some kinds of requests and scenarios.

With those tools in one hand and some languages in the other (go-lang and php mainly, in fact, the benchmark would be go-lang using different libraries but I was curious about a compiled language vs the fastest interpreted one I know so I added some php code), let’s start having fun!.

All the tests were done in the same machine (macbook pro intel i9-9980hk) + docker containers + a dockerized mysql. The API endpoint makes a couple of SQL queries to return about 50 rows of data from a table, the response is being jsonized. There is no auth and no more logic steps, just an endpoint that makes a sql query and returns the data as json.

I’ve run siege 3 times in different scenarios and calculated the average:

And the result is quite interesting:

In this benchmark Go+Gorm+Echo is the clear winner, closely followed by Go+Gorm+Gin. About PHP, dunno if I did something wrong but there is a lot of difference between vanilla PHP (the results are kinda acceptable) and Laravel, still dunno why.

I had so much fun with this “exercise”.