2. COVERED
TODAY
A BRIEF OUTLINE
About me
What is Rest Framework
Express JS & Node JS
Basic API in Node & ExpressJS
MongoDB - connection
MongoDB - Secure
Run Locally
GCP
Deploying to GCP
Running Application
Best Methods
Intro to Load Balancing
3. ABOUT ME
Jimish Parekh, A guy who has
founded small firm called
Pedals Up where enthusiastic
developers like myself work
and have fun together.
Developing amazing web and
mobile application is our
passion at Pedals Up whether
it is our product or our
clients'.
GotoLinkedin
9. IT'S
ENVIRONMENT
It's an
environment,
back-end
framework runs
within it. it's
not framework in
itself.
CROSS
PLATFORM
Node.js
includes libuv
which is Google
V8 engine.
SERVER
SIDE JS
Server side
Javascript Run
time
environment and
it's open
source.
NO WINDOW
Being JS env,
Node.js does
not expose
global "window"
object, as it
does not run on
browser.
10. 2010 2012 2014 2016 2018 2020
40
30
20
10
0
WHY SO POPULAR
Huge & active JS ecosystem
open sources
large community
doesn't break compatibility
in majorways
From 2009, since when Node.js
came in market, it has been
popular for following reasons:
11. SINGLE
THREADED
WHY NODE JS
IS BAD?
NODE.JS TECHNOLOGY ITSELF ISN'T BAD,
IT'S QUITE MATURE AND WIDELY USED
FOR MANY DIFFERENT TYPE OF SERVERS
MAY BE BAD CHOICE FOR WEB SERVERS DOUBLING AS
COMPUTATIONAL SERVERS.
12. LET'S START EXPRESS.JS
Single Page
Multi Page
Hybrid
Web application server
framework designed for
building :
Web applications
13. WHY
EXPRESS.JS?
EXPRESS FOR NODE.JS
ExpressJS did for NodeJS what Bootstrap did
for HTML/CSS and responsive web design.
EASY IMPLEMENTATIONS
ExpressJS has made backend development piece
of cake literally. I don't know why someone
should use anything else?
FASTER AND SMARTER
Simplicity, minimalism, flexibility,
scalability are some of its characteristics
and since it is made in NodeJS itself, it
inherited its performance as well.
17. JAVASCRIPT
it uses javascript as it's
language.
BETTER PERFORMACE
Due to atomic transactions,
mongodb gives better
performance than relational
databases.
NOT ONLY SQL DATABASE
Mongodb is document database.
where document is having
dynamic structures.
18. SECURING MONGODB
using mongodb npm
CONNECTING TO
EXPRESS
OPERATIONS AS PER
ROUTES
Rest operationsenabling authentication
19. 01
02 01 RUNNING LOCAL
Deploying this
locally will give
testing experience
02 CLOUD DEPLOY
Every applications
are going to be
deployed on cloud.
20. Why GCP?
Google Cloud platform is preferred more than AWS
and Azure as per survey done in 2020.
21. BETTER
PRICING
Google bills in
minute-level
increments
(with a 10-
minute minimum
charge), so you
only pay for
the compute
time you use.
BIGGEST
NETWORK
private global
fiber and
tiered network
enables GCP to
provide fastest
and smoothest
servers.
DISCOUNTS
GCP gives
disocunts on
long running
workloads with
no up-front
commitment.
LIVE
MIGRATIONS
OF VM
without any
down time GCP
offers live
migrations
which any other
firm does not
offer.
22. IMPROVED
PERFORMANCE
Manages hundreds
of thousands
users at same
time
concurrently
without any
hicups.
CONTINUOUS
EXPANSION
since the
launch of GCP,
they grew
rapidly and
trying to open
more and more
physical
centers all
over the world.
STATE OF ART
SECURITY
Encryption,
authentication,
authorization,
transitions etc.
all are covered by
Google itself.
what more is
needed?
REDUNDUNT
BACKUPS
It stores data
redundantly,
with automatic
checksums to
ensure data
integrity.
24. SCALING
HORIZONTAL SCALING
duplicate your application instances, to cop
with large number of requests
Load balancing
VERTICAL SCALING
injecting more power
adding more memory
BEST THING ABOUT NODE.JS
Scalability is built in the very core of the
runtime.
25. HORIZONTAL
DIFFERENT MACHINES
load balancing needs to be applied in this
case.
RISKS
troubleshooting more challenging, maintain a
load balancer and deployment rules.
SINGLE MULTICORE MACHINE
Have native cluster nodes deploy on different
cores of your machines
26. VERTICAL
ADDING MORE MEMORY
by default, Node won’t use more than 1.76GB
of 64-bit machines’ memory
in case of a 32GB of RAM machine, for
instance, the Node process will limit itself
to only a fraction of its memory
INJECTING MORE POWER
27. MULTIPLE PROCESS ON
SAME MACHINE
There are different strategies
for scaling on a single
machine, but the common
concept is to have multiple
processes running on the same
port, with some sort of
internal load balancing used
to distribute the incoming
connections across all the
processes/cores.
28. DON'T
It is probably not clever to spawn a number of processes bigger than the
number of cores, because at the lower level the OS will likely balance the
CPU time between those processes.
29. NATIVE CLUSTER
The native Node.js cluster module
is the basic way to scale a Node
app on a single machine
PM2
If you are using PM2 as your
process manager , there is a
magic cluster feature that let
you scale your processes.
30. MULTIPLE MACHINES WITH
NETWORK LOAD BALANCING
The main concept in scaling
across multiple machines is
similar to scaling on multiple
cores, there are multiple
machines, each one running one
or more processes, and a
balancer to redirect traffic
to each machine.