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달 전282회 조회
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달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인