Welcome! Log In Create A New Profile

Advanced

[PHP] XCache, APC, Memcached... confused

Posted by Martin Zvar 
Martin Zvar
[PHP] XCache, APC, Memcached... confused
October 22, 2008 11:20PM
Hi,
I became confused after an hour trying to understand the PHP cache
solutions.

XCache, APC, eAccelerator and others are opcode cache systems... is
memcache in the same category? or is it completely different?

If I install for example XCache, set it for certain directory... it will
automatically cache the website into the memory. What happens if the
memory will get full?

Thanks for explanation,
Martin

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Martin Zvar
[PHP] Re: XCache, APC, Memcached... confused
October 22, 2008 11:30PM
I guess the XCache everybody talks about is the open-source here:
http://xcache.lighttpd.net/

But what about this: http://www.xcache.com/ ... is it the same author? :-O


Martin Zvar
Stut
Re: [PHP] XCache, APC, Memcached... confused
October 23, 2008 12:40AM
On 22 Oct 2008, at 22:19, Martin Zvar
Stut
Re: [PHP] Re: XCache, APC, Memcached... confused
October 23, 2008 12:45AM
On 22 Oct 2008, at 22:24, Martin Zvar
Martin Zvar
Re: [PHP] XCache, APC, Memcached... confused
October 23, 2008 12:50AM
Thanks for reply Stut.

So, the APC, XCache etc. doesn't work as FileCache and also doesn't
decrease the number of database queries, since it is not caching the
content...

I see now, it is obvious that it would be very hard to run out of memory.

--
Martin



Stut napsal(a):
> On 22 Oct 2008, at 22:19, Martin Zvar
Martin Zvar
Re: [PHP] XCache, APC, Memcached... confused
October 23, 2008 01:10AM
I am looking at the eAccelerator's website and I realize what got me
confused:

there is a function for OUTPUT CACHE, so it actually could cache the
whole website and then run out of memory I guess...

that means I would be able to store anything into the memory and
reference it by a variable? are the variables accessible across the
whole server? I still don't really understand, but I am trying...



Stut napsal(a):
> On 22 Oct 2008, at 22:19, Martin Zvar
Stut
Re: [PHP] XCache, APC, Memcached... confused
October 23, 2008 01:10AM
On 23 Oct 2008, at 00:04, Martin Zvar
Colin Guthrie
[PHP] Re: XCache, APC, Memcached... confused
October 23, 2008 10:45AM
Stut wrote:
> On 23 Oct 2008, at 00:04, Martin ZvarĂ­k wrote:
>> I am looking at the eAccelerator's website and I realize what got me
>> confused:
>>
>> there is a function for OUTPUT CACHE, so it actually could cache the
>> whole website and then run out of memory I guess...
>>
>> that means I would be able to store anything into the memory and
>> reference it by a variable? are the variables accessible across the
>> whole server? I still don't really understand, but I am trying...
>
> Having never used eAccelerator I can only guess, but it sounds like it's
> a way to cache HTML output. As for how accessible that is I have no
> idea. I suggest you find the eAccelerator mailing list, subscribe to
> that and ask your question there.

If you are looking into caching things in a very flexible way I'd look
at the Zend_Cache API from the Zend Framework.

It has backedns to connection to APC and Memcache and also implements a
disk-based caching system. You can cache all sorts of output, from
function calls (both return value and side-effect output), html output
and arbitrary objects.

Using an opcode cache is generally a good idea (part of the APC core
will be included in PHP6, which is why I'm currently backing that
particular horse), but for an application-level caching strategy, I
think Zend_Cache has a lot going for it :)

Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Anonymous User
Re: [PHP] XCache, APC, Memcached... confused
October 23, 2008 03:30PM
> First of all you need to get it clear in your head what an opcode cache
> is actually doing. It does not "cache the website", it caches the
> compiled version of the PHP scripts such that PHP doesn't need to
> recompile each file every time it's included which is the default way
> PHP works.

And, to be really clear, the savings in compile time is gravy.

The REAL savings is not hitting that slow-spinning disk drive to LOAD the PHP script into RAM.

You'd get very similar performance boost if the opcode cache simply cached the PHP source.

But it's just as easy to cache the compiled version, and that saves a few more microseconds/milliseconds.

Depends how big/long/convoluted the PHP source is, but, really, it rarely is that big of a file.

I doubt that 2 opcode caches can run in parallel, as they both "hook" into the same line of code in PHP. And if they did run in parallel, the second one would not help in the least, and would actually just be more overhead for zero gain.

PS
All the opcode caches have a strategy for unloading less-used scripts if RAM is full, so don't sweat it unless you have crazy number of scripts.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Sorry, only registered users may post in this forum.

Click here to login