Deploy to AWS with Ray's autoscaler
Prepare your login credentials of AWS CLI
Login to our AWS Classroom as introduced in serverless lab.

Click the button "AWS Details", and then click the "Show" button after "AWS CLI", you will get a string of text indicating the credential of your account.

Follow the instruction and copy the credentials to ~/.aws/credentials on your docker container.
Prepare the Ray configuration file for deployment to AWS.
First, you need to get your IamInstanceProfile from AWS Console.
Step-1: Open AWS Console and Search IAM.

Step-2: Click "Roles" on the left navigation, and then click the "LabRole".

Step-3: After open the page for "LabRole", copy the Instance Profile ARNs. We will use it to config our ray cluster

Step-4: Go back to your docker container. In project folder~/ray-lab , create a new file aws.yaml with the following content. Remember to fill your Instance Profile ARNs got from last step into this file at the correct location (line-80 and line-99).
Launch a cluster of Ubuntu (with Ray installed) on AWS EC2
To start the ray cluster on AWS, execute the following command in your docker container
After 3-5 minutes, you should see the following output that states that the cluster on EC2 is ready:
Submit your Ray distributed application from your docker container to the EC2 cluster
Before executing the program, open main.py, comment out line-79 and uncomment line-81.
=>=>=>
Submit the program to the AWS:
The output should be the same as running on your docker container.
Trigger Action 2 to increase the number of chatrooms.
Then the program will get blocked due to insufficient CPU cores to handle increased workload. The following warning message will be prompted.
The program will be unblocked until a new AWS EC2 instance is spawned (~ 3-5 minutes).
Then, you can play the program again. E.g., triggerAction 1and selectuser4 a chat:
You can see that user3 and user4 are in the same Ray worker node while user5 is in the newly created Ray worker node.
Monitor your Ray cluster through the Ray dashboard
To get the public IP of your Ray dashboard, you have to do something different to get the dashboard web URL. Look at the last line of the output of ray up -y aws.yamlin the step above:
The public IP of the Ray dashboard is 3.94.118.22
Open a browser, go to http://{public_ip}:8265. A list of the server (AWS EC2 instance) will be displayed. Click the '+' button beside the server.

All the allocated actors will be displayed.

Remove the EC2 instances after the lab
To save the AWS credit of you account, you should remove all EC2 instances. Execute this command in your docker container.
Last updated
Was this helpful?