DEV Community

Cover image for Brazilian "Rinha de Backend" challenge #1 - How To Fail
Lucas Weis Polesello
Lucas Weis Polesello

Posted on • Updated on

Brazilian "Rinha de Backend" challenge #1 - How To Fail

Father's Day at Brazil I received a message from a friend of mine talking about a tech challenge. A quite simple one: Write a API, that has at least 2 replicas, a load balancer and a database, so someone can try to tear it down with a Stress Test.

I though to myself. That is the next level of CRUD developer, so let's try it out.

The initial idea, by which the commit history made it clear I mistakenly called it "finished", was:

I knew this configuration was far away from aiming for any TOP 20 but I had confidence it wouldn't fail that much.

After my first NGINX configuration and Docker-Compose YAML created I boldly applied to the challenge.

Sitting at the top of my confidence and not-so worried about it I noticed the competitors publishing screenshots of their own benchmarks.I had realized how much I had underestimated it.

Gatling installed locally, lets give it a shot. To be fair...How bad can my application perform, right?

Fantastical failure

Lets not talk about how disappointed I got but how worthy it was to try the tool locally.

So, what was happening?

Besides a bunch of premature closed connections, no healthy upstream, 60000ms timeouts, there was no way I my application was bottlenecking that much...

I tried a lot of crazy stuff:

I was very confident I could get at least into 20% of success...Come on...

api errors after running gatling

I had to do something. I was totally blind and didn't knew where to start.

After running a watch "docker stats" I was able to finally get a grasp on it. My database was being hammered.

database bottlenecking locally

Time to take it seriously. More than competing with my fellow colleagues I wanted to compete with myself. I knew I could do better. It was a long time I got so excited about something I knew nothing about.

In that late Sunday I already knew Monday would be one of those hyperfocus ADHD days.

Next chapter

Top comments (1)

Collapse
 
luiscarlosb3 profile image
Luis Carlos Galvão de Oliveira

I participated to "rinha de backend" too and all my initial five tests failed, ater 1k request, I'm getting only errors. The best part of "rinha" was talk with another devs and get new insights about new solutions.

Great article, waiting for part two.