-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Pages with many products return Error 500 when Varnish is enabled #7657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Same in here @eldonbite. When tried to enter a page with configurables, got 500 with varnish. Using built-in cache it seems ok. |
Some updates: apparently changing certain Varnish parameters won't help. It's actually due to the maximum header size supported by Apache, which is 8KB: http://stackoverflow.com/a/8623061 To ensure that having a huge number of configurable products in a product listing page works when Varnish is enabled, it's best to limit the size of the header to the said length (8190 bytes): http://stackoverflow.com/a/6160643 In the meantime, as a workaround to our project, I created a patch for shortening the product cache tags both in generating the X-Magento-Tags header and when sending a purge request to Varnish. However, with the sheer amount of configurable products and swatches being displayed in our product listings, I had to lower the number of products to display per page down to 36.
|
Some more updates: By doing Huffman coding string replacement on the tags, I managed to further shorten the size of the 40 products per page: 60 products per page: I hope the Magento team could implement some sort of cache tag compression similar to what I did. |
@eldonbite Thanks for info. Sounds insteresting. Platform great but it is a really resource eater. |
Hi @rbostan, It's not exactly a full-blown Huffman encoding algorithm. It's actually just doing a dictionary-based prefix replacement to the cache tags multiple times. For example: Tags: Replacements:
This will shorten the product cache tags to just: HTH 👍 |
@eldonbite Brilliant! |
Didn't see this reported issue (due to the large stack of issues here): X-Magento-Tags header too large #6401 Looks like that one already has a fix in M2.1.3, so I guess upgrading should fix this issue as well. |
Just confirmed that Magento 2.1.3 has already fixed the issue with the large X-Magento-Tags header after I updated the staging instance of our project. Please feel free to close this issue, unless you also plan to work on compressing the tags and allow stores to display as many products per page as possible. |
Closing issue per comment from @eldonbite as confirmation. |
After upgrading to 2.1.3, we were encountering problems similar to this reported issue: #8009 |
Hi All, Anyone has fix for this issue ?? Check this url: |
Any reason, why this issue is closed. Issue is still there in 2.3.3 |
Arrows Team- DHL API schema migration from 6.0 to 6.2
Encountered an issue wherein certain product listing pages with 60 products per page loads properly when using M2's built-in FPC but returns Error 500 when using Varnish.
Preconditions
Steps to reproduce
Expected result
The product listing page should display properly
Actual result
Page returns Error 500
After a lot of hours spent in investigating the issue and even trying to tune Varnish by configuring certain parameters, I noticed this recently submitted issue here in the M2 repository and tried to look into the X-Magento-Tags header.
#7640 X-Magento-Tags header containing whitespaces causes exception
I didn't find any pages that has spaces in the said header, nor blocks with block ID containing spaces, but I noticed something: perhaps due to the sheer amount of products that is being displayed in our product listing pages, some of them have X-Magento-Tags header lengths that reach up to more than 16k characters. I commented-out the "unset" statements in the default.vcl Varnish configuration file to check the contents of the said header and one of them are as follows:
I paginated through the category and found a page that loads properly even with X-Magento-Tags header containing almost 5000 characters.
So what I did was to try modifying the setHeader() function of vendor/magento/framework/HTTP/PhpEnvironment/Response.php to create a sha1 hash of the header's value and then the pages started loading properly.
So I guess a possible fix for this is to either hash the value of the X-Magento-Tags or perhaps compress it if we want a reversible string, e.g.:
$value = base64_encode(gzencode($value));
I'm just not sure of the implications of this solution, like when cleaning or flushing the cache or whatever. I'll just leave it to you guys. Thanks!
The text was updated successfully, but these errors were encountered: