Monitoring and automation

Last Updated: Mar 29, 2017

How does Auto Scaling determine if its ECS instances are available?

If the Server Load Balancer is available in the desired Auto Scaling group, it will check that the ports of the backend ECS instances are functional before forwarding requests to the ECS instances.

What are the triggering conditions for Auto Scaling alarms?

Monitoring alarms in Auto Scaling are triggered based on the CPU load, memory usage, average system load, and Internet and intranet inbound and outbound traffic. These are used to automatically increase or decrease the number of ECS instances.

Can Auto Scaling support dynamic scaling based on custom alarms in CloudMonitor?

No. Dynamic scaling based on custom monitoring settings is not supported.

How can I ensure that application operations are completed before ECS instances are automatically released?

To ensure that Auto Scaling releases an instance after a task is completed on the instance, store an execution script in a custom image, and set up a command to automatically execute the script when the operating system is turned off.

Using CentOS as an example, you can create the following shell test script:

  1. #!/bin/sh
  2. # chkconfig: 0 10 90
  3. # description: Test Service
  4. echo "hello world!" <!-- unsure why the preview displays this text in heading format, please publish it as normal body text -->

Here, 0 is the default start level. There are a total of 7 levels ranging from 0-6.

  • Level 0: Shutdown   
  • Level 1: Single user mode   
  • Level 2: Multiuser command line mode with no network connection   
  • Level 3: Multiuser command line mode with network connection   
  • Level 4: Unavailable   
  • Level 5: Multiuser mode with graphic interface   
  • Level 6: Restart
  • 10 is the start priority and 90 is the stop priority. The priority range is 0-100. The higher the number, the lower the priority.

Put the test file in the /etc/rc.d/init.d/ directory and execute chkconfig —level 0 test on. This test script will then be executed each time the system shuts down.

How can I automate the deployment of the ECS applications created in a scaling group?

To automatically install or update a program, or automatically load code after an ECS instance is automatically created in a scaling group, you must store an execution script in a custom image and set up a command to automatically execute this script upon operating system startup.

Using CentOS as an example, you can create the following shell test script:

  1. #!/bin/sh
  2. # chkconfig: 6 10 90
  3. # description: Test Service
  4. echo "hello world!"

In the preceding output, 6 is the default start level. There are a total of 7 levels ranging from 0-6.

  • Level 0: Shutdown   
  • Level 1: Single user mode   
  • Level 2: Multiuser command line mode with no network connection   
  • Level 3: Multiuser command line mode with network connection   
  • Level 4: Unavailable   
  • Level 5: Multiuser mode with graphic interface   
  • Level 6: Restart
  • 10 is the start priority and 90 is the stop priority. The priority range is 0-100. The higher the number, the lower the priority.

Put the test file in the /etc/rc.d/init.d/ directory and execute chkconfig --level 6 test on. This test script will then be executed each time the system starts up.

The following example shows how to use a script to install Phpwind. Put the Phpwind installer in the script for execution (you will need to enter the database password). An example output is as follows:

  1. cd /tmp
  2. echo "phpwind"
  3. yum install -y \
  4. unzip \
  5. wget \
  6. httpd \
  7. php \
  8. php-fpm \
  9. php-mysql \
  10. php-mbstring \
  11. php-xml \
  12. php-gd \
  13. php-pear \
  14. php-devel
  15. chkconfig php-fpm on \
  16. && chkconfig httpd on
  17. wget http://pwfiles.oss-cn-hangzhou.aliyuncs.com/com/soft/phpwind_v9.0_utf8.zip \
  18. && unzip -d pw phpwind_v9.0_utf8.zip \
  19. && mv pw/phpwind_v9.0_utf8/upload/* /var/www/html \
  20. && wget http://ess.oss-cn-hangzhou.aliyuncs.com/ossupload_utf8.zip -O ossupload_utf8.zip \
  21. && unzip -d ossupload ossupload_utf8.zip \
  22. && /bin/cp -rf ossupload/ossupload_utf8/* /var/www/html/src/extensions/ \
  23. && chown -R apache:apache /var/www/html
  24. service httpd start && service php-fpm start
  25. echo "Install CloudMonitor"
  26. wget http://update2.aegis.aliyun.com/download/quartz_install.sh
  27. chmod +x quartz_install.sh
  28. bash quartz_install.sh
  29. echo "Installation complete"
Thank you! We've received your feedback.