With more businesses moving to cloud-based solutions everyday, we must re-think the strategies used to deploy Perl applications and related libraries, given the volatile aspects of the cloud and its constraints.
In this talk I go over the challenges posed by virtualised environments, and consider several solutions to them. The use cases are all related to Amazon's EC2, but will easily be adapted for GoGrid, Mosso, and others.
Handwritten Text Recognition for manuscripts and early printed texts
Perl in Teh Cloud
1. Perl in Teh Cloud
What do you mean, “no wires”?
2. Scope
• Amazon Web Services Infrastructure products
• EC2, S3, EBS (SimpleDB, SQS, Elastic MapReduce N/A)
• What do you get from AWS? What don’t you get?
• Software packaging and deployment
• Use cases
• No code to see here, move along
3. What’s in EC2?
• On-demand compute power
• Controlled via a web service
• Free-form machines created with very little effort
• Computers without the metal bits
4. S3 - Simple Storage Service
• Storage accessible through web services
• Highly replicated
• Free data transfer within EC2
5. EBS - Elastic Block Service
• A hard disk, somewhere
• Format it however you like
• Attach to and mount on an instance
• Excellent random access performance
• As opposed to an instance’s storage, which is good for sequential
operations, like table scans.
6. The Problem
• Instances can drop out of the sky at any time
• Although this doesn’t happen often, *it will happen*
• An instance’s storage isn’t persistent across launches
• Machines are built from scratch on launch
7. Solutions
• Machine images
• Ye Olde Tarball
• EBS and snapshots
8. Solution - Machine Images
• Canonical machines
• Planning ahead
• Not very flexible
• Time-consuming
9. Solution - Tarball
• Hosted in S3
• Fetched and uncompressed on launch
• Set-up scripts written in whatever language you want
• local::lib
10. Solution - EBS
• Permanent storage
• One volume for one machine
• Snapshot it and create extra volumes on launch
• local::lib
• Easy to screw up
11. A Note About local::lib
• Oh look, code!
• Or perhaps not
• Each project can easily have its own $PERL5LIB
• No interference from other projects
• You can change the system-wide installation without fear of maiming
a project
12. A Note About local::lib
• Sinopsys
use local::lib; # sets up a local lib at ~/perl5
use local::lib '~/foo'; # same, but ~/foo
# Or...
use FindBin;
use local::lib "$FindBin::Bin/../support"; # app-local support library
13. A Note About local::lib
• And to easily install stuff where you want it:
# Install LWP and it's missing dependencies to the 'my_lwp' directory
perl -MCPAN -Mlocal::lib=my_lwp -e 'CPAN::install(LWP)'
# Install LWP and *all non-core* dependencies to the 'my_lwp' directory
perl -MCPAN -Mlocal::lib=--self-contained,my_lwp -e 'CPAN::install(LWP)'
14. Use Cases
• Testing and staging
• Scaling applications
• Disaster recovery
• No data center is a good data center
15. Use Case - Testing & Staging
• Machines are guaranteed to be exact replicas of production
• Never forget to update that module again
• Fire it up, do your thing, and shut it down
• Lead time measured in minutes
16. Use Case - Scaling
• Grow when you need to grow, shrink when you’re wasting resources
• Automated provisioning and de-commissioning
• Did I mention the lead time?
17. Use Case - Disaster Recovery
• Your main database went down
• A web server crashed
• Data replication
• Forget about lead times :)
18. Use Case - Data Center
• There isn’t one
• Stop paying for services you don’t use
• Aircon, racks, connectivity, power
• Remember when you forgot your ID or keys to the rack?
20. See Also
• Bootstrapping local::lib
http://www.simplicidade.org/notes/archives/2009/05/locallib_bootst.html
• RightScale
http://rightscale.com/
• AWS for Eclipse