EC2 Fundamentals Flashcards
What is an EC2?
EC2 = Elastic Compute Cloud = Infra as a service
What are EC2 capabilities?
- Virtual Machines (EC2)
- Storing data on virtual drives (EBS)
- Distributing load across machines (ELB)
- Scaling the services using an auto-scaling group (ASG)
What OS Can you use on an EC2?
- Linux
- Windows
- Mac OS
What are the 7 settings you can choose on an EC2?
- OS
- CPU
- RAM
- Storage space
- Network Card (speed, public IP address)
- Firewall Rules (security group)
- Bootstrap script (configure at first launch) for EC2 user data
What are the 2 options of storage you can have in EC2?
- Network-attached (EBS & EFS)
- Hardware (EC2 Instance Store)
What is Bootstrapping?
launching commands when a machine starts (runs once at beginning)
What is the EC2 user data (bootstrap) used for?
To Automate boot tasks such as:
- Installing updates
- Installing software
- Downloading common files from internet
- Anything really
What user does the EC2 User Data script runs with?
Root (has sudo rights)
What are the EC2 instance types?
t2.micro
t2xlarge
These dictate vCPU, Mem (GiB), Storage, Network, EBS bandwidth
Which instance type of EC2 is included in the free tier?
t2.micro (up to 750 hours per month)
What happens when you stop and start an EC2 instance?
The public IP might change (the private wont)
How many instance types of EC2 are there?
7
What are the instance types of EC2?
- General Purpose
- Compute optimised
- Memory optimised
- Accelerated computing
- Storage optimised
- Instance features
- Measuring Instance performance
What does “m5.2xlarge” mean?
m = instance type
5 = generation
2xlarge = size within the instance class
What is a General Purpose EC2 instance type good for?
Great for diversity of workloads such as web servers or code repositories
Balance between:
1. compute
2. memory
3. networking
What are Compute Optimised EC2 instances good for?
Compute-intensive tasks that need high perf processors.
- batch processing workload
- media transcoding
- high perf web servers
- high perf computing (HPC)
- scientific modelling & ML
- dedicated gaming servers
What are Memory Optimised EC2 instances good for?
Fast performance for workloads that process large data sets in memory
- High perf relational/non relational database
- distributed web scale cache stores
- in-memory databases optimised for BI (Business intelligence)
- apps performing real-time processing of big unstructured data
What are Storage Optimised EC2 instances good for?
Good for storage-intensive tasks that need high sequential read/write access to large data sets on local storage
- High frequency online transaction processing (OLTP)
- Relational & NoSQL databases
- Cache for in-memory databases (Redis)
- Data warehousing apps
- Distributed file systems
What do Security Groups do?
Control how traffic is allowed in/out of EC2 instances
What kind of rules do Security Groups contain?
Allow rules only
What do Security Groups rules reference by? (what do they see and say yes or no)
Based on IP or Security Groups
How is a Security Group used? Give a scenario
You put the SG around an EC2, and they block everything. You then set the allow list for inbound/outbound traffic.
Are Security Groups like a firewall?
Yes
What do Security Groups regulate?
- Access to ports
- Authorised IP ranges - IPv4 / IPv6
- Inbound traffic
- Outbound traffic
Does a Security Group allow all inbound traffic by default?
No. You set who is allowed in
Does a Security Group allow all outbound traffic by default?
Yes
Can Security Groups be attached to multiple instances?
Yes
Can Security Groups be in multiple regions/VPC combinations at the same time?
No - locked down to a region/VPC combination
Will the EC2 instance see the traffic that a Security Group blocks?
No because the SG lives outside the EC2
What is a good practice for SHH and Security Groups?
To maintain one separate SG for SSH access
What does it mean if your application is timing out and is not accessible?
Security Group issue
If you application gets a “connection refused” error, is it a Security Group issue?
No - application error or not launched.
How can you Reference other security groups?
Instead of selecting which IPs can pass through the SG, you can select Security Groups instead. For example, you have an EC2 instance with Security Group, that security group can allow all the traffic from Security Group 2 & 3 which each has another instance inside of them.
What is port 22?
SSH (Secure Shell) - log into linux instance
What is port 21?
FTP (File Transfer Protocol) - upload files into a file share
What port is SFTP?
22 just like SSH (Secure Transfer Protocol) - upload files using SSH
What is port 80?
HTTP - access unsecured websites
What is port 443?
HTTPS - access secured websites
When do you use SSH?
When you want to log into your servers via the terminal and perform maintenance/actions
Which OS can use SSH?
- Linux
- Mac
- Windows 10 =>
Which OS cannot use SSH?
Win 10 <
What is an alternative if you cannot use SSH?
Putty
Which OS can use Putty?
Win 10 higher/lower
What is an EC2 instance connect?
Uses your web browser to connect to an EC2 instance.
What is the command for connecting to an EC2 instance?
ssh -i “keypair.pem”@<ip></ip>
What is the command to make the keypair private after you download it ?
chmod 0400 <keypair></keypair>
If you already have a .pem keypair and want to use Putty what can you do?
Convert it within Putty to a .ppk file.
What do you need to include in the Host Name (or IP address) filed in Putty?
ec2-user@<ip></ip>
ec2-user is already created in that linux instance from AWS
What command do you use to SSH from Win10 +?
ssh -i .<.pem> ec2-user@<ip></ip>
What is an alternative to SSH?
EC2 Instance Connect
What should you never do with your AWS Access Key ID and AWS Secret Access Key while SSH’d in an EC2?
Do not use AWS configure which will ask you to type out that info. If the instance is not private someone else can retrieve that info from using EC2 Connect.
What are On-Demand instances best for?
Short workload, predictable pricing, pay by second
What are reserved instances? (EC2)
1 & 3 year options
Used for long workloads
Convertible Reserved instances - long workloads with flexible instances
What are Savings Plans instances?
1 & 3 year options
commitment to an amount of usage, long workload
What are spot instances?
Short workloads
Cheap
Can lose instances (less reliable)
What are dedicated hosts instances?
You book an entire physical server, control instance placement
What are Dedicated Instances?
only for you, no other customers will share your hardware (single tenant)
What are Capacity Reservations instances?
reserve capacity in a specific AZ for any duration
Which EC2 instance has billing per second for Windows or Linux after the first minute?
EC2 on Demand
Which EC2 instance has billing per our for all OS except Win & Linux?
EC2 on Demand
Which EC2 instance plan has the highest cost but no upfront payment?
EC2 on Demand
Which EC2 instance plan has no long-term commitment?
EC2 on Demand
What is EC2 on demand recommended for?
Short-term & un-interrupted workloads
Which EC2 instance has up to 72% discount compared to on-demand?
Reserved Instances
What is the reservation period for EC2 Reserved Instances?
1 year or 3 years (discounts)
What are the payment options for EC2 Reserved Instances?
No upfront (+)
Partial upfront (++)
All upfront (+++)
What is the EC2 reserved instances scope?
Regional or Zonal (reserve capacity in an AZ)
Which EC2 instance is recommended for steady-state usage apps (databases)
EC2 Reserved Instances
What can you do with EC2 Reserved Instances in AWS Marketplace?
Buy & Sell
What are Convertible Reserved Instances?
Can change the EC2 instance type, instance family, OS, scope & tenancy
What discount do Convertible Reserved Instances have?
Up to 66%
Which EC2 instance can get a discount based on long-term usage (up to 72% - same as Reserved Instances)
EC2 Savings plans
Which EC2 instance commits to a certain type of usage ($10/hour for 1 or 3 years)
EC2 Savings plans
What happens to usage on an EC2 Savings Plans if it is exceeded?
Billed on the On-demand price
Which EC2 instance is locked to a specific family & AWS region (e.g. M5 in us-east-l)?
EC2 Savings Plans
What is EC2 Savings Plans instance flexible across?
Instance Size
OS type
Tenancy (Host, Dedicated, Default)
Which EC2 Instance type has discount up to 90%?
Spot instance
Which instances you can lose at any point of time if your max price is less than the current spot price?
Spot Instances
They are reserved to the highest bidder
Which are the MOST cost-effective instances in AWS?
Spot instnaces
Which instance is best for failure resilient workloads?
Spot
Which instances are best for batch jobs
Spot
Instances that are best for Data analysis
Spot
Instances best for Image processing
Spot
Instances best for distributed workloads
Spot instances
Instances best for workloads with flexible start & end time
Spot
Which instances are not suitable for critical jobs or databases?
Spot
What are EC2 Dedicated Hosts?
Physical Server with EC2 instance capacity fully dedicated to your use
Which EC2 instance allows you to address compliance requirements and use your existing server-bound software licenses?
EC2 Dedicated Hosts
What are EC2 Dedicated Hosts Purchasing Options?
On-demand (per second for active Dedicated Host)
Reserved (1 or 3 years - No upfront, partial, all upfront)
Which EC2 instance is the most expensive option?
EC2 Dedicated Host
Which EC2 instance is best for software that have complicated licensing model (BYOL - Bring your own license)
EC2 Dedicated Hosts
Which EC2 instance is best for companies that have strong regulatory or compliance needs?
EC2 Dedicated Hosts
What are EC2 Dedicated Instances?
Instance that runs on hardware thats dedicated to you
Which instance may share hardware with other instances in the same account?
EC2 Dedicated Instances
Which instance has no control over instance placement (can move hardware after Stop / Start)
EC2 Dedicated Instances
What is the Difference between Dedicated Hosts and Dedicated Instance?
Dedicated Host hardware can be shared across many instances in the same account and you get access to the physical server.
Dedicated Instance is deployed on reserved hardware for each tenant (single tenant)
Which EC2 can Reserve On-Demand instances capacity in a specific AZ for any duration?
EC2 Capacity Reservations
Which EC2 you always have access to their capacity when you need it?
EC2 Capacity Reservations
Which EC2 has no time commitment? (create/cancel any time) and no billing discounts?
EC2 Capacity Reservations
Which EC2 can be combined with Regional Reserved Instances and Savings Plans to benefit from billing discounts?
EC2 Capacity Reservations
Which EC2 you are charged on demand rate whether you run instances or not?
EC2 Capacity Reservations
What is EC2 Capacity Reservations best suited for?
Short-term, uninterrupted workloads that need to be in a specific AZ
Scenario - On Demand
Coming and staying in a hotel whenever we like, and pay full price
Scenario - Reserved
If you plan ahead to stay at the hotel for a long time you can get a good discount
Scenario - Savings Plans
You pay a certain amount per hour for a certain period and stay in any room type (you can change ec2 type over time (size, os etc)
Scenario - Spot instances
Bid for the empty room and highest bidder keeps the rooms. You can get kicked out at any time
Scenario - Dedicated Hosts
Book the entire building of the Hotel
Scenario - Capacity Reservations
Book a room for a period of time with full price even you don’t use it - just in case you need it.
What is a Spot Request?
It is a request that contains the type of the request (one-time | persistent) along with other information needed to create the Spot instance. It also has information such as valid from, valid until for the request.
If its a one-time and your spot instance stops then you will need another request to recreate the spot instance. If its persistent, then the request stays alive and the instance gets created again from the same request.
When can you ONLY cancel Spot Instance requests?
When the state of the spot request is: Open, Active, or Disabled
Does a Spot instance get terminated if you cancel a spot request?
No - you need to terminate the instance
What is the correct order of terminating Spot instances?
First the request, and then the instance
What are Spot Fleets?
Set of spot instances & optional On-Demand Instances
What does Spot fleet due when there is a target and price constraints?
It will try to meet target capacity with price constraints in place
What are launch pools?
They are instance types, OS, Availability Zone and Spot Fleet can choose from multiple pools that you have set up
Can Spot Fleets choose from multiple launch pools?
Yes they can choose from the ones you set up
What happens to Spot Fleets when they reach capacity or max cost?
They stop launching instances
What are the 3 strategies for Spot Fleets?
lowestPrice
diversified
capacityOptimised
What is the lowestPrice strategy of a Spot Fleet?
Spot Fleet will choose instances from the pool with the lowest price (cost optimisation, short workload)
What is the diversified strategy of a Spot Fleet?
Distributed across all pools (great for availability, long workloads)
What is the capacityOptimised strategy of a Spot Fleet?
pool with the optimal capacity for the number of instances
What does Spot Fleet allow us to do?
Automatically request spot Instances with the lowest price
Spot Request vs Spot Fleet?
You create the spot request and choose what goes in the request where as Spot Fleet you create the pools, and then it chooses on its own which one is needed to do what you want at the lowest price
What EC2 instance type should you use if you have a database on-prem, and the database has thousands of requests per second?
Storage Optimised EC2 because they are best for workloads which require high, sequential read/write access to large data sets on local storage