[MUSIC PLAYING]
JOLENE TEO: Hey, everyone.
I'm Jolene Teo, and I'm a customer engineer
at Google Cloud.
And welcome back to the Google Cloud Technical
Guides for Startups, where we are creating a series of videos
for technical enablement to help startups to start, build,
and grow your businesses successfully and sustainably
on Google Cloud.
In our previous episode, we showed you
how you can get started on Google Cloud.
Today, we'll be moving on to our third stop,
streamlining application development.
We'll be covering first the basics
of what exactly is serverless.
And following that, I'll be introducing
to you the portfolio of solutions available
and when to choose which.
I'll then share with you a little bit more about Cloud Run
and also run through a demo as well.
Right after, I'll be sharing with you
some tips on how you can optimize both performance as
well as cost.
And last but not least, we'll be running
through a simple application of an e-commerce platform
together, as well as a customer case study.
We'll then wrap up with some of the links
that you can follow up with right after this video.
So come on now, let's explore the land of the serverless
together.
First of all, we need to get our basics right.
What does serverless mean?
When you make use of a serverless infrastructure,
it means that you are able to deploy and scale
your applications more quickly and securely in a fully
managed environment.
This also means that your developers
can focus on writing the code instead of having to worry
about the infrastructure.
This leads to faster time to market, which is definitely
important for startups.
On top of that, your workloads will automatically
scale according to the traffic, and you only
need to pay for what you consume.
All in all, this enables faster and more secure
development, deployment, as well as operations.
Now that we have the basics sorted out,
let me share with you how Google Cloud can
help you to streamline your application development.
So first up, we have Cloud Run.
Now, Cloud Run is really great for running
any form of applications or containers
in a fully managed environment.
Next we have Cloud Functions, which
is definitely great for any event-driven applications.
And last but not least, we have App Engine,
which also can help to run applications
in a fully managed environment.
I'm pretty sure you must be wondering when to choose which.
Well, I've got your back.
Here are some of the most common use cases
being compiled together for you to help you
with your product decision making.
And now, we're going to zoom in to the latest addition, as well
as a very popular one, which is Cloud Run.
Cloud Run enables you to run your containerised applications
on a managed compute platform quickly and securely,
bringing you from containers to production within seconds.
Write your code your way, using your favorite languages,
such as Python, Ruby, Go, and many more.
Not only that, with Cloud Run you only
have to pay for the resources that your startup consumes.
And this means that you won't have to pay
for overprovisioned resources.
Cloud Run is also built upon the open standard Knative,
which ensures the portability of your applications.
And all of the above allows you to build your applications
the way you want to.
Right, it's about time to give you a tour.
Now on to the demo.
In this demonstration, we'll be creating a Cloud Run service
with the use of a container image being built.
We will then explore versioning, as well as traffic splitting.
Now for today, we'll be making use
of a simple application, which is a simple meme generator
service.
How it works is that it takes in an upper text, a bottom text,
as well as an image in the URL bar in order to create a meme.
Now, you can follow along with your own application
or make use of a sample one in the description box below.
All right, let's jump into the first two sections.
First, let's begin by taking a look at the application code.
Here, we can see the application code.
And remember that you can code in any
of your favorite languages, such as Python, Ruby,
Go, and many more.
And over here we can see the meme generator service works
by first taking in an upper text, a bottom text,
as well as an image URL in order to create and generate a meme.
And next, over here we also have a Dockerfile
that defines the base image where it's all being packaged
into a container.
Next, I'm going to show you how easy it
is to build the container image by using the builds command.
All right, we're going to speed this up
a little bit until it's been done.
And now it's done.
And now we're going to deploy this onto Cloud Run.
All right, now we're going to navigate over the Cloud Run.
And here we are right now in Cloud Run.
And to create a new Cloud Run service,
you can simply click on the Create Service button.
And over here, you can give your service a name,
select the region, as well as select the container image
that you want to deploy.
In this case, we'll be selecting the container image
that we have just built. Following
that, you can just click on Create in order to deploy.
Now we have our container image running on Cloud Run.
And here we have our application up and running.
As you can see, you have all of the information
that you may need right at your fingertips,
from the managing of your revisions,
which we'll get into shortly, metrics, logs, and many more,
making it really easy for your startup to manage.
And right now, we're going to check out our application
simply by clicking on the URL.
And here we can see that our service is up and running.
We can simply click on an example
to see how the application works.
And now we're going to test it out too,
simply by adding in and editing the upper text, bottom text,
as well as image URL to generate a new meme.
And there we have it.
Next, I'm going to show you how easy it
is to deploy a new version of the application.
All right, so now we're going to head back to the application
code and edit it a little by including a hello, well
as a welcome message.
We're going to quickly click Save.
And once we're done, we're going to rebuild this container
image.
We're going to split this part up a little
until the container image is being built as well.
And we're done.
And now we're going to head back to Cloud Run
and redeploy this new revision.
As you can see, it's really simple.
And you can easily select the latest container image that you
have just built, and deploy.
And immediately, we're done.
You can see that we have our new version now up and running
on Cloud Run.
Now moving on to the third part of our demo.
What if you want the different versions to serve
different levels of traffic?
Let's take a final look at traffic splitting.
With Cloud Run, it is extremely easy
to manage your traffic for the different revisions
that you may have.
Simply click on Manage Traffic.
And over here, you can fill out the form
to the different levels of desired traffic
for your different revisions.
And with that, we are done with the demo.
Over here, you saw how easy it was
to not only deploy on Cloud Run, but to also
manage your revisions, as well as manage your traffic.
Now you may wonder, what are the most important things
to take note of for cost as well as performance?
In this section, we'll be covering
the best practices for cost optimization
as well as performance optimization.
I'll be putting some links in the description box below as
well for your further reading.
To optimize performance, first of all,
remember the specified minimum number
of container instances you want to be
kept warm and ready to serve requests.
Secondly, don't forget to also try
to minimize the number of dependencies,
as well as the size of them, to make sure that your service is
a lean one.
Thirdly, lazily load code which is infrequently being used
if your language supports it.
And also make use of global variables, as well.
The initialization of global variables
occurs during the start up, which can severely
increase the code start time.
Now, one great example of a variable
that is expensive to initialize will
be the database connections.
Database connections are great to keep as global variables.
And finally, make use of minimal container images.
Larger container images can increase your security
vulnerabilities.
And this is because they contain more than what your code needs.
As for cost optimization, setting the right number
of maximum instances, depending on your traffic as well as
desired level of request latency,
can help you to optimize your overall costs.
Secondly, it is also important to take note and optimize
your CPU as well as RAM.
CPU usage is generally a huge contributor
to what your overall costs.
Thirdly, it is also highly important
to make use of billing alerts, as well as labels.
Budget alerts provide an early warning signal
to unexpected increases in your bill.
And as for labels, labels allow you to assign a simple text
value to particular resources.
And this allows you to understand
which are the most significant contributors
towards your overall bill to allow you to take action
on them.
On top of that, implementing basic local caching,
where a local in-memory copy of frequently loaded or generated
data is being kept, can produce significant and dramatic
improvements to both cost as well as performance.
And last but not least, do not forget
to always make sure you measure the effectiveness
of your changes so that you can keep track of them
and continue to improve and optimize the costs.
Now, let's take a look at a fictitious use
case of a simple e-commerce application.
When an order is being first placed
on the front end, which is being deployed on Cloud Run,
Cloud Run receives the request and sends it
over to Pub/Sub, which is an asynchronous messaging service.
The subsequent microservices, which
are also deployed on the Cloud Run,
can then subscribe to these Pub/Sub events.
These microservices can then make calls
to the other parts of the architecture.
As you can see in the examples over here.
And if we wanted to take a look at a real life example,
we have Arabesque AI.
Arabesque AI provides AI driven asset management.
And, amongst other incredible results,
they were able to reduce their server costs with Cloud Run.
And not only that, they were also
able to automate infrastructure management,
resulting in higher productivity.
All in all, Google Cloud is able to help you
with the streamlining of your application development.
Now I hope that today's session has given you
a good understanding and overview,
as well as how you can get started.
And after this video, if you are keen to find out more and you
cannot get enough of application development,
feel free to check out the suggestions here,
as well as the links in the description below.
And in the next episode, you'll be
able to learn more about containerization,
how to deploy on the Google Kubernetes Engine, optimization
of performance, as well as look through a sample
architecture, as well as a customer case study.
All right, and that's a wrap for today.
See you in the next video.
[MUSIC PLAYING]