As one experiment we created a daemon process in Perl and PHP, to compare. Here are the results.

Overview

Edoceo created this project Custos; one of the requirements was a simple daemon process that ran jobs from a queue. Fetch the job over HTTP GET/JSON, process the jobs, HTTP PUT/JSON. Simple right?

Our first construction of the daemon was in PHP, then we decided to build the same daemon process in Perl. We wanted to know if there would be signifigant difference is resource consumption or performance.

Results

Here is the resource usage as reported by htop after running the processes for four hours.

perl vs php resource usage

We had assumed that the Perl process would be lighter, but clearly is not. While the Virtual Memory reported by PHP is much higer that Perl, that's not actual RAM consumption (read up on VM allocation to be sure).

The important numbers are RES and TIME+. RES is the closest to the actual RAM used; and ties nicely with the consumption reported in MEM%. TIME+ is the CPU usage over four hours of these scripts executing - the PERL daemon has used 2 minutes 23, while the PHP script as only chewed 56 seconds.

Granted these scripts are quite trivial in their operation. We make no claims about performance of Perl vs PHP in larger, more comples daemons or services. Best to choose the hammer you know how to use. That said, moving forward we'll just continue using the PHP one.

The Perl Script

The full source is available on github. The important part is that we'er only using:

The PHP Script

Also available on github, this one is a pretty plain PHP script using the curl functions for HTTP and native functions for JSON processing.