• Resolved aapc

    (@aapc)


    We recently launched a site makeover on a high traffic site which included both Relevanssi and Relevanssi Live Ajax Search. Development went well but as soon as we launched the site, we started seeing huge performance issues. I reached out to my hosting provider and he told me the following process was getting “hammered”

    /wp-admin/admin-ajax.php?action=relevanssi_live_search_messages

    As soon as I deactivated Live Search, the site became much more responsive and server utilization dropped. I really love this plugin. Is there anything we can do to get this to work more efficiently?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Can your hosting provider tell what is hammering it? Or is the search just so heavily used? This is the first time anyone has reported performance problems with this plugin, but I have no idea where and how the plugin is used.

    That process doesn’t do much in itself. It reads a a very small template file and displays that. I’m really surprised that is heaviest part of the process, because it definitely isn’t. Doing the search itself should be much harder job.

    You can disable calling this action with this snippet:

    add_action( 'init', function() {
        global $wp_filter;
        unset( $wp_filter['wp_ajax_nopriv_relevanssi_live_search_messages'] );
        unset( $wp_filter['wp_ajax_relevanssi_live_search_messages'] );
    }, 11 );

    This will make the spinner disappear, though. To get it back, add this manually somewhere in the search form:

    <div class="live-ajax-messages">
    	<div id="relevanssi-live-ajax-search-spinner"></div>
    </div>

    But to me this sounds like there’s some problem here. The message template action should be very light, so it sounds like something’s wrong here and figuring out why it’s such a problem would make sense.

    Thread Starter aapc

    (@aapc)

    I think by hammering he meant that it’s both showing up numerous times and taking time to complete. I can ask him to clarify but I will certainly say that by deactivating the plugin, we saw a tremendous difference. It’s a fairly high traffic site and a bet a lot of people were using the search feature.

    I was testing on our staging site today I see that the plugin submitted a search each time a letter was pressed. I understand that’s desirable but it could be contributing to the aforementioned “hammering”. For example, as I typed a 3 word search, the site fired off 6 requests to admin-ajax.php and each one took, on average, about 500ms give or take. I would imagine with 5-10k users at any one moment, this can add up pretty quickly. Maybe a slight delay after keyup might help for those that type slowly?

    Plugin Author Mikko Saari

    (@msaari)

    Ok, I see. Yes, the searches do pile up, but I don’t think the messages request is the real problem. The search request is probably a much bigger problem, as that’s actually taxing for the server.

    The delay is something you can adjust from the plugin settings. The default delay is 300 milliseconds. This would set the delay to 500 milliseconds:

    add_filter( 'relevanssi_live_search_configs', function( $config ) {
      $config['default']['input']['delay'] = 500;
      return $config;
    } );

    There’s also $config['default']['input']['min_chars'] if you want to adjust the minimum character count from 3.

    It’s also possible that with the kinds of numbers you have, running Relevanssi and Live Ajax Search isn’t a very good idea. If you have thousands of users running searches at the same time, it may be useful to invest in an external search solution like AddSearch, Elastic or Algolia.

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