[HELP] - Alternatives to Async requests due to rate limits

I’m trying to create a script which finds how many friends a part you are from any other user, using a depth-first-search algorithm. (It is the most efficient method I’m aware of at the moment)

But due to the fact it requires so many :GetFriendsAsync() requests, I’m getting many HTTP 429 (Too Many Requests) errors, which is slowing down my searches to be unreasonably long.

I don’t know how I could decrease the number of requests I’m doing per search without having to use a system which saves and occasionally updates friend data (using datastores), because I want it to be up to date.

I’ve implemented a server cache (which saves all async outputs on a list if its used later in the server) but it doesn’t really seem to help. Are there any HTTPS servers I could use that would be significantly faster? Or any way to batch my async requests? Because I am at a loss here.

Here is a part of my code for fetching friend data for reference;

local function GetPlayerFriendList(player_id)
	-- Check cache first
	if Friend_List_Cache[player_id] then
		return Friend_List_Cache[player_id]
	end

	local friendslist, err
	for attempt = 1, 3 do  -- Retry up to 3 times
		local success
		success, err = pcall(function() 
			friendslist = Players:GetFriendsAsync(player_id)
		end)
		if success then break end
		task.wait(attempt * 0.2)  -- Exponential backoff
	end

	if not friendslist then
		return nil, err
	end

	local friends = {}
	for item, _pageNo in iterPageItems(friendslist) do
		table.insert(friends, item)
	end

	-- Cache the result
	Friend_List_Cache[player_id] = friends
	return friends, nil
end

Like areyoufriendswithdavid.com?

That’s sort of what you will have to do. You need to have a database of who people are friends with, and maybe you could optimize it further by caching paths between frequent users.

Personally, I think this is more fit for an external server as it would be easier to manage the database and it could probably be larger than what Data Stores allow.

Yeah, that was the inspiration. If it turns out I’ll need a server for it I’ll probably give in, but I hope theres an alternative for it. Do you recommend any good hosting services for an external server?