# Autoscaling for openvidu

**URL:** https://openvidu.discourse.group/t/autoscaling-for-openvidu/4171
**Category:** Issues developing apps
**Tags:** v2
**Created:** [August 26, 2022, 1:26pm UTC](https://openvidu.discourse.group/t/autoscaling-for-openvidu/4171 "2022-08-26T13:26:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Balaji](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/balaji/32/2004_2.png) [@Balaji](https://openvidu.discourse.group/u/Balaji)
#### Post date: [August 26, 2022, 1:26pm UTC](https://openvidu.discourse.group/t/autoscaling-for-openvidu/4171/1 "2022-08-26T13:26:48Z")

</div>

Hello guys,  
I was trying to implement the auto-scaling for the openvidu application is AWS.  
I have isolated the “openvidu\_app\_1” container and deployed in fargate and connected it to the internal ALB on “5442”. similarly i have attached the EC2- instances already running remaining container to the same Internal ALB on “5443” so that it can be passed to the “openvidu\_app\_1” as an environmental variable.  
I have replaced the “localhost:5442” and “localhost:5443” configured in the upstream of nginx conf with the Internal ALB “DNSname\_of\_Internal\_ALB:5442” and “DNSname\_of\_Internal\_ALB:5443”  
This way the setup works perfectly without any hurdles, i have also tried to join from multiple rooms and multiple windows and devices, it works perfectly with:

\*\*\* 1 fargate container(Openvidu\_app\_1) and 1 EC2 (Openvidu\_openvidu-server\_1 and all other containers)\*\*  
\*\*\* increased number of fargate container(Openvidu\_app\_1) and 1 EC2 (Openvidu\_openvidu-server\_1 and all other containers)\*\*

But the problem i am facing is when i tried to scale the number of EC2 instances, the application failing with an error

 ![wserror](https://global.discourse-cdn.com/free1/uploads/openvidu/original/2X/e/e049ad214e1bde5a8b1b4cdc122c8f5a2341c504.jpeg)

at first i have tried search for that error and came across a solution from openvidu community

> [@WebSocket connection to 'wss://mydomain/openvidu' failed: Error during WebSocket handshake: Unexpected response code: 400](https://openvidu.discourse.group/t/websocket-connection-to-wss-mydomain-openvidu-failed-error-during-websocket-handshake-unexpected-response-code-400/710):
>
> Hello! Thanks for your job! It great! When I try to install openvidu, version 2.13.0 for the server and 2.12.0 for the browser is installed. I see a warning in the console about version mismatch. Installation was performed according to the instructions [https://docs.openvidu.io/en/2.13.0/deployment/deploying-on-premises/](https://docs.openvidu.io/en/2.13.0/deployment/deploying-on-premises/) ( curl [https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/install\_openvidu\_2.13.0.sh](https://s3-eu-west-1.amazonaws.com/aws.openvidu.io/install_openvidu_2.13.0.sh) | bash ) I try to start the broadcast from the webcam, but I get connection errors via soc…

I was using the Openvidu-server version 2.20.0 and i followed the above mentioned solution and changed the `location /` block as suggested but the error remains same.

Can anyone please let me know where i am going wrong and what changes need to be done?

Thankyou!
