YOUR FEEDBACK
Java Application Development wrote: Good Post....... Thanks...
AJAXWorld RIA Conference
$300 Savings Expire August 22
Register Today and SAVE!


2008 East
DIAMOND SPONSOR:
Data Direct
Frontiers in Data Access: The Coming Wave in Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
Intel
Virtualization – Path to Predictive Enterprise
Green Hills
IT Security in a Hostile World
JBoss / freedom oss
Practical SOA Approach
GOLD SPONSORS:
Software AG
The Art & Science of SOA: How Governance Enables Adoption
PlateSpin
Effective Planning for Virtual Infrastructure Growth
Fujitsu
Automated Business Process Discovery & Virtualization Service
Ceedo
Workspace Virtualization
Click For 2007 West
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP LINKS YOU MUST CLICK ON


Put Your PHP App on Steroids
Optimizing with APC: Alternative PHP Cache

Ian Selby's Gen X Design Blog

Nothing's cooler than writing a bad-ass site or application and watching it gain popularity and a significant user base. By the same token, nothing's more frustrating than watching your app fall on its face when its running under high load. If you're like me, you know how disheartening this can be, as it usually means that it's time for a hard dose of reality: your code probably isn't as awesome as you thought it was.

Or is it? There’s a whole slew of things that a person could point a finger at regarding slowly running code. The most-oft thing that gets called out is code with a lot of overhead (a ton of includes, excessive logic, and the like), and right behind that is poorly designed databases (unoptimized indexes, no indexes, ridiculous amounts of joins, blah, blah, blah). Well, let’s assume for a minute that you’ve got a fair amount of experience under your belt, so you know your code is pretty damn optimal, and you also have a DBA buddy that took a look at your database and helped you tweak it up a bit. What do you do if this isn’t enough? Before you say, “throw more / better hardware at that mo-fo”, why not take a moment and learn about APC: Alternative PHP Cache…

OK, as usual, let’s make sure we are aware of a few general understandings before we get into the goodness of APC. It is very important to understand that despite all your optimization work, you’re always going to run into two major hurdles when it comes to keeping your app running blazing fast… that’s just the way it is. True, there’s a lot of things I’m glazing over here, and there’s even more points that could be debated… if you want to talk about it, feel free to contact me, I love talking code. For the sake of brevity and clarity, however, we’re going to steer clear of the nitty-gritty and look at things in a much broader scope. So, anyway, those two hurdles: memory, and database bottle-necking. You’re always going to need more memory, and at some point, your database is going to be slowing your app down. But before you get ready to get that beefier server, or a separate database server, or anything else (as much fun as new toys can be), let’s take a look at what can be done with your existing hardware and code.

I think it’s a fair statement that a lot of applications retrieve the same information from a database over, and over again, and that it’s also safe to say that this information gets updated at predictable intervals. Wouldn’t it be nice if we could store this data somewhere so we don’t have to keep pinging the database over and over for the same thing? It would also be pretty cool if we could leave that data stored, and update it not only in the database, but in the “storage area” as well? Good news kids, you can certainly do that… all with the magic of caching… APC caching!

I’m going to show you how APC can be leveraged to cache your application data, thus eliminating a ton of repetitive trips to the database, and thus removing your bottleneck! As an added bonus, I’m also going to do my best to explain some of the other goodness of APC and caching in general, as a lot of the articles floating around the web assume you simply understand what “opcode caching” and other stuff like that means (I certainly didn’t for a while).

Hopefully, if you’ve written an app that would benefit greatly from APC, you understand how PHP works. If you don’t, here’s a quick review… PHP is an interpreted language, which means that the code you write isn’t actually compiled, like actual application code is. The PHP code you write is compiled at the time it’s requested, and it’s compiled every time. Obviously, this is a really fast process, but I’m sure you can see how it’s also problematic. Well, that’s why APC was developed (by one of the guys that developed PHP, in fact). APC keeps that PHP code you’ve written compiled in memory, or caches it. This is what an opcode cache is, nothing more than a cache of pre-compiled code. By simply installing APC and enabling it, you will probably see a noticeable speed improvement in your app. But there’s a lot more we can do with APC to speed up an app, and we’ll get to that shortly, but I think I need to answer a more pressing question: “How the hell do I get and install APC?”

About Ian Selby
Ian Selby has been developing web sites professionally for over 7 years, and has always tried to stay on the cutting edge of web trends and technologies. He has a passion for all things Web 2.0, loves shiny icons and gradients, and lives in the San Francisco Bay area. He works for Aptana and is owner of Gen X Design, a freelance development and design company. He blogs at http://www.gen-x-design.com/.

ENTERPRISE OPEN SOURCE MAGAZINE LATEST STORIES . . .
Money is being made with Open Source. Some make spectacular money by exploiting Open Source (Google, Apple) and some things wouldn't even exist without it (Internet, Software as a Service, Cloud Computing) - so it really boils down to finding the right business model.
ELASTRA announced Elastra Cloud Server support for the Eucalyptus platform. ELASTRA’s products are designed for portability across compute clouds and currently provide support for the Amazon EC2 and S3 compute and storage environments. Because Eucalyptus exposes its virtual machines ...
Jitterbit has announced the availability of Jitterbit 2.0 Enterprise, which includes new capabilities, scalability and management tools. With this new release, organizations have the ability to solve integration challenges between legacy, enterprise, and on-demand applications and data...
A new API is supposed to integrate LinMin Bare Metal Provisioning 5.2 into environments that haven’t been able to do bare metal provisioning of Windows, Red Hat, Novell, Ubuntu, CentOS, Fedora or Asianux on physical systems or virtual machines before. The rev also features single-com...
The United States Court of Appeals for the Federal Circuit Wednesday overturned a year-old San Francisco district court decision that deprived the aggrieved plaintiff in a dispute over open source software governed by the Artistic License of the right to sue for copyright infringement ...
Google has waded into the encryption business with an open source cross-platform toolkit called Keyczar that’s supposed to make it easier for ISVs to put cryptography in their applications. It says Keyczar supports both encryption and authentication with both symmetric and asymmetric...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE