Archive - Benchmarks RSS Feed

Net::DNS and gethostbyname

I was trying out DNS resolvers for perl and made these two scripts. test.poller.se returns 3 A records, the scripts print out 2 of them.

netdns.pl

#!/usr/bin/perl
 
use warnings;
use strict;
 
use Net::DNS;
 
my $resolver = new Net::DNS::Resolver;
my $query = $resolver->query("test.poller.se", "A", "IN");
 
my @hosts;
my $rr;
foreach $rr ($query->answer) {
        push(@hosts, $rr->address);
}
 
print $hosts[0] . "\n";
print $hosts[1] . "\n";

gethostbyname.pl

#!/usr/bin/perl
 
use warnings;
use strict;
 
use Socket;
 
my @hosts;
my ($name, $aliases, $addrtype, $length, @addrs) = gethostbyname("test.poller.se");
$hosts[0] = inet_ntoa($addrs[0]);
$hosts[1] = inet_ntoa($addrs[1]);
 
print $hosts[0] . "\n";
print $hosts[1] . "\n";

Performance difference for the two is quite big. Of course, Net::DNS is more then just a simple resolver.

$ time for i in `seq 1 1000`; do ./netdns.pl > /dev/null; done
real	1m18.185s
user	0m46.203s
sys	0m29.418s

$ time for i in `seq 1 1000`; do ./gethostbyname.pl > /dev/null; done
real	0m26.886s
user	0m7.784s
sys	0m17.969s

Rackspace Cloud vs. Amazon EC2

Rackspace Cloud, or Amazon EC2, which is best? This is just a quick performance comparison using SysBench. The following products where tested.

Product CPU Memory Disk Price
EC2 Small Instance 1 virtual core 1,7GB 160GB $0.085 per hour
Rackspace 256MB 4 virtual cores 256MB 10GB $0.015 per hour
Rackspace 1024MB 4 virtual cores 1GB 40GB $0.065 per hour

Servers where running Ubuntu 9.10 i386, tests where performed on two different occasions, average scores where used. Here’s the results, less is good.

Product SysBench CPU Sysbench Memory Sysbench File I/O
EC2 Small Instance 29.7s 491.3s 28.6s
Rackspace 256MB 5.6s 219.1s 26.4s
Rackspace 1024MB 4.1s 196.1s 17.8s

The following commands where used to do the benching, interesting values was the total time to run the test.

sysbench --num-threads=4 --test=cpu run
sysbench --num-threads=4 --test=memory run
sysbench --num-threads=4 --test=fileio --file-test-mode=rndrw prepare
sysbench --num-threads=4 --test=fileio --file-test-mode=rndrw run

Conclusion

According to SysBench, Rackspace Cloud is much faster then EC2 in general, and cheaper as well. EC2 however comes with more memory and disk.

Comparison of APC and XCache

APC
Alternative PHP Cache, will be included in the core of PHP 6.

XCache
Developed by one of the developers of Lighttpd.

Benchmarks where done on a small Amazon EC2 instance, running official Ubuntu 9.10 image. Benchmarks where done on two different occasions, average results are used. The following packages are installed from APT.

  • libapache2-mod-php5
  • php5-mysql
  • php-apc
  • php5-xcache
  • mysql-server

The following web sites will be tested

  • Hello World script
  • WordPress 2.9.1
  • Joomla 1.5.15

Benchmarking itself is done with ab (Apache benchmarking tool) on localhost, doing 1000 requests over 10 connections (-n 1000 -c 10). Interesting numbers are request per second.

Here’s the results, numbers are requests per second, the percent is the improvement.

Without accelerator With APC With XCache
Hello World 1499 1602 (7%) 1563 (4%)
WordPress 2,82 12,61 (347%) 12,97 (360%)
Joomla 2,25 3,60 (60%) 3,48 (55%)

The big increase in WordPress performance could be because not much sample data is installed in the default installation (compared to the option in the Joomla install, which i used), which could mean that the large bottleneck in Joomla is MySQL not PHP, while being the other way around for WordPress. But even with large amount of data, the performance improvement should be good.

Conclusion
Since there isn’t any big difference in performance between the two, I would choose APC. Mainly because it will be included in the core of PHP 6.

The problem with Apache

Apache is a great web server, I use it myself a lot. There is however one huge problem when working with it in big deployments, and that’s the enormous start and reload times when working with many virtual hosts. When using regular web servers you probably don’t have more then 2 or 3 thousand vhosts, but when deploying a cluster of load balanced web servers you can easily handle tens of thousand of them. And that’s where the problem come in.

This very nice excel graph shows the problem quite nicely.

With 2000 vhosts there’s no problem, the start time is around 2 seconds and reload time is around 5 seconds. But with 40 000 of them it’s another story, as you can see.

These tests where performed on a dual xeon server with 2GB of memory and a nice (15krpm, RAID10) SAN backend for storage and no load on the server.

In comparison, Litespeed reloads with 40 000 vhosts in under 5 seconds.

Page 3 of 3«123