the most awesome guy ever.

The Blog of Darryl E. Clarke

  Random musings from a jaded coder who just needs a hug.

Archive for the ‘Ubuntu’ Category

The Switch: Apache + Mod_PHP to Nginx + PHP-FPM

Thursday, December 22nd, 2011

File this under “another thing I should’ve done ages ago.”

I decided that I should explore the world of Nginx as a web server since many people have been telling me it’s good. And all I can say is holy shit, it’s good. The setup was simple and after a few idiotic mistakes on my part, it was up and running.

At first I was skeptical as to how fast it would be and with my first couple of benchmarks, nginx was definitely faster.. but not by much. With just a simple php file on a very low resource machine (Ubuntu 11.10, on a 256MB VM at rackspace which I use for playing around) I used ‘ab’ to test 1000 requests with 10 concurrent:

Nginx:
Concurrency Level:      10
Time taken for tests:   0.473 seconds
Complete requests:      1000
Total transferred:      191000 bytes
HTML transferred:       26000 bytes
Requests per second:    2112.79 [#/sec] (mean)
Time per request:       4.733 [ms] (mean)
Time per request:       0.473 [ms] (mean, across all concurrent requests)
Transfer rate:          394.09 [Kbytes/sec] received

Apache:
Concurrency Level:      10
Time taken for tests:   0.533 seconds
Complete requests:      1000
Total transferred:      245000 bytes
HTML transferred:       26000 bytes
Requests per second:    1877.53 [#/sec] (mean)
Time per request:       5.326 [ms] (mean)
Time per request:       0.533 [ms] (mean, across all concurrent requests)
Transfer rate:          449.21 [Kbytes/sec] received

As you can see from the initial benchmark, there’s not much difference, but it is noticeable. And if you throw even more at it I’m pretty sure the gap will be bigger.  One thing that stood out most to me is the extra amount of data that Apache sends.

After I setup a zend framework application, I ran the benchmarks again. Same 10 concurrent, 1000 requests:

Nginx:
Concurrency Level:      10
Time taken for tests:   15.892 seconds
Complete requests:      1000
Total transferred:      3735000 bytes
HTML transferred:       3577000 bytes
Requests per second:    62.92 [#/sec] (mean)
Time per request:       158.922 [ms] (mean)
Time per request:       15.892 [ms] (mean, across all concurrent requests)
Transfer rate:          229.51 [Kbytes/sec] received

Apache:
Concurrency Level:      10
Time taken for tests:   17.724 seconds
Complete requests:      1000
Total transferred:      3791000 bytes
HTML transferred:       3577000 bytes
Requests per second:    56.42 [#/sec] (mean)
Time per request:       177.242 [ms] (mean)
Time per request:       17.724 [ms] (mean, across all concurrent requests)
Transfer rate:          208.88 [Kbytes/sec] received

Again, the difference is there. Nginx is clearly faster. It’s clearly winning. But I’m still just benchmarking with settings that I know Apache can handle on the low resource box. And this of course is all about resources and effectively using them. So I pumped it up. Time to do ab -c 100 -n 10000, ten thousand requests with one hundred concurrent and the results are amazing:

nginx:
Concurrency Level:      100
Time taken for tests:   122.030 seconds
Complete requests:      10000
Total transferred:      37350000 bytes
HTML transferred:       35770000 bytes
Requests per second:    81.95 [#/sec] (mean)
Time per request:       1220.301 [ms] (mean)
Time per request:       12.203 [ms] (mean, across all concurrent requests)
Transfer rate:          298.90 [Kbytes/sec] received

Apache:
CRASHED after 485 requests.
apr_poll: The timeout specified has expired (70007)
Total of 485 requests completed
load average: 83.73, 30.80, 11.43

The server load under apache went into a state of pure cluster-fuck. Apache could not contain itself with 100 concurrent connections on a box with such low resources, whereas Nginx handled it with EASE. The requests per second were slightly slower at 81.96 when doing 100 concurrent connections, but that request count is still amazing compared to apache crashing.

I’m sorry Apache+mod_php, you lose. Now it’s time to migrate all my stuff.

Tags: , , ,
Posted in Linux, PHP, Ubuntu, Zend Framework

Ubuntu: Sharing is Caring

Friday, April 29th, 2011


Over the last 24 hours, since the release of Ubuntu 11.04, I’ve managed to upload over 200GB on the torrents.  Here’s a little graph of my bandwidth use.  I’m sure this is just a drop int he bucket.  It’d be interesting to see how much other individuals upload during the same release time.

I don’t do as much as I should to work with the community, but at least I share!

Tags: , , , , ,
Posted in Linux, Ubuntu

Happy 10-10-10 and More.

Sunday, October 10th, 2010

Happy 10/10/10 which is kind of cool, but mostly annoying by itself.

Seeing as 101010 is binary for 42, Happy ultimate answer to the ultimate question day.

Also, Happy Canadian Thanksgiving.

Also, Happy Ubuntu Day.  They released Ubuntu 10.10 18 days early so it could fall on 10.10.10.  So if you’re an Ubuntu fan and you’re expecting a release on Oct 28th like it normally would’ve been scheduled, you can go download Ubuntu 10.10 now.

Tags: , , , , , , ,
Posted in Randomness, Ubuntu

Replacing a Live System RAID On The Fly

Friday, June 26th, 2009

Well, this is one of those crazy fun things that I had to attempt. My old system drive consisted of two 80 GB IDE drives in a mirror configuration. Pretty standard, but they were getting sluggish and I happen to have a few 320GB SATA drives doing nothing.

This is not a tutorial. This is a step by step account of a process I took to replace my disks; This is to be taken only as a suggestion as your configuration and mileage may vary. There may also be a better way of doing this.

So, lo and behold, I plugged them in to my eSATA ports and started rolling over!  For the sake of this exercise the original drives will be sda, sdb. The new drives will be sdc and sdd. The raid device is md0. (more…)

Tags: , , , ,
Posted in Linux, Ubuntu

Summer Project: Setup PostgreSQL

Saturday, May 23rd, 2009

Using my shiny new upgraded Ubuntu 9.04, I’ve gotten around to installing PostgreSQL.

Note: this is not a tutorial.

The installation was simple, as are most installations with Ubuntu. The initial “get going” was a bit odd for PostgreSQL though. The one thing you have to remember when initially trying to get things going is this… (more…)

Tags: , ,
Posted in Coding, MySQL, Ubuntu

Ubuntu 9.04 on a Dell Latitude D610, Success.

Saturday, May 9th, 2009

I had the joy of recovering data from a busted-ass Windows XP installation.  You know, the one where it blue screens no matter what boot process you try with an error about “kernl32.dll” being screwed? Yeah, one of those.  So, I fired up an Ubuntu live CD to test the hardware and figure out if anything was actually wrong with the laptop – and much to my surprise – everything just worked.

I’ve watched Ubuntu grow over the years and I’ve used it on many machines.  The trickiest has always been cheap laptops.

The specs on this machine are fairly simplistic:

  • Intel Pentium M 1.6Ghz
  • 1255MB of ram (strange, eh?)
  • 40 GB hard disk
  • cheap-o-dell-branded cd-rw/dvd-rom (modular, though)
  • broadcom gigabit ethernet
  • intel wireless
  • bluetooth (dell branded, onboard usb device)
  • standard ac’97 modem, ac’97 audio
  • and a bunch of other fluff.

I’m just really impressed that everything works.  I didn’t have to find any windows drivers, or do anything goofy to get things rolling.  All the function keys (standby, hybernate, wireless, battery status…) work as expected.

Kudos to Ubuntu.

Tags: , , ,
Posted in Linux, Ubuntu