Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: drewactual on January 13, 2018, 09:37:23 PM

Title: Memcache/d shared across several servers
Post by: drewactual on January 13, 2018, 09:37:23 PM
this could just as easily be in the server settings board... but, there is the 2.0.x aspect to it, too.

I have several servers in a stack- physically separate servers.  each of them are running apache4 (2.4), php7.0, and in a centos 6.9 build.. each of them are running memcache and memcached's latest build. 

SMF on the production server sniffs out memcached just fine- and is running in level1 cache mode.  memcache is also loaded (field populated) with that servers IP and the memcache's port. 

i want to spread the load to the other servers. 

if i were doing this for sessions, in php.ini or httpd.cnfg i would simple use memcache as the handler, and the repository would be:

Code: [Select]
session.save_handler = memcache  ;<sets the handler
session.save_path = 'tcp://ip.ip.ip.ip:11211,tcp://ip.ip.ip.ip:11211' ;<sets the paths for sessions, this example two servers
memcache.allow_failover=1 ;<the infamous php glitch that is required to be negotiated
memcache.session_redundancy=3 ;<adding the glitch to the redundancy equals 3 not 2

and that^ sets up the sessions magic across the two...

i'm also reading that running this:
Code: [Select]
$memcache = new Memcached();
$memcache->setOption(Memcached::OPT_DISTRIBUTION, Memcached::DISTRIBUTION_CONSISTENT);
#the weight argument is optional
#all 2 servers have equal weight
#they are all equally likely to be selected.
  array('ip.ip.ip.ip', 11211, 25), //server 1
  array('ip.ip.ip.ip', 11211, 25), //server 2

^ensures the load is evenly spread instead of weighing one server down.

now my question is if this is required while using SMF's admin area for cache>memcache settings?  or, is simply providing the IP and the port sufficient, and SMF negotiates the rest? i mean, if SMF negotiates this, that's great- awesome, actually... but how does it set it on both servers? (the above code has to be duplicate on both? SMF is only loaded on the one- does it just forward the cache using memcache servers proxy?)...

thank you tremendously in advance!!!!

Title: Re: Memcache/d shared across several servers
Post by: Arantor on January 14, 2018, 05:21:18 AM
Weighing a server down? How big is this forum that seems to require multiple memcache servers??
Title: Re: Memcache/d shared across several servers
Post by: drewactual on January 14, 2018, 12:09:02 PM
there is a lot more to it than a forum.  but if the resources are going to be there, i will use them for the forum too.  atop of that, i have them one way or another- installed, provisioned, and running, so, why not use them?

at any rate, i was reluctant to set the pointers during traffic time, and thought i'd have the time to ask here, but it didn't work out.  i went ahead and did it late last night, and discovered SMF isn't capable of linking the instances of memcache on different physical servers... not even when the httpd is set across the pool to share the sessions load.  possibly it is on the same server (virtualhosts) but what is the point if you're not being throttled on resources by a shared host configuration? 

because you asked: now the reason i brought the second physical server online in the first place is because i'm moving a massive and resources hungry DB and application to it's own cordoned location with it's own resources to consume apart from the site with SMF- it needs those resources, but only because the author of that page wrote it twenty years ago and it was sloppy even then insofar as practices- using persistent connections and opening yet another when same user requests another query... the data being pulled by a single request on that page can and often is in the gigabyte range in size.... so... even on it's own 4x4 16g server with ssd drives, it WILL be throttled, and the remaining resources allotted for a site intended to serve up cookie-less static material for both the forum based site and the one with the huge clumbsy db and ui.  the third server, which i haven't bothered setting up yet, will have only one purpose- and that will be cache and sessions, leaving the ram on the other servers practically dedicated to internal functions and compression.  all run http2 and have latest ssl ciphers scoring well on validators and speed testers... i'm getting ready for something in the spring that will put all of this under load. 
Title: Re: Memcache/d shared across several servers
Post by: Arantor on January 14, 2018, 12:18:44 PM
Just because they're available doesn't naturally make it a good idea.

The fastest possible case is a memcache server sitting on the same physical server as the forum - no traffic has to leave the server. The minute you introduce network latency to the deal, it starts to become a question of whether it's actually worth hitting the network or actually serving from disk.

Especially if this isn't actually a large forum installation. If this is anything under half a million posts, the overhead of actually using memcache will likely be greater than other methods.
Title: Re: Memcache/d shared across several servers
Post by: drewactual on January 14, 2018, 12:35:02 PM
that's certainly worth thought...
simpler is almost always better...
occam's razor seems to believe that, anyway.  i'd be foolish to disagree with either mr. occam or you.  :) 

the obvious solution, then, is to leave the forum- it's resources, location, functions- totally alone and do what i gotta do with the other sites on the other servers.  the forum just broke 32k posts from just under 200 users- not a big forum by any means, but not bad since not yet six months old.  i'm getting around 30k original hits a day on the forum, and around 70k on the other side of that site, which is a WP install serving the sites content- and the two engine are entwined. (i didn't say integrated).  the 'forum' is where the regular community engages, as with most sites... but they are my foundation and the forum has to be protected at all costs- without them, it all falls apart.  the site with the ridiculously resources hungry db is very important, and it's astonishing how much traffic it gets, which is a bad combo.  it has rendered the forum (and the site with the forum) useless several times over the last month. 

i'm going to hire someone to rewrite that big db site with modern script and db functions.  much of these issues will disappear when that happens.