VALENTIN DELEPLACE: Hi, Martin.
MARTIN OMANDER: Hey, Valentin.
I heard you wrote a web app and would
like to run it in the cloud?
VALENTIN DELEPLACE: Yes, I wrote a simple web app.
Also, I love serverless, and I need
to deploy my app to the cloud.
Today, we'll explore three different ways
I can make that happen.
[MUSIC PLAYING]
You know I'm a big fan of QR codes.
They're one of the most underrated pieces
of brilliant technology of the last decades.
MARTIN OMANDER: [LAUGHS] Well, they're beautiful.
So what do you want to do with these things?
VALENTIN DELEPLACE: Today, I'll show you
a nice cloud app called Hot Maze to transfer
a file from my computer to my mobile phone.
For this, I could plug a USB cable,
or maybe send myself an email, or use Dropbox or Google Drive,
but I prefer QR codes.
MARTIN OMANDER: OK, that sounds neat.
Tell me more.
VALENTIN DELEPLACE: I'll make a very quick demo.
Here, I have a picture of a gopher on my computer.
I drag and drop it here, and bam, I'm generating a QR code.
Then I scan the QR code, and then I
have the gopher on my phone.
That's it.
MARTIN OMANDER: Oh, cool.
Does it also work with video files or text files?
VALENTIN DELEPLACE: Yes, you can send any file you want.
MARTIN OMANDER: OK.
So this is a cloud service?
VALENTIN DELEPLACE: Yes.
The most simple way to achieve a transfer between the two
devices who don't know each other very well
is to have the computer upload to the cloud
and the mobile download from the cloud.
MARTIN OMANDER: OK.
So where do you host the web page,
and where do you upload the files?
VALENTIN DELEPLACE: I have a strong preference
for serverless, because I don't have to manage instances
myself, because of cost--
I don't pay when it's not in use--
and because of automatic scaling in case
I have thousands of friends using the service
at the same time to upload their own gophers.
In Google Cloud, I'm spoiled for choices of serverless computing
hosting options.
MARTIN OMANDER: OK, so which one did you choose?
VALENTIN DELEPLACE: All of them.
There are several valid combinations to choose from.
Let's explore three possible options.
First, App Engine Standard.
I've been loving this one even before the word
serverless existed.
See?
App Engine can both host my HTML and static resources
and process what happens in the cloud backend
when I drop a file, executing my source code.
First, I created a regular Go web server
that I tested locally on my workstation.
Then I could deploy it without modifying the source code.
This is the command line I used to deploy to App Engine.
I chose Go out of six languages available in App Engine
Standard.
On file drop, we asked the web app
to generate two secure URLs--
one to let the browser upload to Cloud Storage,
and one to let the phone download from Cloud Storage.
MARTIN OMANDER: OK.
But so far, the server is only connected to the web
page in the computer browser.
How can you push anything to the phone?
You don't even know its IP address.
VALENTIN DELEPLACE: That's the beauty of the QR code.
The web page encodes the secure download URL inside the QR
code, and this is all the info that is needed for the phone
to retrieve the file when scanning the QR code
and extracting the URL.
MARTIN OMANDER: Amazing.
So to summarize, you did all this
using App Engine and Cloud Storage?
VALENTIN DELEPLACE: Yes.
That was option number one.
Option number two is Google Cloud Functions.
You see, functions are great to quickly implement something
to do in response to an event.
For example, our events are someone
just drag and dropped a file, and someone just
scanned a URL QR code.
We also need to host the web page itself.
And for this, I recommend Firebase Hosting.
I have a command to deploy each function and another command
to deploy the website's static assets.
MARTIN OMANDER: So Firebase Hosting for the frontend
and Cloud Functions for the backend logic,
and Cloud Storage for the temporary file?
VALENTIN DELEPLACE: That's right.
Functions are a modern approach for developing services that
are stateless, loosely coupled, that process incoming events
and communicate with each other by message passing.
They're a good fit for fine-grained microservices.
MARTIN OMANDER: OK.
You said you had a third serverless alternative?
VALENTIN DELEPLACE: Yes.
We can deploy the whole thing, frontend and backend,
to Cloud Run.
For my app, it's very similar to deploying to App Engine,
but with explicit containers.
So if you already have a container-driven workflow
and use a container registry, then deploying to Cloud Run
will be seamless.
You can also install almost any binary dependency
you need in a container, which is mindblowing, in my opinion.
If, like me, you don't know that much about Docker
files and container technologies,
though, you may like the ready-to-use buildpacks
for deployment.
MARTIN OMANDER: OK.
Valentin, what's your recommendation?
VALENTIN DELEPLACE: Well, the three serverless solutions
work really well, because the app design is stateless
and all these platforms, except Go, has a backend language.
They all achieve high scalability
and cost efficiency.
If you want to know more about the small differences
in the developer experience and in the infrastructure
more than trade-offs, please check the articles
linked in the description.
MARTIN OMANDER: So I have hundreds of photos and videos
of cats on my hard drive.
Could I use your app to copy them to my phone?
VALENTIN DELEPLACE: Photos of cats?
Really?
Yes, I guess you could use my app for that.
Thank you for watching.
You can also find the source code
for this app in the description below.
Feel free to add any questions you might have in the comments.
[MUSIC PLAYING]