magento / community-features

Magento Features Development is an Initiative to Allows Community Memebers Join to Development of Magento Features
46 stars 18 forks source link

Search suggestions result in dozens of queued AJAX requests #71

Closed magento-engcom-team closed 3 years ago

magento-engcom-team commented 6 years ago

Preconditions

  1. Install Magento Open Source 2.2.2 with sample data

Steps to reproduce

  1. Load frontend with the Network panel open in Chrome's DevTools. Start typing quickly (even random characters is ok).

Expected result

  1. Magento should wait a small period of time (50ms?) before sending a search suggestion to the server

Actual result

  1. Every character that is typed results in a new AJAX request being sent to the server, which causes them to get backed up. 13-01-06 screen shot 2018-03-27 at 1 00 47 pm-mwqn5
  2. A side effect of the server being slammed with requests: If Redis is being used for session management, some of the requests might return a 503 error like this:
    Warning: session_start(): Failed to read session data: user (path: /var/www/stage/releases/20180223190752/var/session/) in /var/www/stage/releases/20180223190752/vendor/magento/framework/Session/SessionManager.php on line 189

    This can be overcome by increasing the max_concurrency value in env.php, but this isn't the best solution to this problem.

Suggested Solution

Implement the underscore debounce function to delay the sending of the search suggestion until the user stops typing. However this may result in a degradation of the user experience as search suggestions might show more slowly so the wait variable passed to debounce should be tested to determine the best tradeoff between server load and user experience.

Original Report: https://github.com/magento/magento2/issues/14402 by @erikhansen

sivaschenko commented 3 years ago

Fixed in https://github.com/magento/magento2/pull/16669