Uptime Monitoring

WordPress is easy to use. Behind the scene, it is a complex piece of software, running on PHP and MySQL. Monitoring the uptime of WordPress sites may seem straightforward. But, in reality, it is easy to miss the downtime using conventional methods.

Let me provide you with an example. Let’s take this site… tinywp.in . I monitor this site using multiple uptime monitoring services. They keep watching the home page at https://www.tinywp.in and see if it shows any errors. They notify me in case of the following errors

  • 500 Internal Server Error
  • 502 Bad gateway
  • 504 Gateway timeout

Basically, uptime monitoring services notify me of any 5xx errors. We may also configure them to notify upon 4xx errors such as 404 (Not Found Error). Usually, it is not necessary to notify upon 3xx status codes (related to redirection).

Everything looks good for a normal site, include a WordPress site. But, there are occasions, the normal monitoring wouldn’t be enough.

White Screen of Death

There are multiple occasions when a site goes down with white screen of death, but the monitoring services fail to notify me. This is because the site returns 200 (Success) message. In most such occasions, the site would actually send some content to the browser, but not enough to display something useful. It means the site sends back partial content.

How do we solve this?! Most monitoring platforms offer the ability to fetch the actual page and look for a particular word or text in it. We do not want to search for the title of the site, as it appears in multiple areas. The good practice is to look for a word or text that appears at the bottom of the site, such as the footer information. Copyright information is probably the best text to search for.

Full-page Caching

Most sites use some sort of caching, including full-page caching. The notable exceptions are e-commerce sites or any site where we have tons of logged-in users (such as a forum). For a blog, where we have a series of articles, having a full-page caching layer has come a standard practice. There are multiple full-page caching solutions are available, such as WP Super Cache, WP Rocket cache (paid product, though). Irrespective of the actual full-page caching layer a site uses, they all basically cache the home page and articles in a site. There are some caching solutions keeps the cache outside of PHP, such as Varnish (in memory) or WP Super Cache (in disk). So, even if PHP / MySQL goes down, the cached content is fetched from disk or memory and is served to the visitors.

It looks great. However, please read the last line in the previous paragraph. When PHP / MySQL goes down, the visitors would not be aware of it. So does a uptime monitoring service. So, the best practice is the monitor the uptime of a page that actually involves PHP and / or MySQL without any caching layer in the middle. Can you guess what it is?

There are multiple pages where WordPress requires PHP and MySQL. One such page is the login URL such as https://example.com/wp-login.php . So, when we instruct our monitoring services to monitor the login URL of our site, we will be notified of any downtime in PHP / MySQL (even though the front-end of the site is still being served from cache for other visitors). Be sure to utilize the word search functionality in your uptime monitoring service, if it is supported. Normally, we can search for the text “Lost your password?” that appears just below the login button.

Conclusion

In reality, the uptime monitoring can become more complex. For example, if we use a proxy such as Incapsula or Cloudflare that offers “always-on” technology (albeit only for a limited number of pages), we may never know if other parts of the pages are inaccessible. So, it is recommended to actually monitor a random page (that changes every day or hour). In addition, we can create our own little page to detect if it is only PHP or MySQL is down. We still need to consider these edge cases, if we are dealing with a mission-critical website.

We may even consider monitoring the performance of the site. At times, both the front-end and back-end may be up. But, both or one of them may be slow (too slow compared to a normal day). As a result, we would be losing visitors, losing the search engine rankings, etc.

To start with, I’d suggest to monitor both the front-end of the site (such as home page) and the back-end of the site (such as the login URL). In this way, we would know when the site goes down for logged-in users and normal visitors.

Happy blogging!

Please don’t hire me!

Please do not hire me because the cost of living in the country where I live is way cheaper than where you live. Just because the cost of living is lower doesn’t mean you can hire my services at a fraction of rate charged by the tech people from your own country!

Of course, the cost of food and real estate are much cheaper here. The cost of food is rapidly increasing here due to globalization of food industry. However, as my life resolves around IT and products related to IT, the cost of tech products are always higher than whichever country you live in!

To illustrate with an example, iPhone X (64GB model) costs USD 999 in US. Here, the same model costs INR 87400 or approximately USD 1378 upon currency conversion. All hardware products are priced higher due to reasons only known to the retailers. Software products aren’t cheap here either, just because the cost of living is way cheaper!

So why hire me?

I care about security and performance!

Performance

I live in a city where the maximum possible connection speed is just 6mbps (as of this writing; up from 4mbps since November 2017). Also, I do not get all the latest gadgets that are just launched, because I can’t afford one. I always get products that were launched at least 6 months ago (when the prices come down a bit after the initial hype). It is not uncommon to buy products that were 2+ years old! Naturally, I get products that were older and slower. It has taught me how to utilize my existing infrastructure efficiently, such as how to speed-up a server or a site under heavily restricted speed conditions! So, performance has been my top priority, just after security!

Security

Security should always be the top most priority for any serious business. I have seen failures when security is not given the importance it deserves. We can run a successful business without a good UI or without a fast load time. But, not without keeping a close eye on security! Security is simply related to the reputation. Which business owner would want to lose his / her business reputation?! I have allegedly helped a whistle-blower to run a successful website that exposed multiple scams. If you want to know my association with that website, please search for “pothi kalimuthu savukku” in your favorite search engine. So, I know a thing or two about security and how to protect a business from bad bots, guys or girls. Of course, there is no such thing as perfect security!

Oops Moments in DevOps

A post on a new year is usually about resolutions! But, isn’t the best time to revisit the last year’s mistakes and resolve to never repeat it this year (and years to come)?! Since, my strong skills are with DevOps, I’d like to share some oops moments (you may call them blunders) that you’d never want to do it, if you are starting on DevOps or if you just want to understand where things go wrong in DevOps. In general, you go by the defaults, you’d be in trouble in the future. Whatever software you use, make sure you understand the default values and what each of them does! Here are the top three mistakes that I did… Continue reading “Oops Moments in DevOps”

Excluding iPad from wp_is_mobile!

Mobile Detect Logo
Mobile Detect Logo by Dragoș Gavrilă!

wp_is_mobile function in WordPress considers iPad as mobile! This scenario creates issues on iPad, iPad Pro, or any relevant tablets. To be precise, iPads are shown a mobile version of a site rather than the desktop version! Searching the internet didn’t yield a clean way to overcome this situation. Heck, there are even plugins to detect mobile devices and to exclude iPads from being mobiles.

Continue reading “Excluding iPad from wp_is_mobile!”

WP Rocket – Nginx configuration

I prefer open-source software and have been a long-time advocate of OSS in general. Recently, I started liking WP Rocket plugin that offers some unique features. I already have a perfect Nginx configuration for WP Super Cache plugin (that I consider as the best full-cache plugin till date). Since, WP Rocket uses disk caching like WPSC, I wanted to quickly convert the existing configurations to fit WP Rocket. I did succeed in it and you can find it in my WordPress-Nginx repo. Here I explain how WP Rocket stores the cached content and how it could be integrated into Nginx.

Continue reading “WP Rocket – Nginx configuration”

Sandboxing email for a local WP site using just three lines of code!

In a local-staging-live workflow, often we have some restrictions on both local and staging / development environments. A common restriction is to disallow indexing of the development site that may introduce duplicate content in the search result, if indexing is allowed (that is not uncommon when we set up the live site and then copy it to develop further :-) ). There are lot more restrictions and workarounds in order to setup a perfect development or local environment. Here, let me share a particular solution regarding emails. Let me start with some of the use cases.

Continue reading “Sandboxing email for a local WP site using just three lines of code!”

WordPress Preloading Posts / Pages / Images – What, when and how!

Preloading posts is one of the popular recommendations by most articles on the internet on how to speed up your WordPress site. Since, most WordPress sites (I’d say over 99%) have little or negligible traffic, it is highly recommended to get the posts preloaded in the cache so that the visitors do not have to wait to get the generated on-the-fly that actually takes some time. In this case, by the time the post is generated to be served to the visitor, the visitors may have gone to visit another website. So, do I recommend preloading? Yes (for low traffic sites) and no (for high traffic sites). Read more for a bit of explanation on this…

Continue reading “WordPress Preloading Posts / Pages / Images – What, when and how!”