Category: Optimization

  • Load Testing Mysql with mysqlslap

    I have a few thoughts for some testing/comparison of mysql tables that I have been curious about.  Before starting though, I thought it was prudent that I should give it some thought about the approach.  The first thing that came to mind was altering the A Simple But Effective Speed Comparison code to execute a bunch of SQL queries against my local installation.

    I really didn’t like this approach because of the potential inaccuracy due to the overhead of the language and connecting to mysql before executing the queries.  The whole purpose of these potential upcoming articles is to compare mysql, not a specific language integrating with mysql.

    Luckily for us, as of Mysql 5.1.4, a tool called mysqlslap is shipped with the server installation.  This tool allows us to client emulation against our mysql server!

    (more…)

  • Update: It Actually Should Be LEPP Not LEMP or LAMP!

    In several recent posts: It’s LEMP not LAMP! and Amazon EC2 Shoutout! I’ve discussed how I switched from a shared hosting account with GoDaddy to a dedicated Micro instance with Amazon.  At the same time I decided to go out and try nginx (pronounced Engine-X) and remove Apache from the equation.

    This saw some incredible results.  However, several times since switching I’ve run into several database issues where it appears Mysql runs out of memory!  Performing a top command shows over 15 mysql processes running at anyone giving time each taking up to 10% of the memory.  On a micro instance I only get 600mb, so this adds up quickly!

    (more…)

  • Comparing a while loop against a foreach loop of an array

    Are you confused by the title?  I was when I first got the idea to even write this blog as well.  I was recently perusing the CakePHP change logs and came across an interesting commit – Optimization for Hash Method.

    The optimization is quite simple, this code:

    [code]
    while (($key = array_shift($parts)) !== null)
    [/code]

    Is replaced with the following code:

    [code]
    foreach ($parts as $key)
    [/code]

    This is actually done several times in the commit.  It seems that the original developer is really keen on using the array_shift function.  Just in seeing this code, I thought the original code was odd to utilize that function so I immediately had to do a comparison and validate the optimization!

    (more…)

  • What I Learned This Summer

    Well – it’s Friday and all of the kids are back in school.  While this post is being published, I’m probably stuck in traffic!  I can’t believe it’s a new school year already, luckily my kids aren’t old enough so it’s just traffic that I need to get used to.

    This has been a great summer so far and I thought it would be a good idea to summarize the variety of things I’ve learned about – but have not necessarily blogged about…

    (more…)

  • 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!