News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Memcached with sockets support?

Started by bdewong, November 01, 2018, 03:55:24 PM

Previous topic - Next topic

bdewong

Does anyone know if SMF supports memcached connections using sockets? And if so, how should the configuration be?

My host just recently changed over from using the standard IP method and it has broken caching for me. They've said to change the connection to be something like this instead: /home/user/.hostdata/memcached.sock and SMF just choked on it.

Any help?

Thanks in advance.

Arantor

I don't believe it does support it (and changing it isn't necessarily simple either)

drewactual

It does for me...

Caveat... I run both memcache and memcached on an ea4 build with ea4 and php7... Google how, it just requires a certain build of memcache to be installed via packages, and configured to run along side.

It seems tricky, but once you choose right package out of like hundreds of them, its a simple matter of changing the right lines in the conf file.  It runs flawless in my busiest site, and the only errors I see are login errors by users. Btw, I ise memcached for sessions, also flawless. (Knocking on wood, of course) 

Iirc I got the package off of GH and it was labeled to run with ea4/php7... I loaded and configured it via ssh.  It requires the same config as of youre working with >5.4. A few lines added via ssh that are on the same Get hub as the package.

Good luck!!!

bdewong

@drewactual You say that it works, but what do you put in your SMF config to get it to work? i.e. what settings do you use?

drewactual

11211 or some such is the default port for memcache/d, but needs to be on port 0.. You've got to give it zero or it will default... When you set memcache/d up in its conf file it needs to write to a 0775'd location as user: nobody.  I cant recall what else if anything, but you should be able to google it up... Your host should be able to assist too... As soon as I got it to run SMF picked it up, but I struggled to get it running.  My issue was permissions... May be yours too?   

drewactual

this is the first time i've been to a real keyboard- maybe this will help:

you've got a conf file for memcache/d and it needs to be set- it will run in it's default setting, but in order for it to operate the way you want, in this situation, you've got to tell it.  this is where the address your host gave you comes into play... I DON'T know how SMF is set up to handle it, but it doesn't matter to a point as this is a server level function- do you want memcache/d to run? have apache fire it, then, and this is outside of SMF...

once it is running, and you can check if it is via ssh, the interface with SMF was simply "IP:port", and in my case "xxx.xxx.xxx.xxx:0"... once it was running the line went from red to green, even before i 'configured' SMF in the cache panel, meaning SMF recognized it.   

your memcached .conf file will look SOMETHING like:


-d  logfile logfile /var/log/memcached.log -v -vv -m 50 -p 11211 -u memcache -s  /home/user/.hostdata/memcached.sock -a 775 -c 1024 -S


now this next bit will need to be reviewed by one of the wizards here such as Arantor, Kindred, SirOsis, ect...  I don't recall doing it, but i may have and i'm not somewhere i can check right now :

you may have to tell SMF afterall... All i recall doing is telling it port 0... but... add/swap this in Settings.php :

find:
$cachedir = dirname(__FILE__) . '/cache'; # Path to the cache directory.
swap with:
$cachedir = dirname(__FILE__) . '/home/user/.hostdata/memcached.sock'; # Path to the cache directory.




Arantor

Uh... wtf? You shouldn't be setting cachedir like that. If it isn't supported by configuring through the admin panel, the results are not guaranteed and I know at least one plugin (and several others that come to mind) that will choke on that because it assumes cachedir is a real physical folder that can be accessed afterwards.

It might work but good luck hunting down some of the more intricate bugs this will likely generate.

drewactual

agreed... i think that last line should point to a file location, and it can be where other functions look for the cache too- it just has to be where memcached is configured to look for it is all.  I don't recall having to do this on mine- i just recall pointing to port:0 on the SMF admin panel.  maybe it is because i pointed the memcached conf file to the same file SMF uses by default? (the '/cache' folder/directory in a standard OOB SMF build?)  I will have to look when i get to a computer with access to my page.   

i literally looked for days for a memcache that would work like i needed it to- there was one package available and it took some tweaking to get set up in the ea4/usr/conf file.  As it is, sessions are handled by memcached and memcached is used as an accelerator as well, on a ea4/php7/FPM-FastCGI build and with OPCache operating as well.  there can be 1500+ users online in that forum and the load doesn't suffer- still loading in right at a second consistently and with a hundred helpers sitting idle at any given time.

Arantor

This is why I explicitly said up front I didn't think it supported it because mangling the cachedir ends badly (there's a reason it's called *DIR*) and the stock code doesn't like a port of 0 (it will just backfill to 11211 by default) in get_memcached_server() in Load.php. Maybe your setup runs on sockets and listens on the port and it's really just using that.

That's using the memcache extension; SMF 2.0 doesn't support the memcached extension out of the box.

I honestly don't know about memcache on SMF, I haven't used it in a long time, I long since moved everything like that to Redis.

Advertisement: