Home > Blockchain >  Simple game comprising Java backend & React.js frontend. Best approach with Google app engine?
Simple game comprising Java backend & React.js frontend. Best approach with Google app engine?

Time:05-22

I created a simple two-player game (Connect 4) with a Java/Spring backend and React.js frontend. I understand it would be simpler to create the entire app in React, but I’m studying Java development and decided to learn React to demonstrate my understanding and create a portfolio website.

I’m struggling to decide how best to deploy the app. I deployed the backend on its own to GC App Engine. After a few false starts it eventually worked. However, if I visit the project url from two separate browsers/devices, both devices are looking at the same instance of the backend, i.e. two individual users are looking at the same ‘game’, which is not what I intended.

What is the best approach to deploy the front & backend so each user is playing their own individual game? This is literally my first foray into any kind of web development, so I may have bitten off more than I can chew. Thanks.

CodePudding user response:

I would suggest you use multiple services on your project. You can either use the same deployment command for deploying or updating the services that make up your application.

services in App Engines behave like microservices and therefore you can deploy multiple services to run as a set of microservices.

Here are the requirements for deploying multiple services:

  • You must initially deploy a version of your application to the default service before you can create and deploy subsequent services.
  • The ID of each of your services must be specified in their corresponding app.yaml configuration files. To specify the service ID, include the service element definition in each configuration file. By default, excluding this element definition from your configuration file deploys the version to the default service.

You can deploy one service as frontend and the other as backend.

You can check this documentation on services for additional information.

CodePudding user response:

I looked at the documentation regarding services but I still don’t understand their use in the context of my problem. I may have misunderstood your explanation, but I don’t think I explained my problem clearly. Having looked at the documentation, my use of the word ‘instance’ is not the same as an app engine instance.

It would make sense to me to have two services in my project; one for the backend and one for the frontend. To solve the problem of each individual player interacting with the same backend API, and so unwittingly interacting with the same single Connect4 game, generating multiple services would not be a solution. Is my understanding correct?

The comment from NoCommandLine on my original post is probably a better description of what I want to achieve.

  • Related