question

Dean Loades avatar image
Dean Loades asked

GetPlayersInSegment is really slow suddenly. What has changed?

I have a Cloudscript scheduled task that queries GetPlayersInSegment a couple of times. This used to run without a problem but has recently started timing out at 7secs.

Has something changed that would make this function much slower? All I want is to query the total number of players in the segment,is there a more efficient way to do that yet? (Or better yet, query the total players in a leaderboard as that is what I am ultimately after)

CloudScript
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

GetPlayersInSegment is going to take a variable amount of time depending on a few factors, but in particular, the number of players you have and the frequency with which it is called are major factors, so I can't really recommend using it in a Cloud Script that's called more than rarely. In particular, using it in a client-triggered Cloud Script is specifically something you should never do. The issue is that calling that triggers re-evaluation of the segment. So if clients could trigger it, that would mean frequent (and even overlapping) re-evaluations, which would slow it down immensely (and any simultaneous requests would be rejected). We'll be providing for longer-running scripts post-GDC, so what I'd recommend is when we enable that, use it in a once-per-hour scheduled task to update a Title Data value that you use to represent the total number of players.

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

Dean Loades avatar image Dean Loades commented ·

Thanks for the info, @Brendan.

It isn't client triggered, it's running as a scheduled task every five minutes. I'll try decrease the frequency and see if that helps. It was all working until recently, so maybe the issues you guys have been having recently has pushed it over the edge.

Has there been any progress on being able to get the total number of players on a leaderboard? What I am doing is actually a huge hack just to get / approximate that value. So if I could do that it would be so much easier for me (and your servers probably...)

0 Likes 0 ·
brendan avatar image brendan Dean Loades commented ·

Thanks, I wasn't assuming you were using it from a client call, but it's best to call that out, so that everyone's aware.

As to adding the total number of players to the leaderboard, it's in our backlog, but prioritization is a combination of our own strategic goals plus input from developers. If a lot of developers are asking for a feature, that helps to move it up in our prioritization. In this case, we haven't had many requests for this, so other things that more folks are asking for are ahead of it on the backlog.

0 Likes 0 ·
Dean Loades avatar image Dean Loades brendan commented ·

Ok. In that case I will attempt the next hack. Submitting a bad score that will hopefully find the bottom of the leaderboard and use his rank as the total number of players! *evil laughter*

0 Likes 0 ·

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.