Edit:
I was struggling with how to ask this question, but here is a way shorter and more direct verision…
Should each client send requests to a single service, which then authenticates once and communicates with all the other services, or should the client send requests directly to each of the microservices who authenticate the requests themselves?
Hey all! I’m trying to create a microservice based application as an independent study but I’m having trouble designing it, specifically the communication. I won’t go into detail about what each service does because it’s mainly the communication and authentication I’m confused about.
The project is really simple right now. There is a gateway server where the user connects, and then authenticates their connection (by hitting an auth service). Now that the connection is authenticated they can make calls to a game server where they can perform actions. It’s pretty much just a little game; the game server makes calculations every 33 milliseconds (30fps) and the API let’s users make simple actions like moving characters or placing objects.
Here’s what it looks like:
So here’s where I’m confused. What’s the best way to allow the gateway to get requests and communicate these actions to the other services?
Here are my thoughts…
Idea 1: Redirection
Each service will have it’s own gRPC API so they will have their own protobuf service. This means I can’t really have the gateway accept gRPC calls that are meant for a different service and have it just redirect them and return the result (to my knowledge). But is there a way to simply have calls go through the gateway to ensure authentication (both encryption and user identification) and then go to the right service?
Idea 2: Generic calls hit the gateway then the gateway handles the rest
I also thought about creating some generic format for gateway calls:
{ servicename, methodName, params... }
And then have the gateway interpret these and perform the correct calls to the service specified. Does this make more sense than redirecting messages?
I would love any advice as I’m just starting out developing services with Go and to this whole idea of microservices.