Likely you won’t like hearing this…
Looks like your problem is a combination of CloudFlare + Magento.
[ … rant on … ]
It appears your primary problem is you’re using CloudFlare.
CDNs add complexity creating difficult to debug problems + CDNs only help sites which are abysmally tooled… meaning the LAMP stack is untuned (using default config files). Way better to invest in tuning your LAMP stack, rather than using CloudFlare.
First thing I always do with new clients is strip out all CDNs (CloudFlare) + Proxies (NGINX/Varnish) + caching nonsense (memcached).
[ … rant off … ]
Here’s the problem with CloudFlare.
- Take a look at these two waterfalls…
Notice they are completely different which means either CloudFlare or your Hosting or how CloudFlare is interacting with your Hosting is glitchy…
Glitchy… tech term for inconsistent times to serve content.
Repeat tests of a site should give somewhat similar results.
- You can easily see the problems by drilling down on specific assets.
I do this by curl’ing (copy a file via curl or wget to one of my servers) + comparing time to serve the asset.
- Notice asset #34
951ms for CloudFlare…
243 ms on one of my servers.
- Notice asset #27
680ms for CloudFlare…
225ms for one of my servers…
Remove all cruft (CloudFlare + NGINX + anything else you’re running).
The other challenge is you appear to be using Magento, which is extremely difficult to tune.
If you’re generating substantial cash from this site, best tuning approach…
Relocate /tmp to tmpfs (off disk into memory). This will cause PHP session files + MySQL temporary datasets (side effect of complex SELECTs) be memory resident (run at memory speed, rather than disk head seek speed + disk i/o speed).
If you’re running any downlevel LAMP code, upgrade to latest everything.
Currently this means Apache-2.4.25 + PHP-7.1.5 and latest OpenSSL + config Apache to run HTTP2 + ALPN + Stapling + Strict Transport.
If you’re running MySQL (shudder), remove they MySQL software (leave data) + install latest MariaDB.
If you’re running MyISAM tables, convert to InnoDB (after MariaDB is installed).
Run mysqltuner every few days + implement any diagnostics emitted.
If you’re not generating substantial cash from your site yet, dump Magento + go with WordPress.
With Magento you’ll always spend more for slower throughput.
I’ve never been able to tune a Magento site to come close to WordPress speed.
- Finally, if you simply must use Magento (horror or horrors), then you’ll have to run a memory resident database subsystem, if you have any appreciable traffic.
This means at boot time of your machine or LXD container, copy /var/lib/mysql into a tmpfs filesystem. Start MySQL/MariaDB pointing to memory resident database. Run an rsync every minute from tmpfs to /var/lib/mysql to pickup any changes. Then at host or container shutdown, as part of the systemd MySQL/MariaDB shutdown action, after daemon stops, do one final rsync to bring all data consistent.
- Also you’re running PHP 5.4.16 which is highly hackable.
Best first step, update your LAMP stack to latest.
If you’re hacked, likely your site speed will become a secondary issue.