# Scaling Challenge Leaderboards for Millions of Athletes

DevFeed: [Scaling Challenge Leaderboards for Millions of Athletes](<https://devfeed.tech/articles/scaling-challenge-leaderboards-for-millions-of-athletes-26576.md>)

Original publisher: [Read original article](<https://medium.com/strava-engineering/scaling-challenge-leaderboards-for-millions-of-athletes-9ab09ef01381?source=rss----89d4108ce2a3---4>)

Author: Mike Kasberg

Published: 2024-01-18T17:01:41Z

Content type: article

Language: en

Sources: [Strava Engineering](<https://devfeed.tech/sources/strava-engineering.md>)

Topics: [it modernization](<https://devfeed.tech/topics/it-modernization.md>), [legacy systems](<https://devfeed.tech/topics/legacy-systems.md>), [Sports](<https://devfeed.tech/topics/sports.md>)

Tags: [challenge](<https://devfeed.tech/tags/challenge.md>), [leaderboards](<https://devfeed.tech/tags/leaderboards.md>), [programming](<https://devfeed.tech/tags/programming.md>), [relational-databases](<https://devfeed.tech/tags/relational-databases.md>), [scalability](<https://devfeed.tech/tags/scalability.md>), [scaling](<https://devfeed.tech/tags/scaling.md>), [sql](<https://devfeed.tech/tags/sql.md>), [system-design-concepts](<https://devfeed.tech/tags/system-design-concepts.md>)

## AI overview

Strava replaced its Redis based challenge leaderboards after participation reached 1.2 million athletes and inefficient access patterns threatened reliability. In particular, calling HGETALL on a hash containing every challenge member required work proportional to leaderboard size; bursts of challenge completions could overload Redis and disrupt other queries. The new Gauntlet system uses MySQL for durable storage and indexed leaderboard operations. Because counting all scores above an athlete's score still scales linearly, it caches scores at spaced ranks, finds the nearest better cached score, then counts only the bounded number of entries between that point and the athlete's score. Batched updates maintain these cached ranks, with occasional rebalancing. Strava dark launched writes before exposing leaderboards, then tested the interface internally before enabling athlete facing challenges. The article reports a country leaderboard load dropping from over 40 seconds to under 250 ms in one comparison, with average response time more than ten times faster. The excerpt does not provide details beyond the described design and results.

## Source excerpt

Strava challenges offer a fun way for athletes to compete against themselves and others! Back in 2020, our legacy challenge leaderboard system was running into bottlenecks and scalability problems on a regular basis, and we often found ourselves putting out fires to keep the system stable. In late 2020 and early 2021, I worked on a project to replace the old leaderboard system with a new one that could handle a much larger number of athletes competing in challenges. This blog post is about that project. I drafted most of this post when the project wrapped up in 2021, but didn't get it published before I went on paternity leave -- and then I forgot about it. I think the project was interesting and worth sharing, so I'm glad I finally remembered my draft (three years later 🫣) and found some time to put in the finishing touches and get it published! Enjoy! In January 2020, Strava's monthly 5K running challenge attracted more than half a million participants for the first time. This was a big milestone, doubling the participation from just a year earlier when we had only a little more than 250,000 participants in the January 2019 5K challenge. But we weren't done growing! Just 5 months later, our challenge participants doubled again and we broke 1 million participants in a monthly challenge for the first time with the May 2020 5K, where 1.2 million Strava athletes participated! In less than a year and a half, the number of athletes participating in Strava's monthly challenges had quadrupled. As you can imagine, the increase in challenge participation came with a significant increase in load on our systems. In particular, we were beginning to approach the limits of what our existing challenge leaderboard system could handle. If the number of challenge athletes participating in our monthly challenges were to double again, our challenge leaderboard system wouldn't handle it well. We needed to do something to improve the way our leaderboard system scaled with more challenge