question

thomasp avatar image
thomasp asked

Rules, CloudScript and External Service communication issues

Hello,

We are currently encountering some trouble achieving our objectives. Could you please provide us some insights on how to solve our issue ?

———————————

Objective :

- From a cloud script, we want to call an external API.

Setup :

- Using Rules system, we trigger a custom cloud script that is doing an http call to our external service.

- From Unity, client call PlayFab in order to update it’s email

- PlayFab trigger the rule and launch our cloud script

Problem :

- CloudScript stop execution after 1 sec, even is we are doing a non blocking process

———————————

We are a bit concerned by this issue as we :

- Don’t want to rely on the client making this call

- Will need to do more of this kind of interaction in the future (calls to external services triggered by rules / scheduled tasks)

- Cannot revert the process and make the external endpoint update user’s email due to PlayFab number of call per IP limitation (client API can only be called by the actual client, otherwise they will be rate limited).

Thanks for your valuable help.

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.

Sarah Zhang avatar image Sarah Zhang commented ·

The limit of CloudScript execution time is 10 seconds. 1 second won’t exceed the limit. Did it return any error? If it did, could you please provide the error messages?

0 Likes 0 ·
Francois Boucher-Genesse avatar image
Francois Boucher-Genesse answered

No worries for the delay @Sarah Zhang, I understand it's the holidays. I'm doing a follow-up in this forum as I would imagine this is a critical issue for other developers as well.

Going to a premium plan means paying 24k / year, which is a steep increase from the 1.2k / year most indies will look at when wanting to work with playfab. Naturally I would like to make sure there are no other solutions first, especially since this seems like such a basic need.

A summary of our objectives:

  • manage some tasks with our custom backend server, as playfab's cloudscripts are quite limited in nature. This means a communication between playfab and the custom server.
  • limit the number of calls the client makes (we don't want to make a call to playfab, then to our custom server if unnecessary)
  • leverage playfab's authentication system to communicate with our custom server.
  • leverage playfab's automation system to trigger tasks with our custom server

Potential solutions:

  • We route most client's calls to our custom servers, which then communicates with playfab through the server API. It seems like authentication could be done with the client's session ticket (please confirm). This method doesn't work for calls that are only available to the client, such as AddOrUpdateContactEmail, so we still sometimes end up with two calls from the client. This also doesn't leverage playfab's automation system.
  • Use Azure Functions instead of cloud scripts? Is there still a 1 second limit if we call an azure function instead from a triggered action? If the same limit applies, can functions do an http call without waiting for the answer, allowing us to be under 1s (still not ideal as we'd like to know the result of that call)?

Are these solutions valid, and am I missing another alternative?

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.

Sarah Zhang avatar image Sarah Zhang commented ·

@Francois Boucher-Genesse

Thanks for the patience. After the team’s reminder. I need to correct my answer.

Firstly, the limit for Cloud Script execution time (triggered action) is indeed one second. I left this out in my initial reply. And if this limit is too short to meet your need, we can help you raise it to 2 seconds at most. And we cannot upgrade it further for Premium Plan. If you want to raise it to 2 seconds, please let us know.

Secondly, as you said, the Cloud Script using Azure Functions is a workaround suitable for you. Azure Functions do not have the same time limits.

0 Likes 0 ·
Francois Boucher-Genesse avatar image Francois Boucher-Genesse Sarah Zhang commented ·

Hi @Sarah Zhang,

That definitely makes more sense to me, we're happy to look into Azure Functions as an alternative.

I can't find any particular PlayFab limit for Azure functions when called from triggered scripts. Is there a time limit? If so, how long is it and which method is recommended in Azure Functions for http calls to external services?

Thanks!

0 Likes 0 ·
Francois Boucher-Genesse avatar image Francois Boucher-Genesse Sarah Zhang commented ·

Hi @Sarah Zhang - I'm doing a follow-up on this as we'd like to avoid any surprises when implementing Azure Functions. From the UI, it looks like we are still limited to 1 second. Thanks.

0 Likes 0 ·
brendan avatar image brendan Francois Boucher-Genesse commented ·

For clarity: There are two ways to call Azure Functions in PlayFab – HTTP-based and Queued. HTTP-based calls have all the same limits as legacy Cloud Script. That’s why we have Queued functions available – those can run far longer (up to the Azure limit of 5 minutes).

0 Likes 0 ·
Show more comments
Francois Boucher-Genesse avatar image
Francois Boucher-Genesse answered

@Sarah Zhang Francois here from the same company, answering for Thomas as he's on vacations. 10 seconds is indeed the limit for regular cloud script calls coming from the client, but it's down to 1 second if it's called from a playstream event such as a rule or a scheduled call (see Cloud Script execution time (triggered action) in the limit page https://developer.playfab.com/en-US/<title_id>/limits).

We will often need to call external services based on various server side events, as duplicating calls from the client means we need to implement a _lot_ of additional logic. Thomas gave an example, but we will have several scenarios like this one. At the moment that seems impossible with the 1 second constraint. We also tried to call external services from our cloud script without waiting for the response to be under the 1 second constraint, but couldn't figure out how.

That seems like a pretty basic need for other companies as well, so we're wondering what the recommended approach is.

Thanks!

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.

Francois Boucher-Genesse avatar image Francois Boucher-Genesse commented ·

I'm doing a follow-up @Sarah Zhang.

New posts are typically answered the next day, which is great. Replies are not answered as much though. Since this is a blocking issue for us, I'll open a support ticket in a few days if this thread stays unanswered. Let us know if there's a better way to work with you. Thanks!

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Francois Boucher-Genesse commented ·

Apologies for the delayed response. To meet your needs, you need to upgrade your title limits. To request the title limits upgrades, your account need to in the Premium Plan at least. If it’s necessary for you to upgrade the limit of Cloud Script execution time (triggered action), you can consider upgrading the Account Plan, then submit the support ticket for it.

0 Likes 0 ·
thomasp avatar image thomasp commented ·

Hello @Sarah Zhang

Thanks for your support. I'm trying to implement the suggested way.

Unlike what you said previously, PlayFab UI display the exact same time limitation for Cloud Script Azure Function : 1 second.

Seems we then are still in the exact same issue using Azure Function.

This is a screen shot, please see the most bottom line.

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.