Blog

  • It’s LEMP not LAMP!

    I’m sure many of you have heard the term LAMP before – standing for Linux Apache Mysql and PHP.  This is a very typical setup for many open source websites.  It’s been around for ages.  But make way for LEMP.  In a recent report by w3techs, a new HTTP server is climbing its way up the ranks called nginx, but it is pronounced Engine-X; hence, the term LEMP – standing for Linux Engine-X (nginx) Mysql and PHP.

    According to this w3techs report nginx is now used by almost 12.5% of the websites we know what web server they are running on.  More significantly a staggering 28.2% (of the 12.5%) websites rank in the top 1,000 worldwide (according to their Alexa ranking).

    Along with my recent switch to Amazon EC2, I also decided to switch to a LEMP stack.  I thought I should throw out another shout out to HowToForge.com for this AMAZING step-by-step tutorial on installing a LEMP stack with extremely simple to follow instructions on my brand new Ubuntu 12 server.

    Check out the step-by-step instructions to setting up your LEMP server.

    I think I only had to make one modification to this instruction set before being able to perform one of the apt-get install commands I had to perform an update on the box.  Luckily enough, the OS told me exactly what to do!

    A friend and former colleague introduced me to nginx a while back with his blog about Setting up WordPress with nginx and FastCGI.  This is quite useful for understanding the nginx configuration for a virtual host that requires rewrite rules as nginx currently has no support for .htaccess files!

  • Amazon EC2 Shoutout!

    I was previously hosting all of my sites with GoDaddy, using one of their unlimited domain hosting services.  While this was pretty inexpensive compared to similar services, I was never truly happy with the load time.  Often taking over 1.2 seconds to load this blog!

    At my current job, I had the pleasure of doing of some speed testing with some Amazon EC2 services.  I was certainly impressed with them.  While I was doing some costing for work, I decided to do a bit of costing for myself.  I run several websites, no hits by any means, but enough that I care about the poor performance I was getting at GoDaddy.

    My annual fee at GoDaddy was in the neighbourhood of $100/year.  Quite decent for the 7-10 websites I’m currently hosting.  However, I started looking at the micro instances that Amazon offers.  These start as low as $0.02 per hour.  When you cost this out over the entire year, it works out to around $180/year.  Obviously more expensive, but Amazon also offers reserved instances.  Knowing that my sites will be around for the whole year, getting a 1 year reserved instance brings it down to $130/year; much closer to the previous $100/year that you barely notice it!

    If you’re a regular visitor of this blog, you’ll now notice that the site takes less than 0.5 seconds to load!  Not too shabby for a few bucks more a year.

    Now, here’s the real kicker, Amazon is offering FREE micro instances for a year with certain usage limitations!  So far, my sites are taking complete advantage of it and I’m extremely happy.

    Before making the jump, please remember there is a big difference; one is managed by a team of professionals to keep running versus running your own dedicated server with EC2.

    If you have a little bit of knowledge and know what you’re doing, I definitely suggest taking advantage of Amazon EC2’s free micro hosting!

    P.S. I am not getting anything in return from Amazon for writing this post, just thought Amazon deserved the recognition for providing me with free micro hosting!

  • A Simple But Effective Speed Comparison

    A little while ago, I wrote a simple .NET application that performs X amount of requests and calculates an average speed of those requests.  It does this by dropping the highest and lowest request times, then taking an average speed on the remaining requests.

    This does a decent job for a straight up speed test.  However, a few possibilities could arise, such as CPU hogging that could skew the results.  Instead, I’ve made a few alterations and converted the speed tester to not be based on the number of requests, but instead based on a specific amount of time.  This should help eliminate some inconsistencies of doing a straight number of requests.

    (more…)

  • PHP: Require/Include vs Autoloader

    Google has long since ingrained into my brain how important every millisecond is when dealing with large amounts of traffic.

    In this post, I’m going to demonstrate a really simplistic way to improve your PHP website performance.  It seems to go against the grain of “old school” vanilla PHP writing, but the results are incredible!  By removing the use of require and include and replacing it with a spl_autoload_register function instead, the time savings are more than 10 times!

    Not only that, in theory it’s less lines of code!

    (more…)

  • JavaScript: Easy Creation of “Countdown Timers”

    If there is one thing I don’t like doing – it’s doing the same thing twice or even more!  So I was building an application on the side where I need to have a listing that performs a simple countdown.  At this point I’ve been lazy and just have it counting down the seconds, but this example would be really easy to update to put a proper countdown of days, hours, minutes, and seconds – and heck if you get really adventurous even weeks, months, and years!

    (more…)