EC2 - EC2 101 Flashcards
Amazon EC2 is…
…a web service that provides resizable compute capacity in the cloud
EC2 reduces the time required to obtain and boot new server instances to…
…minutes, allowing you to quickly scale capacity, both up and down, as your computing requirements change
EC2 changes the economies of computing by…
…allowing you to pay only for the capacity that you actually use
EC2 provides developers the tools to…
…build failure resilient apps and isolate themselves from common failure scenarios
EC2 pricing options
On Demand, Reserved, Spot, Dedicated Hosts
On Demand
allow you to pay a fixed rate by the hour with no commitment.
On Demand use case example
If you’re a startup, you can pay for instances by the hour with no long term commitment for experimentation, terminate instances when you are complete.
Reserved
provide you with a capacity reservation, and offer a significant discount on the hourly charge for an instance. 1-year or 3-year terms
Reserved use case example
If you need a minimum of 2 webservers to serve your customers
Spot
enable you to bid whatever price you want for instance capacity, providing for even greater savings if your apps have flexible start and end times. engineering, pharma companies use these
If bid price > spot price…
…instances can be provisioned
If spot price > bid price…
…instances will be terminated
Dedicated Hosts
physical EC2 server dedicated for your use (hourly rate). Dedicated hosts can help you reduce costs by allowing you to use your existing server-bound software licenses
On Demand Use Cases
Users that want the low cost and flexibility of EC2 without any up-front payment or long-term commitment
Apps with short term, spiky, or unpredictable workloads that cannot be interrupted
Apps being developed or tested on EC2 for the first time
Reserved Use Cases
Apps with steady state or predictable usage
Apps that require reserved capacity
users able to make upfront payments to reduce their total computing costs even further
Example of combining reserved + on demand instances
2 webservers = reserved. Need more for Black Friday = on demand
Spot Use Cases
Apps that have flexible start and end times
Apps that are only feasible at very low compute prices
Users with urgent computing needs for large amounts of additional capacity
Spot Use Case Examples
Large pharma company saves money by using compute capacity during very low demand times
Large world events, e.g. Brexit, analysts need to find solutions really quickly
Dedicated Hosts Use Cases
Useful for regulatory requirements that may not support multi-tenant virtualization
Great for licensing which does not support multi-tenancy or cloud deployments (e.g. Microsoft, SQL, Oracle)
Can be purchased on demand (hourly)
can be purchased as a reservation for up to 70% off the on-demand price
Termination of Spot Instances - EXAM TIP
If the spot instance is terminated by Amazon EC2, you will not be charged for a partial hour of usage. However, if you terminate the instance yourself, you will be charged for any hour in which the instance ran
Instance Types
D = Dense R = Memory-optimized (RAM) M = General Purpose (main choice) C = Compute-optimized G = Graphics-Intensive I = High Speed Storage (I/O) F = Field Programmable Gate Array T = Lowest Cost, General Purpose (t2 micro) P = Graphics/General Purpose CPU (pics) X = Memory-optimized (extreme RAM)
Dense Storage use case
Fileservers/Data Warehousing/Hadoop
Memory Optimized use case
Memory Intensive apps/DBs
General Purpose use case
Application Servers
Compute Optimized use case
CPU Intensive apps/DBs
Graphics Intensive use case
Video Encoding/3D application streaming
Field Programmable Gate Array use case
Hardware acceleration for your code
Lowest Cost, General Purpose use case
Web Servers/small DBs
Graphics/General Purpose GPU use case
Machine Learning, Bit Coin Mining, etc
Memory Optimized use case
SAP HANA, Apache Spark, etc
What is EBS?
EBS allows you to create storage volumes and attach them to EC2 instances.
Once a volume is attached…
…you can create a file system on top of these volumes, run a database, or use them in any other way you would use a block device
EBS volumes are placed…
…in a specific AZ, where they are automatically replicated to protect you from the failure of a single component
single component?
storage array
EBS volume types
General Purpose SSD (GP2) Provisioned IOPS SSD (IO1) Throughput Optimized HDD (ST1) Cold HDD (SC1) Magnetic (Standard)
General Purpose SSD (GP2)
General purpose, balances both price and performance
Ratio of 3 IOPS per GB with up to 10K IOPS and the ability to burst up to 3000 IOPS for extended periods of time for volumes under 1 Gib
Provisioned IOPS SSD (IO1)
Designed for I/O intensive apps such as large relational or NoSQL databases
Use if you need more than 10K IOPS
Can provision up to 20K IOPS per volume
Highest-performance SSD volume designed for mission-critical applications
Throughput Optimized HDD (ST1)
Big data Data warehousing Log processing Sequential data Cannot be a boot volume
Cold HDD (SC1)
Lowest cost storage for infrequently accessed workloads
File Server
Cannot be boot volumes
Magnetic (Standard)
Lowest cost per GB of all EBS volumes types that is bootable.
Ideal for workloads where data is accessed infrequently, and apps where the lowest storage cost is important
Can you mount 1 EBS volume to multiple EC2 instances?
No, use EFS instead
General Purpose SSD (GP2) Use Cases
- Recommended for most workloads
- System boot volumes
- Virtual desktops
- Low-latency interactive apps
- Development and test environments
Provisioned IOPS SSD (IO1) Use Cases
-Critical business applications that require sustained IOPS performance, or more than 10,000 IOPS or 160 MiB/s of throughput per volume
-Large database workloads, such as:
MongoDB
Cassandra
Microsoft SQL Server
MySQL
PostgreSQL
Oracle
Throughput Optimized HDD (ST1) Use Cases
- Streaming workloads requiring consistent, fast throughput at a low price
- Big data
- Data warehouses
- Log processing
- Cannot be a boot volume
Cold HDD (SC1) Use Cases
- Throughput-oriented storage for large volumes of data that is infrequently accessed
- Scenarios where the lowest storage cost is important
- Cannot be a boot volume
By default, if an EC2 instance is terminated, what happens to the EBS root volume attached to it?
The volume will be deleted since “Delete on Termination” is checked by default
Bootstrap scripts are placed in…
…User Data under “Advanced Details”
AWS tagging best practices
Tag everything!
Where do you request spot instances?
Purchasing Option in Configure Instance Details
Where do you request a dedicated host?
Tenancy in Configure Instance Details
To launch reserved instances…
Reserved Instances > Purchased Reserved Instances, add instances to cart
Encrypted boot volumes (default)
Root volumes cannot be encrypted by default. Other EBS volumes can be encrypted if you check Encrypted
Termination protection…
…is turned off by default. You must turn it on yourself if you want it.
On an EBS-backed instance, what is the default action if the instance is terminated?
The root EBS volume is deleted.
EBS root volumes of your DEFAULT AMI’s
cannot be encrypted, but you can use a third party tool to encrypt the root volume, or this can be done when creating AMIs using the console or API
A security group is…
…a virtual firewall
1 instance can have how many security groups?
Multiple. Also, multiple instances can be one security group
If you change security group rules…
…changes take effect immediately
If you allow inbound rules (e.g. HTTP, HTTPS, SSH) but don’t allow outbound rules, will those outbound rules affect the request?
No; since security groups are stateful, the inbound requests will be allowed back out automatically
Can you deny traffic with a security group?
No, only allow rules are allowed
The default security group…
…allows all inbound and outbound traffic by default
By default, all inbound traffic is…
…blocked
By default, all outbound traffic is…
…allowed
When creating a new volume…
…make sure it is in the same AZ as your instance, or you will not be able to attach it to your instance
After SSH into instance and elevating privileges, type what to find volumes?
lsblk
To attach a volume…
…you need to format and mount it
To check if a volume has data…
file -s e.g. file -s /dev/xvdf
“data” = no data
To format a volume…
mkfs -t ext4 . ext4 is file format for Linux
To mount a volume…
mount
e.g. mount /dev/xvdf /myfileserver
Which directory is created by default when you mount a volume?
lost+found
To unmount a volume…
umount
If you forget to unmount a volume when you try to detach it…
…use Force Detach
Where are snapshots stored?
S3
When another snapshot is taken…
…only changed data since your last snapshot is sent to S3, since snapshots are incremental
Can you make a volume from a snapshot?
Yes
Can you change the volume type, size when you make a volume from a snapshot?
Yes
What is stored on your root volume?
OS
Think of a snapshot as…
a photograph (point in time copies of volumes)
If you create a snapshot for the first time…
…it may take some time to create
What does RAID stand for?
Redundant Array of Independent Disks (putting together a bunch of disks as one disk)
RAID types
RAID 0, RAID 1, RAID 5, RAID 10
RAID 0
Striped, No Redundancy (if one disk fails, the entire volume fails), Good Performance (use: gaming)
RAID 1
Mirrored (take one disk, mirror a copy to another disk), Redundancy
RAID 5
at least 3 disks, good for reads, bad for writes, AWS does not recommend ever putting RAID 5’s on EBS
RAID 10
Striped & Mirrored, good redundancy, good performance
Where are RAID volumes used on AWS?
If you do not get disk I/O you require, add multiple volumes and create RAID array (usually RAID 0 or RAID 10 on AWS)
Best practice when launching Windows instances
Create a new keypair for Windows instances, separate from Linux instances
Username, password for Windows instances
User = Administrator Password = upload private key file into "Retrieve Password" window to obtain password
To manage disks…
Right-click, Disk Management. Right-click on an unallocated volume and choose volume type you want to create, select drive you want the RAID volume assigned to
How can I take a Snapshot of a RAID array - background?
Problem - Take a snapshot, the snapshot excludes data held in the cache by apps and the OS. This tends not to matter on a single volume; however, using multiple volumes in a RAID array, this can be a problem due to interdependencies of the array.
How can I take a Snapshot of a RAID array - continued
Stop the application from writing to disk. Flush all caches to the disk.
How can we do this? Freeze the file system, unmount the RAID array, shut down the associated EC2 instance (easiest)
What is an AMI?
AMI provides the info required to launch a virtual server in the cloud. Specify an AMI when you launch an instance, and you can launch as many instances from the AMI you need. You can also launch instances from as many different AMIs as you need
AMIs consist of…
a template for the root volume for the instance
launch permissions that control which AWS accounts can use the AMI to launch instances
a block device mapping that specifies the volumes to attach to the instance when it’s launched
T/F: AMIs are regional.
Yes, you can only launch an AMI from the region in which it is stored. However, you can copy AMIs to other regions using the console, command line, or EC2 API
select your AMI based on…
Region, OS, Architecture, Launch Permissions, Storage for the Root Device
Instance Store is also known as
Ephemeral Storage
EBS
Persistent Storage, fast provisioning times, more durability
Can you attach EBS volumes after launching an instance?
Yes
Can you attach instance store volumes after launching an instance?
No, but you can attach them before launching
Can instances with instance stores be stopped?
No, only reboot or terminate
Root device for EBS volume is created from
an EBS snapshot
Root device for instance store volume created from
a template stored in S3
Can you detach instance store volumes?
No
Which takes longer to provision, EBS or instance store?
Instance store
Can Instance store volumes be of any instance type?
No, there are limits on instance families
On an instance store volume, what happens if the host fails?
instance data is gone
What happens if you reboot both volume types?
You will not lose your data
Can volumes be stopped?
EBS - Yes
Instance store - No
Will root volumes be deleted on termination by default?
Yes. With EBS, you can tell AWS to keep the root volume
Health check ping path
file to test health check i.e. an html file saying that instance is healthy
Response timeout
how long it takes to do a healthcheck
Interval
how long to wait between healthchecks
Healthy threshold
how many consecutive health checks an instance must pass before becoming healthy
Unhealthy threshold
how many consecutive health checks an instance must fail before becoming unhealthy
Is IP address given for ELB?
No, a DNS name is given instead since the IP address may change
By default, how many AZs is an ELB deployed into?
2
Instances monitored by ELB are reported as either
In service or out of service
How do health checks work?
they check the instance health by talking to it