Jump to content

Both APC and Memcache


Recommended Posts

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

Link to comment
Share on other sites

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
:)
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

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.

Link to comment
Share on other sites

  • 3 weeks later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
×
×
  • Create New...