In my project I retrieve some data from the database, but can anyone explain me how to save this data inside the server to keep it available to clients connecting to the UE server?
Let me explain: the logic is that of an MMORPG, where the database contains in the table the objects and their standard values, as I think it works in every game. So by taking via an API call the data from the object table, I should save it in the Unreal Engine server, right?
But here’s the problem: How do I save this data inside the UE server to keep it available for people who log in without making a per-client call every time?
Personally I would make an sql / mysql server for data persistence.
Use the tools that are designed for the task.
You can pass in the information through a custom rest API.
OFC you would have to host the server yourself. Unreal does not have any built in data base functionality out of the box (data tables are not equivalent to relational databases).
You could use Epic Online Services for this too (it does have a persistence option) but it might be more costly in the long term.
I already have one server where I hosted the database and one where I have the UE server. But again I don’t understand where and how it is best to save the data from the server and then replicate it to the connected clients, so that there are no calls for each client
You only need to save data for persistence reasons. So if a player logs off you can for instance save their current stats / inventory / character or quest progress. You can also do incremental snapshots of the data during gameplay.
Saving / Loading data does not take part in the replication process between clients, only during the initial loading of a players account & logging off.
Most current information would be in server memory and what is safe to store on the client side memory (a rule of thumb never trust the client data).
To load data you would do a rest call to the server and pass in requested serialized data that would be de-serialized and interpreted as in game data => causing the spawning of player data / objects etc.
This could be binary data or json formatted information.
You would need to add secondary authentication like a token generation and retrieval for a session before any server actions to keep things safe.