Faster Perl Deployment on Stackato with PPM
by Troy Topnik

Troy Topnik, September 13, 2012

PERL! taptaptap

I've never had the mental wiring to really master regular expressions, so I usually need to lean on some sort of Rx testing or debugging tool to get them to work the way I want.

Normally I use Komodo IDE's Rx Toolkit for this, but David Oswald has written a very useful regex debugging tool for Perl called retester which will work in any browser.

Dependencies via CPAN

While looking into configuring this application to run on Stackato, I noticed that it already had a dotcloud.yml file. I thought this would be a good opportunity to explore the differences between dotCloud and Stackato for Perl web applications. Specifically, how they handle module dependencies.

Both Stackato and dotCloud can install Perl modules using the standard CPAN tools. Just specify the modules you need in a Makefile.PL to compile them on the PaaS. The relevant section for retester's Makefile.PL looks like this:

    PREREQ_PM => {
        'Mojolicious' => '3.0',
        'Try::Tiny' => '0',
        'Capture::Tiny' => '0',
        'Time::HiRes' => '0',
        'Sys::SigAction' => '0',
        'Safe' => '0',
        'Carp' => '0',
        'Moo' => '0',
        'Plack' => '0',
        'Test::More' => '0',
        'Test::Exception' => '0',
        'List::MoreUtils' => '0',

You can push this application as-is to a Stackato system by answering a few interactive prompts from the stackato client. Application staging takes a while on Stackato (5m14s in my test) because compiling Perl modules from source using cpanm is somewhat time consuming. Disabling tests speeds things up a fair bit (2m16s).

Pushing the application to dotCloud was in the same ballpark (2m42s) as the "--notest" results on Stackato (they disable tests by default), but there's an even faster way to do this.

Using PPM

ActiveState developed PPM initially as a solution to the problem of getting CPAN modules on Windows machines that didn't have a compiler or build tools installed.

But using binary packages is also a lot faster, no matter what architecture you're deploying to. Most popular Linux distributions use binary package formats (e.g. RPM and DEB) in preference to source package based installation (e.g. Gentoo, Free BSD, MacPorts).

There are some advantages to compiling packages from source, but in the context of Stackato it makes much more sense to use binary packages where possible. Stackato runs Perl applications using ActivePerl, so you can use PPM packages to install modules without having to compile them (and all of their dependencies) on the spot.

To get Stackato to use PPM, add a 'ppm' block in the 'requirements' section of a stackato.yml file. Here's the relevant snippet from the retester fork in Stackato Apps:

    - Mojolicious
    - Try::Tiny
    - Capture::Tiny
    - Time::HiRes
    - Sys::SigAction
    - Safe
    - Carp
    - Moo
    - Plack
    - Test::More
    - Test::Exception
    - List::MoreUtils

Using PPM, deployment time to Stackato drops to just 42 seconds. A nice improvement if you're doing repeated pushes or updates of the application.

On the other hand, it's not quite enough time for a coffe break or other diversions.

Subscribe to ActiveState Blogs by Email

Share this post:

Category: stackato
About the Author: RSS

Troy Topnik is ActiveState's technical writer. After joining ActiveState in 2001 as a "Customer Relationship Representative" (AKA Tech Support), Troy went on to lead the PureMessage Enterprise Support team before moving on to a technical writing role in 2004. His talent for describing software for new users stems from his difficulty understanding things that developers find obvious. He has a Bachelor of Music from the University of Victoria.