Climbing the green mountain

How to defeat the evil green mountain

what is the green mountain?

A picture is worth a thousand words. The green mountain is the response time graph from huboard. From time to time the GitHub api hangs and takes a really long time to return data which causes huge spikes in the response time for huboard. I recently release some fixes to huboard to help mitigate this problem.

Ways to fix the green mountain

First and easiest method is to add a retry mechanism in your api library and set a low timeout for your requests. Since huboard uses the api library ghee, which I happen to know very well since I wrote it. It was really easy.

Ghee uses faraday it was very easy to configure ghee to retry requests it was also quite easy to add some middleware into faraday to set the timeout to 1 second

The second way is to cache responses from the github api. This turned out to be a bit of a technical challenge. The GitHub has support for making conditional requests the send an e-tag header with every request made. The twist is that you need to return that e-tag in your next api call to see if anything has changed. It gets complicated when you make several api requests within a single request you have to cache the entire request and then pull out the cached request to get the last e-tag and then send a request to GitHub to see if anything has changed. Thankfully it wasn’t too hard to implement with ghee. Yeah for the power of middleware

So far so good, there are still spikes but you will notice that the legend on the left side is much lower, going from spikes up to 3 seconds to every request being under a second! Thats a pretty big win for me and the users of course.

Happy huboarding!!!

The 30 Second Standup