CloudFlare is one of the best CDNs out there. The most annoying error that you encounter in case of CloudFlare is error 522.
This error occurs in both CloudFlare free and pro version. But, however, here CloudFlare is not the player of the game.
Error codes starting from "5" are server side errors. You can refer to the list of HTTP status codes for more.
What causes this error 522?
As you may know, CloudFlare being one of the best CDNs out there makes requests for resources blazingly fast.
It demands resources from your server quickly. If your server fails to serve CloudFlare within time, then error 522 shows up.
From this, you can notice that the real problem is with your server but not the CloudFlare.
Most of the times, this error occurs in case of shared hosting. Because the resources are shared.When CloudFlare does not get the resources for its query within the timeout period error 522 pops out.
Why your server fails to react to CloudFlare queries? Your server will be busy serving other database queries and demands of other plugins.
What's the fix?
Ditch Hyperactive Plugins
Ditch out the plugin or module that supply database queries to your server often. Make your server free enough to serve CloudFlare.
Find out which of your plugin is slowing down the site.
As per Pareto's principle, "Roughly 80% of the effects come from 20% of the causes".
80% of the time, error 522 occurs due to faulty plugins, querying your server's database more often. Spotting down the hyperactive plugin should be the first go in this case.
For monitoring the profile or activity of each of the plugin, you may have to install the P3 (Plugin Performance Profiler)
On installing this plugin, it monitors all the activities of the plugin silently. Including the number of database queries it makes and monitors any server load issues caused by the installed plugins.
It also displays the impact caused by the plugins on page speed and others. It answers, what is the number of SQL queries per visit?
Using this plug-in, you can easily jot down the plug-ins that are causing server load issues.