Failure Friday – Tore Friskopp https://torefx.com Fri, 08 Nov 2024 09:24:49 +0000 en-US hourly 1 https://wordpress.org/?v=4.8.3 https://torefx.com/wp-content/uploads/sites/2884/2019/07/tore-150x150.png Failure Friday – Tore Friskopp https://torefx.com 32 32 Failure Friday #1- How we maxed out a credit by not capping API usage https://torefx.com/failure-friday/failure-friday-1-how-we-maxed-out-a-credit-by-not-capping-api-usage/ Fri, 15 Mar 2024 08:42:02 +0000 https://torefx.com/?p=27 It’s time for a Failure Friday, one of my many F-ups! πŸ™ˆ This time a story about how we maxed out a credit card πŸ€‘ by not capping the google API usage.

This happened while creating Attentionflow.ai, a service that generates game previews and reviews using sport statistics and event data. πŸˆπŸ“Š

We had a bright idea πŸ’‘Let’s add weather data! Did the players battle it out in a downpour β˜” or bask in the sunshine? β˜€οΈ

To get that info, we combined three APIs;

  • A sports API 🏟️
  • Google’s Geolocation API πŸ“
  • A free weather API 🌀️

The first API gave us the date and venue. Google’s Geolocation API gave us the latitude and longitude of that location which was needed as input for the weather API, which gave us the weather data.

And – boom πŸ’₯ – we had weather forecasts in all our reports!

And very soon we had a maxed out credit card. πŸ’³πŸ˜²

The mistakes: Our code had checked the location of every stadium in the world every 5 minutes, and also checked, and re-checked, and re-checked again the latitude and longitude of each of those locations. 🌍⏱️

Google had, dutifully, charged us for every. single. request. πŸ’Έ

Of course, we should have had endless cache on the data retrieved. Stadiums very seldom move to a new address. 🏟️➑️🚚 That was a fail number one.

However, those whoopsies can happen when you are trying to push out new features at a high pace. πŸš€

The real lesson learned, for me at least, was to always make sure you have a cap on API usage.

All in all, it cost us €1,000. Money that could have been better spent elsewhere. Literally anything else would have been better.

But at the time I was super happy we had not used the other credit card that had a 25K spend limit. πŸ˜…

The image above is not from our API usage, it’s from another insane growth.

]]>