Install Magento Open Source 2.2.2 with sample data
Steps to reproduce
Load frontend with the Network panel open in Chrome's DevTools. Start typing quickly (even random characters is ok).
Expected result
Magento should wait a small period of time (50ms?) before sending a search suggestion to the server
Actual result
Every character that is typed results in a new AJAX request being sent to the server, which causes them to get backed up.
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.
Preconditions
Steps to reproduce
Expected result
Actual result
This can be overcome by increasing the
max_concurrency
value inenv.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 thewait
variable passed todebounce
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