Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General caching questions/discussion #154

Closed
alexciarlillo opened this issue Mar 24, 2015 · 21 comments
Closed

General caching questions/discussion #154

alexciarlillo opened this issue Mar 24, 2015 · 21 comments

Comments

@alexciarlillo
Copy link

I know there were recently two applicable discussions: #38 and roots/trellis#34 ... but after reading them I am still left with some questions.

It seems like the "recommended" way is to use Batcache + Memcached. Okay, great... but is Batcache still supported? It had no update in >7 months and the version on WordPress.org has not been updated for 2 years. Even if it is still maintained and works, it looks like you still need to have advanced-cache.php in the wp-content/ (or app/) directory. But since this is configuration, we should not be linking it via shared? So how do I manage it for deployment?

On top of that, I mostly run single sites on single servers. Or maybe a couple vhosts on a server. Memcached is not really for this situation and Batcache even recommends using WP Super Cache in that case. I like WP Super Cache and am familiar with it but am running into the same issue with advanced-cache.php and the cache/ directory it creates. I don't mind blowing up the cache on deploy, and I suppose I could also link cache/ to shared/ as is done with uploads/... but I'm still not sure if that is "right" and am still left with advanced-cache.php sitting in app/. On top of that, Batcache instructions on github are less than clear... i.e. what the hell is Ryan's Memcached Backend 2.0, what does it do and why do I need it? I know that is a Batcache thing and not Bedrock, but no one seems to be home over there anyway.

I am only just dipping my toes into Bedrock to see if it will work for our organization and so far I love it, but I am little surprised that more focus has not been put on the issue of caching since it is pretty vital to any WP site that generates even moderate traffic. I just want to try and get some input on the "best practices" approach because if I need to start deviating too far from the norm than there is really no purpose for me to continue with Bedrock.

@alexciarlillo
Copy link
Author

It occurs to me, too late of course, that this might be better suited for Discourse. Apologies.

@rohmann
Copy link

rohmann commented Mar 24, 2015

Honestly I wouldn't want Bedrock to get too deep into caching, as that can get pretty opinionated.

advanced-cache.php is actually more functionality rather than configuration. You can override it's global variables in your config files though. Batcache hasn't really needed to be updated. It's old in internet years, but solid. I'm pretty sure they use a modified version of it on WordPress.com.

Batcache doesn't work with memcached directly, instead it interfaces with the WordPress Object Cache. You need the Memcached backend plugin, because it allow WordPress to use Memcached as an object cache. You could really use any object cache you want. Here's one for Redis that works nicely: https://github.com/ericmann/Redis-Object-Cache

Bedrock gets us miles towards a sustainable deployment environment, but honestly until WordPress allows for some changes it will never be perfect. Personally I just commit the advanced-cache.php and object-cache.php right into my app folders and just manage their updates manually.

@etcook
Copy link
Contributor

etcook commented Mar 24, 2015

@alexciarlillo I believe the latest trend is away from static caching altogether, and relying on the pure performance characteristics of hhvm + proper object caching in Redis or memcached. IIRC, Jaquith had a recent presentation covering this stack.

Personally, I've always used Varnish - mostly because of the issues with W3TC/Super Cache and integration with Bedrock.

@etcook
Copy link
Contributor

etcook commented Mar 24, 2015

@rohmann I tried ericmann's plugin again two days ago, and had a few problems. They might have been environment specific issues, though.

I did, however, use the object-cache.php out of this, https://wordpress.org/plugins/wp-redis/, successfully.

@alexciarlillo
Copy link
Author

@rohmann I see your point and I agree. There are enough options for caching outside of the WP environment that it doesn't make sense for Bedrock to get involved. However, I do think that establishing some best practices for using simpler caching methods (read: W3TC and WPSC) would help others in the Bedrock community.

@etcook I am just getting sysops to bring us up to PHP 5.5 and Apache 2.4 on RedHat 6... I am doing my best to modernize our stack but right now it is baby steps and getting the support from sysops the further we deviate from the standard (read: outdated) LAMP stack they offer the rest of the departments.

I suppose my problems are mostly institutional, and there already exist many correct solutions to this problem. I am trying to find ways around artificial restrictions imposed by those who manage the environment, while at the same time adhering to Bedrock's principles. I'm sure I'm not the only one in this community doing so, but I don't feel like this particular venue is appropriate for the discussion so I will go ahead and close this.

I appreciate your responses and will mostly likely just go ahead and commit advanced-cache and object-cache into my app folders for now until I can get buy in to establish a more modern LAMP stack.

Thanks

@etcook
Copy link
Contributor

etcook commented Mar 24, 2015

@alexciarlillo Much of what is parroted regarding the web technologies is nonsense. Apache 2.4 is fine - just go MPM Event if memory is an issue and turn AllowOverride off. mod_php typically benches at parity with nginx as long as it is properly configured and AllowOverride is off (which it isn't by default). People don't realize just how taxing checking for the .htaccess is. Embedded php (mod_php) benchmarks faster than fastcgi (fpm).

Would you have access to an external Redis perhaps? What about Varnish?

@alexciarlillo
Copy link
Author

@etcook External Varnish or Redis is something I had not really considered. Varnish is a possibility since it acts a reverse proxy. I am not as familiar with Redis but assumed the overhead from needing to fetch data off-site would begin to negate caching improvements.

I have never been too concerned about our Apache performance. Our sites really are pretty low traffic, it is just that occasional burst that kills us. That's why a lot of these solutions seem like overkill for our situation. Just caching the home page and our news page would probably solve 99% of the problem when we run into that load spike, which is why I was trying to keep it simple.

@etcook
Copy link
Contributor

etcook commented Mar 24, 2015

@alexciarlillo As long as you're on the internal network, the transactional overhead of the object cache requests to Redis should be pretty small, and in most cases will exceed the performance of the equivalent db call, unless you have those cached in memory (E.g. query or innodb cache)

Varnish is great. It's flexible and you have a lot of control.

@swalkinshaw
Copy link
Member

This repo/bedrock-ansible kind of recommends Batcache but that's mostly because it's straight forward and most important of all, NOT W3TC or Super Cache.

@alexciarlillo funny because I also found the instructions for Batcache confusing and lacking. Even more confusing is that you should use the memcached PECL extension (note the d) and not memcache extension.

On Ubuntu this means installing php5-memcached instead of php5-memcache.

This also means you need to use https://github.com/tollmanz/wordpress-pecl-memcached-object-cache instead of the normal https://wordpress.org/plugins/memcached/ one.

Aside: that well known memcached one also has bugs that have been fixed over a year ago yet not released to the plugin directory. See the latest two commits by nacin here: https://plugins.trac.wordpress.org/log/memcached/ (WP is a cesspool)

We use Batcache on https://roots.io and ended up just committing both object-cache.php and advanced-cache.php to our repo which almost kills me :(

One possible alternative is to use https://github.com/Koodimonni/Composer-Dropin-Installer but I don't trust it enough completely yet. Also not entirely sure how I feel about the solution overall. It's kind of just abusing the power of Composer.

Downsides of Batcache: yes it auto purges during "normal" operations like creating a post, updating a page, etc. But there are a ton of cases it doesn't cover which means you'll 100% have to end up clearing memcache on every deploy. This kills me a little inside as well.

After all the downsives I've talked about above, it's probably better to just use Nginx or Varnish cache. There's a plugin that purges Varnish caches which I've never tried: https://wordpress.org/plugins/varnish-http-purge/

@etcook
Copy link
Contributor

etcook commented Mar 25, 2015

@swalkinshaw Is there anything wrong just adding some postupdate/postinstall scripts, akin to what Bedrock is doing?

That's where I conditionally handle all file moves (E.g. domain mapping plugin, etc).

@swalkinshaw
Copy link
Member

@etcook that's pretty much what https://github.com/Koodimonni/Composer-Dropin-Installer does I believe. I just don't love the idea of moving around individual files but I guess it can't be worse than committing the files.

@etcook
Copy link
Contributor

etcook commented Mar 25, 2015

@swalkinshaw What about just creating symlinks?

@swalkinshaw
Copy link
Member

@etcook you'd commit them I assume? not a bad compromise.

@etcook
Copy link
Contributor

etcook commented Mar 25, 2015

@swalkinshaw Yes. In fact...the more I think about it, the more I think I'm going to remove the script and do just that.

@alexciarlillo
Copy link
Author

Well the requirement of php-memcached instead of php-memcache kills the memcached solution for me. I am limited to packages available in RHEL Software Collections (php 5.5 and a good amount of modules are available, but not the -memcached one). Luckily Nginx is available to me so I think that is my best bet for a real caching solution.

@swalkinshaw
Copy link
Member

@alexciarlillo just to be clear, I didn't say it was a requirement. It's just the better method.

You can still use Batcache + php5-memcache + https://wordpress.org/plugins/memcached/ (assuming you use the trunk version)

@alexciarlillo
Copy link
Author

@swalkinshaw ahh my mistake. thanks for clarifying.

@cmosguy
Copy link

cmosguy commented Dec 1, 2015

So is the consensus here to stay far away from W3 Total Cache? I just ran into the problem wither none of the files could be served from from the /app directory etc. Yes @swalkinshaw it is a total mess with bedrock. What do you guys recommend to here then?

@swalkinshaw
Copy link
Member

@cmosguy yes as mentioned above. Use Batcache, Nginx caching, Varnish, or anything not like the normal WP plugins (W3TC, Supercache, etc).

@cmosguy
Copy link

cmosguy commented Dec 2, 2015

@swalkinshaw thanks! BTW, what do you guys use that does the CDN and minification for the .css and .js files to AWS Cloudfront or some other provider? I liked the W3TC because it could do this, but I'd like to know which plugin you are using that is compatible with Bedrock.

@retlehs
Copy link
Member

retlehs commented Dec 2, 2015

@cmosguy please use https://discourse.roots.io/ for questions and support. i'm locking this as it's an old, closed issue.

@roots roots locked and limited conversation to collaborators Dec 2, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants