acf/settings/acfe/modules/performance called millions of times a day
-
Hello!
I was going through New Relic and I’ve noticed
acf/settings/acfe/modules/performance
is being called 83M times a day, andacfe/modules/performance/config
59M times a day.I’m not sure if this is due to
acf/pre_load_metadata
being also called 44M of times, so I’m gonna go ask ACF support the same question too ??Do you have any idea about what might be causing the hook to be called so many times with barely 6.000 visitors a day?
-
Hello,
Thanks for the feedback!
When enabled, the Performance Module call its
performance
&performance/config
filters a lot of times because these settings are interrogated in various places to determine if DB calls related to ACF metadata should be short-circuited or not. These are not really used when Performance Mode is disabled.The high count of
acf/pre_load_metadata
filters you see on your Relic dashboard is also a side effect of the Performance Module, because this filter is designed for this specific usage: being able to short-circuit DB call.The more fields you have on a page, the more these filters will be called, because the module is interrogated for each ACF meta in order to maintain compatibility with posts that have unconverted meta and allow customization via the config array.
Regarding the efficiency side, such high numbers might look insane. But if you’re interested in performance, I would suggest to look at what filters actually do rather than the number of times they are called.
For example, you could use a very simple WP filter such as
init
which is only called one time per page load. In that hook, you could perform some intensive DB request that retrieve thousands of posts to do some tasks. Now this hook is still called only one time, but its execution time went from 0ms to 4s, on each page load.Regarding
performance
andperformance/config
, these hooks only return aboolean
and anarray
without any other operation, which is why they have a “0ms average call time” stat on your Relic Dashboard. They are basically “free” (+100kb in PHP memory).If you’re still worried about the performance difference with and without this module, you could run some tests on a post with 100 ACF fields: a Repeater with some Group of Fields. Without the Performance Mode, that would make 200 meta saved on that post (1 field = 2 meta). Check the filters calls, and you’ll see that indeed
performance
andperformance/config
count is very low (because the module is disabled), but the page execution time went up due to DB requests.Now enable the Performance Mode with Ultra Engine, and the filters call count went up, but execution time went down (because there’s only 1 meta instead of 200). It’s basically trading DB requests for 100kb PHP memory.
Indeed, in an ideal world, Performance Mode would be directly integrated into ACF core and forced for everyone, so we could lower that calls number. But at the moment, that’s the only way to achieve such DB enhancement with this level of customization as an ACF plugin.
As a side note, since you pointed out that you have 6k users on your website, I don’t know if that’s already the case, but you might would like to implement some cache, such as LiteSpeed (which is hands-down one of most performant cache solution). It would drastically lower DB calls, and filters calls too, since static pages would be served to visitors instead of full PHP/DB requests.
I hope this answers your questions.
Have a nice day!
Regards.
I’m amazed at the thoroughness of your reply, thank you so much! I’m so proud to be a Pro subscriber ??
This really answered all the questions I had in my mind, it was extremely helpful. I’m totally fine with a few KB or RAM being used instead of hammering the DB with unnecessary calls ??
As for the cache, we already have several cache layers in place:
- Cloudflare (Enterprise)
- WP Rocket
- Object Cache
- Varnish
- Redis
Would there be any reason to use LiteSpeed too on top of these, or would they overlap each other somehow?
Hello!
I’m happy to hear that this answered your questions!
Regarding your question about LiteSpeed and cache in general, I’m excited to discuss that topic, because it’s one of my personal interest.
As an introduction, I would like to mention that like any technology and trend on the web there is no absolute truth, and the following discussion is not meant to be an argument on the “perfect solution”. It’s based on my personal research, experience and commonly known facts.
I will leave CloudFlare for the second part of the message as it’s kinda independant from the actual server stack topic.
LiteSpeed could be introduced as followed: It’s a drop-in replacement for Apache, which comes with its own PHP wrapper, and a specific plugin for WP. This particular trait means it typically replaces stack such as Apache + Varnish + WP Rocket.
You could compare it to NGINX engine. However, unlike NGINX, LiteSpeed keep the traditional Apache syntax and is compatible with .htaccess too, which is a huge advantage. It just replaces Apache seamlessly.
Being an engine, it means LiteSpeed actually take care of static files (images, scripts, documents…), and send PHP requests to its PHP wrapper. Just like Apache which traditionally use mod_php, or NGINX with php-fpm, LiteSpeed comes with its own optimized PHP wrapper: LSPHP.
Regarding actual performance, there are several benchmarks which all come to same conclusion: LiteSpeed is faster, scale better, and utilized less CPU & memory than any combination of Apache / NGINX / Varnish. Here are some few of them, but you can make your own research:
- LiteSpeed Cache vs Varnish Cache
- Varnish Comparison Benchmark (LiteSpeed website)
- LiteSpeed Magento vs Nginx + Varnish cache
- LiteSpeed vs Nginx
- LiteSpeed vs Nginx vs Apache
There is one downside to all these awesome perks tho. Unlike Apache or Nginx, LiteSpeed is a paid solution. In my opinion, If you’re a performance geek, it’s worth every penny because of its speed and ease of use.
This was for the engine part. Now to return a little more to the surface and compare it with traditional cache applications such as WP Rocket, LiteSpeed also has some ground-breaking advantages.
Typically with WP cache plugins, any documents & static files will be cached for non-logged users. It’s called “Public Cache”, and it means that non-loged users will be served with HTML files instead of performing PHP requests. Now with LiteSpeed, there’s also a second layer of cache called “Private Cache”, which also serve cached documents to logged-in users, based on their role for example.
This second layer is very useful for dynamic websites such as Woocommerce or websites with a “Member Area”. Added on top of that, LiteSpeed has an ESI implementation (Edge Side Includes) which allow to only serve specific parts of the page dynamically, instead of doing a whole page request.
For example on a Woocommerce website, that means logged users would be served with a fast Private Cache, and only the topbar with the “Cart & Items” will actually make a real “PHP request” (to calculate price and custom stuff). You can read more about these technologies on their blog here:
I’m not aware of any other WP plugin that implement such cutting-edge features. Regarding Object Cache & Redis, LiteSpeed is indeed fully compatible with them. Their plugin also have a specific dashboard to connect it (see documentation), alongside with all the most advanced JS/CSS/Image tweaks.
To talk a little bit about CloudFlare, I’m also a huge fan of it. I’m not an Entreprise user tho. In my opinion the most important CloudFlare features regarding WordPress performance are CloudFlare APO & CloudFlare Argo.
You probably already have APO in your entreprise plan. I don’t know if you use it, but if not, you definitely should. APO is a specific optimization for WordPress websites which cache non-logged users documents into their Edge Cache. It means that cached pages will be served from a datacenter near the user location, just like a classic JS/CSS file. It is delivered as a WordPress plugin to install.
The second important optimization is Argo, which is a priority tunnel billed on usage. It’s basically the “true” paid CDN solution of CloudFlare. It will serve JS/CSS files faster, and it also works in pair with APO, serving pages faster too!
For the rest of the Cloudflare perks, I don’t have any other praises to make. As an Enterprise user, you probably know them.
I hope you’ll find these information useful. As you can see I’m a big fan of LiteSpeed. If you’re a performance geek, I would really recommend to take a deeper look ??
Have a nice day!
Regards.
Well looks like I found a fellow performance enthusiast ??
Thank you so much, this post was incredibly insightful and a pleasure to read!
I’ve recently moved the website on Cloudways (it’s amazing btw), and I don’t think using LiteSpeed is an option there, but they do use their combination of Apache + NGINX + Varnish which is incredibly fast, and I’m getting pretty awesome performance (due also to lots of optimization on my end to be fair haha)
And with a load of 250 concurrent users, the server response time is ~28ms
So in general I’m pretty happy right now and I don’t think it’s worth diving into LiteSpeed for now ??
But I’ll definitely look into APO and Argo as they seem extremely interesting!
Once again thanks a lot for your replies and for this fantastic plugin, wish you a wonderful day ahead!
Hey!
Congrats! That’s some great stats!
Yeah I heard about Cloudways, it looks quite promising, especially the free Object Cache Pro.
I’m not a huge cloud hosting enthusiast tho. I still have some hard time to imagine paying the price of a full dedicated server for only a fraction of its specs (RAM/CPU/Storage). But it is the price of tranquility.
Regarding their stack, NGINX / Varnish / WP Rocket is indeed very strong and proof-tested. Like I said in my previous post, LiteSpeed becomes really relevant for dynamic websites, with e-commerce for example. Since there is no Private Cache in WP Rocket, logged users would always perform PHP requests there.
Regarding Cloudflare APO/ARGO, I think we have a nice example of potential enhancement here. As you can see in the headers of your documents, they have this param: “cf-cache-status: DYNAMIC”.
Which means that for documents, Cloudflare reach your Cloudways server (probably somewhere in US) and send the info all the way back. Since I’m based in Europe, typically your document loading is about 120ms here. With Cloudflare APO, Cloudflare would not even reach your Cloudways server and directly send your document from my nearest datacenter.
Update: I see that you implemented APO. I can confirm you that now documents loading is about 30ms here! There are some page that still have a BYPASS flag, so I guess you’re currently tweaking it.
Congrats! That’s some great stats!
Thanks!! It’s also in part thanks to your plugin and your tips from this post ??
?I still have some hard time to imagine paying the price of a full dedicated server for only a fraction of its specs (RAM/CPU/Storage). But it is the price of tranquility.
I agree, but for ~ €50 per month I can’t really complain, and since I’m a solo developer handling both code and hosting, I’m happy to pay a little bit extra for that peace of mind and their excellent support. I really can’t afford the company’s website to go down!
Regarding their stack, NGINX / Varnish / WP Rocket is indeed very strong and proof-tested. Like I said in my previous post, LiteSpeed becomes really relevant for?dynamic?websites, with e-commerce for example. Since there is no Private Cache in WP Rocket, logged users would always perform PHP requests there.
True that, but the only users who log in to our website are editors/admins so I’m fine with that ??
?There are some page that still have a BYPASS flag, so I guess you’re currently tweaking it.
Uhm, I haven’t tweaked much yet actually, I’ve just enabled it through their WP plugin and that’s about it, I still didn’t get a chance to dig deeper into the dashboard, but that’s interesting because I haven’t bypassed any pages :/
I am bypassing some via WP Rocket, but that should not affect APO’s rules…I’ll look into that thank you mate! ??
Thanks!! It’s also in part thanks to your plugin and your tips from this post
??
Uhm, I haven’t tweaked much yet actually, I’ve just enabled it through their WP plugin and that’s about it, I still didn’t get a chance to dig deeper into the dashboard, but that’s interesting because I haven’t bypassed any pages :/
I am bypassing some via WP Rocket, but that should not affect APO’s rules…Here is an example to help you dig in: https://newzoo.com/resources?type=trendreports&tag=all.
This document has the following headers:
cf-apo-via: origin,qs cf-cache-status: BYPASS
It might have something to do with the URL Query String parameters (the
qs
flag):type=trendreports&tag=all
.Have a nice day!
Regards.
Oh wow I hadn’t noticed, thanks a lot! You’re right, it might be due to the query parameters which might be hard to cache because they change the filters on the page.
I’ll look into that!
You have a nice day too thanks ??
- The topic ‘acf/settings/acfe/modules/performance called millions of times a day’ is closed to new replies.