Advertisement:

Author Topic: Is there a way to/should one enable both APC and Memcached  (Read 712 times)

Offline SeverityGaming

  • Newbie
  • *
  • Posts: 6
Is there a way to/should one enable both APC and Memcached
« on: September 16, 2019, 12:01:37 PM »
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!

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 21,559
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Is there a way to/should one enable both APC and Memcached
« Reply #1 on: September 16, 2019, 12:05:50 PM »
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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,632
    • StoryBB/StoryBB on GitHub
Re: Is there a way to/should one enable both APC and Memcached
« Reply #2 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)
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline SeverityGaming

  • Newbie
  • *
  • Posts: 6
Re: Is there a way to/should one enable both APC and Memcached
« Reply #3 on: September 16, 2019, 02:48:44 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.
I run SMF using just memcache and PHP's built in opcode on PHP 7.1


thanks guys!

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,632
    • StoryBB/StoryBB on GitHub
Re: Is there a way to/should one enable both APC and Memcached
« Reply #4 on: September 16, 2019, 02:53:03 PM »
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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 21,559
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Is there a way to/should one enable both APC and Memcached
« Reply #5 on: September 16, 2019, 03:55:35 PM »
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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,632
    • StoryBB/StoryBB on GitHub
Re: Is there a way to/should one enable both APC and Memcached
« Reply #6 on: September 16, 2019, 03:59:59 PM »
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...
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 21,559
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Is there a way to/should one enable both APC and Memcached
« Reply #7 on: September 16, 2019, 04:56:26 PM »
Thanks.
I also just search and saw this mod that adds basics https://custom.simplemachines.org/mods/index.php?mod=4119
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

Offline L2Scarlet

  • Semi-Newbie
  • *
  • Posts: 16
Re: Is there a way to/should one enable both APC and Memcached
« Reply #8 on: September 28, 2019, 01:20:06 PM »
You can useXCache [nofollow] or eAccelerator [nofollow]
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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,632
    • StoryBB/StoryBB on GitHub
Re: Is there a way to/should one enable both APC and Memcached
« Reply #9 on: September 28, 2019, 01:28:23 PM »
If only that were actually true for what is being discussed; it really isn't.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.