问题
Anyone know why firebase storage would be so ridiculously slow compared to firebase hosting?
Results
- Time to download image of firebase hosting:
16ms - Time to download same image from firebase storage:
2.23s (2.22s is TTFB) - Time to download same image from firebase storage (Asia Pacific Region):
1.72s (1.70s is TTFB) - (File size: 22.7kb / jpeg / firebase storage has read open to everyone)
This is repeated over and over in tests. Is there any way to speed this up to a decent time, or is firebase storage unusable for small files (images/thumbs)?
For Comparison
- S3 North Cal - approximately
500ms - S3 Asia Pacific - Approximately
30ms - Cloudinary - Approximately
20ms
Extra info:
- I am based in Australia.
- Exact same files. Always images under 100kb.
- The slow down is always in the TTFB according to dev tools.
- Hosting URL: https://.firebaseapp.com/images/thumb.jpg
- Storage URL: https://firebasestorage.googleapis.com/v0/b/.appspot.com/o/thumb.jpg?alt=media&token=
回答1:
I found the solution.
If you have your files already uploaded to storage go to: https://console.cloud.google.com/storage/browser?project=your_project > pick your bucket > select all interesting files and click Make public (or something similar - I'm not english native).
To have all new uploaded files public by default you need to install Google cloud SDK (https://cloud.google.com/sdk/docs/) and from your command line use the following command for your bucket:
gsutil defacl set public-read gs://your_bucket
After that all my current and new images are available here storage.googleapis.com/my_project.appspot.com/img/image_name.jpg and downloading time is definitely shorter.
回答2:
Hosting = Storage + CDN, so really what you're seeing is you hitting a CDN near you, rather than going directly to the GCS or S3 bucket. Same is true with Cloudinary/Imgix. This is why performance is so much better for Hosting than Storage.
Addressing the issue of TTFB being so different between AWS and GCP: unfortunately this is a known issue of GCS vs S3 (see this great blog post w/ in depth perf analysis). I know this team is working to address this problem, but going the "stick a CDN in front of it" route will provide a faster solution (provided you don't need to restrict access, or your CDN can authorize requests).
Note: GCP has announced a Sydney region (announcement blog post) to be launched in 2017, which might help you.
来源:https://stackoverflow.com/questions/43851742/firebase-storage-very-slow-compared-to-firebase-hosting