question

bfg avatar image
bfg asked

Scheduled Task server.GetPlayersInSegment "InternalServerError"?

I have a scheduled task that runs a cloud script that queries against a player segment. It always seems to fail when the task runs automatically, but I can manually run the task and it works fine.

TitleID: 238B

SegmentID: 552CBFB069AD479B

The error I get is "InternalServerError"

1 comment
10 |1200

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

JayZuo avatar image JayZuo ♦ commented ·

I can reproduce your issue on my side. I've reported this to the related team to see what's the problem here.

0 Likes 0 ·

1 Answer

·
Andy avatar image
Andy answered

We were chatting about this bug earlier today. While we still need to determine exactly where the problem lies, I did take a look at how you were using the API.

It's an interesting solution to a raffle-like feature. Unfortunately, it won't scale to large numbers of users. While, right now, you only have to make one call to GetPlayersInSegment, when you have more players, you'd need to make more (because the call can only return so many players at a time). Eventually, you'd need to make more calls than you're allowed to in a single cloud script execution. That's when the solution completely breaks down.

Instead, consider using our leaderboards and prize tables. When a player "buys a ticket" or otherwise becomes eligible for the raffle, assign them a random score on the leaderboard. Then, at the end of the day or week, you can reset the leaderboard and use a prize table to assign a reward to the n highest scores.

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

bfg avatar image bfg commented ·

Hey Andy,

I'm happy to know I was able to find a bug and get the talks going on your end. PlayFab is an amazing service and I plan to use it for years to come.

Yeah, we exactly weren't sure on how we wanted to implement the raffle system, and nothing we came up with was truly scaleable. We originally thought of using the leaderboard, but in its current state, it does not serve for exactly what we want to do. We don't want to assign a reward to the n highest scores, we want to randomly pick someone and assign the reward to only that person. Is there a way that you can think of that would be a solution? I don't know of the number of people who have requested this feature, and I wouldn't be surprised if I was the only one, but I think a prize table option that randomly picks one person in the entire leaderboard would be a handy solution to a raffle system.

Also, if it helps with identifying the problem, I created a test cloud script function GetSegmentTest which only grabs the segment and spits out the results. I have that executing at the same time as the failing scheduled task and the past 15 runs succeeded.

0 Likes 0 ·
Andy avatar image Andy ♦♦ bfg commented ·

Glad to hear you're happy with the service overall!

For my leaderboard suggestion, I wasn't thinking you'd really use scores, just random numbers. Think of it like giving everyone a random ticket. Then, the highest ticket wins (or, if you like, the 153rd highest ticket wins).

0 Likes 0 ·
bfg avatar image bfg Andy ♦♦ commented ·

That is an interesting idea. I'll have to talk to my team about that. Our original thought was that the user could purchase/obtain tickets and we would pick from the pool of tickets.

Did that bug happen to be resolved? I set my scheduled task to run every hour and the entire night all the run iterations were able to complete.

0 Likes 0 ·
Show more comments
bfg avatar image bfg commented ·
@Andy

Any updates on the internal server error bug?

0 Likes 0 ·
Andy avatar image Andy ♦♦ bfg commented ·

This bug got delayed behind a re-architecture of our backend segmentation system. That's just about ready to roll out and should address the issue. I'd like to reiterate, though, that the solution we talked about earlier in this thread won't scale to larger numbers of players.

0 Likes 0 ·
Andy avatar image Andy ♦♦ Andy ♦♦ commented ·

After further discussion, we've decided this behavior is by design. GetPlayersInSegment can be a long-running call. That means it isn't suitable to be called from Cloud Script.

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.