PRIYANKA: Welcome to "Get Cooking in Cloud,"
where we share the best recipes to apply in your cloud kitchen.
I'm Priyanka, and the next few episodes,
we will talk about mobile app backend solutions.
[MUSIC PLAYING]
So today I've invited Jen Person to the kitchen
to show us how to get cooking with the mobile app backend.
Jen, thank you so much for coming.
JEN: My pleasure, Priyanka.
I've brought an appetizing solution with me today.
PRIYANKA: Ah, amazing.
And actually, I've got an app that I
would like to try this on.
It's called "Priyanka's Kitchen,"
and it's a cooperative cooking game for mobile.
JEN: I love that kind of game.
PRIYANKA: Me too.
And apparently lots of other folks like it too.
"Priyanka's Kitchen" is experiencing
a tremendous growth in App Store and Play
Store, which is awesome, but I'm seeing a huge increase
in the number of files my app needs to store
and the amount of data I need to quickly sync
between multiple users.
It seems mobile has its own challenges.
Can you help cook up such a backend service?
JEN: That's a great question, Priyanka.
Most mobile apps and games need a backend service
for things that can't be done solely on device, like sharing
and processing data from multiple users,
or storing large files.
PRIYANKA: Very true.
But here on "Get Cooking in Cloud,"
we've shown a lot of backend service solutions.
What's different about a mobile backend?
JEN: You're absolutely right.
Building a backend service for a mobile app
is similar to building a web-based service.
But there are some additional requirements.
First, it's important to limit on-device data storage.
Storage on mobile devices is limited.
Users need to be able to use their storage space the way
that they want to.
PRIYANKA: For dog pictures and memes.
[LAUGHING]
JEN: Next, a mobile backend service
needs to synchronize data across multiple devices.
When playing a mobile game with friends,
your moves need to sync up across everyone's devices.
PRIYANKA: Lags and jitters aren't
acceptable for mobile games, especially when I'm winning.
[LAUGHING]
JEN: And we know that the quality of mobile networks
varies greatly.
So mobile apps need to assume times
with limited or no connectivity, handling that offline case
gracefully.
PRIYANKA: I think I'm getting a handle
of these mobile backend differences,
like how mobile devices and services need to send
notifications and messages.
JEN: Exactly.
PRIYANKA: And of course, mobile backends
should minimize battery drain.
JEN: You got it.
So as you can see, there are some key requirements
we have to consider.
And I've cooked up a few different design patterns
to demonstrate ways to use Google Cloud Platform
to address these requirements.
For today's recipe, I brought along some Firebase.
PRIYANKA: Sounds spicy.
JEN: Doesn't it?
Even though Firebase sounds like just one ingredient,
it definitely isn't a bland solution.
Firebase is a fully managed platform
for building iOS, Android, and web apps.
It provides automatic data synchronization,
authentication services, messaging, file storage,
analytics, and more.
PRIYANKA: So starting with Firebase
seems to be an efficient way to build or prototype
mobile backend services.
Now, when is a good time to serve Firebase?
Family dinners?
Weddings?
Friday parties?
Birthday parties?
[LAUGHING]
JEN: Yes.
Firebase is great for a last-minute dinner.
You can develop your app quickly because Firebase client
SDKs simplify getting backend services up and running.
But I recommend Firebase for all sorts
of mobile back indications.
Firebase products are designed to scale
so you can use them seamlessly from prototype to production
to top app, like "Priyanka's Kitchen."
PRIYANKA: So why is Firebase a great backend solution,
especially for mobile apps?
JEN: Well, Firebase addresses a lot of the unique needs
of mobile apps.
It's great at limiting on-device space usage when
you manage key value data in Cloud Firestore
and files in cloud storage for Firebase.
It makes sending notifications and data messages a snap
with Firebase Cloud Messaging.
It offers automated real-time data synchronization
across multiple devices.
It gracefully handles the offline case
and offers authentication of users
through a variety of identity providers.
PRIYANKA: Firebase sounds like an out
of the box solution for many mobile app backend needs.
I can't wait to try it out myself.
But before making Firebase my backend solution
for "Priyanka's Kitchen," is there anything
else I should know?
JEN: Yes.
So I don't always recommend Firebase
for apps that need a backend service
to modify the synchronized data.
PRIYANKA: Hm.
That's interesting.
Give me an example.
JEN: Firebase products handle a lot
of the heavy backend lifting for you.
So you don't have to build some features yourself.
But there are still situations where
you may need to modify data outside of the client.
For example, if "Priyanka's Kitchen" keeps a leaderboard,
you'll want to run the code to rank users in a server.
PRIYANKA: That's true.
I do need to keep the leaderboard up to date.
But Firebase does have server SDKs called the admin SDKs.
Does Firebase have a server solution
in which to use these SDKs?
JEN: That's a great question.
Well, one of the many Firebase products
is a serverless solution called Cloud Functions for Firebase.
Cloud Functions let you automatically
run backend code in response to events
triggered by Firebase features and HTTPS requests.
You can use the admin SDKs in a Cloud Function
to modify the synchronized data, among other tasks.
PRIYANKA: So I could use Cloud Functions to update user ranks?
JEN: Yes, you certainly can.
But as your app grows, this can get
more challenging to run from a Cloud Function.
PRIYANKA: Ah, so let me guess.
Is it because Cloud Functions are short-lived?
JEN: You guessed it.
Cloud Functions are short-lived.
So if you have a small amount of user scores to process,
you can rank them quickly before the function tears down.
But when you have lots of user scores
to analyze, say, hundreds of thousands,
then a long-running server is a better fit.
In that case, Firebase alone will not
be a complete solution.
I'll talk about that recipe another day.
PRIYANKA: Aw, you're killing me.
Wow, you are right.
Firebase isn't a bland solution at all.
It seems like there's a lot to it,
so it can be hard to picture.
I would love to see what a complete Firebase
solution looks like.
JEN: Well, I just happen to have a completed Firebase solution
right here.
Here you can see a diagram of our design pattern.
And right here is Friendly Pix.
It's a sample app that features examples
of how to use many different Firebase products.
PRIYANKA: Looks amazing.
So what should our viewers at home
do if they would like to cook up their own Firebase app?
JEN: You can check out the guides, reference docs,
code examples on GitHub, and the Firebase YouTube channel.
PRIYANKA: There you have it, folks.
That's all for today on "Get Cooking in Cloud."
Here's hoping you can whip up something great.
Join us next time because Jen will be coming back to show us
another tasty mobile app backend solution.
If you liked this video and would
like to see more of such content,
don't forget to like and subscribe to our channel!
[MUSIC PLAYING]