How can I track down CPU intensive requests in mod_perl? - perl

Using Apache 2.2 and mod_perl on Ubuntu 8.04 I have several applications on a server. Using Apache in pre-forking mode. Usually things are working well but once in a while I see one of Apache processes using 100% of the CPU.
There are several web sites on the server with their own VirtualHosts and there are
is and SVN server running via Apache.
How could I track down which application and which calls in that application generate the high load?

Devel::NYTProf is pretty much the premier profiler for Perl right now, with Devel::NYTProf::Apache for easily profiling mod_perl applications.
See Tim Bunce: NYTProf v2 – A major advance in perl profilers for a pretty overview with pictures.
Unfortunately, Devel::NYTProf isn't pre-packaged in Ubuntu Hardy. (It is pre-packaged in Jaunty, Karmic, Lucid, and later.) You can either use some apt trickery to install packages from those distributions, install from CPAN, or just upgrade ;-)

If you have a large subversion repository and path-based authorization enabled in your apache configuration you're going to see some long-running, high CPU apache tasks. You'll probably also have complaints from subversion users about slow commits and updates, along with 503 errors and subversion complaining about truncated SSL responses. If this is the case, I'd make subversion my prime suspect.

Use a custom log format or a write a PerlLogHandler that records the request information along with the PID and resource use information. See, for instance, Randal's Web Techniques Column 48.

Related

Installer for Software? Paas?

currently I'm looking for an open source project that gives me the opportunity to install software easily. I prefer direct calls or access with a REST interface.
I thought that CloudFoundry would fits my needs but it is'nt so.
AppFog (https://www.appfog.com/product/) comes much closer to my goal. It allows me to install Drupal, Wordpress, PhpMyAdmin, NodeJS Apps and so on.
The conclusion is that I'm looking for an project that...
is open source.
gives that possibility to install, configure and
uninstall software
is extendable when a specific software not
available
is accessible with an interface like REST.
is "hostable" on my own linux server
I would be happy for all kind of hints and tips :)
Cheers Tobias
Docker is seems to be the next big thing in the PaaS world. There are dozens new projects that build on top of docker or supporting it. For example OpenShift and Apache Stratos support docker. So if you look at solutions based on docker you can find a solution for you needs.
Right now I'm using docker for hosting couple of Drupal websites with simple bash scripts to manage them. Nginx is used for web traffic routing
Docker is open source
Gives you ability to prepare and install apps
You can build what you need on top of it
It has REST interface
It is running on nearly all major Linux distros
Its relatively easy to learn and use
Has great community
Tobias,
Suggest you look at Apache Stratos:
100% open source
Easy to Get Up and Running
Highly extensible, flexible, expandable
Uses REST APIs
Runs on Linux (Ubuntu or SUSE)
Mature (version 4)
See:
Intro article -- "Why Apache Stratos is the Preferred Choice in the PaaS Space"
http://wso2.com/library/articles/2014/05/why-apache-stratos-is-the-preferred-choice-in-the-paas-space/
Apache Stratos Project site -- which notes that "Stratos PaaS is easy to get it up and running in quick time. A developer will be able to run and test PaaS framework on a single machine to try out."
http://stratos.apache.org/
Cheers,
Michael
OpenShift is what you looking for :
it is open source and free for 3 gears for ever.
gives that possibility to install, configure and uninstall software in openshift.redhat.com or in rhc client tools.
it is extendable when a specific software not available is accessible throw DIY(Do it yourself)
with an REST interface
is "hostable" on Fedora or CentOS .
It is really easy to setup throw Eclipse.

Pre-forking Dancer app on CentOS

I have a prototype application (RESTful web service database front-end) that is written using Dancer. As a prototype this runs fine under Apache with mod_proxy, and Dancer's routes work really nice.
My next step is to see if I can get this to scale a bit as some of the queries can be very slow and I don't want the slow queries blocking other requests.
I'd like to use rpms to manage the needed perl modules. For Dancer, this is no problem as CentOS-6 plus EPEL provide sufficient rpms to allow me to build/install Dancer and Dancer::Plugin::Database rpms.
Trying to build Plack rpms isn't working nearly as well however due to a varietly of reasons, one of which is that some of the system modules are too low a version number (and no, overwriting the system rpms with higher version local builds is not considered an option).
EPEL does provide rpms for CGI::Emulate::PSGI and HTTP::Server::Simple::PSGI but I'm not seeing how to wrangle either one of them into a desired solution.
So, my question is: Is there a clean/maintainable way to get Dancer running on CentOS-6 with pre-forking? Barring that, how does one get Apache to play nicely with a local perl install (where I can use tools like cpanm to install things)?
I highly recommend you the use of perlbrew, and forget the system perl.
If you want to restrict yourself to the packages shipped with CentOS, then you can run your Dancer app under mod_perl. There is a Plack adapter for mod_perl, so it is rather straightforward.
For example
<Location /myapp>
SetHandler perl-script
PerlHandler Plack::Handler::Apache2
PerlSetVar psgi_app /var/www/html/myapp.example.com/app.psgi
</Location>

Problems getting memcached stats on Windows (Membase)

I just installed Membase's version of Memcached (because it seems to be the only / best option to run memcached on windows) and I'm finding a strange problem.
I'm trying to make a little debug tool for myself (only for dev, not for production), and i'm trying to get the contents of memcached. However, all these commands fail:
stats maps
stats cachedump
stats slabs
stats items
stats sizes
I'm running these both from PHP and from telnet.
The only stats options that seem to work are plain "stats", and "stats reset". All the others just say "ERROR"
I'm running memcached version 1.4.4_304_g7d5a132 (according to "stats") or 1.6.4_1_ga5cbcfd (according to "version"). Not sure which one it is.
I've found references to these commands all over the Internet, and I haven't found any information about being deprecated.
Am I doing something wrong?
Are these commands removed from Membase?
Any recommendation on another version of memcached that I can simply install and will run on Windows (the simpler it is to install, the better)
Thank you!
Daniel
Hey Daniel, the Membase server version of memcached is the easiest/best version for Windows available. I'm happy to help you get the information you want...it might also be good to post something on our forums so all can see: http://techzone.couchbase.com/forums/
The main problem here is that we have currently implemented a proxy to allow easier cluster management. I can get more into the details there, but the proxy will aggregate statistics across the cluster and these particular commands don't make sense to aggregate.
If you download the latest Membase version (1.7, pre-release: http://techzone.couchbase.com/products/membase/1-7-beta) you will get the following stats script that will allow you to run all of these commands:
C:\Program Files\Membase\Server\bin\mbstats :11210 raw [maps|items|slabs|sizes] [bucket_name]
I would recommend against using cachedump as it can have performance problems and isn't officially supported by the memcached server (even though it "works" in some small scales).
Perry Krug
Sr. Solutions Architect, Couchbase, Inc.

How can I host a mod_perl application on a shared RHEL server?

I want to host a mod_perl application on a shared RHEL server where I do not have access to a root account. mod_perl is available on the server as are all Perl modules required (my app runs fine with CGI).
Here are two problems I anticipate: Apache restarts would be required whenever I update my code the first time and subsequently on periodic updates. Second, I would have to use some <Perl> directives in .htaccess. I would be happy to hear experiences, gotchas, hints from others who might have done this successfully. Thank you!
This might not be useful in your case, but you can always run an
Apache instance in your home directory, and have the frontend proxy
incoming requests to that instance. That way, you have full control
over the configuration, Apache modules, Perl modules, and Perl itself.
It also uses system resources better (slow clients don't tie up the
heavy perl app, only the lean frontend instance), and is actually the generally
recommended way of deploying mod_perl applications.
Another option, and one that will involve less screwing around, would
be to get a $20/month VPS and use that. Then you can do whatever you
want, as you'll have full root access.
You can't do it without the ability to restart Apache httpd.
Perhaps the admin will give you sudo powers so you can do that at least.
Try Perl under FCGI instead.
You aren't gonna be able to use mod_perl without root on a shared hosting account. The "run my own instance" sounds okay, but you will need a way to start up apache if the server reboots.
FCGI is your best bet. That or get something where you can get root access to your own apache process. The added benefit of such an account would be you could install CPAN modules without going through the extra hassle of setting up a non-root library and messing with $PERL5LIB.

Best Practice: Erlang Application Deploy on windows

When deploying a ready to use erlang application I don't want the user to
Find the right erl release on the
internet.
Install the erl vm
unzip and decide a location for the beam files (with the application)
read a readme
modify anything that even looks like a config file
I have a couple of ideas of what could be a way but I would like to get some input.
SAE (stand-alone Erlang) used to be a pretty good solution for situations like you describe, but that no longer seems to be maintained.
Although I've never used it myself, CEAN seems like it might come close to what you want: it offers a self-extracting installer (though not for Windows at present) and the option to deliver a customized minimal Erlang framework.
There is also Erlware.
At our core we host public
repositories containing reliable
Erlang OTP-compliant applications. Our
repositories enable developers to use
software written by the Erlang
community and to publish and
distribute their own software.
It's more backend orient though, so not a complete solution.
The reltool application first released with Erlang R13B02 is aimed at solving this issue. Note that it is currently a beta release (version 0.5).