пятница, 16 марта 2012 г.

Why server is so slow? - Use "The USE Method" !


I'm excited!
I've just found fabulous posts in DTrace blog -

1. The USE Method - http://dtrace.org/blogs/brendan/2012/02/29/the-use-method/
2. The USE Method: Solaris checklist - http://dtrace.org/blogs/brendan/2012/03/01/the-use-method-solaris-performance-checklist/
3. The USE Method: Linux checklist - http://dtrace.org/blogs/brendan/2012/03/07/the-use-method-linux-performance-checklist/
At glance - it's about method of checking system performance problem - USE (utilization, saturation, errors) method. In case of server system we have different resources - CPU, memory, storage, network etc.
For each resource we check

  • utilization: the average time that the resource was busy servicing work
  • saturation: the degree to which the resource has extra work which it can’t service, often queued
  • errors: the count of error events 


Usually we need to check for errors first, then utilization and saturation after this. But it's really short explanation - I beg you to check original posts. :) In next two posts Brendan provides recomendations with lists of commands for Solaris and Linux for using USE method.
And USE method is usable even without dtrace - Linux do not have native dtrace, and authors of original Dtrace blames current versions of Linux dtrace very hard. :)


воскресенье, 4 марта 2012 г.

Perl is on Heroku now !

Russian link is here.

Recently I found some amazing trick - you can use your favourite web-platform on Heroku! It can be possible using special feature called buildpacks. Of course, Perl is supported too - Miyagawa yourself wrote buildpack for PSGI/Starman application deployment - https://github.com/miyagawa/heroku-buildpack-perl :)
So, I've decided to move my Plusfeed.pl application to Heroku - because Stackato's trial period is over now. Also some annoying bug was also fixed - I've change ID of message to URL instead of Etag and now message will not go up in RSS feed after adding comment or +1. :(
Instruction below - 
1. Please create Makefile.PL for your application (see ExtUtils::MakeMaker for its format)
use strict;
use warnings;
use ExtUtils::MakeMaker;

WriteMakefile(
    NAME      => 'plusfeed.pl',
    VERSION   => '0.05',
    AUTHOR    => 'Denis Zhdanov ',
    EXE_FILES => ['app.psgi'],
    PREREQ_PM => {
        'Google::Plus'             => '0.004',
        'XML::RSS'                 => '1.49',
        'XML::Atom::SimpleFeed'    => '0.86',
        'Plack::App::Path::Router' => '0',
        'Plack::App::File'         => '0',
        'Plack::Builder'           => '0',
        'Path::Router'             => '0.11',
        'CHI'                      => '0.5',
        'Starman'                  => '0.3',
    },
    test => {TESTS => 't/*.t'}
);

2. Add your app to Heroku using custom buildpack - 
git init
git add .
git commit -m "Initial version"

heroku create --stack cedar --buildpack \ http://github.com/miyagawa/heroku-buildpack-perl.git
git push heroku master
All magic is in this buildpack line (of course, change  to the name of your application). 
You will get something like 
-----> Heroku receiving push
-----> Fetching custom buildpack... done
-----> Perl/PSGI app detected
-----> Installing dependencies
-----> Installing Starman
       Starman is up to date. (0.3000)
-----> Discovering process types
       Procfile declares types     -> (none)
       Default types for Perl/PSGI -> web
-----> Compiled slug size is 6.8MB
-----> Launching... done, v7
       http://plusfeed-pl.herokuapp.com deployed to Heroku
(In the first time you will get much more lines with installation of cpanm and all dependencies, but not for update).
Thats all, folks! Your app is up and running. 
My app lives on http://plusfeed-pl.herokuapp.com now.