question

astrakh avatar image
astrakh asked

Integration with external services to query all users online

I want to create an external service (bot) that can post a number of users online based on the last login timestamp. As an improvement, I want to associate with a user additional data (stats, scores, etc) and be able to query with the same bot.

What is the best way to implement it?

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

If you need this close to realtime, you could do this one of two ways:

1. Use the webhook feature to forward key events (login and stat updates) to your own server, which updates your external service.

2. Use an Action triggered by those events to run an Azure Function Cloud Script that makes calls into your service to update it with the latest info.

If you're specifically asking for advice on how to create the external service, there's a very wide range of options, but I'd probably go with Azure Redis as a data store, especially if you're going to be updating that data with high frequency. And as long as you're confident you'll have a reasonable player population, I wouldn't bother with any kind of pre-load or cached recovery mechanism in case it falls over - just let it use the latest events to populate the info on current players.

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

astrakh avatar image astrakh commented ·

I need it relatively close to real-time, a few minutes delay will work. And I'm asking here for advice specifically on the PlayFab integration, the external service architecture is clear.

The question is how to query the user data, e.g. I have 20k users, I need to order them by last login time desc, take top XXX and fetch the name/avatarUrl attributes?

0 Likes 0 ·
brendan avatar image brendan astrakh commented ·

User data does not generate events, so you would need to send that data separately to your external service. If possible, we would recommend moving that data to statistics, or even just custom events, so that you can have it all flow through the PlayStream system.

We do not provide for arbitrary query of user data, as that system is not designed for that, and trying to read 20K users in a single call could cause performance issues. You would have to read user data from each user sequentially, in a script. Since that would take a non-trivial amount of time, we would strongly recommend moving this logic to the PlayStream system.

0 Likes 0 ·
astrakh avatar image astrakh brendan commented ·

Thanks for clarifications, it sounds like I have to build a service and data storage separate from PlayFab to aggregate data I need.

0 Likes 0 ·
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.