63
Introduction to Amazon Web Services for developers Roman Gomolko [email protected] July 2015 Ciklum Speakers Corner

Introduction to amazon web services for developers

  • Upload
    ciklum

  • View
    241

  • Download
    6

Embed Size (px)

Citation preview

Page 1: Introduction to amazon web services for developers

Introduction to Amazon Web Services for developers

Roman Gomolko

[email protected]

July 2015

Ciklum Speakers Corner

Page 2: Introduction to amazon web services for developers

Let’s get acquired

Page 3: Introduction to amazon web services for developers

UserReport

● Developing products that allow to learn the audience

● Started using AWS more than 5 years ago

● Fully migrated to AWS more than 1.5 years ago

● Processing 3 billions requests monthly

● Generating reports based on 8 billions of requests with batched reports

● Online reports on 300 millions of records

● Used ~50% of services provided by AWS

● Totally happy regarding using AWS

Page 4: Introduction to amazon web services for developers

Cloud Computing

Cloud computing is a model for enabling access to a shared pool of configurable computing resources

Page 5: Introduction to amazon web services for developers

Typical Cloud benefits

● Pay for what you are using

● High scalability - retrieve as many resources as you need

● High availability

● Gartner's Hype cycle – cloud computing has reached a maturity

Page 6: Introduction to amazon web services for developers

Cloud models

● IaaSInfrastructure like physical (rarely) or virtual servers, storage, networking, load balancers, IP addresses allocation etc

● PaaSHosted databases, pre-configured web-servers that can run your application, platforms that can run your code

● aPaaSTools and services that automates and facilitates utilizing Cloud Services. Providing tools for development, deployment, monitoring etc

● SaaSGmail, MailChimp, Highrise, Google photo, Jira Cloud etc

Page 7: Introduction to amazon web services for developers

Amazon Web Services

IaaSPaaS

aPaaSSaaS

Page 8: Introduction to amazon web services for developers
Page 9: Introduction to amazon web services for developers

Naming convention

● Everything is Elastic

● Everything is Simple

● DRY

Elastic Compute Cloud = ECC = EC2

Simple Storage Service = SSS = S3

Elastic Load Balancer = ELB

AutoScale Group = ASG

...

Page 10: Introduction to amazon web services for developers

AWS is regional

Page 11: Introduction to amazon web services for developers

AWS is regional

● Almost all services are region specific

● Pricing of services depends on region

● Not all services are available in all regions

● New services are launching in N. Virginia (US East 1) first

http://aws.amazon.com/about-aws/global-infrastructure/regional-product-services/

Page 12: Introduction to amazon web services for developers

Regions are not solid

● Splitted into Availability Zones (AZ)

● AZs have independent power supply

● Cross-AZ network speed is blazing fast

● Some services belong to AZ, some - not

Page 13: Introduction to amazon web services for developers

Iaas basics

● EC2Virtual computers managed by XEN running on Intel CPUs

● EBSSSD or magnetic drives dynamically attached to EC2 instances with configurable size (up to 16Tb) with configurable IOPs

● ELBLoad balancing before your EC2 instances

● VPCCreating network and group your instances/services into “Private Cloud”

Page 14: Introduction to amazon web services for developers

PaaS basics

● CloudFrontCDN for downloading and streaming

● S3Infinite storage for objects (files) with security and HTTP access

● RDSHosted databases like MySQL, MS SQL, PostgreSQL, Oracle, Aurora with licenses included

● DynamoDBNoSQL database designed for high performance and availability

Page 15: Introduction to amazon web services for developers

PaaS basics

● Route53Fully managed and DNS and domain registration

● ElastiCacheFully managed hosted memcache and Redis

● SQSQueue designed for high availability and millions of messages

Page 16: Introduction to amazon web services for developers

Some more PaaS

● CloudSearchSearch engine for free-text search among millions of documents

● EMRFully managed Elastic MapReduce and Spark clusters

● Elastic Transcoder Encoding media-files in different formats with different quality

● … and more

Page 17: Introduction to amazon web services for developers

aPaaS

● CloudWatchMonitoring of your infrastructure and applications

● Elastic BeanstalkAutomated web-applications and workers hosting

● CloudFormationManage your cloud services in one place with help of text file

● CodeDeployAutomates deployment of your application

● OpsWorksChef cooked by AWS to automate provisioning and deployment

Page 18: Introduction to amazon web services for developers

SaaS basics

● SESSending e-mails from Cloud

● SNSPush notifications

● WorkMailHosted exchange server for organizations

● WorkSpacesVirtual office became reality

Page 19: Introduction to amazon web services for developers

Migration of existing web-application to AWS

DBWebServer

Page 20: Introduction to amazon web services for developers

Migration to Cloud

● One bite at a time - migration to Cloud itself is a big deal

● Cloud may have similar services to what you are using in your app. Similar is not the same.

● Usually you have application which works somehow try to keep your structure unchanged

● Less efforts, faster migration

Page 21: Introduction to amazon web services for developers

Hosting your web-application

1. Create EC2

2. Connect to it

3. Configure it

4. Deploy code to it

5. Access website

Page 22: Introduction to amazon web services for developers

Creating EC2. Choose operating system image

Page 23: Introduction to amazon web services for developers

Creating EC2. Choose instance type

Page 24: Introduction to amazon web services for developers

Creating EC2. Instance details

Page 25: Introduction to amazon web services for developers

Creating EC2. Storage

Page 26: Introduction to amazon web services for developers

Creating EC2. Tags

Page 27: Introduction to amazon web services for developers

Creating EC2. Security group

Page 28: Introduction to amazon web services for developers

Creating EC2. Review. Almost done

Page 29: Introduction to amazon web services for developers

Creating EC2. Selecting key-pair

Page 30: Introduction to amazon web services for developers

Connecting to your instance. Wait until launched

Page 31: Introduction to amazon web services for developers

Connecting to your Linux instance

Linux / Mac OS X

ssh -i "<keypair>.pem" ec2-user@<instance IP>

Windows

● convert .pem to .ppk using Putty KeyGen

● connect to instance using Putty

● refer help for more details

Page 32: Introduction to amazon web services for developers

Connecting to your Windows instance

● Wait 4-20 minutes after starting instance

● Retrieve password using you keypair

● Use Remote Desktop to connect to your instance. Use Administrator as name

● Password will expire, better create permanent user

Page 33: Introduction to amazon web services for developers

Configuring your instance as you like

sudo apt-get install apache2

sudo apt-get install php5

sudo apt-get install libapache2-mod-php5

sudo /etc/init.d/apache2 restart

import-module servermanager

add-windowsfeature Web-Server,

Web-WebServer, Web-Security

Page 34: Introduction to amazon web services for developers

Deploy your application

Page 35: Introduction to amazon web services for developers

Accessing your web-application

● Your public IP is not static. It will be changed after reboot

● You can request IP address and attach it to instance dynamically

● In future you can assign this IP to another instance

● Put this IP to your DNS or write to host file

Page 36: Introduction to amazon web services for developers

Database. Let’s try RDS

Page 37: Introduction to amazon web services for developers

Multi-AZ deployments for reliability

multiply hosting cost by number of AZ zones

Page 38: Introduction to amazon web services for developers

Configure your instance and DB master credentials

Page 39: Introduction to amazon web services for developers

Secure your database

Page 40: Introduction to amazon web services for developers

Take advantage of managed solutions

Page 41: Introduction to amazon web services for developers

Wait. Cloud? I need more redundancy

1. Create EC2

2. Connect to it

3. Configure it

4. Stop it

5. Create AMI

6. Launch required number of instances using this AMI

7. Deploy code to them

8. Access website

Page 42: Introduction to amazon web services for developers

Launching from you AMI

Page 43: Introduction to amazon web services for developers

Horizontal scaling of application checklist

● Data-less

● Stateless

● Shared session

● Same encryption keys

Page 44: Introduction to amazon web services for developers

Distribute traffic between instances

● DNS round-robin

● Load balancer

Page 45: Introduction to amazon web services for developers

Elastic Load Balancer

● Accept incoming traffic and distribute among instances

● Monitors instance availability

● Can accept HTTPS traffic and map to HTTP endpoint of web-server

● Allows to not expose web-servers to worldwide

● Allows Connection Draining

● Provides useful metrics like latency, requests per minute, count of 2XX, 4XX and 5XX response codes

Page 46: Introduction to amazon web services for developers

I’ve become popular. Need to scale

Instance roles:

● Web/front-end

● Worker/back-end

● DB

Scaling strategies:

● Vertical scaling

● Horizontal scaling

Page 47: Introduction to amazon web services for developers

Vertical scaling

● Good if your bottleneck is CPU, RAM or disk

● Can be done with downtime or without it

Page 48: Introduction to amazon web services for developers

Vertical scaling of EC2.

● Simple - downtime

○ Stop

○ Change instance type

○ Start

● Complex - no downtime

○ Launch new instance with required instance type

○ Switch traffic from old instance to new one

Page 49: Introduction to amazon web services for developers

Vertical scaling of RDS

● Can be done without downtime in case of Multi-AZ deployment

● Not that fast in any way

Page 50: Introduction to amazon web services for developers

Where is fun stuff?

Page 51: Introduction to amazon web services for developers

I want to be Elastic

Page 52: Introduction to amazon web services for developers

AutoScale groups

Launch configuration - how your instance will look like

AutoScale group - control how many instances will be in your group

Page 53: Introduction to amazon web services for developers

Launch Configuration - customize instance bootstrap

Page 54: Introduction to amazon web services for developers

AutoScale group

Page 55: Introduction to amazon web services for developers

AutoScale Group - scaling policies

Page 56: Introduction to amazon web services for developers

Finally

● AWS can scale our application automatically looking on CPU load

● AWS can scale-down instances when load decreased

Page 57: Introduction to amazon web services for developers
Page 58: Introduction to amazon web services for developers

Small catch-up

● We know what is EC2 and how to deploy application first time

● We know how to horizontally scale up and down your application

● It looks pretty cumbersome

● We don’t know where we should store users’ files

● We don’t know how to improve website performance

● We don’t know how to update your application

Page 59: Introduction to amazon web services for developers

Pricing

http://calculator.s3.amazonaws.com/index.html

Page 60: Introduction to amazon web services for developers

Bad reasons to migrate

● Migrating everything by just virtualizing existing stuff and expecting savings

● Expecting magical performance boost and “Cloud will solve all problems”

Page 61: Introduction to amazon web services for developers

Good reasons to migrate

● Extremely flexible

● Pay for what you use

o cheap to fail

o cutting cost of testing and applying new technologies

● Fast changes - get what you need when you need

● Allows to focus on your product - not on CDN, Mail sending, file storages,

Page 62: Introduction to amazon web services for developers

File storage

● DIY - Distributed File System

● Let’s Amazon handle it - Elastic File System (Preview)

● Ready to change code - S3

Page 63: Introduction to amazon web services for developers

S3, CloudFront, Beanstalk demo time