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 ‘Linux’ 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

You Want Us To Be Secure…

Thursday, August 4th, 2011

But you make it so complicated.

From a technical standpoint, I understand how simple it is to create certificates for SSL/TLS and put them into configs and use ’em.

From a user standpoint, I can not understand the who/what/when/where/why as to the whole security industry and being so damn complicated.

So many SSL providers out there off you packages from FREE to thousands of dollars and for what? It’s just encryption. It’s just a browser asking “Hey, is this certificate valid still?”

So many providers also make it hard to just register. You’ve gotta jump through hoops and do crazy things like create a CSR and upload it when they could just have a simple, secure (irony) web form to let you generate one on the spot. Sending documents back and forth to “verify” your identity.

Seriously, I just want some encryption.

I also like the “we need to verify you’re the owner” processes… so many loopholes.

There’s a huge opening in this industry for someone who wants to make this whole process simple and easy (and cheaper). Just sayin’.

Tags: , , , , ,
Posted in Linux, Randomness, Security

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

I Finally Upgraded to Debian 5

Saturday, October 17th, 2009

On my production web server, I’m kind of a crazy fool.  I often do things that make people cringe and scream and say “what the hell are you doing?”

One of those said things is doing a distribution upgrade on-the-fly of the OS.  Since the installation of my server some three and a half years ago, Debian has had two major releases.  My server started with sarge, upgraded to etch, then upgraded again to lenny.  Unfortunately this time after 1210 days without rebooting my server I was forced to reboot. That is to say, since I installed my server where it lives it had never been rebooted.

The reboot occurred because the new libc required kernel 2.6. I was still cooking with an old 2.4 kernel.  After a pile of apt-get trickery, I got the necessary packages installed and had to reboot.  Once the 2.6 kernel was up and running everything else installed without a hitch.  I had to track down a few configuration changes with a couple of things, but overall I think the upgrade went smooth and with only a few minutes of downtime.  Not bad, I say, not bad.

Tags: , , , , ,
Posted in Linux

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

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