Initially the Zone Link server was designed using Node.js but unfortunately that solution is quite slow, inflexible and not very good for scaling the project.
The server will be instead split into several pieces to make it flexible, modular and much faster and additionally the whole project will be changed into a gRPC implementation.
gRPC is a communication protocol using HTTP 2 which allows streaming as well as protobuf allowing requests to be way more compact than in normal RESTful API implementations. The result is a server which has both unary calls (one way requests to the server) and streaming (client server communication) in one protocol instead of using HTTP and Websockets. Additionally there is no need to use Json because we are dealing with tightly packed binary data (no serializing / deserializing) which results in a 5-10 times faster server. Another cool thing about gRPC is that you don’t have to deal with data parsing anymore. gRPC allows you to call methods (functions) remotely which means that the data is already automatically passed into methods.
Additionally the sever will be hosted on several Raspberry Pis 4 as the cloud costs are quite ridiculous. Prices can reach even $2000 – $4000 per month for a small project while the server can be hosted on Raspberry Pis for around $10 a month with the initial investment of around $500 for the hardware.
The server will now consist of 4 Raspberry Pis 4:
- Authorization Database + gRPC API
-Contains a PostgreSQL database (containins user login information and authentication tokens) and additionally a gRPC server which exposes the database to the rest of the system.
- Authorization Server (gRPC)
-Talks to the Authorization Database and manages user registration / logins as well as authorization token management / validation for the whole system.
- Logic Database + gRPC API
-Contains a PostgreSQL database (contains Zone Link user data related to the game) and additionally a gRPC server which exposes the database to the Logic Server.
- Logic Server (gRPC)
-Manages the actual Zone Link logic, allows communication between clients.