I'd like to talk to anyone who has been successful in configuring CloudFlare to serve their Moodle site.
Cathal, what are your questions regarding CloudFlare? Setting up CF isnt hard, its just the DNS change at your end, depending on your hosting, it will be just click of a button as almost every host includes in their CPanel.
I have tried three services on Moodle, CloudFlare, Incapsula and Google PageSpeed (now retiring).
using cloudFlare, Because I host videos on Moodle using a third party player, so have experienced issues with FireFox (showing live stream where it wasn't), rest everything worked OK. on a free account you'll find Rocket Loader as well, that does boosts CSS,HTML and JS a lot, but it may appear to you that some parts of the site aren't loading as fast as they should be, whilst site speed test sites (like GTMetrix) showed nearly 98% on all tests up from 76% on YSlow (yahoo's service) and 96% on PageSpeed (Google's service).
rest, also if you are using URL sensitive third party plug-ins (Like Disqus) because your HTML pages will be duplicated in their nodes, so you'll start seeing replicated content in your disqus forums, Google PageSpeed does that as well, whilst Incapsula hadnt showed any things like that, but then their performance were as equal as if I hadn't any CDN applied to my site.
I don't find any reason for not recommending CloudFlare, as I have experienced performance boosts on my site, plus extra layer of security and ease of blocking IP based on network or Geo Locations.
Also FYI, Moodle own site (moodle.org) is on cloudflare
Thanks for replying. I'm specifically interested in how to configure Moodle to work with CloudFlare's SSL options. For our organization, we're using the 'Flexible SSL' option, which means that traffic between client and CloudFlare is encrypted, but not between CloudFlare and Moodle. I'm having trouble getting Moodle to work with this option. Have you got a similar setup?
not that I am aware of this can happen between CF and Moodle, as usually data gets stolen in connection between client and server. Also, CF will be bypassing the encrypted requests to origin server and not replicating the encrypted content.
Have you tried asking CF team?
Did you have to make any specific changes to Moodle to get CloudFlare to work properly? I've disabled https:// in the wwwroot in Config.php, with the expectation that CloudFlare is going to handle the encryption between itself and the client. I've also set a rule within CloudFlare to use https:// throughout our Moodle site. This has given me limited success. I get that "this page contains both encrypted and unencrypted content" message.
Yep, I think I'll get in touch with CloudFlare directly and get some advice.
Cathal, only changes (if you have to) that are made at client's end are on web server, as IP coming from CF's network remains the same so to get visitors analytics their code is added to web server so it can accurately analyse incoming traffic. Other this absolutely no change in website's to handle CF.
Where you mentioned getting message of Encrypted and Un-Encrypted, then it should be absolutely normal for static and public content can't be encrypted. if your protocol is showing https, then every thing should be working as it should. though do ask CF and see what they have to say about that.
I am also interested in any information about Cloudflare. I have it up and working with my moodle site hosted on Cloudways. It seems to help a bit, but I see that the amount of content that it caches seems to be around 9 or 10%. This is nice, but I am wondering if I can increase the benefit of Cloudflare's service by creatively using Page Rules or changing some of the settings.
I imagine that someone who knows much more than I has already made these decisions.
Any tips would be welcome.
Curt, CF's servers will not cache everything on your site, but only images, office/pdf files and few others (you can find list of files on CF's website), if it is showing 10% fewer servers needed, means the content that can be cached is not much, but it again depends on how many hits you are getting per day.
also, depending upon what package you are on, you'll find the option of railgun, if you have added your moodle independently then I think it comes with Business package, else if you are hosted on partner then just $20 a month investment will give you Business package and you will be able to make use of railgun, I personally haven't tested rail gun myself, but have heard that it really boosts performance.
If you want to, you can as well give a try to a competitor website (Incapsula), they have a free package as well, those who tested both in comparison says if you are after security, then Incapsula, but if you are after performance and speed then CF.
Thanks for the response. I have tried checking the HTML/CSS and JS options as less as enabling RailGun. I must admit, I have not done any carefully controlled testing of these settings. (I have just a small server at Cloudways with a virtual private server and 2GM ram, and I am not able to devote as much time to it as I would like until summer comes and my teaching load decreases)
Anyway, I do notice a small increase in performance which is nice, as it is free.
I am looking for other things I can do for free to speed the site up.
I see that Memcached is available and enabled on my server at Cloudways, but the fill ratio is a 0% as is the hit rate. On moodle, I see a place where I can "Add an instance" of memcached, but I did not find anything in the documentation on how to proceed. Cloudways has suggested the following:
Does this seem like a good idea?
Also, is there a way to take advantage of "Page Rules?"
I sort of understand how to write the rules, but not sure what specific page rules might do as far as speeding things up or making them not work correctly.
I imagine that others have solved these same problems before and am hoping that you or another can provide me with the solutions at which they arrived.
Now I have memcached up and running. It gets a few hits, but not many. Any way to get memcached to be more active and thus speed up my site?
Whenever I turn on varnish, students can no longer log in. They enter their username and password, but when they hit return, they are just presented with the same screen where they are supposed to enter their username and password.
If I could get varnish working, I imagine it could help.
I am running APC for caching, and I am sure that is helping.
Any idea how to get Varnish working and still allow students to log in?
using two cache extensions sometimes bring issues, and you mentioned using APC already and setting up Varnish can be disastrous for sure for I have once tested turning on WinCache and OpCache and though site was running, was log-ins were having issues.
Have you tried turning off APC and only using Varnish?
As far performance goes, I though have seen good output with Varnish if properly setup, but with recent testing done, I have found opcache worked brilliantly for Moodle.
O.K. then. It seems like I have enough of a handle on this to finalize my setup. I will go leave APC running and turn off Varnish and Memcache, as it seems APC makes most of the benefit of these redundant.
I do have Cloudflare set up as a CDN, and might be getting a tiny bit of benefit from that, although it seems that moodle creates mostly dynamic content.
Certainly the best way to improve the performance it to increase RAM and processor power, but that would involve jumping from $40 per month to $80 per month.
I appreciate your help and unless you think that Varnish might work better than APC or if there is anything else I might do to speed up my site, I think it is running fairly well as it is.
Curt, its always hard to find the sweet spot of performance in terms of hardware, merely increasing memory and processor cores wont always help as then it comes down to the I/Os of database which plays the most important role in terms of Moodle's performance, I wonder why you mentioned $80 as even $40 for 2GB of RAM is quite shocking for me to believe you are paying this much for a VPS, have you tried looking for some other hosts? where you could better hardware for even less prices, do check out prices at contabo.com.
As for CloudFlare, yes the core moodle's performance wont get the benefit out of it for most of the data is fetched from database and CF's servers don't touch the database, even CF's servers dont cache the HTML, but you would be surely getting the benefit out of image files, office files, PDF files etc as they are cached so you would be saving bit of bandwidth, plus client side code is compressed to quickly deliver and another layer of security.
Do give try to opcache, as it wont only reduce your memory requirements (almost 50% reduction), but as well reduce the time to render the page.
is opcache the same thing as APC?
Also, I did check out contabo.com. The prices seemed way lower at first, but when I went to set up a server, it looks like there are extra costs for C-Panel and for them to keep backups of my server.
Are you able to get by without these services?
Is Opcache the same thing as APC?
Yes and No...
APC is a two in one package, one of those things is an Opcache. The other is a User (or object) cache. You can use both or just one of either.
What a lot of people mean these days when they are talk about 'Opcache' is the Zend Opcache as this is the one that has been built into PHP since version 5.5. Before that you needed to pick your favourite opcache product from those available, e.g. Zend, APC, Xcache, WinCache and probably more... You can still pick something other than Zend's opcache if you want to.... Don't (unless you have a compelling reason).
So what is this APC User cache (often refereed to as apcu)? This is functionality that provides a generic object store in APC's memory allocation. In moodle it can be used in the MUC and is an alternative to, Memcached and other caching daemons. It is fast and works well with moodle (you need to install an extra plugin to use it). It does have a downside and that it that it does not support 'eviction' (e.g. a LRU algorithm). This means that your APCu cache will fill and fill until it is full, at which point it purges and starts again. Memcached just leaks old objects to make space for new ones (if it needs to).
From the discussion so far I think you need to understand and separate the different things that a 'Cache' is, each of these are independent and should not affect each other....
* the opcache - a cache of compiled php binary (zend or apc or another one...)
* the muc - Moodle's object cache - things moodle keeps to hand to make it faster, e.g. language strings (apcu, memcached, etc..)
* A caching reverse proxy - e.g. varnish - a cache of actual rendered delivered content between moodle and the user (good config and caution needed to make this work safely!)
Feeling I should mention CloudFlare as that is the topic here....
So CloudFlare does a few things to make your content delivery faster... it acts as a reverse-proxy (a bit like Varnish) but does this in conjunction with a CDN (content delivery network) this make things better for your user as data is logically closer to their client machine and really adds value if your users are over a diverse (i.e. global) distribution. But remember a lot of Moodle content is not cacheable and will see no benefit at all. It can also do some other cool things to take the load off your server too, like SSL termination... I think that covers the main (free) functionality
If you start paying the big bucks you can use things like RailGun. In short Railgun has a client installed on your server which does it's best to minimise the data needed to be transmitted when it needs to come from the source (i.e. your actual server). Again the big gain here is in network latency which is great for that global user base.
What CloudFlare can not do is make you Moodle actually generate content any faster, and even with Railgun your Moodle server *still* has to do the full page render before Railgun can analyse and compress it for transmission (and remember our server is now running a railgun client as well as all the Moodle services).
So CloudFlare is awesome, and innovative and can give some real benefit, but it is not a substitute for actually making your Moodle faster
O.K. I think I am getting this.
Right now, here is my configuration.
VPS-2000 at Cloudways (2GM ram, 2 cores)
Application cache mapped to Memcached. (Seems to be working fine)
Session cache mapped to default.
Request cache mapped to default
Cloudflare working as CDN (seems to have a very small positive benefit due to the fact that it seems to be a great service, but most of moodle content is dynamic)
I am considering mapping the Application cache back to APC, as it seems that APC and moodle were set up to work together, and I don't really notice any difference between APC and Memcache as far as speed is concerned, and I have not noticed much of a problem with APC purges in the past)
Unless there is a better way place to which to map the session cache or request cache, there may not be much else to be done to speed up my site, and since it is working fairly well, I can get back to grading papers and planning lessons.
Does this sound correct?
I think video and images would be considered static content. Any way to those to cache, or, because they are only part of a dynamic page, is it not possible to do so?