Andrey Skobelev avatar image
Andrey Skobelev asked

Custom API server with PlayFab integrated

Hello! I have several questions regarding PlayFab (PF later in text) services and what do I want archieve with them.

This is a study project, my goal is to explore how big games are done with lots of social interactions, serverside logic, async multiplayer (probably some sync too), market, etc.

I want to pair PF with custom serverside logic written in c# using .net core and to understand how to scale it with azure services available.

Here are things that I want to archive during this study project:

Custom server

Custom api server written in c#. Reason: I want to implement a lot of gamelogic concerning things like crafting, opening chests, generating rewards for players etc. on the server. For security reasons, because it seems like best practice not to let clients decide on those things.

I want to integrate this server with several PF services:

  • Authentication. Player connects to the api server with a login request, I forward it to PF, then return the result to the player.
  • Social features. Friends, clans, archievents, leaderboards, etc. Workflow is the same I believe.
  • Player economy to leverage existing PF features.
  • Analytics. It probably will be sent directly from clients, because no use of an additional middle man that just passes data to PF. But maybe I will send some data from the server, too (e.g. sending match/battle results).
  • Cloud database. Don’t know if I really need it, probably existing PF services will suffice, but still a nice thing to consider.

The questions are:

  • Is my approach reasonable at all? I know that a lot of mentioned thing can be accomplished with Cloud Scripts that are already integrated with PF, but I want that logic to be written in c# to further enhance my skills/knowledge with that language (remember, this is the study project).
  • If this approach is ok, how to deploy and scale this kind of server? This is probably the wrong question to ask in the PF forum, because it's a more “general hosting question” type. AFAIK, I will just use Azure hosting services to both deploy, scale, balance to loads and etc. Am I right?


I want to explore both async (and later sync) multiplayer features. Game server again written in c#, deployed and scaled by PF multiplayer services. I believe the logic is pretty much the same: I request a game server from my api server, PF performs matchmaking, spins up the game server (doesn’t matter sync/async multiplayer). Then some request goes to api server to notify that match is over, game server instance goes down, some rewards are distributed to players, etc.

Is this the right way to do that kind of things?

In-Game EconomyCustom Game Serversmultiplayer
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

>> Is my approach reasonable at all?

The approach is suitable for PlayFab Admin API, Server API, and Entity API. But we would suggest you don’t integrate PlayFab Client API with the custom API server. The Client API is designed to be called by clients directly. To prevent possible performance issues, PlayFab set rate limits for the API calls. If an IP address calls a large number of Client API methods concurrently, the IP address would be restricted. The subsequent API calls would return this error - "The client has exceeded maximum API requests". Please also check this thread for more information --

Besides, if you want to implement a custom API server, you can also consider using PlayFab CloudScript using Azure Functions. It’s a feature that enables serverless compute on demand in the language of your choice. You can write it in C#. Please check our documentation for more details.

>> If this approach is ok, how to deploy and scale this kind of server?

As the first answer said, the Azure Functions is an option. If you use the Azure Functions, you can follow our documentation Quickstart: Writing a PlayFab CloudScript using Azure Functions to deploy it and integrate it with PlayFab. If you are considering other options, you can navigate to Azure community support for more professional suggestions.

>> Is this the right way to do that kind of things?

Yes, it’s a feasible way. For asynchronous multiplayer games, you can also use SharedGroupData. But for synchronized multiplayer games, dedicated servers are necessary. PlayFab Multiplayer Server is a server hosting service designed for this target. You can check this documentation Integrating with PlayFab Multiplayer Servers to integrate the Multiplayer server with Matchmaking. Using this option can automatically allocate a game server for the resulting match.

If you have other technical questions about PlayFab, please feel free to post the new threads in the forum to ask them.

10 |1200

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

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.