If the Server Load Balancer is available in the expected Auto Scaling group, it will check that the ports of the backend ECS instances are functional before forwarding requests to the ECS instances.
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.
No. Dynamic scaling based on custom monitoring settings is not supported.
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 run this script upon operating system startup.
Take CentOS as an example, you can create the following shell test script:
# chkconfig: 6 10 90
# description: Test Service
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 run
chkconfig --level 6 test on. This test script will run 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:
yum install -y \
chkconfig php-fpm on \
&& chkconfig httpd on
wget http://pwfiles.oss-cn-hangzhou.aliyuncs.com/com/soft/phpwind_v9.0_utf8.zip \
&& unzip -d pw phpwind_v9.0_utf8.zip \
&& mv pw/phpwind_v9.0_utf8/upload/* /var/www/html \
&& wget http://ess.oss-cn-hangzhou.aliyuncs.com/ossupload_utf8.zip -O ossupload_utf8.zip \
&& unzip -d ossupload ossupload_utf8.zip \
&& /bin/cp -rf ossupload/ossupload_utf8/* /var/www/html/src/extensions/ \
&& chown -R apache:apache /var/www/html
service httpd start && service php-fpm start
echo "Install CloudMonitor"
chmod +x quartz_install.sh
echo "Installation complete"