question

Brent Batas (Lisk) avatar image
Brent Batas (Lisk) asked

GetPlayersInSegment with more than 10,000 players?

I'm looking at the GetPlayersInSegment API (

https://api.playfab.com/documentation/server/method/GetPlayersInSegment) and I'm wondering if it's possible to run it for more than 10,000 players.

Use case:

I want to iterate through all players to initialize new player statistics when a new "ranked season" happens. Specifically, I want to initialize their Elo to be based on some formula based on their past season's Elo.

Currently, we have about 7500 players, so GetPlayersInSegment would work, but I anticipate we'll have more than 10,000 players before long.

apis
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

·
brendan avatar image
brendan answered

How to approach this is really going to depend upon your goals. What you should not do is write a tool which gets the list of players and makes calls against them as fast as you can. It needs to be throttled to no more than 20 or so API calls per second, so that you don't wind up getting throttled on our side. However, you may want to just use a Scheduled Task for this, since that's specifically what they do - perform some action, like a Cloud Script, on a segment of users.

If you do want to get all the players in the Segment, you can do that using the GetPlayersInSegment API call, in batches of 10,000. Just use the ContinuationToken to get the next batch of 10,000, until you reach the end.

Now, that all assumed you're fine with the process taking non-zero time, since it's not possible to process all players in a segment at once. The alternative would be to reset the statistics, either on a schedule or via the Admin API, so that they're automatically wiped for all players. And still another option would be to have multiple statistics, and simply swap which one you're using when you change seasons.

6 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.

Brent Batas (Lisk) avatar image Brent Batas (Lisk) commented ·

Thanks for the detailed answer. I misunderstood the 10,000 limit - happy to hear that you can use the continuation token in the manner you described.

It would be fine if this took even a full day or two to run this, so time isn't too much of a concern. We aren't sure yet when seasons would change, so I prefer to run it manually rather than on a set schedule, at least for now.

0 Likes 0 ·
brendan avatar image brendan Brent Batas (Lisk) commented ·

Got it. One thing to know then, is that Scheduled Tasks don't have to run automatically on a schedule. They can also be set up to run manually, so that you can kick them off when you need to.

1 Like 1 ·
Brent Batas (Lisk) avatar image Brent Batas (Lisk) brendan commented ·

Useful to know, thanks. I will most likely be doing things via GetPlayersInSegment(), but out of curiosity, how would I do it via Schedule Tasks? In the Actions menu dropdown, the closest thing I see is "Increment player statistic" but that doesn't seem quite the same as resetting/wiping them.

0 Likes 0 ·
Show more comments
Show more comments

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.