Click here to Skip to main content
15,878,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have been working on a Unity game for a bit. The database is MySql. I want to create a link between the unity server I have and the website server. So I have an array of servers for my game already. I have another server that I installed apache/php/mysql on with a basic page. This website would be used from everything to forums/password reset/account management/purchase. Is there a way that I can retrieve data from the unity server to the website serve and also send data back. Trying to keep it separate for security reasons, however it may not even matter if I'm adding this link.

Also any other ideas for a better way to go about is appreciated!

What I have tried:

I have not tried anything yet. Just a general wondering if its even possible.
Posted
Updated 6-Apr-21 3:14am
v3

1 solution

This is an example of distributing databases and having them synchronise. It's a common practise for applications with enormous user bases (ie. YouTube) to optimise for speed, by having multiple databases available for reads and writes, and having distributed systems synchronise the data when resources are available. Interestingly, if you ever refresh a YouTube page and notice different view counts, it's because it's probably hit a different server which has a different, cached version of the view count, so that number can go up and down!

In theory, the priority here would be that your website needs to perform immediate operations on the primary database, while your website database can operate off some slightly stale data. For example, if you close your account on the website then you should not be able to login to the game effective immediately.

In this situation I would recommend having the website have an available connection pool to your primary database for important write operations (purchases, account changes). For anything else, I'd recommend having a scheduled task in the background perform any synchronisations which might be needed. For example, updating the website with acquired trophies or achievements.

This would also mean your Unity server should never connect to the website database, have the website responsible for managing any synchronisation and alleviate this responsibility from your game server, freeing up more resources for a better gameplay experience.
 
Share this answer
 
Comments
Cody O'Meara 6-Apr-21 10:27am    
Thanks Chris! This is very well explained and gives me a starting point to research further.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900