3

I want to deploy an interactive rendering service that uses the WebSocket protocol. The service is containerized and can serve up to N (let's say 1 <= N <= 10) clients. The reason for the small N is that each new connection creates a new process (within the container) that has quite some resource requirements. I have read some tutorials about application load balancers, service load balancers, AWS Fargate, etc. These load balancing strategies mainly focus on CPU load or memory usage. But I couldn't find any documentation that does a "connection based" routing.

Is there an AWS technique/subsystem that allows me to fire up a new container (task?) when one the "current" container (task?) is (almost) "out of seats"? The routing must not route any further connections to the "full" container but the existing connections of that full container must not be dropped. Once a container (task?) has no connections anymore, it should be stopped (if it is not the last one) to avoid consuming too much unneeded resources.

Dave M
  • 4,494
  • 21
  • 30
  • 30
Daniel
  • 131
  • 2
  • I just noticed that https://serverfault.com/questions/900317/amazon-aws-websocket-load-balancing-scale-in is also relevant (don't know it it's possible to manually link the questions, maybe not with my level of karma). – hans_meine Jun 11 '20 at 14:53

1 Answers1

1

Are you the author/developer of this service? If you are you better redesign it because what you describe is not a suitable, scalable architecture.

The closest you can get to your stated requirements is using AWS Lambda - Lambdas are created per-request, i.e. if you have 1 client you'll have 1 lambda running, if you have 100 clients you'll have 100 lambdas running. Automatically. Typically you'd use Lambdas with AWS API Gateway as their frontend.

Doing the same with ALB, ECS, Fargate, etc would require some complex orchestration that you'd have to develop. I wouldn't go that way.

Use Lambda or rearchitect it for a batch processing or something like that.

Hope that helps :)

MLu
  • 23,798
  • 5
  • 54
  • 81
  • Unfortunately I am not the developer of the service, however it is somehow under the control of close cooperation partners but rearchitecting would be a long term issue. The application is interactive (on-demand 2D/3D medical visualization), so batch processing is also no option. I like to learn more about AWS Lambda and AWS API Gateway. If there is an easy way to let the lambda spawn a task and let the AWS API Gateway (now supporting websocket as I read) proxy the websocket connection to this new task, this could be what we need? – Daniel Mar 30 '20 at 07:59