I made a logical mistake in my code, but that's okay. Making mistakes is entirely normal. In fact, every attempt involves a few failures, and my error is a straightforward logical resolution in a problem that involves a leaky bucket algorithm with Redis.
Redis must have a bucket to count how many tokens we have, and only API requests should reduce our tokens. However, we can only call the API if we have enough tokens to spend in our bucket. There are two errors that I made here. First, my Redis calls are depleting the buckets too, and secondly, all my calls are going to the API first, and only after that, the tokens are reduced. All these implementation ideas come from me, but when implemented, things just go wrong.
Practical learning is not easy; you're going to be wrong most of the time. However, every mistake you solve contributes to solid knowledge. If you want to be one of the best, you should practice more.
Top comments (0)