Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt November 11, 2024
ASTRAPI Posted October 15, 2013 Posted October 15, 2013 Hello Is it better to use APC and Memcache together or only one for better performance? I am confused about what i read for them as a few users talking about that they can cache different things and is faster to use both. Some other users talking that is better to use only one for better performance. Ok i know for many servers the solution is Memcached but for only one server how can i benefit more from caching? Thank you
Mikey B Posted October 16, 2013 Posted October 16, 2013 Hello, Both are caching engines so I'd recommend only running one of the two. In my experience APC is relatively easier to set up however Memcached provides better performance. The IPS Community Suite does support both APC and Memcached as well as a number of other caching methods, and you can read about how to implement those here: http://community.invisionpower.com/resources/documentation/index.html/_/new-docs/ipboard/server-environment-and-security/improving-board-efficiency-r565 :)
Rhett Posted October 16, 2013 Posted October 16, 2013 I have had the best luck with xcache personally and run it on all my sites. Results will vary depending on specs, setup, etc
ASTRAPI Posted October 16, 2013 Author Posted October 16, 2013 @Mikey B But they caching different things if i am not wrong..... Memcache: user-land memory caching APC Opcode caching ?
Codehusker Posted October 16, 2013 Posted October 16, 2013 You are mostly correct. Memcache does data caching, but APC does both opcode caching and data caching. XCache does both as well. If you use Memcache for data caching, then you would also want to use APC or XCache for opcode caching. To configure this you'd insert the memcache settings in conf_global, but leave out APC or XCache. The opcode caching will happen without any configuration. As you mention in your first post, if you have multiple servers then no doubt use Memcache. For one server, however, stick with just APC or XCache. Memcache is slightly slower because it's an external program, but APC and XCache are modules added directly into PHP.
ASTRAPI Posted October 17, 2013 Author Posted October 17, 2013 Thanks for the answer... Is there any settings that i must do to memcache so it will do only data caching and avoid to cache the same things twice?
Codehusker Posted October 17, 2013 Posted October 17, 2013 Nope, memcache only does data. You do have to configure IPS to send data to memcache using the instructions Mikey linked to above.
ASTRAPI Posted October 18, 2013 Author Posted October 18, 2013 If i am not wrong APC can cache also data? If yes how can i disable this option so i will use it as opcode cache only? Thank you
IveLeft... Posted October 18, 2013 Posted October 18, 2013 Unixy Varnish is very good and plays with all others nicely if set up correctly (ie APC, eAccelerator, WP Supercache, memcached, or any other caching layer) I use Unixy on all my VPS sites - very good solution
Codehusker Posted October 19, 2013 Posted October 19, 2013 If i am not wrong APC can cache also data? If yes how can i disable this option so i will use it as opcode cache only? Thank you Yes you are right. To prevent APC from duplicating data caching, simply remove it from conf_global.php. APC does opcode caching automatically, but only does data caching when IPB is configured to use it.
ASTRAPI Posted October 28, 2013 Author Posted October 28, 2013 Ok so setting to conf_global.php the memcache there and leave outside the APC to do opcode caching will give the best performance? Thank you
Grumpy Posted November 1, 2013 Posted November 1, 2013 Late to the party, but I feel like you are just doing what you're told rather than knowing what you're doing. There are two types of caching involved between apc & memcache. OP (operation) Cache is caching of php execution. PHP is a code in text. It has not been compiled into machine language. So, without op caching, it will compile the code again and again each time it's run. (well, there's lot of gritty details about this, but you can just take that as the simple version.) That's why you want an OP cache to skip recompiling the same code. This is purely in the realm of PHP and it really doesn't matter what IPB does or doesn't do. You can turn it on/off in php settings and that's it. Memcache is not in this business and cannot be due to it's structure. Data caching is something separate and offered by both. This is something you can control; this is something IPB can control. For the sake of simplification, let's say you generated a page. And another user asks for that exact same page. Then would there be a point in re-generating that same page? Or would it be better to save the generated content and just give it again? That is what data caching does. It saves portions for re-usage so that it doesn't need to be generated again. Caching modules cannot do this automatically. That's because they don't know what you want, what's dynamic, what needs to be cached, etc. But IPB does know. So, you tell IPB your where to store these temporary data--that is, the IPB setting (conf_global.php). Since this is not automatic, it is not possible that you cache duplicate contents across different mediums (unless IPB did something stupid). I don't know why Mikey stated that memcache is better in performance. This is strictly untrue. APC builds itself into PHP. That is, it becomes part of PHP. So, when you store something in APC, the storage connection is already established and available. Memcache is a completely separate service from PHP. The only connection to PHP it has is a module that tells PHP how to talk to memcache. Typically, the connection is made over TCP/IP. This means that if you want to store/retrieve/anything with memcache, you need to open a connection, complete your action and close the connection every single time. The TCP overhead of this process exists for memcache and it is not minuscule, however, it does not exist for apc. (Theoretically) the act of storing/retrieving it into memory should be the same amount of time. So, apc has to be faster than memcache. Now, there are ways to make the tcp overhead go away by using unixsockets. But I don't want to get into more details there. If you have a single machine, there is absolutely no reason whatsoever to choose memcache over apc/xcache. It's more complicated, and it isn't faster.
ASTRAPI Posted November 20, 2013 Author Posted November 20, 2013 All was great until i read the last line again :) So if they cache different things why not use both?
Grumpy Posted November 21, 2013 Posted November 21, 2013 All was great until i read the last line again :smile: So if they cache different things why not use both? You ARE using both (op cache & user/data cache) when you install apc and tell IPB to use apc.
ASTRAPI Posted November 24, 2013 Author Posted November 24, 2013 I have both and i use on IPB config the memcache and let APC outside to work... Is that ok?
Grumpy Posted November 26, 2013 Posted November 26, 2013 I have both and i use on IPB config the memcache and let APC outside to work... Is that ok? Yes, that will still work. Though, it makes me feel like you ignored a large part of my text wall...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.