Client/server design advice needed

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By jarek

Hi, I’m new to Godot, and after few days of browsing through networking examples, it still confusing.

I’m thinking of a game, that will require a Godot client with GUI, and a server that processes the logic and stores user data.
It’s not going to be very interactive, users don’t need to communicate with each other a lot, they can do through the server, so no p2p between users. Network traffic also not going to be very heavy for each user. I was thinking of exchanging json formatted messages between client a server.

Once the game gets popular, though, the server must be able to support many clients (lots! hopefully :))

Because the server uses no GUI, and should be conservative on resources to handle many clients, I was considering to use c++ implemented server, but it’s not a must. I realize it makes impossible to use mid/high level networking APIs from Godot. But it lets me more easily implement complex logic, stay efficient and easily store many users’ data locally with fine controlled memory management etc. I’m proficient in C++ so I’m not worried it’s gonna be all easy to me.

I just wonder, what’s gonna be more difficult:
A) Godot server and then handling server side optimizations for heavy load, much data, saving it and serving to clients, plus processing game logic.
B) Optimized c++ server, but more complex network that must be implemented on lower level also on the user side.
C) Use Godot server for network with Native logic…?

Thanks in advance for any hints and ideas to consider.

It seems that your server doesn’t need to be done in Godot. Why not use a classic server language. Maybe combined with a database? (I.e. MariaDB / MySql)

It would be easier to scale such a server up or move it on some rented space / cloud service.

Languages could be PHP or RUST and many other (i.e. Node.js, Java (JSP), even Python).
All those should deal well with json data structures via http requests.

wombatstampede | 2020-01-16 07:23

From my point of view c++ or java doesn’t make much difference (I have tons of professional c++ experience, making games for fun in free time). C++ gives me much better control of resources consumed…

PHP or Node.js or even Python - would that be any different from Godot based server in terms of resource consumption? If not, I can just use Godot, right?..

jarek | 2020-01-16 21:07

For Godot, there’s a “headless” export template for linux’es. Which is usually the OS of choice for web servers.

While i.e. PHP + Nginx (+ maybe MariaDB) might be a convenient, flexible & robust start for servers (often such software come preloadable/preinstalled). C++ will actually be more effective on the performance side. But an own C++ server would be a more proprietary way (Godot as well) which might (or might not) pose problems when porting to other servers/cloud services.

wombatstampede | 2020-01-17 08:03

:bust_in_silhouette: Reply From: oofman

What you need is “Godot dedicated server tutorial” (2018-07-26) by Tom Langwaldt:

But I really suggest you try to build more simple game first without multiplayer if you don’t have much programming experience or P2P if you are junior to mid level programmer because dedicated server takes a bit more time to debug.

Creating a P2P game really helps to understand core Godot multiplayer mechanics. Here is a good tutorial to start with:

Good Luck,
oofman

Thanks for your answer. Don’t worry I have programming experience. I’m just new to Godot.
I’ve seen that dedicated server tutorial before posting the question. It nicely and briefly outlines the mechanics, but it uses the high level APIs including RPC, which brings me back to my doubts about resource consumption and efficiency of the server itself.

After looking the video, I may be missing something, but P2P game actually looks to me more complex than a server + clients concept, where the server doesn’t have to display any graphics. In my concept the server processes the logic, and the client is mostly just a user interface.
I agree looking at the examples of using RPC with Godot, this seem quite trivial to implement. I guess the only way to find out whether the Godot framework overhead is not going to kill my server is to just write the game, attract thousands of players and see what happens :smiley:

jarek | 2020-01-16 21:17