EC2 & Elastic Beanstalk & Lambda
EC2 & Elastic Beanstalk & Lambda
• Amazon EC2 reduces 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 changed.
• Amazon EC2 changes the economics of computing by allowing you to pay only for capacity that you actually
use.
EC2 Options
On Demand
• Users that want the low cost and flexibility of amazon EC2 without any up-front payment or long-term
commitment.
• Applications with short term, spiky, or unpredictable workloads that cannot be interrupted.
• Applications being developed or tested on Amazon EC2 for the first time.
EC2 Options
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
• Users able to make upfront payments to reduce their total computing costs even further.
EC2 Options
Capacity Reservations
• Capacity Reservation requests are granted or denied based on your EC2 instance limits and our available
capacity.
• When you create a Capacity Reservation, we reserve the specified capacity for your use.
• The reserved capacity is charged at the selected instance type’s On-Demand rate whether an instance is running
in it or not.
• You can also use your regional reserved instances with your Capacity Reservations to benefit from billing
discounts.
EC2 Options
Spot
• Enable you to bid whatever price you want for instance capacity, providing for even greater saving if your
applications have flexible start and end times.
• Users with large computing needs for large amount of additional capacity.
• If the spot instance is terminated by Amazon EC2, you will not be charged for a partial hour of usage. However,
if you terminated the instance yourself, you will be charged for any hour in which the instance ran.
Dedicated
• Autoscalling • Lambda
• Elastic IPs
• AMIs
• Maintenance Windows
• Placement Groups
What is EBS ..?
• Amazon EBS allows you to create storage volumes and attach them to Amazon EC2 instances.
• Once attached, you can create a file system on top of these volumes, run database, or use them in any other way
you would use a block device.
• Amazon EBS volumes are placed in a specific Availability Zone, where they are automatically replicated to
protect you from the failure of a single component.
EBS Volume Types
1. General Purpose SSD (GP2)
5. Magnetic (Standard)
EBS Volume Types
1. General Purpose SSD (GP2):
• Designed for I/O intensive applications such as large relational or NoSQL databases.
• Use if you need more than 10,000 IOPS.
EBS Volume Types
3. Throughput Optimized HDD (ST1):
• Lowest cost per gigabyte of all EBS volume types that is bootable.
• Magnetic volumes are ideal for workloads where data is accessed infrequently, and applications where the
lowest cost is important.
Note: You cannot mount 1 EBS volume to multiple EC2 instances, instead use EFS.
What is EFS ..?
• Amazon Elastic File System (Amazon EFS) is a file storage service for Amazon EC2 instances.
• Amazon EFS is easy to use and provides a simple interface that allows you to create and configure file system
quickly and easily.
• With Amazon EFS, storage capacity is elastic, growing and shrinking automatically as you add and remove
files, so your applications have the storage they need, when they need it.
• You can pay only the storage you use (no pre-provisioning required).
• It enables you to achieve fault tolerance in your applications, Seamlessly providing the required amount of load
balancing capacity needed to route application traffic.
• Operating at the request level, Application Load Balancers provide advanced routing, TLS termination and
visibility features targeted at application architectures, including micro services and containers.
Network Load Balancers
• Choose a Network Load Balancer when you need ultra-high performance and static IP addresses for your
application.
• Operating at the connection level, Network Load Balancers are capable of handling millions of requests per
second while maintaining ultra-low latencies.
• Choose a Classic Load Balancer when you have an existing application running in the EC2-Classic network.
Autoscaling
• Auto Scaling helps you ensure that you have the correct number of Amazon EC2 instances available to handle
the load for your application.
• Auto Scaling helps you maintain application availability and allows you to dynamically scale your
Amazon EC2 capacity up or down automatically according to conditions you define.
• You can also use Auto Scaling for Dynamic Scaling of EC2 instances in order to automatically increase the
number of Amazon EC2 instances during demand spikes to maintain performance and decrease capacity during
lulls to reduce costs.
• Placement groups are recommended for applications that benefit from low network latency, high network
throughput, or both.
• To provide the lowest latency, and the highest packet-per-second network performance for your placement
group, choose an instance type that supports enhanced networking.
• First, you create a placement group and then you launch multiple instances into the placement group.
• You can't move an existing instance into a placement group. You can create an AMI from your existing instance,
and then launch a new instance from the AMI into a placement group.
Amazon EBS vs Instance Store
Sr.No. EBS Instance Store
1 The root device for instance launched The root device for an instance launched from the
from the AMI is an Amazon EBS AMI is an instance store volume created from a
volume created from an Amazon EBS template stored in Amazon S3.
snapshot.
2 EBS backed instances can be stopped. Instance store volume cannot be stopped. If the
You will not lose the data on this underlying host fails, you will lose your data.
instance if it is stopped.
Note: You can reboot both, you will not lose your data. By default, both root volumes will be deleted on
termination, however with EBS volumes, you can tell AWS to keep the root device volume.
Elastic Beanstalk
What is Elastic Beanstalk ..?
• By using Elastic Beanstalk you can quickly deploy and manage applications in the AWS Cloud without
worrying about the infrastructure that runs those applications.
• AWS Elastic Beanstalk reduces management complexity without restricting choice or control.
• You simply upload your application and Elastic Beanstalk automatically handles the details of capacity
provisioning, load balancing, scaling and application health monitoring.
• Elastic Beanstalk supports applications developed in Java, PHP, .NET, Node.js, Python, and Ruby, as well as
different container types for each language.
Lambda
What is Lambda ..?
• AWS Lambda is a compute service that lets you run code without provisioning or managing servers.
• AWS Lambda executes your code only when needed and scales automatically, from a few requests per day to
thousands per second.
• You pay only for the compute time you consume - there is no charge when your code is not running.
• We can trigger lambda from multiple AWS service events. Like S3, Dynamo DB, API Gateway, Lex, Kinesis
etc.
• Runtime:
• key-value pairs that are accessible from your function code. These are useful to store configuration settings
without the need to change function code
• Encryption configuration:
• Select a KMS key to encrypt the environment variables at rest, or simply let Lambda manage the
encryption.
• Execution role:
• Network:
• DLQ Resource: Choose the AWS service to send event payload to after exceeding maximum retries.
SNS or SQS
• Enable active tracing : x-ray and charges are applied.
Lambda Invocation Types
• Event:
• RequestResponse (Default)
• DryRun
• It will automatically retry the invocation twice, with delays between retries.
• If you have specified a Dead Letter Queue for your function, then the failed event is sent to the
specified Amazon SQS queue or Amazon SNS topic. If you don't specify a Dead Letter Queue
(DLQ), which is not required and is the default setting, then the event will be discarded.