How do I scale in Docker Swarm Mode W Terraform Digital Ocean Load Balancing

0 votes

How can I perform automatic scaling based on metrics like CPU usage and Network usage?

For example create a new instance if my CPU usage is above 70% on all the nodes, and destroy an instance if the CPU usages falls below 30%. These would have to be sustained usages of course, like all nodes running at more than 70% CPU Usage for more than 5 minutes.

I did some research into this but its not very clear. For example Digital Ocean has a monitoring service which can send you an email if the CPU Usage is abnormally high (or Networking Load) based on a threshold you set. The problem is they don't have WebHook support yet so I can't send these signals to my application.

One idea I had was to set a special email for these notifications and check the email. Based on the email response I then create a modified terraform file and 'terraform apply' it to modify the infrastructure?

I'm not sure if this is good form either since the point of terraform is code as infrastructure, but if the infrastructure is designed to create new instances and destroy instances all the time based on CPU Usage or Network Usage I'm not sure how you convey that concept correctly in terraform?

Can anyone help me with this?

Jun 19, 2018 in Docker by Atul
• 10,240 points
1,470 views

1 answer to this question.

0 votes
The solution you could build for Digital Ocean could work for all other Cloud providers as long as they provide an API for creating/destroying nodes.

So either you switch to AWS which has a built-in auto-scaling, either you build your own solution. It's a lot of work but it's not hard to set up. You need to have a full visibility on your cluster like a monitoring system that track all your cluster nodes from a node registry/discovery and then collect metrics and trigger alerts.

You may configure you alert system to run your Terraform job, ansible playbooks, trigger a Jenkins Job via HTTP api,... that will scale in/out your infrastructure based on the metrics.

I hope the above information would be helpful to you.
answered Jun 19, 2018 by shubham
• 7,340 points

Related Questions In Docker

0 votes
1 answer
0 votes
2 answers

How do I fix the “no space left on device” error in docker?

Try cleaning up: $ docker volume rm $(docker ...READ MORE

answered Aug 14, 2019 in Docker by Sirajul
• 59,230 points
12,625 views
0 votes
1 answer

How do I install phantomjs with node in docker

Here is what you can try. Link for existing ...READ MORE

answered Aug 1, 2018 in Docker by Damon Salvatore
• 5,980 points
5,756 views
0 votes
2 answers
+2 votes
1 answer
+5 votes
7 answers

Docker swarm vs kubernetes

Swarm is easy handling while kn8 is ...READ MORE

answered Aug 27, 2018 in Docker by Mahesh Ajmeria
3,856 views
+3 votes
4 answers

How do I execute multiple commands using docker-compose

It can be solve by using bash -c ...READ MORE

answered Sep 20, 2018 in Docker by shubham
• 7,340 points
110,819 views
+2 votes
6 answers

copy directories in docker container excluding any one directory

One of the way could be copy ...READ MORE

answered Dec 10, 2018 in Docker by Prateek
34,714 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP