Ch3 Elasticity and Scalability Concepts
Technical requirements
Sources of failure
Dividing and conquering
Virtualization technologies
LAMP installation
Scaling the webserver
Resiliency
EC2 persistence model
Disaster recovery
Cascading deletion
Bootstrapping
Scaling the compute layer
Scaling a database server
Summary
Further reading
3. Ch3 Elasticity and Scalability Concepts
• Technical requirements
• Sources of failure
• Dividing and conquering
• Virtualization
technologies
• LAMP installation
• Scaling the web server
• Resiliency
• EC2 persistence model
• Disaster recovery
• Cascading deletion
• Bootstrapping
• Scaling the compute
layer
• Scaling a database
server
• Summary
• Further reading
4. Ch3 Elasticity and Scalability Concepts
AWS Command Line Interface
https://aws.amazon.com/cli/
• Technical requirements
• Sources of failure (S3)
1. No, you're not crazy. Part of the internet broke
2. How a typo took down S3, the backbone of the internet
3. Amazon S3 Outage Has Broken a Large Chunk of the Internet
Root Cause - Typo
Failure should be our teacher;
as Thomas A. Edison said, "I have not failed. I've just found 10,000 ways that won't work."
6. • Serial configuration RDS
EBS
• Parallel configuration
• Active-Active (AA)
• High Availability (HA)
Warm Standby, Hot Standby, Cold
7. • Reactive and proactive scalability
Horizontal scalability
To avoid single points of failure (SPOFs)
Vertical scalability
加ram 加cpu 舉例來說 Elastic Compute Cloud (EC2) has different instance types, families, and sizes, which allows
for the vertical scalability of a single compute node, as shown in the following screenshot:
LAMP
• Exercise
11. Scaling the web server
1. Obtain the instance-id with the following expression:
export CURRENT_INSTANCE=$(aws ec2 describe-instances --query 'Reservations[*].Instances[*].InstanceId' --filters
'Name=instance- state-name,Values=running' --output text)
2. We must stop the instance to change the instance-type attribute to m4.large, as follows:
aws ec2 stop-instances --instance-id $CURRENT_INSTANCE --output json
3. Once stopped, modify the attribute via the CLI, as follows:
aws ec2 modify-instance-attribute --instance-id $CURRENT_INSTANCE - -instance-type m4.large
4. Restart the instance, as follows:
aws ec2 start-instances --instance-id $CURRENT_INSTANCE --output json
13. ./lsblk 列出 Block Device
EC2 persistence model
Xen hypervisors using HVM virtualization.
Every EC2 instance has private access to a DNS metadata server within the VPC at the 169.254.169.254 canonical address.
metadata server can be used to read information about the instance itself, along with the surrounding infrastructure in which it is running.
This is valuable when you are writing bootstrapping scripts, applying application configurations, and even performing service
authentication techniques.
With a simple curl command, we can access the block-device-mapping information from this image.
Direct Attached Storage (DAS) / Network Attached Storage (NAS)
15. Direct Attached Storage (DAS) / Network Attached Storage (NAS)
1. To properly associate the volume, let's query the AZ in which this instance is currently running, as follows:
aws ec2 describe-instances --instance-ids $CURRENT_INSTANCE -- output json --query
'Reservations[0].Instances[0].Placement'
The result is as follows:
{
"Tenancy": "default", "GroupName": "", "AvailabilityZone": "us-east-1a"
}
2. Create the volume by using the AvailabilityZone information, as follows:
aws ec2 create-volume
--size 80
--availability-zone $(aws ec2 describe-instances --instance-ids $CURRENT_INSTANCE --query
'Reservations[0].Instances[0].Placement.AvailabilityZone' --filter 'Name=tag:Name,Values=WebServer' --output
text)
--volume-type gp2
3. Now, describe the volumes that are available in order to find the status information, as follows:
aws ec2 describe-volumes
19. Bootstrapping cloud-init
1. We will provision our new instance by using the following user data input file. You can find this file in the GitHub repository under
chapter02/bootstrap.txt:
aws ec2 run-instances --image-id ami-14c5486b --key-name BookShelfApp --instance-type t2.medium --security-group-ids sg-
bddd92cb --user-data file://bootstrap.txt
2. Refresh the current instance variable, as follows:
export CURRENT_INSTANCE=$(aws ec2 describe-instances --query 'Reservations[*].Instances[*].InstanceId' --filters
'Name=instance- state-name,Values=running' --output text)
3. Now, associate the Elastic IP as follows:
aws ec2 associate-address --allocation-id eipalloc-d300d8db -- instance-id $CURRENT_INSTANCE
4. Navigate to your Elastic IP address by using your web browser (in my case,
it's 52.44.105.242); we can now validate that our web server was created from scratch, as shown in the following screenshot: