question

Steve Falzon avatar image
Steve Falzon asked

Performance advice requested API calls vs CloudScript

Hi Folks, I hope everyone is having a pleasant day.

I have an Azure function that makes a couple of calls to the playfab api, registering a player then updating their title email to send a verification email.

This all works fine. However the function takes around 2 seconds to complete.

I've never worked with cloud script so I hoped to get a little advice before I embark on something that in the end may not make any difference to performance.

Theoretically, could I increase performance by moving the functionality to a cloud script, calling that once to add/verify the user? Or will I be making the same calls to the same endpoints so there'll be no difference?

cheers

Steve

sdksCloudScript
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

·
Sarah Zhang avatar image
Sarah Zhang answered

Theoretically, the performance of C# would be a little faster than JS. Moving the function to Cloud Script won’t speed the execution up. And as you mentioned, the response time of the API endpoint determines when the function is completed. They are no difference basically.

Besides, do you call the Client API AddOrUpdateContactEmail on Azure Function to update the contact email? If so, we wouldn’t suggest using Client APIs on servers or server-hosted side such as Azure Function and Cloud Script. The Client APIs have lower limit of maximum request rate than the Server APIs and Admin APIs, call them on the Azure Function may exceed the limits. We would suggest you follow this documentation -- Using a Rule to Verify a Contact Email Address - PlayFab | Microsoft Docs to register players and add contact emails on clients, then use the Rule to send the verification email.

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.

Steve Falzon avatar image Steve Falzon commented ·

Hi Sarah, thanks for the info.

I am already using rules and email templates to send verification emails as described in the article you referenced.


What I do, to get round the fact there is no built-in way to verify a user email when their master account is created, is call PlayFabRegisterUser and then AddOrUpdateContactEmail as you indicate. I'm using the NodeSdk for this.

So I need to look at the server/admin apis more closely? The document you reference is for the Client Api which is similar to how I'm doing this at the moment except I'm not logging in with a custom Id I'm just registering the user then updating the title email where the rule kicks in.

Using c#, my primary language, isn't a problem but as the issue is with my api calls resulting in the function waiting for responses, I can't see how that would help. (thinking out loud...) Perhaps I can use the wait time to do something, I'll figure something out, there's lots of ways I can do this.

Thanks again Sarah. Your help is very much appreciated.

Steve

0 Likes 0 ·
Steve Falzon avatar image Steve Falzon commented ·

Correction to above, it's: RegisterPlayFabUser not PlayFabRegisterUser, that I call initially.

0 Likes 0 ·
Steve Falzon avatar image Steve Falzon commented ·

Given this answer

https://community.playfab.com/questions/16267/updating-user-email-from-server-api.html ,

states there is no equivalent server/admin api I was wondering why the advice is not to use client api from azure functions? Is it the synchronous nature of at least some of the api? If so, I've used promises to wrap the calls, seems to work ok.

Is there any other reason not to use the client api from functions?

The entire process is working smoothly, no problems at all. Just the wait time is a small issue. As I say, maybe I can use the wait time productively.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Steve Falzon commented ·

Please refer to the description in this thread -- Passing SessionTicket to server - Playfab Community. For summary, when the client APIs are called on the same IP address enough frequently, it would exceed the maximum client API rate.

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.