|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP LINKS YOU MUST CLICK ON Industry News Put Your PHP App on Steroids
Optimizing with APC: Alternative PHP Cache
By: Ian Selby
Jun. 9, 2008 11:00 AM
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… 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?” ENTERPRISE OPEN SOURCE MAGAZINE LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||