Best practices for websocket deployment

0

We have built a websocket system for our requirement and will be deploying it on AWS EC2.

I am looking for best practices in terms of load-balancing. We are thinking of having ALB to front the websocket server nodes. We expect to get around 50,000 connections initially and most likely will have 3 websocket servers deployed.

  • What are the best practices / configurations on ALB for this?
  • We will also be having API servers on EC2. Should we share the same ALB or have different ALB set up for websocket and API?
  • Is there a way to configure the load-balancing based on connection-count?
  • In case a websocket server restarts/goes down, our assumption is that ALB will also disconnect all the clients and they are expected to reconnect on their own. Is this correct?
spy16
gefragt vor 4 Monaten281 Aufrufe
3 Antworten
0
Akzeptierte Antwort

Customize health checks to accurately reflect server load and capacity. Default health checks might not be suitable for WebSocket connections which primarily rely on I/O operations. https://aws.amazon.com/blogs/compute/using-websockets-and-load-balancers-part-two/

Set up ALB listeners properly. Listeners are essential for handling incoming connection requests. You must define at least one listener for your ALB to manage traffic. https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html

Utilize forwarding actions and weighted target groups to distribute traffic. You can route requests to multiple target groups with assigned weights, influencing how traffic is distributed among them. https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html

Be aware that ALBs don't immediately detect an unhealthy node. If a WebSocket server restarts or goes down, the ALB may continue routing connections to it until it is marked unhealthy. https://aws.amazon.com/blogs/compute/using-websockets-and-load-balancers-part-two/

ALBs provide metrics like NewConnectionCount, representing the total number of new TCP connections established, and RejectedConnectionCount, indicating connections rejected due to the load balancer reaching its maximum connection limit. https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-cloudwatch-metrics.html#:~:text=,the%20load%20balancer%20to%20targets

You may want to use different ALBs for WebSocket and API servers, depending on your architecture and traffic patterns. This can provide greater management and tuning according to the needs of each service.

profile picture
EXPERTE
beantwortet vor 4 Monaten
profile picture
EXPERTE
überprüft vor 4 Monaten
0

Hi,

this post describes the best practices re. load-balancing and websockets when using LightSail: https://aws.amazon.com/blogs/compute/using-websockets-and-load-balancers-part-two/

Best,

Didier

profile pictureAWS
EXPERTE
beantwortet vor 4 Monaten
0

Thank you all ! I will take a look at these resources.

spy16
beantwortet vor 4 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen