Comments (14)
Looks like it works, thank you very much :)
from laravel-firebase.
I'm glad, thanks for the feedback! šŗ
from laravel-firebase.
Thanks for testing it out! I think the āno-dev
issue could be resolved by changing the dependency to dev-discovery as 4.41.1
or by changing the minimum stability - but thatās not the point, especially if itās back at being slow.
Iāll start working on a better, more permanent solution and let you know once I have something ready. Thanks for your help and your patience!
from laravel-firebase.
That's an interesting problem! š¤
Are you using a Service Account JSON file locally and on GAE/GCR? If so, please try leaving the FIREBASE_CREDENTIALS
environment variable empty on the Google Infrastructure - this should force the SDK to use auto-discovery and discover the GAE/GCR environment, which should save some of the expensive roundtrips via external internet connections.
I hope this helps!
from laravel-firebase.
Hey, thanks for the quick reaction. On local dev, I'm exposing GOOGLE_APPLICATION_CREDENTIALS as Environment variable. On GAE/GCR, I'm not setting any env vars.
from laravel-firebase.
Darn... I was hoping it would be as easy as that. For the moment I have no other ideas, but I will try it out tomorrow on GAE/GCR as well, if I can at least reproduce the issue, I can hopefully also figure out why this is happening. š¤
from laravel-firebase.
Did some digging and i found a fix.
If i open up this file:
https://github.com/kreait/gcp-metadata-php/blob/master/src/GcpMetadata.php
and replace the constructor with:
public function __construct()
{
$this->client = new \GuzzleHttp\Client();
}
Instead of the auto injected guzzle client then performance returns to normal. 28 seconds down to 200 milliseconds.
As for WHY this is a problem i have no idea, but this does make the problem go away.
Is there anything I can to do help to get this fixed in an official release so I don't have to monkeypatch my php code? :)
Edit:
I should probably add that we found that calls to the GCP meta data service were taking just under 5 seconds each before this fix, and after this they're back down to 2-3 milliseconds each.
from laravel-firebase.
You already did! Thank you for digging into it and finding a solution!
As you're currently already monkeypatching š , could you please try modifying the Factory in https://github.com/kreait/firebase-php/blob/master/src/Firebase/Factory.php#L418
from
} elseif ((new GcpMetadata())->isAvailable()) {
to
} elseif ((new GcpMetadata(new Client()))->isAvailable()) {
and see if this yields the same improvements? If so, I'll release a patch release today and look for a more sustainable solution after that.
Some background: I initially planned to rely on Google's packages as less as possible and to make the SDK HTTP-Client-independent (as it's currently tied to Guzzle). Unfortunately, I never came around really doing it, and so, the SDK is currently in this weird state that I'm duplicating some of the functionality that google/auth
already provides. I'm not happy with that at all, but I think now could be the time to finally embrace Guzzle and the google/auth package, at least for the 4.x releases š
from laravel-firebase.
Oh, i came across that part of the code in my bug hunting ;)
That won't (completely) work because a few lines above that we call:
$serviceAccount = $this->getServiceAccount();
That one ends up going into new Discovery\OnGoogleCloudPlatform(),
which has the same metadata problem.
from laravel-firebase.
Ah, of course! š¤¦āā
Could you please add/replace
"kreait/firebase-php": "dev-discovery"
to your project's composer.json
to see if this helps? It's not pretty, but if it works, I would consider it good enough ^^
from laravel-firebase.
Ok, that causes issues:
- The application is back to being slow
and 2)
If i run composer install
it works just fine but if i run composer install --no-interaction --no-dev
it crashes with:
(1/1)Ā ErrorClass 'Kreait\Laravel\Firebase\ServiceProvider' not found
inĀ Application.phpĀ line 196
atĀ Application->register('Kreait\Laravel\Firebase\ServiceProvider')inĀ app.phpĀ line 82
from laravel-firebase.
Thanks for the replies so far, and looking forward to being able to rip this ugly monkey patch out of my codebase ;)
from laravel-firebase.
I just released a new version of kreait/gcp-metadata
which should be available on Packagist by now as well.
Could you please do a composer update
or add "kreait/gcp-metadata": "^1.1"
to your composer.json - I hope this will resolve the issue, it's basically the same thing you already did š
from laravel-firebase.
Seems to work :)
Going to do some more testing but I ripped out my monkey patch and the response times on my rest calls are in the 100-200ms range where i expect them to be :)
from laravel-firebase.
Related Issues (20)
- how to set up pagination? Please help HOT 1
- Next release HOT 2
- No publishable resources for tag []. Publishing complete. HOT 5
- Callable functions
- SenderId mismatch HOT 7
- Laravel error HOT 2
- getting error HOT 1
- Incompatibility with Eloquent Resources? HOT 1
- Confirm email verification Support
- Its not supported php 8. Please fix this
- Push notifications are not getting displayed in IOS and Android randomly HOT 1
- Be able to override FirestoreClient::DEFAULT_DATABASE HOT 7
- Support PHP8.3 HOT 2
- Firestore insert or update problem when using laravel-octane HOT 3
- Auto discovery not working similar to v4.x HOT 3
- Cannot mock final class for phpunit tests as it's return type is other final class HOT 1
- Support symfony/cache version 7 HOT 3
- Make Support For Laravel 11 HOT 2
- Curl error on Laravel 11 HOT 7
- laravel publish issue HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-firebase.