“New Relic is where dev, ops, security, and business teams solve software–performance problems with data.”
As a prelude, let me state that I have no affiliation with New Relic, nor do I get any financial remuneration from them. I am just a customer of New Relic.
Can you find the queries or processes lagging and slowing down your WordPress environment using the plugin “Query Monitor”? Sure, but it is hard to find the source of the query running slowly and very time-consuming. New Relic provides the tools to dig deeper into your back end and identify where the slowdown is happening by allowing you to drill down to the query and plugin level.
It will point to the queries and processes that are running slow. But to make sense of the information in front of you, you still need to interpret what New Relic is telling you, know how your website works, and how to make code changes. In my opinion, New Relic is a critical tool that you need to have in your toolbox.
The following is a factual account of an issue I experienced with my website. Being an old dog when programming is concerned, I am a young pup when WordPress is concerned. So, when I started working with WordPress, I made lots of mistakes. But please, keep reading.
As part of the original migration of my website to WordPress, I developed a plugin to ingest posts from a third-party vendor. We had the same process on my previous website, but it was a homegrown CMS and did not have any tools to monitor the workload and performance of this process.
So after spending some time learning New Relic, and looking at what was going on with the website, it became apparent that I had a problem with one or more of my queries. As far as I know, we could have had the same issue before we migrated to WordPress, but I did not know because I had no tools to give me an inside view of my backend. Who knows, maybe ignorance was blessed?
Looking at the Top databases graph, I could see that Throughput and Query responses were very high all the day, 24/7. I use Google Analytics and know our traffic patterns throughout the day. So, I knew the numbers were not legit, because traffic was high even thru the early hours of the day.
So, because of the ability of New Relic to drill down to the database query and the WordPress plugin details, I was able to identify very quickly that I had several slow and inefficient performing plugins. I discovered that my plugin was using very inefficiently WordPress and Advanced Custom Fields(ACF) default joins. Now, I happen to believe that ACF is a must plugin, but it needs to be used correctly and know how ACF interacts with the database. In this case, it was not ACF’s fault, it was my code.
Also, I discovered that I can not “trust” 100% what New Relic was telling me. According to New Relic, Yoast SEO was performing very slowly too, among others. So of course, I looked into that. But the reason why Yoast was performing slowly, was that my plugin was chewing up lots of the processing time and was making other processes slow. Once I turned off my plugin and let the system settle, Yoast started behaving normally. You have to use New Relic as a guide, not as the gospel.
As I said earlier, because of the New Relic drill-down functionality, I identify my plugin as the guilty party down the specific queries that needed my attention. In my opinion, New Relic paid itself for the year just by the time that we saved with one plugin. Depending on your code, you may need to do something different than I did.
Also, a big red flag that New Relic identified was the default process that WordPress executes every time you add a post to a category or tag. WordPress will calculate the count of posts in each category and tag. I was adding 25 posts every 5 minutes, so every time an individual post was added, the system was calculating those counters. Just by using wp_defer_term_counting(true), I was able to speed up the process by a lot:
wp_defer_term_counting(true); //defer counting terms
//mass insertion or posts and assignment of terms here
wp_defer_term_counting(false); //count terms after completing business logic
Final Word
I am 100% convinced that New Relic is a must, and depending on your website traffic, you may be able to open a free account with New Relic. Now, you may need to ask your Hosting Service if you can use New Relic. New Relic requires you to install some monitors on your server to send the data to New Relic.