PHP
  Home arrow PHP arrow Page 4 - Optimizing System Performance
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Mobile Linux 
App Generation ROI 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
PHP

Optimizing System Performance
By: Sams Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2006-11-30

    Table of Contents:
  • Optimizing System Performance
  • Optimizing Performance
  • Database Optimizations
  • Keep Your Code Simple
  • Exam Prep Questions

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Optimizing System Performance - Keep Your Code Simple


    (Page 4 of 5 )

    If you're coming from a Java background, you might be used to writing a large infrastructure of classes that rely on each other to perform a particular task.

    Don't try this with PHP! PHP's OOP features work best when your framework is small and efficient. Creating objects in PHP is a rather slow process, and, as such, it should be used conscientiously.

    Caching Techniques

    Sometimes, it's just not possible to optimize your code beyond a certain point. It might be that your queries are too complicated or that you depend on a slow external resource, such as a web service, over which you have no control.

    In these cases, you might want to think about using a caching solution that "saves" the output of an operation and then allows you to access it without performing that operation again.

    There are several types of cache; for example, you can save the results of a database query, or even an entire web page. The latter means that you generate your pages normally at predetermined intervals and save them in the cache. When a page is requested by a user, it is actually retrieved from the cache instead of being generated from scratch.

    You can find several packages in the PEAR repository that are useful for output caching of various type. Naturally, there are also commercial solutions that perform a similar task, such as the ones provided by Zend.

    Bytecode Caches

    When PHP runs your scripts, it does so in two steps. First, it parses the script itself, transforming it into a sort of intermediate language referred to as bytecode. Then, it actually interprets the bytecode (which is simpler than PHP itself) and executes it. If your scripts don't change between one execution and the next, the first step could easily be skipped, and only the second step would have to be taken.

    This is what "bytecode caches" do. They are usually installed as simple extensions to PHP that act in a completely transparent way, caching the bytecode versions of your script and skipping the parsing step unless it is necessary—either because the script has never been parsed before (and, therefore, can't be in the cache yet) or because the original script has changed and the cache needs refreshing.

    A number of commercial and open-source bytecode caches (also called accelerators) are available on the market, such as the one contained in the Zend Performance Suite, or the open-source APC. Most often, they also modify the bytecode so as to optimize it by removing unnecessary instructions.

    Bytecode caching should always be the last step in your optimization process because no matter how efficient your code is, it's always going to provide you with the same performance boost. And, as a result, it could trick you into a false sense of security that would prevent you from looking at the other performance optimization techniques available.

    More PHP Articles
    More By Sams Publishing


       · This article is an excerpt from the book "Zend PHP Certification," published by...
       · You would better be aware with GZIP compression within PHP since this is heavily...
       · Thanks for the advice!
     

    Buy this book now. This article is excerpted from the book Zend PHP Certification, written by George Schlossnagle et al (Sams; ISBN: 0672327090). Check it out today at your favorite bookstore. Buy this book now.

       

    PHP ARTICLES

    - Working With Different Namespaces in PHP 5
    - User Management Explained: Overview
    - Using Namespaces in PHP 5
    - Database Security: Guarding Against SQL Inje...
    - Building a Modular Exception Class in PHP 5
    - Database and Password Security for Web Appli...
    - Handling MySQL Data Set Failures in PHP 5
    - Building Site Registration for Web Applicati...
    - Intercepting Customized Exceptions in PHP 5
    - Securing Your Web Application Against Attacks
    - Sub Classing Exceptions in PHP 5
    - Authentication for Web Application Security
    - Building a Content Management System with Co...
    - Filters and Login Systems for Web Applicatio...
    - Working with the Email Class in Code Igniter





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT