Firebase Storage uses 490MB but I have no buckets? - firebase

Firebase Storage is using 490 MB, but no bucket has been initialized.
I am not able to track where this storage com from, but it is quite strange to check that Firebase is charging 0.10 USD for an empty Storage.
Where can I delete this storage and why firebase is charging for having no buckets?
Currently I am using Firebase Authentication, Firestore, Realtime Database, Hosting and Functions.

Every time you deploy to Cloud Functions, it takes some space in a new storage bucket. This is covered in the documentation FAQ about Cloud Functions billing for node 10.
You can delete those files over time if you want.

My recommendation is to use object lifecycles in the artifacts storage bucket! that way the files deletion is automated.
Follow this documentation:
https://cloud.google.com/storage/docs/lifecycle
(Firebase should be the one responsible for creating this rule!)

Related

Does redeployment of the same Cloud Function in firebase take up extra space?

I deployed a cloud function in firebase but instead of using a local emulator for testing purposes, I redeployed it several times to debug and test. After this, I see that my usage in the cloud storage in firebase is upwards of 500 MB although I have not stored any files in the Cloud Storage. Is this due to the multiple redeployments of the function? If yes, will deleting the cloud function free up this space or is there another way.
Thanks.
Yes, deploying a Cloud Function will take up more space in Cloud Storage. There is a dedicated storage bucket for the build of the server images that get deployed. You can see this for yourself in the Google Cloud Console for your project. You can manually delete the content if you don't want to pay for the storage.
I don't think that deleting the function will also delete the storage, but you can try that for yourself and observe if it works the way you expect.
See also:
How to delete outdated Firebase Cloud function containers from GC Storage?
will Cloud Function affect Firebase Storage bandwidth usage?

How to automate set-up of custom Firebase Storage buckets?

I use Google's Firebase Storage through the Java Admin API to store files in a Spring Boot application. For security reasons, I create a separate storage bucket for each customer organization. Since I blow away my test environment frequently, I delete and create these storage buckets often. I'm looking for help to get these buckets quicker into Firebase.
Here's what I currently do:
My Spring Boot application creates a bucket with the Google Cloud Storage libraries per the Firebase Storage documentation.
I add the Google Cloud Storage buckets to Firebase by importing them in the Firebase Storage web console. I can import multiple buckets at once.
I apply the default security rules to each Firebase Storage bucket. I can only do this one bucket at a time.
I want to automate steps 2 & 3:
From what I can see in the Firebase docs, I can't do steps 2 and 3 with the Java Admin API.
I can probably automate step 3 through the Firebase CLI tool. For that, I need to set up a "deployment target" that includes all the buckets. I have to add the buckets by name, one by one, and can't use any wildcards here. But my bucket names include database IDs which will be pretty much the same across my environments. So I hope that this deployment target only changes when I add more customer organizations.
Does anybody know of better ways to automate steps 2 and 3?
I decided to change my approach: I now put all customer organizations into one bucket.
It's just too much work to deal with the different buckets now. With one bucket, I just delete all the folders in there which seems simple for now in the Firebase Storage web console.
I'm not sure how my project would behave with hundreds or thousands of buckets. On the contrary, it seems that having thousands of folders within a bucket is a valid use case.
The lack of functionality for Storage buckets both in the Firebase CLI and the Google Cloud SDK indicates to me that you shouldn't have many buckets in your project.

can I set my firebase storage in different region from my Firestore and cloud function?

most of my users will be in Indonesia. I am using Firestore, Cloud Function and Firebase storage in my project. currently I am in development phase and all my data is temporarily stored in us-central 1.
when fetching data from firestore or when I trigger the cloud function, the speed of operation is still acceptable around 1-3s (my data in us-central 1 and I am in Indonesia).
but when fetching image data from Firebase storage, it feels so slow due to high latency. so that is why I want to recreate my project and choose the region as near as possible from Indonesia
but if I see from the table in here: https://cloud.google.com/about/locations#asia-pacific
the nearest cloud storage for firebase from Indonesia is in Singapore, but unfortunately firestore and cloud functions are not available yet in Singapore,
the nearest firestore and cloud function available region from Indonesia are in Hongkong.
so my questions are
how to set my firestore and cloud function in Hongkong but my Firebase Storage is Singapore ?
If I can set in two different regions like that, is there any additional cost for this ?
How to set my Firestore and Cloud Function in Hongkong but my Firebase Storage is Singapore ?
As explained in the documentation:
Before you use Cloud Firestore, you must choose a location for your
database... This location setting is
your project's default Google Cloud Platform (GCP) resource location.
At the time of writing, this Cloud Firestore location is an immutable choices, i.e. it is not changeable (Creating a new project is the only way to change it).
For Cloud Storage, "your default GCP resource location is used for GCP services in your project that require a location setting, specifically, your default Cloud Storage bucket". However, with Cloud Storage, you have the possibility to create new buckets in other locations, if you are under the Blaze pricing plan.
You already got an answer, here, on how to reference to a specific bucket :-)
For Cloud Functions, you should refer to this documentation. You will read that "by default, functions run in the us-central1 region" but that it's quite easy to change the location of a Cloud Function by setting the region parameter in the function definition.
If I can set in two different regions like that, is there any additional cost for this?
Yes, you will have extra cost if your Cloud Function (which is in asia-east2 i.e. Hong Kong) interacts with your Cloud Storage (e.g. creates a file in Storage) which is in asia-southeast1, i.e. Singapore. More details in the documentation, here and here.

Storing many small files in Cloud Firestore?

I have an application where thousands of small files are stored in Google Cloud Storage, and I have a million small records of metadata in Firebase Realtime Database.
When I switch database to Cloud Firestore beta in the Firebase Console, it warns me that the Cloud Storage will be disabled:
"Enabling Cloud Firestore Beta will preclude you from using Cloud Datastore with this project, notably from the associated App Engine app."
So I would have to move the files to Cloud Firestore? I don't see any examples from Google on storing files in Cloud Firestore? Should they then be stored as Base64 string or what?
Cloud Storage != Cloud Datastore
Cloud Datastore is a NoSQL database that has been around for quite a while and is very similar to Firestore in many regards. The reason for them not being available in parallel might be that they are actually using the same backend in some way.
Cloud Storage is for storing arbitrary files and isn't affected by you using Firestore at all.

Firebase : Differences between realtime database and file storage

I learnt about real-time data storage and hosting storage from this post Difference between Data Storage and Hosting Storage?
But i am still not clear about real time Database and and newly introduced file storage.
Does anybody have some brief explanation about it ?
Thanks in advance .
(As per the concern about duplicated with Difference between Data Storage and Hosting Storage? what the problem solves and what i am asking are two different things and hosting storage and file storage are different in case of google firebase )
Firebase now offers these places to store your data:
Realtime Database
Remote Config
Hosting
Storage
Cloud Firestore
The best place to store your data, depends on the type of data you want to store and the way you want to consume it.
The Firebase documentation says this about it:
The Firebase Realtime Database stores JSON application data, like game state or chat messages, and synchronizes changes instantly across all connected devices.
Firebase Remote Config stores developer-specified key-value pairs to change the behavior and appearance of your app without requiring users to download an update.
Firebase Hosting hosts the HTML, CSS, and JavaScript for your website as well as other developer-provided assets like graphics, fonts, and icons.
Firebase Storage stores files such as images, videos, and audio as well as other user-generated content.
On choosing between Cloud Firestore and the Firebase Realtime Database, the Firebase documentation says:
Firebase offers two cloud-based, client-accessible database solutions that support realtime data syncing:
Realtime Database is Firebase's original database. It's an efficient, low-latency solution for mobile apps that require synced states across clients in realtime.
Cloud Firestore is Firebase's new flagship database for mobile app development. It improves on the successes of the Realtime Database with a new, more intuitive data model. Cloud Firestore also features richer, faster queries and scales better than the Realtime Database.
*Realtime database store data only json format and it is specially used in app where data is synchronized concurrently like ola app(user location),sensex(Nifty) app where data not persist .
*Firebase Storage just only store data like memory card.It is specially used for store backend data of app.

Resources