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
已提問 4 個月前檢視次數 281 次
3 個答案
0
已接受的答案

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
專家
已回答 4 個月前
profile picture
專家
已審閱 4 個月前
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
專家
已回答 4 個月前
0

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

spy16
已回答 4 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南