Fireship · @fireship
7 Ways to Deploy a Node.js App
Uploaded July 26, 2021 · Length 9:14
Summary
7 ways to deploy a Node.js app, including using own hardware, Google Cloud Platform, and Kubernetes, with trade-offs between cost, complexity, and scalability.
- node.js deployment
- cloud computing
- kubernetes
- serverless architecture
- google cloud platform
- vm deployment
- docker deployment
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
in this video we'll look at seven
- 0:02
different ways to deploy
- 0:03
a server side application i built this
- 0:05
api with node.js
- 0:06
and now i'm ready to share it with the
- 0:08
world but one does not simply deploy an
- 0:10
app to production
- 0:11
there's all kinds of different ways to
- 0:13
get the job done with trade-offs between
- 0:15
cost complexity and scalability
- 0:17
on the surface deployment seems like it
- 0:19
should be easy we just need a computer
- 0:21
to host the app which we connect to the
- 0:22
internet so it can handle requests from
- 0:24
all of our users
- 0:25
but resources are limited and that means
- 0:27
we need to synchronize many computers
- 0:29
all over the world
- 0:30
just to keep things running fast by the
- 0:31
end of this video you'll be able to
- 0:33
analyze the trade-offs like a cto to
- 0:35
choose the best deployment strategy for
- 0:37
your server side application
- 0:38
if you're new here like and subscribe
- 0:40
then let's jump right into it
- 0:42
first of all let's look at some of the
- 0:43
features in this node.js application
- 0:45
it requires node 16 which is the current
- 0:48
bleeding edge version and that means
- 0:49
wherever we deploy
- 0:50
needs to support that exact version of
- 0:52
node it provides a basic rest api built
- 0:55
with the express js framework nothing
- 0:57
too special
- 0:58
but we want these endpoints to have
- 0:59
extremely fast response times
- 1:01
one of the endpoints though creates a
- 1:03
websocket connection with the client
- 1:05
that means that the connection between
- 1:06
the client and server needs to stay
- 1:08
open for a long time that'll come into
- 1:10
play later because not every deployment
- 1:12
strategy
- 1:12
supports long-lived connections like
- 1:14
that now one other important feature of
- 1:16
this server
- 1:17
is that it's stateless that means it
- 1:18
doesn't store any persistent data in
- 1:20
memory or on the disk
- 1:22
that's needed between different http
- 1:24
requests anything related to the
- 1:26
application state would be stored in a
- 1:27
dedicated database
- 1:29
now to run this app on our local machine
- 1:31
we use the npm start command made
- 1:33
available in the package
- 1:34
json file now the question becomes how
- 1:36
do we do the same thing for a computer
- 1:38
that's accessible to the greater
- 1:40
internet the first option
- 1:41
is to use your own hardware you might
- 1:43
have an old pc laying around or maybe
- 1:45
you want to invest in your own server
- 1:47
rack or you can even use a 100
- 1:48
raspberry pi like i showed in this video
- 1:50
this was actually a common way to deploy
- 1:52
a web application 15
- 1:54
years ago because back in those days the
- 1:56
cloud didn't exist yet
- 1:57
almost every startup today will use the
- 1:59
cloud because it's convenient and


