question

shinnosukehashimoto avatar image
shinnosukehashimoto asked

Maximum number of API requests

We would like to know the maximum number of API requests PlayFab can handle for each pricing plan. (I am currently on the free plan)

Our game is designed to have 3000 users logged in at the same time upon release.

To verify that PlayFab can handle that load, we created a console application and ran the API. (Source code is attached below).

And when we created the 10th player, we got the following exception

ElapsedTime: 3464ms, custom Id: user_0
ElapsedTime: 3709ms, custom Id: user_1
ElapsedTime: 3965ms, custom Id: user_2
ElapsedTime: 4204ms, custom Id: user_3
ElapsedTime: 4441ms, custom Id: user_4
ElapsedTime: 4681ms, custom Id: user_5
ElapsedTime: 4873ms, custom Id: user_6
ElapsedTime: 5103ms, custom Id: user_7
ElapsedTime: 5363ms, custom Id: user_8
ElapsedTime: 5578ms, custom Id: user_9
!!!Exception!!! ElapsedTime: 5718ms ,  custom Id: user_10
ExceptionMessage: The client has exceeded the maximum API request rate and is being throttled
 1-6493fffd-44a2a9445c0d8ea06295daad
using System.Diagnostics;
using Cysharp.Threading.Tasks;
using PlayFab;
using PlayFab.ClientModels;

namespace MyApp;

internal class Program
{
    static async UniTask Main(string[] args)
    {
        await Login(3000);
    }

    private static readonly string titleId = "xxxxx";

    public static async UniTask Login(int userNum)
    {
        var settings = new PlayFabApiSettings { TitleId = titleId };
        var sw = new Stopwatch();
        var customId = string.Empty;

        try
        {
            sw.Start();
            var instance = new PlayFabClientInstanceAPI(settings);

            for (var i = 0; i < userNum; i++)
            {
                customId = $"user_{i}";

                var result = await instance.LoginWithCustomIDAsync
                (
                    new LoginWithCustomIDRequest
                    {
                        CreateAccount = true,
                        CustomId = customId
                    }
                );

                if (result.Error is not null)
                {
                    throw new Exception(result.Error.GenerateErrorReport());
                }

                Console.WriteLine($"ElapsedTime: {sw.ElapsedMilliseconds}ms, custom Id: {customId}");
            }
        }
        catch (Exception e)
        {
            Console.WriteLine($"!!!Exception!!! ElapsedTime: {sw.ElapsedMilliseconds}ms ,  custom Id: {customId}");
            Console.WriteLine($"ExceptionMessage: {e.Message}, Stacktrace: {e.StackTrace}");
            sw.Stop();
        }
    }
}
apislimits
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

With a paid plan, PlayFab supports unlimited player accounts, so you don't have to worry about throttling due to high user volume. The problem here is that you were creating player account with the same device in a short period of time. For Login APIs like LoginWithCustomID, PlayFab has a request rate based on the IP. If you call the APIs with different outbound IPs, you will not be throttled.

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

shinnosukehashimoto avatar image shinnosukehashimoto commented ·

@Gosen Gao

I see, so you are saying that if 3000 people execute ClientAPI's LoginWithCustomID at the same time, no error will occur, right?

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao shinnosukehashimoto commented ·

Yes, no error will occur if 3000 people(different IPs) execute ClientAPI's LoginWithCustomID at the same time.

1 Like 1 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.