fastly-magento2: 503 Service Unavailable error when requesting 'admin/fastlyCdn_Edge_Dictionary/ListAll'

Hi guys

Yesterday we enabled Fastly on a staging environment of the Magento Cloud.

But we sometimes see errors popping up in random adminhtml pages under Stores > Configuration (not only in Advanced > System), this error is displayed in a red box: A technical problem with the server created an error. Try again to continue what you were doing. If the problem persists, try again later.

When looking through the Network tab of my inspector, I can see that some XHR requests to the Fastly module throws a 503 error which causes this problem.

I can see 3 similar XHR requests, two of them work and one fails. The ones which work:

The one which fails with a 503 error:

And I also sometimes see this one fail with a 503 error:

It’s a bit random these errors, sometimes it’s the first one, sometimes the other one, sometimes even both, and then sometimes no errors, really strange behavior.

Looking at the actual contents of the response, we see something like this (it feels like this is a server error somehow, but no idea how to debug this):

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>503 Service Unavailable</title>
  </head>
  <body>
    <h1>Error 503 Service Unavailable</h1>
    <p>Service Unavailable</p>
    <h3>Guru Mediation:</h3>
    <p>Details: cache-ams4432-AMS some-number some-other-number</p>
    <hr>
    <p>Varnish cache server</p>
  </body>
</html>

Extra info which might be relevant:

  • we have no Edge Dictionaries setup at the moment.
  • Magento 2.2.2
  • fastly/magento2 version 1.2.48

Any ideas what can cause this or how we can solve this?

If there are no errors, those request return valid looking json strings, so I don’t think the problem is in the Fastly module itself, but actually on the server side. If we have to report this to the Magento Cloud support instead, please let us know.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 29 (14 by maintainers)

Most upvoted comments

We have addressed this in #177. Fixes were released as part of 1.2.54.

We’ll look into doing this differently.

The issue is caused by Redis session blocking mechanism. The Cm/RedisSession library has a variable which limits the maximum number of processes that can wait for lock on one session. By default it’s value is 6. The default value leads to errors on Magento frontend/backend when, for example, a web page makes several AJAX requests to Magento.

That’s what you see when navigate to Stores > Configuration > System: Fastly extension starts sending several AJAX requests to Magento and you reach the maximum concurrency limit. When it happens, Magento responds with 503 error and you can find “Area code is not set” errors in the var/report/ directory.

To avoid the issue, you have to increase the max_concurrency value in app/etc/env.php:

'session' =>
        array (
            'save' => 'redis',
            'redis' =>
                array (
                    'host' => '127.0.0.1',
                    'port' => '6379',
                    'database' => 0,
                    'max_concurrency' => 20,
                ),
        ),

If you’re a Magento Cloud user, you mustn’t edit env.php manually, but add the SESSION_CONFIGURATION variable with Redis configuration in JSON format. You can get more details by submitting a support request.