I run a subfolder based WordPress Multisite with ~200 websites, recently through our host I have tried to decrease our memory to 128mb per thread at 12 threads, instead of 256mb at 6 threads, but when I did that I was not able to login to the admin panel at all.
On investigation I found that the admin panel is using 215mb / 256mb available, so of course I wasn't able to login on 128mb. The site itself (non admin pages) only uses around 20-30mb for each page load. Disabling all plugins takes memory utilization from 215mb to ~180mb.
On even further investigation, I found that this is because there are hundreds (386) calls to "switch_to_blog()" and "restore_current_blog()" in order to populate the "My Sites" dropdown on every admin screen. If I remove the admin bar / disable these core admin bar files WP Admin memory utilization drops to around 36mb! If I remove a single site from our multisite memory utilization drops by ~3mb, so it stands that adding sites increases the overhead.
Is there a reason for this overhead for the WP Admin bar? Maybe I'm being stupid? Is there a way I can disable the admin bar for admin without messing with core files, or any other solution to this. Unfortunately my host (Kinsta) is not able to give admin higher memory than normal users.
Thanks!
UPDATE: Doing more tests, I made a user that has no websites assigned to it (so the My Sites list will have 0) and here is the memory usage (it's a bit more on the admin page vs on website pages, but still a lot less):
And here is a user with something like 180 websites assigned:
I run a subfolder based WordPress Multisite with ~200 websites, recently through our host I have tried to decrease our memory to 128mb per thread at 12 threads, instead of 256mb at 6 threads, but when I did that I was not able to login to the admin panel at all.
On investigation I found that the admin panel is using 215mb / 256mb available, so of course I wasn't able to login on 128mb. The site itself (non admin pages) only uses around 20-30mb for each page load. Disabling all plugins takes memory utilization from 215mb to ~180mb.
On even further investigation, I found that this is because there are hundreds (386) calls to "switch_to_blog()" and "restore_current_blog()" in order to populate the "My Sites" dropdown on every admin screen. If I remove the admin bar / disable these core admin bar files WP Admin memory utilization drops to around 36mb! If I remove a single site from our multisite memory utilization drops by ~3mb, so it stands that adding sites increases the overhead.
Is there a reason for this overhead for the WP Admin bar? Maybe I'm being stupid? Is there a way I can disable the admin bar for admin without messing with core files, or any other solution to this. Unfortunately my host (Kinsta) is not able to give admin higher memory than normal users.
Thanks!
UPDATE: Doing more tests, I made a user that has no websites assigned to it (so the My Sites list will have 0) and here is the memory usage (it's a bit more on the admin page vs on website pages, but still a lot less):
And here is a user with something like 180 websites assigned:
Yes, you can drop the "My sites" menu from a plugin.
function admin_bar_menus_remove_my_sites() {
remove_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
}
add_action( 'add_admin_bar_menus', 'admin_bar_menus_remove_my_sites' );