-
Notifications
You must be signed in to change notification settings - Fork 192
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
DDoS-ing the Metadata Server. #297
Comments
@dwsupplee since you tagged it as investigating, it's not just PHP 7.4 but all 7.x releases |
At Etsy we've encountered the same issue; during periods of high enough traffic (e.g. backfills) we've seen metadata server outages that result in the following backtrace:
...where the
...which ends up calling the We use the |
If we added a new class, like @ericnorris suggested, we could have something like this: // GCE cache implementing CacheItemPoolInterface
$cache = new FileCache();
// optional GCE cache config
$cacheConfig = [
'lifetime' => 1500,
'prefix' => '',
];
$gceCache = new GCECache($cache, $cacheConfig);
// fetch default credentials with the cache
$credentials = ApplicationDefaultCredentials::getCredentials($scope, null, null, null, null, $gceCache);
// check directly with the cache
$onGce = GCECredentials::getCredentials(null, $gceCache); We can't use the existing We could also add // FetchAuthTokn cache implementing CacheItemPoolInterface
$authTokenCache = new FileCache();
// optional GCE cache config
$authTokenCacheConfig = [
'lifetime' => 1500,
'prefix' => '',
];
// GCE cache implementing CacheItemPoolInterface
$gceCache = new FileCache();
// optional GCE cache config
$gceCacheConfig = [
'lifetime' => 1500,
'prefix' => '',
];
// fetch default credentials with the cache
$credentials = ApplicationDefaultCredentials::getCredentials(
$scope,
null,
null,
$authTokenCache,
$authTokenCacheConfig,
$gceCache,
$gceCacheConfig
);
// check directly with the cache
$onGce = GCECredentials::getCredentials(null, $gceCache, $gceCacheConfig); Do these solutions sound sufficient, and do you have a preference for either of them? |
@bshaffer, I actually proposed a different solution internally (props to @etsteeeve for implementing) that seems to work for us. We've instead written a wrapper class called Perhaps this could be implemented in the library as a |
@ericnorris This is a really great idea! If you or @etsteeeve want to submit a PR please do! Otherwise I can take a look. It would be nice to have caching for |
I've coded up a potential option, please tell me what you think. |
fixed in Passing a cache into
|
@bshaffer I disagree with the provided soultion. I think this code must be disabled by default. I'm sure that this is a big problem when without any credentials you get enabled this mechanism and it ruins any feature tests. E.g. when you use datastore/spanner (or something else with GRPC) in feature tests and you don't need any credentials (because you can use datastore/spanner emulators) you get each test slowed down by at least 1.5 sec (3 tries with 500ms timeout per GRPC class). And the default caching mechanism doesn't work because it's in-memory storage and a state of an app is cleared between test cases. |
Hello,
With high volume traffic, a check (on each interaction with Google APIs!!!) if the application is running on GCP by calling the metadata server is becoming quite a bottleneck response-time wise.
The specific code is located here:
google-auth-library-php/src/Credentials/GCECredentials.php
Line 258 in c438cda
Environment details
The text was updated successfully, but these errors were encountered: