Compute in the Cloud
Compute in the Cloud
Module overview
Topics
• Compute services overview
• Amazon EC2
• Amazon EC2 cost optimization
• Container services
• Introduction to AWS Lambda
• Introduction to AWS Elastic Beanstalk
2
Module objectives
3
Compute services overview
Compute Power in the Cloud
• At some stage you will require compute power
• You are writing or using applications and need a location to run this code
on
• Due to the familiarity with the technology a lot of people when starting will
use a cloud based server
• IAAS (Infrastructure As A Service)
• PAAS (Platform As A Service)
• This is fine and is a good starting point
• It allows you to use your code in the cloud in a similar way that you would
of done if you were using an on premise solution
• All of the same features are there which you would see if you owned the
server
• As you develop your skill set though you will find that this solution is not
as popular as you might first think and later in the course we will see
more examples where SAAS is more popular and WHY 5
Compute Options
Amazon Web Services (AWS) offers many compute services. This module will discuss the
highlighted services.
Amazon EC2 Amazon EC2 Amazon Elastic Amazon Elastic VMware Cloud
Auto Scaling Container Registry Container Service on AWS
(Amazon ECR) (Amazon ECS)
AWS Elastic AWS Lambda Amazon Elastic Amazon Lightsail AWS Batch
Beanstalk Kubernetes Service
(Amazon EKS)
10
Equipment
• Just consider a server which is physical
• You need to specify the hardware so that it has a lifetime
• As an example the laptop which I use at the university
• This was purchased at a specification where it will still be useful
for 5 years
• At the start it is overspecified
• Right now it is good at what it does
• In the near future it will start to slow down as the resources which
are needed is greater than its capability
• You have not a lot of choice on this as the lead time to get equipment
is slow
• It is also a large upfront investment to buy this equipment
11
Equipment
● This is just to visualise - in reality the line will change a lot
Useful depending on the workload
Use for the expected tasks
Useless
Purchased Time Recycle 12
Amazon EC2 - Video
Amazon
EC2
What is Amazon EC2?
• What is Elastic Compute Cloud (EC2)
• The term might simply be causing an issue as it is something you have not
seen
• The truth is in Cloud computing they usually use different names to what
you are used to
• The idea is that you do not get stuck with the concepts which you have for
physical devices
• Here you realise that the hardware is flexible and can change
What is Amazon EC2?
• What is Elastic Compute Cloud (EC2)
• This is simply a populated motherboard
• CPU
• Type - ARM, Intel Xeon, AMD EPYC, Apple M series
• Features
• Cores
• Memory
• Network Bandwidth
• Storage Bandwidth
• Storage Type
• If needed additional cards i.e. Nvidia GPU
• https://aws.amazon.com/ec2/instance-types/
• https://aws.amazon.com/ec2/instance-explorer/
What is Amazon EC2?
• Comparison to Physical setups
• You do not need to replicate your physical infrastructure in the
cloud
• The best idea is to try a processor and setup and see how it
operates
• Just because your physical server has 16 cores does not mean that your
Virtual server (EC2) also needs this
• It is easy with Cloudwatch to gather statistics and then work out if your
EC2 instance is over specified
• If it is then this is costing you money!
What is Amazon EC2?
• Remember also you are paying as you use this
• In the physical world you will buy a server to experiment on and then just
leave it going
• In the Cloud environment it is a consideration to turn it off when you are not
using it i.e. overnight
• When it is not running you are NOT paying
• The fact that it is configured for your use, still does not mean you are
paying
• You only pay when you are using it i.e. powered on
• Consider this when using the provided Sandbox as well
• When you are not using this turn it all off
Amazon Elastic Compute Cloud (Amazon
EC2)
Example uses of Amazon
EC2 instances
✔ Application server
✔ Web server
✔ Database server
✔ Game server
✔ Mail server
✔ Media server
✔ Catalog server Amazon EC2 instances
✔ File server
✔ Computing server
On-premises servers
✔ Proxy server
20
1. Select an AMI
1. AMI
• Amazon Machine Image (AMI)
2. Instance Type
• Is a template that is used to create an EC2 instance (which is a virtual
3. Network settings machine, or VM, that runs in the AWS Cloud)
4. IAM role
• Contains a Windows or Linux, MAC operating system
5. User data
• Often also has some software pre-installed
6. Storage options
7. Tags • AMI choices:
8. Security group • Quick Start – Linux and Windows AMIs that are provided by AWS
9. Key pair • My AMIs – Any AMIs that you created
• AWS Marketplace – Pre-configured templates from third parties
• Community AMIs – AMIs shared by others; use at your own risk
21
Amazon Machine Image (AMI)
• Here is a list of provided AMI’s
• https://aws.amazon.com/marketplace
• Of Course though you can just use your own and you will do this in one of the
practical sessions
• You create your OS and the patches and the software you need
• You will register this as an AMI which is private to you
• You can then launch EC2 instances based on this
• Although not a great way to do this
• Simply create an OS
• Patch this
• Install the software you need
• Put a copy of your application on this
• Make an AMI
• This is now your “Golden Image”
• Simply use this for all of your servers
Disclosure
• As full disclosure
• If you are writing software really the Golden Image is now rarely used
• It is a easy one to understand and think it is a good idea
• In the world of fast changing computing and cyber security risks
• the golden image can go out of date very quickly
• In the cloud think of everything as being temporary and short usage
• This does not mean your application is short term usage - it is the compute
which is
• The risks are more important than the benefits of this quick technique
• Nice to try though in a lab :)
Where to work
• As we will see later Cloud computing DOES cost money
• If you are working on some software you can simply work locally and then transfer this to
the a EC2 server
• An example which we have at the university is to work on a Virtual Image on a VMWare
server
• The idea of working on a VMWare server is that IF you make a mistake and you install
conflicting libraries or any other software
• You simply roll back to a previous version
• On all most everything I do now it is all done in virtual machines (Free from the
university for VMWare)
• In the past I have had way too many problems playing with open source software
which ruined an installation
• Anyway once your virtual image is operational as you want - simply move this to the
Cloud and run again on EC2
• This can even be automatic for you where really you do not know where you are
working - the monitoring system is making the best decisions based on your
considerations
Amazon Machine Image (AMI)
28
Moving between the clouds
AWS GCloud
2. Select an instance type
30
EC2 instance type naming and sizes
Instance type Example instance sizes
details
Instance
vCPU Memory (GB) Storage
Name
Instance type naming t3.nano 2 0.5 EBS-Only
t3.large 2 8 EBS-Only
t3.xlarge 4 16 EBS-Only
t3.2xlarge 8 32 EBS-Only
31
Select instance type: Based on use
case
Instance type
details
https://aws.amazon.com/ec2/instance-types/
EC2 instance type
• It is important to so select the right processor for the task
• These are virtual CPU (vCPU) but are mapped to a physical CPU
• When you look at each type as a computing person you can decide if has the right
functionality for what YOU need
• The right decision can reduce your costs
• This does involve your computing knowledge which you did some in the first year with Jim
• As an example if you look at the M5 instance type
• https://aws.amazon.com/ec2/instance-types/m5/
• This has the Xeon 8000 series processor with “Intel Advanced Vector Extensions 512
(AVX-512) instruction set”
• In this case it has the capability of improving the performance for Neural Networks
• If you are doing image processing look for chips with Intel AVX-512
• This is the same for ARM and AMD Processors
• https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html
• Do not just look for the Cores
EC2 instance type
• ARM Processors are now getting a lot of good discussions
• In the right jobs they can be a lot quicker at a lower cost
• https://www.infoq.com/articles/arm-vs-x86-cloud-perform
ance/
• In AWS the ARM processor is Graviton2
• Smaller is better in this graph - but do go and look at
the article
• You need to experiment to work out if it is better for
your software
• Here is a IEEE paper on this topic
• https://ieeexplore.ieee.org/document/9582322
• In summary for video work they found:
• H264 use ARM
• H265 use Intel
Instance types: Networking features
35
3. Specify network settings
1. AMI
• Should a public IP address be automatically assigned?
2. Instance Type • To make it internet-accessible
3. Network settings
AWS Cloud
4. IAM role
Region
5. User data
Availability Zone 1 Availability Zone 2
6. Storage options
VPC
7. Tags
Public subnet
8. Security group Example:
9. Key pair specify to
deploy the Instance
instance here
Private subnet
36
4. Attach IAM role (optional)
Choices made by using the • Will software on the EC2 instance need to interact with other
Launch Instance Wizard: AWS services?
• If yes, attach an appropriate IAM Role.
1. AMI
• An AWS Identity and Access Management (IAM) role that is
2. Instance Type
attached to an EC2 instance is kept in an instance profile.
3. Network settings
4. IAM role • You are not restricted to attaching a role only at instance
5. User data launch.
6. Storage options • You can also attach a role to an instance that already
7. Tags exists.
8. Security group Example: Application on
9. Key pair attached to instance can
access
Role that grants Amazon
S3 bucket
Simple Storage Service Instance
with objects
(Amazon S3) bucket
access permissions
37
5. User data script (optional)
38
6. Specify storage
39
Amazon EC2 storage options
40
Example storage options
Host computer
• Instance 1 characteristics – Amazon Elastic
Block Store
• It has an Amazon EBS root
(Amazon EBS) Instance Store
volume type for the operating
system. Attached as Attached as
• What will happen if the instance is Root volume Storage
stopped and then started again?
20-GB volume Instance 1 volume Ephemeral
volume 1
Attached as
• Instance 2 characteristics – Storage volume
• It has an Instance Store root Attached as
500-GB volume Root
volume type for the operating
system. volume Ephemeral
Instance 2
volume 2
• What will happen if the instance
stops (because of user error or a
system malfunction)?
41
Security group settings
Choices made by using the • A security group is a set of firewall rules that
Launch Instance Wizard: control traffic to the instance.
• It exists outside of the instance's guest OS.
1. AMI
2. Instance Type • Create rules that specify the source and which
3. Network settings ports that network communications can use.
4. IAM role
• Specify the port number and the protocol, such as
5. User data Transmission Control Protocol (TCP), User Datagram
6. Storage options Protocol (UDP), or Internet Control Message Protocol
7. Tags (ICMP).
8. Security group • Specify the source (for example, an IP address or
9. Key pair another security group) that is allowed to use the rule.
Example rule:
42
9. Identify or create the key pair
44
Another option: Launch an EC2 instance
with the AWS Command Line Interface
• EC2 instances can also be created
programmatically.
AWS Command Line
Interface (AWS CLI)
Launch Start
pending
AMI
Reboot Stop
rebooting running stopping stopped
Stop-Hibernate
Terminate
shutting-down
Terminate
terminated
46
EC2 instance metadata
47
Amazon CloudWatch for monitoring
• Basic monitoring
• Default, no additional cost
• Metric data sent to CloudWatch every 5 minutes
• Detailed monitoring
• Fixed monthly rate for seven pre-selected metrics
• Metric data delivered every 1 minute
48
Amazon CloudWatch for monitoring
49
• Amazon EC2 enables you to run Windows and
Section 2 key Linux virtual machines in the cloud.
51
Thank you for your time
52
Thank you for your time
53