ALEXIS MOUSSINE-POUCHKINE: In the previous episode,
we realized that a Firebase project is actually
a GCP project under the hood, and that data that's
stored in Cloud Storage can be equally accessed
via Firebase powered mobile apps and web clients,
as well as from GCP hosted applications.
In this episode, we'll explore two more products--
Cloud Functions and Cloud Firestore.
Stick around.
[THEME MUSIC]
Cloud Functions is really a Google Cloud product
which also happens to be visible from Firebase.
Cloud Functions is a popular implementation
of the Functions as a Service paradigm,
where an event in a system, such as an HTTP
call or a file uploaded to a bucket,
triggers the execution of a small piece of code,
a function.
Check out the Serverless Overview episode
for more details on Cloud Functions.
An important architectural difference
between the Firebase and GCP approach to Cloud Functions
is that Firebase will offer you to wrap your functions
into callable functions.
Such functions can be invoked via the Firebase SDK
with user tokens and device instance ideas propagated
directly to the function.
Another important difference is the language that's supported.
When using Firestore, Node.js and TypeScript
are supported, while Go, Python, and Java are also
available when using GCP Cloud Functions directly.
Before we compare web consoles, you can also
use command line interfaces--
G Cloud or the Firebase CLI.
Both come with their own set of functionalities,
and it's recommended to decide which one works best for you
and stick to it.
To deploy functions with Firebase,
you'll need to install Firebase command line tools using NPM,
as deploying from the Firebase console is not possible.
In GCP line, you can deploy functions
straight from the console, integrating
with GCP's private source repositories,
or even typing the function source code in line.
Firebase command line tools do, however, come with an API
for strongly typed handling of some trigger events,
and with the ability to deploy multiple functions at once.
Just as you would expect, a Cloud Function
created with a Firebase project can also
be managed using Cloud Console.
In fact, clicking on Detailed Usage Stats in Firebase
will take you to that same function,
only in Cloud Console, where you'll
get additional features, such as monitoring graphs, a tab
to test the function, and the ability
to set features such as retry on failure,
memory allocation, or timeouts.
Whichever way you use Cloud Functions in your Firebase
or GCP architecture, they're likely to be
very effective at what they do best--
small tasks in reaction to all sorts of events.
Cloud Firestore is Google's state of the art NoSQL document
database.
It is schema-less and offers to store documents containing
attributes in a hierarchy of collections.
It is fast.
It supports transactions.
It's highly available, strongly consistent,
and it does not require managing any kind of infrastructure.
Some will say it's a serverless database.
Cloud Firestore comes in two flavors--
datastore mode, which is mostly suitable for server projects,
and native mode for mobile and web apps.
Let me focus here on the native mode, which
is the one that is common to Firebase and GCP users.
This mode can automatically scale
to millions of concurrent clients,
but what makes it even more special
is the fact that it offers near real time notifications.
This is what enables synchronization
of data across devices.
With its built-in offline support,
you can access and make changes to your data,
and those changes will be sent to the cloud when
the client comes back online.
Data stored in Cloud Firestore can
be accessed using Firebase SDKs, and of course, you
can use either console to view and edit data and indices,
and to monitor database access usage.
With Cloud Firestore, you can query the database directly
from your mobile or web clients without the need
to set up an intermediary server to manage access to your data,
and this is why the Firebase console has an additional tab
for security access roles.
If you are a Firebase user shipping
an app that accesses Firestore, then you really
should use Firebase Authentication
and think carefully about your security access rules.
On the GCP side, there are no equivalent security rules,
as you typically access Firestore using a service
account.
Generally speaking, server side code
is considered trusted, as opposed to client code
from mobile apps.
Finally, supported Firestore SDK languages include Python,
Node.js, Java, C#, .NET, Go, PHP, and Ruby,
with Firebase mobile SDKs adding web, Android, and iOS support.
These mobile Firebase SDKs include local caching
as a unique feature to help implement
the offline capability that I mentioned earlier--
same project and billing infrastructure,
common Cloud Storage, Cloud Functions,
and Cloud Firestore services.
The two platforms have a lot in common.
So whether you're a GCP developer
interested in building mobile and web apps with Firebase,
or a Firebase user trying to grow your usage of GCP
services, you should now have a good sense of what's possible.
It's time to get going with Firebase or GCP or both.
Thanks for watching this video.
Please like, subscribe, comment, share, and look forward
to more GCP Essentials videos.
[THEME MUSIC]