This is part of a blog series giving a high level overview of the different services examined on the AWS Solution Architect Associate exam, to view the whole series click here.
- EC2 provides secure, resizable compute capacity.
- Gives you complete control of your computing resources including choice of storage, processor, networking and operating system.
- Allows you to increase/decrease capacity in minutes
- You need to create a key pair — public & private for asymmetric encryption.
- The EC2 Root volume is a virtual disk where the OS is installed, it can only be launched on SSD or Magnetic.
- Termination protection is turned off by default (turn on to make sure user doesn’t accidentally terminate instances)
- On an EBS backed instance, the root EBS volume is deleted when the instance is terminated
- Bootstrap scripts are code that gets ran as soon as your EC2 instance first boots up.
1.On-Demand — Fixed rate for compute capacity by hour or second with no commitment or up front costs. Typically used for short term, spiky or unpredictable workloads that can’t be interrupted.
2. Reserved — You have a capacity reservation which offers significant discount compared to on-demand, but you are require to have a contact for 1–3 years. Used for applications with steady predictable use. However, you cant move between regions.
Types of Reserved pricing:
- Standard reserved instances — Provides the most discount (up to 75% off) and the more you pay upfront /the longer the contact, the cheaper the price.
- Convertible reserved instances — up to 54% off and allows you to change between instance types e.g. t1-t4 as long as its of greater or equal value
- Scheduled reserved instances — can be launched within a time window to match capacity of a predictable schedule.
3. Spot — when AWS has excess capacity it drops the price so people can use that capacity —but they can take it back at any time. You can set the price you are willing to pay and it will run when its below or at that price — if it goes above that price you lose it. Provides up to 90% discount and typically used for apps with flexible start/end times, But don’t use for anything critical that needs to be online all the time.
4. Dedicated Hosts — Physical EC2 server dedicated to your use. Can reduce costs by allowing you to use your existing software licenses e.g. if you’re locked in with a vendor such as Oracle. You may also need to use in order to meet regulatory requirements.
- Collection of spot instances and optionally on-demand instances. Attempts to launch a number of them together to meet a certain capacity within your price budget.
- The allocation of spot instances depends on how they fulfil your spot fleet request from the possible pool of instances.
Spot Fleet Strategies
Lowest Price → This is the default strategy. Chooses the fleet pool with the lowest price.
Diversified → Distributed across all pools.
Capacity Optimised → Pool for optimal capacity for the number of instances launching.
InstancePoolsToUseCount → Distributed across the number of pools you specify — this can only be used with the lowest price option.
- Basically a virtual firewall for your EC2 Instances
- All inbound traffic is blocked by default, but all outbound traffic is allowed.
- You add rules to the security group to allow traffic in.
- Changes to a security groups rules take effect immediately and are automatically applied to all instances associated with that group.
- Security Groups = STATEFUL; when you create an inbound rule, an outbound one is created by default.
- Security groups are only permissive — you can’t create rules to deny access, only allow access.
- You can have more than one security group attached to an EC2 instance and in this case the rules from each are aggregated.
- Allows you to hibernate your EC2 instances, so that you can stop them and pick back up where you left off again.
- It does this by saving the content from the in-memory state of the instance (RAM) to your EBS root volume.
- Useful for long running services and services that take long to boot.
- Can’t hibernate for more than 60 days
- Once in hibernation mode there is no hourly charge — you only pay for the elastic IP Address & other attached volumes
- Boots up a lot faster after hibernation as it does not need to reload the operating system.
EC2 Placement Groups
- A way of placing EC2 Instances so that instances are spread across the underlying hardware to minimise failures.
- Placement group names need to be unique within your account
- Only certain instances can be launched in placement groups e.g compute optimised, CPU, memory optimised & storage optimised.
- You can’t merge placement groups, but you can move an existing instance into a placement group.
- There is no charge associated with creating placement groups
3 Types of placement groups:
- Clustered Placement:
Grouping instances close together within a single Availability Zone. Typically used to achieve low network latency & high throughput. Recommended you have the same type on instances in the cluster.
2. Spread Placement:
Opposite to clustered placement group, instances are placed on distinct racks on the underlying hardware. Typically used for small numbers of critical instances that should be kept separate from each other, so that one failure would not affect another. Spread placement groups can span multiple Availability Zones.
EC2 creates partitions by dividing each group into logical segments. Each partition has its own set of racks, network and power source to help isolate the impact of a hardware failure. Can be multi AZ.