Category: Optimization

  • 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…)

  • CakePHP Version Comparison with PHP Version Comparison

    I’ve seen a few recent blog articles comparing the new version of PHP 5.4 to its predecessors and I thought I should get involved with this a bit as well.

    To perform this test, I will layout the conditions I have chosen.  I’m trying to keep this as simple as possible.  I currently run a Dell Laptop with Windows 7 on it:

    Windows NT 6.1 build 7601 (Unknown Windows version Business Edition Service Pack 1) i586

    Because I often do a lot of .NET development recently I have PHP running as a CGI under IIS 7.5.

    I then created a very simple .NET application that performs 100 requests of the same web page and tracks the response time.  These lists of response times are sorted and the highest and lowest responses are dropped.  The average is then calculated from this.

    (more…)

  • CakePHP 1.2 VS 1.3 VS 2.0 Page Request Times

    When I first started using CakePHP a few years ago, we had a lot of complaints about speed.  If you do some Google searches comparing CakePHP to other frameworks, it seems to be near the bottom of the pack.  I previously wrote a few articles on optimizing CakePHP here:

    Implementing the following tips certainly helped; however, if there are issues with the core framework response time, no amount of optimization will truley help.  So after reading up on CakePHP 2.0 and it’s recent speed improvements, I wanted to do some straight CakePHP comparisons.  Below are 10 load times for CakePHP 1.2, 1.3, and the new 2.0.  These load times are of a brand new install simply loading the default home view, no database connection or any model loading. (more…)

  • Building A Scalable Queueing System With PHP

    In today’s article we are going to cover building a queueing system with PHP.  Before we begin, let’s define what a queueing system is.  The best place to start is the dictionary:

    “to line up or wait in a queue”

    Now that we have our definition, let’s define why we would want to build a queueing system.  A queueing system is an excellent tool that will allow us to take a specific process and perform the functionality “offline”, e.g. the process will line up and we will process them one at a time at a later date.  This will probably be easier to explain with an example.

    Imagine an admin area of a website that allows the administrator to send out a mass email to all of their users.  The simple process to building this functionality would be as follows:

    1. Build a form that accepts a subject and a body for the email.
    2. Retrieve the list of users from your database.
    3. Loop through the users and send each person an individual email.

    The above example works nice and fast when there are only a few hundred users.  However, imagine trying to send this email to 10,000 users.  The administrator would be waiting a long time for this process to finish.  Not only that, if they closed the browser, it probably would not finish properly.

    So, the goal of our queueing system is to remove a specific process from running “online” (in a web browser) and running it “offline” with a scheduled task. (more…)