Simple Machines Community Forum

SMF Support => Server Performance and Configuration => Topic started by: sevamaster on February 02, 2012, 11:33:04 AM

Title: Memcache and APC together
Post by: sevamaster on February 02, 2012, 11:33:04 AM
To SMF experts.

My server has APC installed and  smf detects and uses it (level 3 caching).
Yesterday, I installed memcache and  filled in the Memcache settings: IP address (using a single server).
Visually, no changes in speed are noticed.

Tell me please, could  the sms use two caching instruments (because they are using two different caching)?
And if not, what should I use?

Note, that if  Memcache is preferable, then in any case the smf says that APC is detected.
That is, if the APC and Memcache installed and there is  IP prescribed  for Memcache, which one (or both) will be used?

Thank you.


PS. SMF 2.0.2
Title: Re: Memcache and APC together
Post by: Oldiesmann on February 02, 2012, 11:58:40 AM
If you have memcache set up, SMF will use it instead of APC or any other cache thing on your server.

SMF checks for things in the following order when trying to cache things:
memcache
eAccelerator
MMCache
APC
Zend Platform
xCache

I'm not sure why, or why it's detecting APC before memcache, but that's the way things work :)
Title: Re: Memcache and APC together
Post by: sevamaster on February 02, 2012, 02:10:25 PM
Thank you Oldiesmann.
So, it's not possible to use both  (apc and memcache) at the same time?
If so, which one is better for smf (which to use[ or disable])?
Title: Re: Memcache and APC together
Post by: Oldiesmann on February 02, 2012, 04:17:34 PM
No, it's not possible to use both at the same time, and it wouldn't work too well if you did - why would you cache something multiple times with two different services, and how would SMF know which one was the most up to date?

I don't know which is better as I have no experience with memcached. I'm sure someone else here can answer that though.
Title: Re: Memcache and APC together
Post by: Vekseid on February 20, 2012, 01:33:48 AM
APC is somewhat faster than Memcached, since it makes an internal call rather than going over a socket - a network socket at that.

However, memcached, being a distributed cache, is useful if you want to cache a ridiculous amount of data. However, I've never found that SMF takes much advantage of this possibility, or well (in fact caching at level 3 gives serious issues).

Using both is useful in a small set of limited circumstances. For example, in the new CMS code I've written, multiple machines may have unique configurations associated with them. Thus, the config data gets loaded by APC (apc_load_constants), while memcached caches everything else in one or more pools.
Title: Re: Memcache and APC together
Post by: Something like that on February 20, 2012, 01:56:23 PM
You certainly do want to have APC running through, to cache the compiled PHP files. APC is more than adequate for SMF. I'd configure it with 64MB of cache, or more if you're running other PHP scripts.

Also make sure that memcached is only listening on an internal IP unless your firewall it from outside access, if you decide to continue using it.
Title: Re: Memcache and APC together
Post by: LiroyvH on February 24, 2012, 02:19:10 PM
Wouldnt it work to make memcached handle the sessions and use APC as the caching?
Personally never tried it though.
Title: Re: Memcache and APC together
Post by: Gandon Suka on March 25, 2012, 01:12:22 AM
Since you run VPS there are much more option to speed up SMF serving as a solo website or as a part of a large project as well.

As per your  question that concers only two boosters: try APC to feel diference otherwise there would be no effect with memcache or memcached in. 
Title: Re: Memcache and APC together
Post by: Pernat1y on March 01, 2013, 03:47:35 AM
Sorry for bumping old topic, but...
Quote from: Oldiesmann on February 02, 2012, 04:17:34 PM
it wouldn't work too well if you did - why would you cache something multiple times with two different services
You are wrong. They will work well together (and it's prefered to use both of them) because they caching different things.
Memcached caches data and objects
APC caches bytecode to speedup execution of PHP scripts itself
Title: Re: Memcache and APC together
Post by: LiroyvH on March 01, 2013, 06:53:53 AM
That has already been pointed out, twice. ;)
Title: Re: Memcache and APC together
Post by: Ricky. on March 01, 2013, 07:56:26 AM
Quote from: CoreISP on March 01, 2013, 06:53:53 AM
That has already been pointed out, twice. ;)
Still wondering why SMF uses single if all is available, I had similar situation and had hacked bit to use both.

I think there should be option to Select either of Disk cache and Memcache
And one among rest.. because others ie. Xcache, APC, eaccelerator are essentially doing same kind of thing.
Title: Re: Memcache and APC together
Post by: LiroyvH on March 01, 2013, 08:33:13 AM
Well, you can compile and configure PHP in such a way that it always uses memcache, then set SMF to use APC.
Should, in theory, work.

On another note, either should always work. For example, if you have XCache, you don't have to enable caching through XCache in SMF in order to make it cache some material plus write stuff to memcached.
I haven't debugged it though so i'm not entirely sure WHAT it stores where when both memcached + xcache are enabled, but I must say that memcached + xcache + nginx are giving me _outstanding_ results on a huge forum around here.
Title: Re: Memcache and APC together
Post by: Arantor on March 01, 2013, 08:36:42 AM
If only that were what the caching system actually did... which it isn't.

The caching system only supports one target at a time because that's the target it's using to store data. It's why eAccelerator should be removed if it hasn't been already because current versions don't support storing data (it's now just a bytecode cache)

Consider for a moment the logic of what you are saying. Bytecode caches store the parsing - how would you tell the cache not to cache from inside what you are caching? Doesn't really make a lot of sense.

How can you possibly use two caches when you only want to save and retrieve data? The bytecode caching would still be done anyway, right?


EDIT: Core, I'm presuming you're using memcache to handle sessions through memcache's own session handler and all other data through xcache? (In other words, SMF is configured to use xcache and is not fundamentally aware of memcache)