2024-12-01
Aaron and I fixed an issue with WPD today, I made the PR and he gave it a sanity check.

Issue 22 - Concurrent requests caused the cache (aiohttp-client-cache), which was using sqlite, to lock and fail.

This is a pretty big bottleneck, and was reported as early as June - Exception thrown when executing multiple parallel requests. As more and more users started using the main instance, database errors became a lot more frequent, second to ratelimits.

The solution? Switching to Redis. aiohttp-client-cache can cache to Redis instead of /tmp or an sqlite database. I setup an env file, with type validation - that took a bit of time. The cache setup itself was easy, a few lines and an if-else to decide between file or redis-based caching.

The associated pull request also adds some other stuff, namely:

late night programming again, I made a few silly mistakes that Aaron caught and fixed, love how seriously he takes testing lol - something to learn from him.