Amazon Web Services
Amazon Web Services
Amazon Web Services
• AWS now spans 76 Availability Zones within 24 geographic regions around the
world, and has announced plans for nine more Availability Zones and three more
AWS Regions in Indonesia, Japan, and Spain.
Magic Quadrant for Cloud Infrastructure as a
Service, Worldwide (2019)
Trusted by…..
Companies using AWS..
• Instagram
• Zoopla
• Smugmug
• Pinterest
• Netflix
• Dropbox
• Etsy
• Talkbox
• Playfish
• Ftopia
History
• 2002- AWS services launched
• 2006- Launched its cloud products
• 2012- Holds first customer event
• 2015- Reveals revenues achieved of $4.6 billion
• 2016- Surpassed $10 billon revenue target
• 2016- Release snowball and snowmobile
• 2018- Offers 120+ cloud services
• 2020- offers 175+ cloud services.
Contd..
• Hosting vs Cloud
What is Cloud Computing?
Cloud computing
• Infrastructure as a service
• Platform as a service
• Software as a service
IaaS
• Infrastructure as a Service, sometimes abbreviated as IaaS, contains the basic
building blocks for cloud IT and typically provide access to networking features,
computers (virtual or on dedicated hardware), and data storage space.
• Infrastructure as a Service provides you with the highest level of flexibility and
management control over your IT resources and is most similar to existing IT
resources that many IT departments and developers are familiar with today.
PaaS
• Platforms as a service remove the need for organizations to manage the
underlying infrastructure (usually hardware and operating systems) and allow you
to focus on the deployment and management of your applications.
• This helps you be more efficient as you don’t need to worry about resource
procurement, capacity planning, software maintenance, patching, or any of the
other undifferentiated heavy lifting involved in running your application.
SaaS
• Software as a Service provides you with a completed product that is run and
managed by the service provider. In most cases, people referring to Software as a
Service are referring to end-user applications.
• With a SaaS offering you do not have to think about how the service is
maintained or how the underlying infrastructure is managed; you only need to
think about how you will use that particular piece of software.
• A common example of a SaaS application is web-based email where you can send
and receive email without having to manage feature additions to the email
product or maintaining the servers and operating systems that the email program
is running on.
Cloud computing Deployment Models
• Amazon Web Services (AWS) is certified as a PCI DSS 3.2 Level 1 Service Provider,
the highest level of assessment available. The compliance assessment was
conducted by Coalfire Systems Inc., an independent Qualified Security Assessor
(QSA).
• Amazon EC2 supports the processing, storage, and transmission of credit card
data by a merchant or service provider, and has been validated as being
compliant with Payment Card Industry (PCI) Data Security Standard (DSS).
• For the list of AWS services that are PCI DSS compliant, see PCI tab on
https://aws.amazon.com/compliance/services-in-scope/
Basics…
• 1. AMI :
• An Amazon Machine Image (AMI) is a template that contains a software
configuration (for example, an operating system, an application server, and
applications). From an AMI, you launch an instance, which is a copy of the AMI
running as a virtual server in the cloud. You can launch multiple instances of an
AMI, as shown in the following figure.
Which OS supported?
• On-Demand Instances – Pay, by the second, for the instances that you launch.
• Spot Instances – Request unused EC2 instances, which can reduce your Amazon
EC2 costs significantly.
• Dedicated Hosts – Pay for a physical host that is fully dedicated to running your
instances, and bring your existing per-socket, per-core, or per-VM software
licenses to reduce costs.
• Dedicated Instances – Pay, by the hour, for instances that run on single-tenant
hardware.
• Partition – spreads your instances across logical partitions such that groups of instances in
one partition do not share the underlying hardware with groups of instances in different
partitions. This strategy is typically used by large distributed and replicated workloads,
such as Hadoop, Cassandra, and Kafka.
• Spread – strictly places a small group of instances across distinct underlying hardware to
reduce correlated failures.
• Application Load Balancer is best suited for load balancing of HTTP and HTTPS
traffic and provides advanced request routing targeted at the delivery of modern
application architectures, including microservices and containers.
• Operating at the individual request level (Layer 7), Application Load Balancer
routes traffic to targets within Amazon Virtual Private Cloud (Amazon VPC) based
on the content of the request.
Network Load balancer
• Network Load Balancer is best suited for load balancing of Transmission Control
Protocol (TCP), User Datagram Protocol (UDP) and Transport Layer Security (TLS)
traffic where extreme performance is required.
• Operating at the connection level (Layer 4), Network Load Balancer routes traffic
to targets within Amazon Virtual Private Cloud (Amazon VPC) and is capable of
handling millions of requests per second while maintaining ultra-low latencies.
Network Load Balancer is also optimized to handle sudden and volatile traffic
patterns
Classic load balancer
• Classic Load Balancer provides basic load balancing across multiple Amazon EC2
instances and operates at both the request level and connection level. Classic
Load Balancer is intended for applications that were built within the EC2-Classic
network.
Why Load Balancer
• An Auto Scaling group contains a collection of Amazon EC2 instances that are
treated as a logical grouping for the purposes of automatic scaling and
management.
• An Auto Scaling group also enables you to use Amazon EC2 Auto Scaling features
such as health check replacements and scaling policies.
• Both maintaining the number of instances in an Auto Scaling group and
automatic scaling are the core functionality of the Amazon EC2 Auto Scaling
service.
Contd..
• The size of an Auto Scaling group depends on the number of instances that you
set as the desired capacity. You can adjust its size to meet demand, either
manually or by using automatic scaling.
• Two types of launch methods available
• 1. Launch Template.
• 2. Launch Configuration.
Contd.
• Amazon Elastic Block Store (EBS) is an easy to use, high performance block
storage service designed for use with Amazon Elastic Compute Cloud (EC2) for
both throughput and transaction intensive workloads at any scale. A broad range
of workloads, such as relational and non-relational databases, enterprise
applications, containerized applications, big data analytics engines, file systems,
and media workflows are widely deployed on Amazon EBS.
Contd..
• You can choose from four different volume types to balance optimal price and
performance. You can achieve single digit-millisecond latency for high
performance database workloads such as SAP HANA or gigabyte per second
throughput for large, sequential workloads such as Hadoop. You can change
volume types, tune performance, or increase volume size without disrupting your
critical applications, so you have cost-effective storage when you need it.
Contd..
• Amazon EBS provides the following volume types, which differ in performance
characteristics and price, so that you can tailor your storage performance and
cost to the needs of your applications.
• The volumes types fall into two categories:
1. SSD-backed volumes optimized for transactional workloads involving frequent
read/write operations with small I/O size, where the dominant performance
attribute is IOPS
2. HDD-backed volumes optimized for large streaming workloads where
throughput (measured in MiB/s) is a better performance measure than IOPS
Solid-state drives (SSD) Hard disk drives (HDD)
Volume type General Purpose SSD (gp2) Provisioned IOPS SSD (io1) Throughput Optimized HDD (st1) Cold HDD (sc1)
Max IOPS per volume 16,000 (16 KiB I/O) * 64,000 (16 KiB I/O) † 500 (1 MiB I/O) 250 (1 MiB I/O)
Max throughput per volume 250 MiB/s * 1,000 MiB/s † 500 MiB/s 250 MiB/s
Dominant performance
IOPS IOPS MiB/s MiB/s
attribute
EBS Snapshots
• Incremental – only backup changed blocks
• EBS backups use IO and you shouldn’t run them while your application is
handling a lot of traffic
• Snapshots will be stored in S3 (but you won’t directly see them)
• Not necessary to detach volume to do snapshot, but recommended
• Max 100,000 snapshots
• Can copy snapshots across AZ or Region
• Can make Image (AMI) from Snapshot
• EBS volumes restored by snapshots need to be pre-warmed (using fio or dd
command to read the entire volume)
EBS Migration
• Amazon EFS provides scalable file storage for use with Amazon EC2. You can
create an EFS file system and configure your instances to mount the file system.
You can use an EFS file system as a common data source for workloads and
applications running on multiple instances in multiple AZs
Contd..
Contd..
• Managed NFS (network file system) that can be mounted on many EC2
• EFS works with EC2 instances in multi-AZ
• Highly available, scalable, expensive (3x gp2), pay per use/provisioned.
Relational Database Service (RDS)
Introduction
• Amazon Relational Database Service (Amazon RDS) makes it easy to set up,
operate, and scale a relational database in the cloud. It provides cost-efficient and
resizable capacity while automating time-consuming administration tasks such as
hardware provisioning, database setup, patching and backups. It frees you to
focus on your applications so you can give them the fast performance, high
availability, security and compatibility they need.
• It’s a managed DB service for DB use SQL as a query language
Available Databases
• Amazon RDS is available on several database instance types - optimized for
memory, performance or I/O - and provides you with six familiar database
engines to choose from, including Amazon Aurora, PostgreSQL, MySQL,
MariaDB, Oracle Database, and SQL Server.
• You can use the AWS Database Migration Service to easily migrate or replicate
your existing databases to Amazon RDS.
Why to use RDS over EC2 ?
• Managed service:
• Continuous backups and restore to specific timestamp (Point in Time
Restore)!
• Monitoring dashboards
• Read replicas for improved read performance
• Multi AZ setup for DR (Disaster Recovery)
• Maintenance windows for upgrades
• Scaling capability (vertical and horizontal)
• you can’t SSH into your instances (You need not actually).
Amazon Aurora
• Aurora is a proprietary technology from AWS (not open sourced)
• Postgres and MySQL are both supported as Aurora DB (that means your
drivers will work as if Aurora was a Postgres or MySQL database)
• Aurora is “AWS cloud optimized” and claims 5x performance improvement
over MySQL on RDS, over 3x the performance of Postgres on RDS
• Aurora storage automatically grows in increments of 10GB, up to 64 TB.
• Aurora can have 15 replicas while MySQL has 5, and the replication process
is faster (sub 10 ms replica lag)
• Failover in Aurora is instantaneous. It’s HA native.
• Aurora costs more than RDS (20% more) – but is more efficient
AWS ElastiCache
Introduction
• ElastiCache is to get managed Redis or Memcached
• Caches are in-memory databases with really high performance, low latency
• Helps reduce load off of databases for read intensive workloads
• Helps make your application stateless
• Write Scaling using sharding
• Read Scaling using Read Replicas
• Multi AZ with Failover Capability
• AWS takes care of OS maintenance , optimizations, setup,
configuration, monitoring, failure recovery and backups
Redis
Redis is an in-memory key-value store
Super low latency (sub ms)
Cache survive reboots by default (it’s called persistence)
Easy to host
User sessions
Leaderboard (for gaming)
Distributed states
Relieve pressure on databases (such as RDS)
Multi AZ with Automatic Failover for disaster recovery if you don’t want to
lose your cache data
Support for Read Replicas
Memcached
• Memcached is an in-memory object store
• Cache doesn’t survive reboots
• Use cases:
• Quick retrieval of objects from memory
• Cache often accessed objects
• Overall, Redis has largely grown in popularity and has better feature
sets than Memcached.
• Redis is better for caching needs.
Elastic BeanStalk
Introduction
• AWS Elastic Beanstalk is an easy-to-use service for deploying and scaling web
applications and services developed with Java, .NET, PHP, Node.js, Python, Ruby,
Go, and Docker on familiar servers such as Apache, Nginx, Passenger, and IIS.
• You can simply upload your code and Elastic Beanstalk automatically handles the
deployment, from capacity provisioning, load balancing, auto-scaling to
application health monitoring. At the same time, you retain full control over the
AWS resources powering your application and can access the underlying resources
at any time.
• There is no additional charge for Elastic Beanstalk - you pay only for the AWS
resources needed to store and run your applications.
Benefits
• Managed WebApp service.
• Fast and simple to begin.
• Developer productivity.
• Impossible to outgrow.
• Complete resource control.
AWS Simple Storage Service
Introduction
• Amazon Simple Storage Service (Amazon S3) is an object storage service that
offers industry-leading scalability, data availability, security, and performance.
This means customers of all sizes and industries can use it to store and protect
any amount of data for a range of use cases, such as websites, mobile
applications, backup and restore, archive, enterprise applications, IoT devices,
and big data analytics.
• Amazon S3 provides easy-to-use management features so you can organize your
data and configure finely-tuned access controls to meet your specific business,
organizational, and compliance requirements. Amazon S3 is designed for
99.999999999% (11 9's) of durability, and stores data for millions of applications
for companies all around the world.
Introduction
• Amazon S3 is one of the main building blocks of AWS
• It’s advertised as ”infinitely scaling” storage
• It’s widely popular and deserves its own section
• Many websites use AWS S3 as a backbone
• Many AWS services uses AWS S3 as an integration as well
Introduction
Use cases
• Backup and restore
• Disaster recovery (DR)
• Archive
• Data lakes and big data analytics
• Hybrid cloud storage
• Cloud-native applications
Buckets
• Amazon S3 allows people to store objects (files) in “buckets”
(directories)
• Buckets must have a globally unique name
• Buckets are defined at the region level
• Naming convention
• No uppercase
• No underscore
• 3-63 characters long
• Not an IP
• Must start with lowercase letter or number
Objects
• Objects (files) have a Key. The key is the FULL path:
• • <my_bucket>/my_file.txt
• • There’s no concept of “directories” within buckets.(just a key with /)
• Object Values are the content of the body:
• • Max Size is 5TB
• Metadata (list of text key / value pairs – system or user metadata)
• • Tags (Unicode key / value pair – up to 10) – useful for security /
lifecycle
• • Version ID (if versioning is enabled)
AWS S3 Versioning
• You can version your files in AWS S3
• It is enabled at the bucket level
• Same key overwrite will increment the “version”: 1, 2, 3….
• It is best practice to version your buckets
• Protect against unintended deletes (ability to restore a version)
• Easy roll back to previous version
• Any file that is not versioned prior to enabling versioning will have
version “null”
S3 Encryption
S3 Encryption for Objects
• There are 4 methods of encrypting objects in S3
1. SSE-S3: encrypts S3 objects using keys handled & managed by AWS
2. SSE-KMS: leverage AWS Key Management Service to manage
encryption keys
3. SSE-C: when you want to manage your own encryption keys
4. Client Side Encryption
Storage classes
• S3 Standard
• Amazon S3 Intelligent-Tiering
• Amazon S3 Standard-Infrequent Access
• Amazon S3 One Zone-Infrequent Access
• Amazon S3 Glacier
• Amazon S3 Glacier Deep Archive
S3 Standard
• Low latency and high throughput performance
• Designed for durability of 99.999999999% of objects across multiple
Availability Zones
• Resilient against events that impact an entire Availability Zone
• Designed for 99.99% availability over a given year
• Backed with the Amazon S3 Service Level Agreement for availability
• Supports SSL for data in transit and encryption of data at rest
• S3 Lifecycle management for automatic migration of objects to other
S3 Storage Classes
Contd..
• S3 Standard offers high durability, availability, and performance object storage for
frequently accessed data. Because it delivers low latency and high throughput, S3
Standard is appropriate for a wide variety of use cases, including cloud
applications, dynamic websites, content distribution, mobile and gaming
applications, and big data analytics.
• S3 Storage Classes can be configured at the object level and a single bucket can
contain objects stored across S3 Standard, S3 Intelligent-Tiering, S3 Standard-IA,
and S3 One Zone-IA. You can also use S3 Lifecycle policies to automatically
transition objects between storage classes without any application changes.
Amazon S3 Intelligent-Tiering
1. Same low latency and high throughput performance of S3 Standard
2. Small monthly monitoring and auto-tiering fee
3. Automatically moves objects between two access tiers based on changing
access patterns
4. Designed for durability of 99.999999999% of objects across multiple
Availability Zones
5. Resilient against events that impact an entire Availability Zone
6. Designed for 99.9% availability over a given year
7. Backed with the Amazon S3 Service Level Agreement for availability
8. Supports SSL for data in transit and encryption of data at rest
9. S3 Lifecycle management for automatic migration of objects to other S3
Storage Classes
Contd..
• The S3 Intelligent-Tiering storage class is designed to optimize costs by
automatically moving data to the most cost-effective access tier, without
performance impact or operational overhead.
• It works by storing objects in two access tiers:
• one tier that is optimized for frequent access and
• another lower-cost tier that is optimized for infrequent access.
Contd..
• For a small monthly monitoring and automation fee per object, Amazon S3
monitors access patterns of the objects in S3 Intelligent-Tiering, and moves the
ones that have not been accessed for 30 consecutive days to the infrequent
access tier.
• If an object in the infrequent access tier is accessed, it is automatically moved
back to the frequent access tier. There are no retrieval fees when using the S3
Intelligent-Tiering storage class, and no additional tiering fees when objects are
moved between access tiers. It is the ideal storage class for long-lived data with
access patterns that are unknown or unpredictable.
Amazon S3 Standard-Infrequent Access
• Same low latency and high throughput performance of S3 Standard
• Designed for durability of 99.999999999% of objects across multiple
Availability Zones
• Resilient against events that impact an entire Availability Zone
• Data is resilient in the event of one entire Availability Zone destruction
• Designed for 99.9% availability over a given year
• Backed with the Amazon S3 Service Level Agreement for availability
• Supports SSL for data in transit and encryption of data at rest
• S3 Lifecycle management for automatic migration of objects to other S3
Storage Classes
Contd.
• S3 Standard-IA is for data that is accessed less frequently, but requires rapid
access when needed. S3 Standard-IA offers the high durability, high throughput,
and low latency of S3 Standard, with a low per GB storage price and per GB
retrieval fee. This combination of low cost and high performance make S3
Standard-IA ideal for long-term storage, backups, and as a data store for disaster
recovery files.
Amazon S3 One Zone-Infrequent Access
• † Because S3 One Zone-IA stores data in a single AWS Availability Zone, data stored in this
storage class will be lost in the event of Availability Zone destruction.
Contd.
• S3 One Zone-IA is for data that is accessed less frequently, but requires rapid
access when needed. Unlike other S3 Storage Classes which store data in a
minimum of three Availability Zones (AZs), S3 One Zone-IA stores data in a single
AZ and costs 20% less than S3 Standard-IA.
• S3 One Zone-IA is ideal for customers who want a lower-cost option for
infrequently accessed data but do not require the availability and resilience of S3
Standard or S3 Standard-IA. It’s a good choice for storing secondary backup
copies of on-premises data or easily re-creatable data. You can also use it as
cost-effective storage for data that is replicated from another AWS Region using
S3 Cross-Region Replication.
Archive
• Designed for durability of 99.999999999% of objects across multiple
Availability Zones
• Data is resilient in the event of one entire Availability Zone
destruction
• Supports SSL for data in transit and encryption of data at rest
• Low-cost design is ideal for long-term archive
• Configurable retrieval times, from minutes to hours
• S3 PUT API for direct uploads to S3 Glacier, and S3 Lifecycle
management for automatic migration of objects
S3 Glacier
• S3 Glacier is a secure, durable, and low-cost storage class for data archiving. You
can reliably store any amount of data at costs that are competitive with or
cheaper than on-premises solutions.
• To keep costs low yet suitable for varying needs, S3 Glacier provides three
retrieval options that range from a few minutes to hours. You can upload objects
directly to S3 Glacier, or use S3 Lifecycle policies to transfer data between any of
the S3 Storage Classes for active data (S3 Standard, S3 Intelligent-Tiering, S3
Standard-IA, and S3 One Zone-IA) and S3 Glacier
Deep Archive
• Designed for durability of 99.999999999% of objects across multiple
Availability Zones
• Lowest cost storage class designed for long-term retention of data
that will be retained for 7-10 years
• Ideal alternative to magnetic tape libraries
• Retrieval time within 12 hours
• S3 PUT API for direct uploads to S3 Glacier Deep Archive, and S3
Lifecycle management for automatic migration of objects
Glacier deep archive
• S3 Glacier Deep Archive is Amazon S3’s lowest-cost storage class and supports
long-term retention and digital preservation for data that may be accessed once
or twice in a year. It is designed for customers — particularly those in
highly-regulated industries, such as the Financial Services, Healthcare, and Public
Sectors — that retain data sets for 7-10 years or longer to meet regulatory
compliance requirements.
• S3 Glacier Deep Archive complements Amazon S3 Glacier, which is ideal for
archives where data is regularly retrieved and some of the data may be needed in
minutes. All objects stored in S3 Glacier Deep Archive are replicated and stored
across at least three geographically-dispersed Availability Zones, protected by
99.999999999% of durability, and can be restored within 12 hours.
S3 Versioning
• Versioning enables you to keep multiple versions of an object in one
bucket.
• It is enabled at the bucket level
• Same key overwrite will increment the “version”: 1, 2, 3….
• It is best practice to version your buckets
• Protect against unintended deletes (ability to restore a version)
• Easy roll back to previous version
• Any file that is not versioned prior to enabling versioning will have
version “null”
S3 Encryption
• You can easily customize the network configuration of your Amazon VPC. For
example, you can create a public-facing subnet for your web servers that have
access to the internet. You can also place your backend systems, such as databases
or application servers, in a private-facing subnet with no internet access. You can
use multiple layers of security, including security groups and network access
control lists, to help control access to Amazon EC2 instances in each subnet.
CIDR
• Your users can easily navigate to this URL and see the image. But they probably
don't know that their request was routed from one network to another—through
the complex collection of interconnected networks that comprise the
internet—until the image was found.
Contd..
• CloudFront speeds up the distribution of your content by routing each user
request through the AWS backbone network to the edge location that can best
serve your content. Typically, this is a CloudFront edge server that provides the
fastest delivery to the viewer. Using the AWS network dramatically reduces the
number of networks that your users' requests must pass through, which improves
performance. Users get lower latency—the time it takes to load the first byte of
the file—and higher data transfer rates.
• You also get increased reliability and availability because copies of your files (also
known as objects) are now held (or cached) in multiple edge locations around the
world.
Contd..
Snowball
Introduction
• Migrate Petabyte-Scale Data to the Cloud.
• Snowball is a petabyte-scale data transport solution that uses secure
appliances to transfer large amounts of data into and out of the AWS
cloud. Using Snowball addresses common challenges with large-scale
data transfers including high network costs, long transfer times, and
security concerns.
Contd.
• Physical data transport solution that helps moving TBs or PBs of data in or
out of AWS
• Alternative to moving data over the network (and paying network fees)
• Secure, tamper resistant, uses KMS 256 bit encryption
• Tracking using SNS and text messages. E-ink shipping label
• Pay per data transfer job
• Use cases: large data cloud migrations, DC decommission, disaster recovery
• If it takes more than a week to transfer over the network, use Snowball
devices!
Snowball Process
1. Request snowball devices from the AWS console for delivery
2. Install the snowball client on your servers
3. Connect the snowball to your servers and copy files using the client
4. Ship back the device when you’re done (goes to the right AWS
facility)
5. Data will be loaded into an S3 bucket
6. Snowball is completely wiped
7. Tracking is done using SNS, text messages and the AWS console
Diagram
Snowball Edge
• Snowball Edges add computational capability to the device
• 100 TB capacity with either:
• Storage optimized – 24 vCPU
• Compute optimized – 52 vCPU & optional GPU
• Supports a custom EC2 AMI so you can perform
processing on the go
• Supports custom Lambda functions
• Very useful to pre-process the data while moving
• Use case: data migration, image collation, IoT
capture, machine learning
AWS Snowmobile
• Transfer exabytes of data (1 EB = 1,000 PB = 1,000,000 TBs)
• Each Snowmobile has 100 PB of capacity (use multiple in parallel)
• Better than Snowball if you transfer more than 10 PB.
Hybrid Cloud for Storage
• Athena is easy to use. Simply point to your data in Amazon S3, define the schema,
and start querying using standard SQL. Most results are delivered within seconds.
With Athena, there’s no need for complex ETL jobs to prepare your data for
analysis. This makes it easy for anyone with SQL skills to quickly analyze
large-scale datasets.
Contd..
• Serverless service to perform analytics directly against S3 files
• Uses SQL language to query the files
• Has a JDBC / ODBC driver
• Charged per query and amount of data scanned
• Supports CSV, JSON, ORC, Avro, and Parquet (built on Presto)
• Use cases: Business intelligence / analytics / reporting, analyze &
query
VPC Flow Logs, ELB Logs, CloudTrail trails, etc...
AWS SQS
Introduction
• Amazon Simple Queue Service (SQS) is a fully managed message queuing
service that enables you to decouple and scale microservices, distributed
systems, and serverless applications. SQS eliminates the complexity and
overhead associated with managing and operating message oriented
middleware, and empowers developers to focus on differentiating work.
Using SQS, you can send, store, and receive messages between software
components at any volume, without losing messages or requiring other
services to be available.
• SQS offers two types of message queues.
• Standard queues offer maximum throughput, best-effort ordering, and at-least-once
delivery.
• SQS FIFO queues are designed to guarantee that messages are processed exactly
once, in the exact order that they are sent.
Concept
• multiple applications need to communicate with one another many
times.
• There are two patterns of application communication
Contd..
• Synchronous between applications can be problematic if there are
sudden spikes of traffic
• What if you need to suddenly encode 1000 videos but usually it’s 10?
• In that case, it’s better to decouple your applications,
1. SQS: queue model
2. SNS: pub/sub model
3. Kinesis: real-time streaming model
Standard Queue
• Oldest offering (over 10 years old)
• Fully managed
• Scales from 1 message per second to 10,000s per second
• Default retention of messages: 4 days, maximum of 14 days
• No limit to how many messages can be in the queue
• Low latency (<10 ms on publish and receive)
• Horizontal scaling in terms of number of consumers
• Can have duplicate messages (at least once delivery, occasionally)
• Can have out of order messages (best effort ordering)
• Limitation of 256KB per message sent
Delay Queue
• Delay a message (consumers don’t see it immediately) up to 15
minutes
• Default is 0 seconds (message is available right away)
• Can set a default at queue level
• Can override the default using the DelaySeconds parameter
Visibility Timeout
• When a consumer polls a message from a queue, the message is “invisible”
to other consumers for a defined period… the Visibility Timeout:
• Set between 0 seconds and 12 hours (default 30 seconds)
• If too high (15 minutes) and consumer fails to process the message,
you must wait a long time before processing the message again
• If too low (30 seconds) and consumer needs time to process the message (2
minutes), another consumer will receive the message and the message will
be processed more than once
• ChangeMessageVisibility API to change the visibility while processing a
message
• DeleteMessage API to tell SQS the message was successfully processed
Dead Letter Queue(DLQ)
• If a consumer fails to process a message within the Visibility
Timeout…the message goes back to the queue!
• We can set a threshold of how many times a message can go back to
the queue – it's called a “redrive policy”
• After the threshold is exceeded, the message goes into a dead letter
queue(DLQ)
• We have to create a DLQ first and then designate it dead letter queue
• Make sure to process the messages in the DLQ before they expire!
Long Polling
• With Lambda, you can run code for virtually any type of application or backend
service - all with zero administration. Just upload your code and Lambda takes
care of everything required to run and scale your code with high availability. You
can set up your code to automatically trigger from other AWS services or call it
directly from any web or mobile app.
Contd.
Sample Use case
Contd..
AWS Sample GitHub repo
• Sample codes hosted by AWS on GitHub repo.
• https://github.com/aws-samples
Lambda Functions
• The code you run on AWS Lambda is called a “Lambda function.” After you create your
Lambda function it is always ready to run as soon as it is triggered, similar to a formula in a
spreadsheet. Each function includes your code as well as some associated configuration
information, including the function name and resource requirements. Lambda functions
are “stateless,” with no affinity to the underlying infrastructure, so that Lambda can
rapidly launch as many copies of the function as needed to scale to the rate of incoming
events.
• After you upload your code to AWS Lambda, you can associate your function with specific
AWS resources (e.g. a particular Amazon S3 bucket, Amazon DynamoDB table, Amazon
Kinesis stream, or Amazon SNS notification). Then, when the resource changes, Lambda
will execute your function and manage the compute resources as needed in order to keep
up with incoming requests.
EC2 vs Lambda
• Virtual Servers in the Cloud
• Limited by RAM and CPU
• Continuously running
• Scaling means intervention to add / remove servers
Lambda
• Virtual functions – no servers to manage!
• Limited by time - short executions
• Run on-demand
• Scaling is automated!
Contd.
• Easy Pricing:
• Pay per request and compute time
• Free tier of 1,000,000 AWS Lambda requests and 400,000 GBs of compute
time
• Integrated with the whole AWS Stack
• Integrated with many programming languages
• Easy monitoring through AWS CloudWatch
• Easy to get more resources per functions (up to 3GB of RAM!)
• Increasing RAM will also improve CPU and network!
Programming Languages
• Node.js (JavaScript)
• Python
• Java (Java 8/11 compatible)
• C# (.NET Core)
• Golang
• C# / PowerShell
Configuration
• Timeout: default 3 seconds, max of 300s (Note: new limit 15 minutes)
• Environment variables
• Allocated memory (128M to 3G)
• Ability to deploy within a VPC + assign security groups
• IAM execution role must be attached to the Lambda function
Limits
• Execution:
• Memory allocation: 128 MB – 3008 MB (64 MB increments)
• Maximum execution time: 300 seconds (5 minutes), now 15 minutes but 5 for
exam
• Disk capacity in the “function container” (in /tmp): 512 MB
• Concurrency limits: 1000
• Deployment:
• Lambda function deployment size (compressed .zip): 50 MB
• Size of uncompressed deployment (code + dependencies): 250 MB
• Can use the /tmp directory to load other files at startup
• Size of environment variables: 4 KB
Lambda@Edge
• You have deployed a CDN using CloudFront
• What if you wanted to run a global AWS Lambda alongside?
Lambda@Edge:deploy Lambda functions alongside your CloudFront
CDN
• Build more responsive applications
• You don’t manage servers, Lambda is deployed globally
• Customize the CDN content
• Pay only for what you use
Contd..
• You can use Lambda to change CloudFront requests and responses:
• After CloudFront receives a request from a viewer (viewer request)
• Before CloudFront forwards the request to the origin (origin request)
• After CloudFront receives the response from the origin (origin
response)
• Before CloudFront forwards the response to the viewer (viewer
response)
Contd..
Use cases
• Website Security and Privacy
• Dynamic Web Application at the Edge
• Search Engine Optimization (SEO)
• Intelligently Route Across Origins and Data Centers
• Bot Mitigation at the Edge
• Real-time Image Transformation
• A/B Testing
• User Authentication and Authorization
• User Prioritization
• User Tracking and Analytics
Amazon Cognito