# EC2

### Elastic Cloud Compute

**Compute**: closely related to CPU/RAM

EC2 is a popular service. Other related services are here.

<https://aws.amazon.com/products/compute/>

EC2 service can be broken down into the following

*AMI (Amazon Machine Images)*&#x20;

*Instance Types*&#x20;

*Instance Purchasing Options*&#x20;

*Tenancy*&#x20;

*User Data*&#x20;

*Storage Options*&#x20;

*Security*

AMI - Image baseline with an OS, systems, and applications along with any custom configuration.

Custom AMI can also be built with user-defined customizations.

**EC2 Instance Types**

ECU - EC2 Units&#x20;

vCPU - virtual CPU&#x20;

Processor - Type of Processor&#x20;

AES - Adv encryption system&#x20;

AVX - adv vector extensions audio /video&#x20;

Turbo - whether supports turbo boost or not

**Purchasing Options**

* O&#x6E;**-**&#x44;emand
* Reserved
* Scheduled
* Spot
* On-Demand Capacity Reservations

**On-Demand**

* It can be launched any time and used for as long as needed.
* Flat rate.
* Ideal for development and testing.

**Reserved**

* Purchases for a set period for a reduced cost.
* Complete payment for 1 or 3 year time. Big discount.
* Partial upfront payment for a smaller discount.
* No Upfront. The smallest discount is applied.
* Best suited for long-term, predictable workloads.

**Scheduled**

* Reservations on a recurring schedule daily/weekly/monthly.
* Even if the instance is not used, customers will be charged.

Best suited for scheduled workloads.

**Spot Instances**

* Bid for unused EC2 computes resources.
* No guarantees for a fixed period.
* Fluctuation of prices based on supply and demand.
* Chances instance will be taken away if someone bids a higher price.
* Purchase large EC2 instances at very low prices.
* Nonpriority tasks.

**On-Demand Capacity Reservation**

* Reserve based on different requirements such as AMI, platform, and AZ for a given time.

### Tenancy <a href="#tenancy" id="tenancy"></a>

**Shared Tenancy**

* Any available host with required hosts.
* Multiple customers may use the same host.

**Dedicated Instance**

* Hosted on hardware that no other customers can access.
* Incur additional charges.
* It may be required to meet compliance.

**Dedicated Host**

* Similar to Dedicated Instance
* Additional visibility and control of the physical host.
* Allows you to use existing Software license (for example, windows server license purchased outside AWS)
* Allows using the same host for several instances.

**Storage**

**Persistent Storage**

* Elastic Block Storage (EBS) Volumes / Logically attached via AWS network.
* Automatically replicated.
* Encryption is available.

**Ephemeral Storage - Local storage**

* Physically attached to the underlying host.
* When the instance is stopped or terminated, all the data is lost.
* Rebooting will keep the data intact.

#### DEMO - Deploy EC2
