Jules B
Jules B

Reputation: 21

How to hide multiple websockets services behind an API Gateway?

I'm working on a project that has multiple microservices behind a API Gateway and some of them expose WebSockets API.

The WebApp needs to be able to interact with those APIs.

Current architecture .

Those WebSocket API can be built with frameworks that have their own protocols, using socket.io or not etc.

The main goal of this reflexion is to be able to scale and keep flexibility on my WebSockets APIs implementation.

I thought about two solutions :

I didn't find articles that give feedback after exposing such an architecture and websockets in production, i was hoping to find some here.

Upvotes: 0

Views: 820

Answers (1)

Gerd
Gerd

Reputation: 2803

I agree with you that a simple proxy solution seems to be inadequate as it exposes the internal interfaces to the clients. I found two articles which I think are addressing your problem:

The API Gateway Pattern

Pattern: API Gateway / Backends for Frontends

Both talk about the issues that you have already mentioned in your question: Protocol translation is an advantage of this architecture as it decouples the external API from the protocols internally used. On the other hand, increased complexity due to having another component to be maintained is mentioned as a drawback.

The second article also suggests some existing libraries (namley Netty, Spring Reactor, NodeJS) that can be used to implement an API gateway, so you might want to spend some time evaluating these for your project.

Upvotes: 1

Related Questions