I’ve been receiving reports from my players that they are unable to earn money from as long as 1 week ago. I investigated it and after a couple days, I managed to pinpoint it to GamePassService.
As seen in the images above, GamePassService GET requests is for some reason taking ~2,700,000ms (45 minutes) to get through, and thousands of it is occurring. To add on, HttpCache is increasing rapidly, along with LuaHeap.
This causes a script, named ServerBasic, which handles the earning of money to stop working. Other scripts, such as the one that handles DataStores, still work.
This started happening after I added new features (crates and hats) in the game.
Originally, I was only looking at LuaHeap. I was very confused why LuaHeap was increasing only 6+ hours after a server starts, because <6h old servers have LuaHeap memory usage of <4mb. I tried to optimise the code in ServerBasic to the fullest extent by reducing memory usage as much as possible, but old servers still kept breaking. Moreover, I read each and every new line I added and removed from the new update I released, but none of them affect memory at all. Then, I realised that memory usage from ServerBasic may not be the issue, so I took a look at different tabs in the developer console and discovered that GamePassService GET requests were taking over 45 minutes to complete.
I looked through anything had to do with gamepasses in ServerBasic, and I discovered that I was using UserOwnsGamePassAsync every frame, multiplied by the amount of players.
Explanation here:
I fixed it by adding a cache system for whenever I check gamepass ownership. I tested it thoroughly and released the fix. However, 6+ hour old servers where still breaking. As mentioned in the linked post above, I looked through anything that had to do with gamepasses or MarketPlaceService in every script in the game, but all of them do the same thing- use a function from a module which handles the caching of gamepass ownership checks. I then double checked what I added/removed from the previous version of the game, but I didn’t find anything useful.
I’m at a loss for what to do. This seems to be a bug in my implementation but I’ve tried everything I could to fix this issue. Could someone look into this? I’ll be watching out for broken servers so I can screenshot all the debug information if needed.