If you sites are slow and get always online pages and combine that with 520/522 errors, then 90% sure it’s because your origin server is overwhelmed, crashing and/or unable to handle the traffic or load from visitor requests. You’d want to systematically rule out each possibility starting with
- database queries/slow database MySQL queries
- slow or unoptimised web server/PHP server requests
- web application configuration i.e. Wordpress plugins forum addons or or web app related slowness
- your origin server configuration issues i.e. origin firewall or HTTPS SSL certificate configuration
- web host specific issues i.e. web host firewall or security/DDOS mitigation systems in place
It could be any combination of the above listed issues causing 520/522 errors. I recently fixed one of my clients 520/522 issues which they had up to 200,000 HTTP 520/522 status errors per day which accounted for ~1.7% of their total traffic and they had a combination of all the above listed issues that needed fixing. Alot of it was down to poor optimization and configuration by their previous hired system admin help!