News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Is there a way to/should one enable both APC and Memcached

Started by SeverityGaming, September 16, 2019, 12:01:37 PM

Previous topic - Next topic

SeverityGaming

Hello everyone, hopefully this wasn't answered somewhere else already. (I did some searching in this board but couldn't find anything). Anyway, let's get to it!

The provider that I'm using to run my SMF install has APC/APCu/Memcache available/toggleable in the PHP build/settings that I can adjust. They also offer customers memcache instances to point at. When I hit the "cache" settings page I see that if I disable Memcache in PHP settings, it'll detect APC as being available. If I then disable APC, it'll say nothing is detected. When either are on, I believe I am noticing the acceleration from one or the other. But is there a way to get the benefit of both?

As I understand it, APC/APCu is an Opcode cache, for what's executed by PHP, and Memcache is a value store (so caching settings/values that are calculated or queried from the database instead of pulling them each time). Some websites out there seem to say that there is benefits to using both if used properly.

How is SMF using Memcache and/or APC? If I was to update Load.php such that the two elseif blocks that loop through each accelerator till it finds a working one, such that it'll check for memcache first, and then loop through all of the others seperately. Would I get any benefit, or is SMF using them the same way?


Thanks so much for your time!

vbgamer45

If you are using newer versions of PHP they have opcache enabled by default and APC is not needed.

In SMF APC/Memcache is just used to store data that is accessed often.


I run SMF using just memcache and PHP's built in opcode on PHP 7.1
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Arantor

You can't even use 2.0 APC support in PHP 7 without a lot of work anyway.

In a really ideal world, you'd be using opcache with Redis for sessions and data but 2.0 and 2.1 don't support this (I really should backport Redis out of my setup sometime)

SeverityGaming

Quote from: Arantor on September 16, 2019, 12:40:50 PM
You can't even use 2.0 APC support in PHP 7 without a lot of work anyway.

In a really ideal world, you'd be using opcache with Redis for sessions and data but 2.0 and 2.1 don't support this (I really should backport Redis out of my setup sometime)

It's actually APCu on PHP 7+, there's a guide out there I used to edit Load.php and enable support for it in SMF 2.0.15. I just tried to call it APC in my post for simplicities sake since that's what supported OOB. concept stayed the same.

I like vbgamer45's suggestion though, I think I can do this same setup.
Quote from: vbgamer45 on September 16, 2019, 12:05:50 PM
I run SMF using just memcache and PHP's built in opcode on PHP 7.1


thanks guys!

Arantor

Yes, yes I know - but that was my point, it's not exactly the same and while there's ways, unmodified PHP 7 with SMF 2.0.15 won't cut it. APC and APCu are not entirely the same conceptually; the whole point is that the opcache is now core and as such removed in APCu (the u = user cache), and some functions that used to exist to invalidate opcache no longer exist.

Still maintain that Redis is a better way to go than memcache though you need to be on a fairly busy forum for that to be noticeable really.

vbgamer45

It would be nice to see Arantor if you can submit a patch. I checked out storybb to see if you had there yet.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Arantor

Well, in 2.1 it was split out into classes rather than all bundled in Load.php - and to that effect, https://github.com/StoryBB/StoryBB/blob/master/Sources/StoryBB/Cache/Redis.php is the core class I have.

Overall minimal commit - https://github.com/StoryBB/StoryBB/commit/67675a519f59ca984dace00428e5a3eca2c15aa2

I didn't try and make the session thing done in Redis simply because if you're at the level where you need Redis, and have Redis, you're at the level you can plug in the Redis server into php.ini...

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

L2Scarlet

You can useXCache or eAccelerator
But I strongly recommend you to add in Cloudflare it is extremely faster than any cache engine. (In CF I use standard Cache with Brottli and CSS/HTML/JS minify).
It is loading almost instantly.

Arantor

If only that were actually true for what is being discussed; it really isn't.

Advertisement: