• paulian

    (@paulian)


    Hi,
    thanks a lot for such a wonderful plugin.

    I used version 2.09 and my perfomarce are:
    Traffic between VM and DB: 1.09 MiB/s
    CPU: 25%

    After update to version 2.11:
    Traffic between VM and DB: 55 MiB/s
    CPU: 70%

    I must downgrade to version 2.09.
    Please dont use function “get_blog_option”, its calls “switch_to_blog” and it is very slow. Or use cache.

    Thank you!

    Info:
    My VM is on Google cloud, has 4 vCPU and 16 GB RAM, php-fpm, nginx, W3 Total cache (and cache on client side), google network protection (DDoS).
    Google cloud database with 4 vCPU, 16 GB RAM, constains 60GB data.

    Wordpress with 3 sites, 1k pages, 40k posts, 20k medias, 37 plugins.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Johan Jonk Stenstr?m

    (@jonkastonka)

    I’ll take a look and see what I can do.

    Do you have any suggestion what to use instead of get_blog_option?

    Thread Starter paulian

    (@paulian)

    Thank you for your reply.
    I suggest one of the following:

    1. Simple disable multisite feature with:
    DEFINE('SUPPRESS_COOKIES_MULTISITE', TRUE);

    In code:

    $suppress = DEFINED('SUPPRESS_COOKIES_MULTISITE') && SUPPRESS_COOKIES_MULTISITE;
    $multi = !$suppress && is_multisite();

    instead of:
    if ( is_multisite() ) {

    use:
    if ( $multi ) {

    2. Load all options at once, use scoped cache in global var, so you call switch “switch_to_blog” only once:
    (only snippet, not whole function)

    $get_cacsp_options_data = [];
    const CACSP_OPTIONS = ['cacsp_option_actived', 'cacsp_option_use', 'cacsp_option_only_csp', 'cacsp_option_banner']; //all!
    
    function get_cacsp_options( $option, $new_line_to_space = false, $fallback = '', $esc = false ) {
    	global $get_cacsp_options_data;
    	
    	if ( !$get_cacsp_options_data ) {
    		if ( is_multisite() ) {
    			switch_to_blog( $cacsp_site_id );
    		}
    		
    		try {
    			foreach (CACSP_OPTIONS as $item) {
    				$get_cacsp_options_data[$item] = get_option($item);
    			}
    		}
    		finally {
    			if ( is_multisite() ) {
    				restore_current_blog();
    			}
    		}
    	}
    	
    	return $get_cacsp_options_data[$option];
    }

    3. Use 2. but with wp_cache_set, opcache or similar. You can keep cache until call “update_option”. Or just give choose by using “apply_filters” before loading, if you get data from “apply_filter”, then use it and dont load it. If you dont get data from “apply_filters”, you load it and call another “apply_filters” for possible saving.

    4. Use direct select to DB. But original “get_option” function use cache and own “apply_filters”, so it can be dangerous.

    Plugin Author Johan Jonk Stenstr?m

    (@jonkastonka)

    Thanks! I’ll look into it!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multisite performance issues’ is closed to new replies.