question

Stefan Todorov avatar image
Stefan Todorov asked

Optimizing Multiple Profile Fetch Requests in PlayFab

Hello PlayFab Community,

I'm currently working on a feature where I need to fetch PlayFab profiles for multiple users. My current implementation involves making asynchronous calls to GetPlayerProfileAsync for each user, utilizing Task.WhenAll for parallel processing. Here's a snippet of my implementation:

  var tasks = playersStatisticsData.Select(async entry =>
  {
      var profile = await PlayFabServerAPI.GetPlayerProfileAsync(new GetPlayerProfileRequest()
      {
          PlayFabId = entry.PlayFabId,
          ProfileConstraints = new PlayerProfileViewConstraints()
          {
              ShowAvatarUrl = true,
              ShowDisplayName = true
          }
      });
      entry.Profile = profile.Result?.PlayerProfile;
      entry.DisplayName = profile.Result?.PlayerProfile.DisplayName ?? entry.PlayFabId;
      return entry;
  }).ToList();
  await Task.WhenAll(tasks);

Does PlayFab support batch processing for profile retrieval, and if so, what is the recommended approach?

If batch processing isn't supported, what are the suggested strategies to optimize and manage multiple GetPlayerProfileAsync calls to ensure performance and avoid potential rate-limiting issues?

Player Data
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

·
Infer Wang avatar image
Infer Wang answered

One possible way is creating one segment that contains the players and export players in segment Tutorial to export players in a Segment - PlayFab | Microsoft Learn.

10 |1200

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

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.