19
Nordaaker Building Catalyst apps on the Amazon Web Service Platform

Building Catalyst apps on the Amazon Web Service Platform

Embed Size (px)

DESCRIPTION

In the fall of 2007 Nordaaker started building a photo diary site called phiary.com. We decided to build it on the Amazon Web Services platform. Based on what we've learned, we will look at how you can easily deploy Catalyst apps on EC2, use S3 for storage in your apps, as well as leverage the other unique benefits of the Amazon platform.Attended by:

Citation preview

Page 1: Building Catalyst apps on the Amazon Web Service Platform

Nordaaker

Building Catalyst apps on the

Amazon Web Service Platform

Page 2: Building Catalyst apps on the Amazon Web Service Platform

Story so far...

In the fall of 2007 Nordaaker built a photo diary site called phiary.com. We decided to build it on the Amazon Web Services platform.

Based on what we've learned, we will look at how to easily deploy Catalyst apps on EC2, use S3 for storage, as well as leverage the other unique benefits of the Amazon platform.

Page 3: Building Catalyst apps on the Amazon Web Service Platform

Amazon Web Services

★ Cloud computing:

★ EC2

★ S3

★ SimpleDB

★ Thumbnailing

★ Simple Queue Service

Page 4: Building Catalyst apps on the Amazon Web Service Platform

Amazon Elastic Compute Cloud (EC2)

★ Use templated images to get up and running immediately.

★ Amazon EC2 provides tools that make storing the AMI simple.

★ Use Amazon EC2 web service to configure security and network access.

★ Start, terminate, and monitor as many instances of your AMI as needed, using the web service APIs.

★ Pay for the resources that you consume, like instance-hours or data transfer.

Page 5: Building Catalyst apps on the Amazon Web Service Platform

Catalyst on EC2

★ Install EC2 tools as normal (See Amazon)

★ Specialized AMIs:★ ami-bdbe5ad4 developer-tools/Debian-Etch_Catalyst_DBIC_TT.manifest.xml

★ ami-9fbe5af6 developer-tools/Fedora8-Catalyst_DBIC_TT.manifest.xml

★ Alternatively:★ Use any image you prefer and install Catalyst as normal for that distribution.

★ $ ec2-run-instances <AMI> -K <ssh key file>

Page 6: Building Catalyst apps on the Amazon Web Service Platform

Set up a custom image

★ Log in to your EC2 instance★ $ ec2-describe-instances

★ $ ssh root@<hostname from above>

★ Set up the application the way you want it to work.

★ Install required dependencies, configure the web server, set up cron jobs and, scripts to backup your log files, and so on.

★ Check out from a svn tag, or build package specific distributions for it.

Page 7: Building Catalyst apps on the Amazon Web Service Platform

Create your image

Copy in your cert and pk files from the .ec2 catalog to your server.

Then on your instance:

$ ec2-bundle-vol -d /mnt -k <path to pk file>\ -u 410778958690 -s 1536 --cert <path to cert>

$ ls -l /mnt/image.*

$ ec2-upload-bundle -b <your-s3-bucket> -m \/mnt/image.manifest.xml -a <aws-accesskey-id>\ -s <aws-secret-access-key>

$ ec2-register <your-s3-bucket>/image.manifest.xml

Page 8: Building Catalyst apps on the Amazon Web Service Platform

Permanent IPs

★ When we started up, no persistant IP - DHCP

★ Issue when your instance goes down and you start up a new one.

★ Amazon’s solution - AWS Dynamic IP.

★ Up to 5 per customer, more available on request

Page 9: Building Catalyst apps on the Amazon Web Service Platform

Dynamic Staging

★ No need for a full-time staging server.★ When ready to roll out new code:★ Create new instance★ Update to latest production code★ Test★ Move over IP using EC2 dynamic IP★ Verify★ Shut down the old instance

Page 10: Building Catalyst apps on the Amazon Web Service Platform

Perl API

Net::Amazon::EC2

Access all the functionality you can from the ec2 command line tools:

my $ec2 = Net::Amazon::EC2->new( AWSAccessKeyId => 'PUBLIC_KEY_HERE', SecretAccessKey => 'SECRET_KEY_HERE' );

# Start 1 new instance from AMI: ami-XXXXXXXX

my $instance = $ec2->run_instances(ImageId => 'ami-XXXXXXXX', MinCount => 1, MaxCount => 1);

Page 11: Building Catalyst apps on the Amazon Web Service Platform

Cool things you can do

★ Build-servers on demand.

★ Start extra instances on load (After being dugg?).

★ Run periodic jobs without affecting server performance.

★ Monitor and automatically restart services when down.

★ Combine with SQS to run scalable queuing.

Page 12: Building Catalyst apps on the Amazon Web Service Platform

S3 - Simple Storage Service

★ Supports REST or SOAP api

★ SOAP API is crap, use REST :)

★ Net::Amazon::S3 => Catalyst::Model::S3

★ $c->model(‘S3’)->bucket(‘foo’) ->get_key(‘bar’)

★ DBIx::Class::S3

★ Set expires headers on assets.

★ Not a CDN replacement. Few locations, no edge caching.

Page 13: Building Catalyst apps on the Amazon Web Service Platform

SimpleDB

★ HTTP based data storage API.

★ No transactions/relations.

★ For fairly simple apps.

★ Recently added sorting.

★ Not very fast, but massively parallel. Strategy: parallelize your requests.

★ Net::AWS::SimpleDB

★ To use with Catalyst, wrap with Catalyst::Model::Adapter

Page 14: Building Catalyst apps on the Amazon Web Service Platform

Using DBIx::Class and mysql/postgresql

★ Inconvenient due to lack of persistent storage.

★ Run a mysql cluster + frequent backup to S3 - Good enough in most cases.

★ Availability Zones.

★ AWS Persistent storage in private beta, launching soon.

Page 15: Building Catalyst apps on the Amazon Web Service Platform

Persistent Storage

★ Storage volume that can be mounted in EC2.

★ High speed/ low latency.

★ Volume size from 1GB to 1TB.

★ Supports snapshots to S3.

★ Available “later this year”.

Page 16: Building Catalyst apps on the Amazon Web Service Platform

Thumbnailing

★ We use this for iwatchthis.com

★ Cheap way to collect thumbnails of sites

★ Simple REST API

★ You can just use Net::Amazon::Thumbnail:

★ my $alexa=Net::AWS::Thumbnail->new({access_key=>foo, secret=>bar,size=>”Large”}); $alexa->get_thumbnail($url);

Page 17: Building Catalyst apps on the Amazon Web Service Platform

Simple Queing Service

★ Create an unlimited number of Amazon SQS queues, each of which can send and receive an unlimited number of messages.

★ A computer can check a queue at any time for messages waiting to be read.

★ A message is "locked" while a computer is processing it, keeping other computers from trying to process it simultaneously. If processing fails, the lock will expire and the message will again be available.

★ Access it through Amazon::SQS::Simple

Page 18: Building Catalyst apps on the Amazon Web Service Platform

Nordaaker

Questions?

Page 19: Building Catalyst apps on the Amazon Web Service Platform

Nordaaker

Thank [email protected]