SlideShare a Scribd company logo
Academy PRO
Node.js
in Production
Mykyta Semenistyi
@msemenistyi
Tech Lead
BinaryStudio
http://www.binary-studio.com/
Lectures plan
1. Node.js Platform
2. Web applications - Default stack
3. Web applications - Alternative stacks
4. Node.js in Production
5. Miscellaneous
Node.js in Production
Security
Performance
Npm
Deployment
Security
Authentication - Sessions
Authentication - Sessions
npm install express-session
Authentication - JWT
Authentication - JWT
npm install jwt-simple
Authentication - Passport
Passport - config 307 strategies
Google
Twitter
Facebook
JWT
VK
Linkedin
Amazon
Github
Bitbucket
Kerberos
Passport - login
Passport - serialization
Passport - middleware
Helmet
Helmet helps you secure your Express apps by setting various
HTTP headers. It's not a silver bullet, but it can help!
Helmet - middlewares I
contentSecurityPolicy for setting Content Security Policy
dnsPrefetchControl controls browser DNS prefetching +
frameguard to prevent clickjacking +
hidePoweredBy to remove the X-Powered-By header +
hpkp for HTTP Public Key Pinning
hsts for HTTP Strict Transport Security +
Helmet - middlewares II
ieNoOpen sets X-Download-Options for IE8+ +
noCache to disable client-side caching
noSniff to keep clients from sniffing the MIME type +
referrerPolicy to hide the Referer header
xssFilter adds some small XSS protections +
Helmet - CSP
lusca
Kraken - PayPal
CSRF - Cross-Site Request Forgery
csurf
npm install csurf
cors
cors
npm install cors
HPP - HTTP Parameters Pollution
hpp
npm install hpp
ratelimiter
npm install ratelimiter
express-content-length-validator
npm install express-content-length-validator
nsp
npm install nsp -g
nsp check
No sudo
Security - common
SQL Injections
NoSQL Injections
HTTPS
Performance
Child Process
192.168.1.191:7000
192.168.1.191:5000
Uno
Dos
Child Process
Child Process - IPC
parent.js
sub.js
Child Process - parent
child.channel
child.connected
child.disconnect()
Async ftw
Cluster
Cluster master
Cluster worker 1 Cluster worker 2 Cluster worker n...
Client reqs
round-robin
Cluster
Cluster
192.168.1.191:8000
V8 Microoptimizations
https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
Memory limits
node --max_old_space_size=4096 ./
Npm
Academy PRO: Node.js in production. lecture 4
Academy PRO: Node.js in production. lecture 4
leftpad
Outtakes
There are people behind npm modules
People happen to be assholes
Npm has fixed the issue within hours
Npm has updated its policy of unpublishing
Academy PRO: Node.js in production. lecture 4
Why?
Waste of time
High probability of bugs
No bugfixes and upgrades from others
npm shrinkwrap
npm-shrinkwrap.json
npm dedupe
yarn
Sebastian McKenzie, FB
Offline Mode
Deterministic
Network Performance
Network Resilience
Flat Mode
yarn
brew install yarn
apt-get install yarn
npm install -g yarn
package.json Npm package.json
Npm registry
yarn.lock
yarn - bonus features
npm install -> yarn
npm install -s async -> yarn add async
Deployment
Environment
process.env.NODE_ENV
Development|staging|production
Unix: export NODE_ENV=production
Win: SET NODE_ENV=production
NODE_ENV=production node app.js
Environment
https://github.com/kentcdodds/cross-env
https://github.com/benoror/better-npm-run
Environment - cnfg
https://github.com/boo1ean/cnfg
pm2
npm install -g pm2
pm2 start app.js
Your app is now daemonized, monitored and kept alive forever.
pm2
pm2 list
Pm2 - logs
pm2 logs
pm2 logs newbie
Pm2 - monit
pm2 monit
Pm2 - web
npm i -g pm2-web
pm2-web
Pm2 - clustering
pm2 start ./server.js -i max
Pm2 - startup
pm2 startup
Logging - access log
npm i -s morgan
Logging - Mongoose log
Logging - winston
npm i -s winston
Winston - transports Console
File
Http
Winston More
CouchDB
Loggly
MongoDB
Redis
Riak
Additional Transports
Elasticsearch
SimpleDB
Mail
Amazon SNS
Amazon CloudWatch
Amazon Kinesis Firehose
Graylog2
Cassandra
Azure Table
Airbrake
Newrelic
Logsene
Logz.io
Winston - querying
nginx
Static content
SSL
Reverse proxy
Reverse proxy
Internet
nginx
/etc/nginx/sites-available/default
now
https://child-process-kmregjvdiy.now.sh/
Rauchg
● Static html
● Node.js
● Docker
now
Academy PRO: Node.js in production. lecture 4

More Related Content

What's hot (19)

PDF
Router Virtualization With GNS3
mrmouse
 
PPTX
Nise BOSH in Action
i_yudai
 
PPT
Intro to Node.js
James Carr
 
PDF
インフラ野郎Azureチーム Night
Toru Makabe
 
KEY
Getting Started with MongoDB and Node.js
Grant Goodale
 
PDF
1101: GRID 技術セッション 2:vGPU Sizing
NVIDIA Japan
 
PDF
Mesos DC/OS on opensuse
Masayuki Igawa
 
PDF
StripeCon EU 2018 - SilverStripe 4 application framework
Andy Adiwidjaja
 
PDF
2014-4Q-OpenStack-Fall-presentation-public-20150310a
Ken Igarashi
 
PDF
numPYNQ: accelerating NumPy on PYNQ
NECST Lab @ Politecnico di Milano
 
PPTX
MongoDB and Windows Azure
MongoDB
 
PPTX
Nodejs Security
Jason Ross
 
PPTX
MongoDB and Windows Azure
Doug Mahugh
 
PDF
Web technologies for desktop development
Darko Kukovec
 
PDF
Gluster Cloud Night in Tokyo 2013 -- Tips for getting started
Keisuke Takahashi
 
PDF
Webconf nodejs-production-architecture
Ben Lin
 
PDF
Trying and evaluating the new features of GlusterFS 3.5
Keisuke Takahashi
 
PPTX
Highload осень 2012 лекция 3
Technopark
 
PPTX
GNS3
Jim Calano
 
Router Virtualization With GNS3
mrmouse
 
Nise BOSH in Action
i_yudai
 
Intro to Node.js
James Carr
 
インフラ野郎Azureチーム Night
Toru Makabe
 
Getting Started with MongoDB and Node.js
Grant Goodale
 
1101: GRID 技術セッション 2:vGPU Sizing
NVIDIA Japan
 
Mesos DC/OS on opensuse
Masayuki Igawa
 
StripeCon EU 2018 - SilverStripe 4 application framework
Andy Adiwidjaja
 
2014-4Q-OpenStack-Fall-presentation-public-20150310a
Ken Igarashi
 
numPYNQ: accelerating NumPy on PYNQ
NECST Lab @ Politecnico di Milano
 
MongoDB and Windows Azure
MongoDB
 
Nodejs Security
Jason Ross
 
MongoDB and Windows Azure
Doug Mahugh
 
Web technologies for desktop development
Darko Kukovec
 
Gluster Cloud Night in Tokyo 2013 -- Tips for getting started
Keisuke Takahashi
 
Webconf nodejs-production-architecture
Ben Lin
 
Trying and evaluating the new features of GlusterFS 3.5
Keisuke Takahashi
 
Highload осень 2012 лекция 3
Technopark
 

Similar to Academy PRO: Node.js in production. lecture 4 (20)

PDF
Ondřej Procházka - Deployment podle Devel.cz
Develcz
 
PPTX
Node js meetup
Ansuman Roy
 
PPTX
Openstack Third-Party CI and the review of a few Openstack Infrastructure pro...
Evgeny Antyshev
 
PDF
Continuous integration / continuous delivery
EatDog
 
PPTX
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Evgeniy Kuzmin
 
ODP
Mcollective introduction
Javier Turégano Molina
 
PDF
Grunt.js and Yeoman, Continous Integration
David Amend
 
PPTX
No more Dockerfiles? Buildpacks to help you ship your image!
Anthony Dahanne
 
PPTX
Continuous Integration/ Continuous Delivery of web applications
Evgeniy Kuzmin
 
PDF
The Ultimate Node.js Resource Cheat Sheet 📝: Learn Everything Free
Tapp AI
 
PDF
PyParis 2017 / Writing a C Python extension in 2017, Jean-Baptiste Aviat
Pôle Systematic Paris-Region
 
PDF
JSConfBR - Securing Node.js App, by the community and for the community
David Dias
 
PDF
Digital RSE: automated code quality checks - RSE group meeting
Henry Schreiner
 
PPTX
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Aleksey Asiutin
 
KEY
the NML project
Lei Yang
 
PDF
Jenkins to Gitlab - Intelligent Build-Pipelines
Christian Münch
 
PDF
Instalando Cacti no CentOS 5
Carlos Eduardo
 
PDF
DEF CON 27 - ALI ISLAM and DAN REGALADO WEAPONIZING HYPERVISORS
Felipe Prado
 
PDF
Testing NodeJS Security
Jose Manuel Ortega Candel
 
PPTX
Getting Started With CFEngine - Updated Version
CFEngine
 
Ondřej Procházka - Deployment podle Devel.cz
Develcz
 
Node js meetup
Ansuman Roy
 
Openstack Third-Party CI and the review of a few Openstack Infrastructure pro...
Evgeny Antyshev
 
Continuous integration / continuous delivery
EatDog
 
Continuous integration / continuous delivery of web applications, Eugen Kuzmi...
Evgeniy Kuzmin
 
Mcollective introduction
Javier Turégano Molina
 
Grunt.js and Yeoman, Continous Integration
David Amend
 
No more Dockerfiles? Buildpacks to help you ship your image!
Anthony Dahanne
 
Continuous Integration/ Continuous Delivery of web applications
Evgeniy Kuzmin
 
The Ultimate Node.js Resource Cheat Sheet 📝: Learn Everything Free
Tapp AI
 
PyParis 2017 / Writing a C Python extension in 2017, Jean-Baptiste Aviat
Pôle Systematic Paris-Region
 
JSConfBR - Securing Node.js App, by the community and for the community
David Dias
 
Digital RSE: automated code quality checks - RSE group meeting
Henry Schreiner
 
Kubernetes Navigation Stories – DevOpsStage 2019, Kyiv
Aleksey Asiutin
 
the NML project
Lei Yang
 
Jenkins to Gitlab - Intelligent Build-Pipelines
Christian Münch
 
Instalando Cacti no CentOS 5
Carlos Eduardo
 
DEF CON 27 - ALI ISLAM and DAN REGALADO WEAPONIZING HYPERVISORS
Felipe Prado
 
Testing NodeJS Security
Jose Manuel Ortega Candel
 
Getting Started With CFEngine - Updated Version
CFEngine
 
Ad

More from Binary Studio (20)

PPTX
Academy PRO: D3, part 3
Binary Studio
 
PPTX
Academy PRO: D3, part 1
Binary Studio
 
PPTX
Academy PRO: Cryptography 3
Binary Studio
 
PPTX
Academy PRO: Cryptography 1
Binary Studio
 
PPTX
Academy PRO: Advanced React Ecosystem. MobX
Binary Studio
 
PPTX
Academy PRO: Docker. Part 4
Binary Studio
 
PPTX
Academy PRO: Docker. Part 2
Binary Studio
 
PPTX
Academy PRO: Docker. Part 1
Binary Studio
 
PPTX
Binary Studio Academy 2017: JS team project - Orderly
Binary Studio
 
PPTX
Binary Studio Academy 2017: .NET team project - Unicorn
Binary Studio
 
PPTX
Academy PRO: React native - miscellaneous
Binary Studio
 
PPTX
Academy PRO: React native - publish
Binary Studio
 
PPTX
Academy PRO: React native - navigation
Binary Studio
 
PPTX
Academy PRO: React native - building first scenes
Binary Studio
 
PPTX
Academy PRO: React Native - introduction
Binary Studio
 
PPTX
Academy PRO: Push notifications. Denis Beketsky
Binary Studio
 
PPTX
Academy PRO: Docker. Lecture 4
Binary Studio
 
PPTX
Academy PRO: Docker. Lecture 3
Binary Studio
 
PPTX
Academy PRO: Docker. Lecture 2
Binary Studio
 
PPTX
Academy PRO: Docker. Lecture 1
Binary Studio
 
Academy PRO: D3, part 3
Binary Studio
 
Academy PRO: D3, part 1
Binary Studio
 
Academy PRO: Cryptography 3
Binary Studio
 
Academy PRO: Cryptography 1
Binary Studio
 
Academy PRO: Advanced React Ecosystem. MobX
Binary Studio
 
Academy PRO: Docker. Part 4
Binary Studio
 
Academy PRO: Docker. Part 2
Binary Studio
 
Academy PRO: Docker. Part 1
Binary Studio
 
Binary Studio Academy 2017: JS team project - Orderly
Binary Studio
 
Binary Studio Academy 2017: .NET team project - Unicorn
Binary Studio
 
Academy PRO: React native - miscellaneous
Binary Studio
 
Academy PRO: React native - publish
Binary Studio
 
Academy PRO: React native - navigation
Binary Studio
 
Academy PRO: React native - building first scenes
Binary Studio
 
Academy PRO: React Native - introduction
Binary Studio
 
Academy PRO: Push notifications. Denis Beketsky
Binary Studio
 
Academy PRO: Docker. Lecture 4
Binary Studio
 
Academy PRO: Docker. Lecture 3
Binary Studio
 
Academy PRO: Docker. Lecture 2
Binary Studio
 
Academy PRO: Docker. Lecture 1
Binary Studio
 
Ad

Recently uploaded (20)

PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Empower Inclusion Through Accessible Java Applications
Ana-Maria Mihalceanu
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
Timothy Rottach - Ramp up on AI Use Cases, from Vector Search to AI Agents wi...
AWS Chicago
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Python basic programing language for automation
DanialHabibi2
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 

Academy PRO: Node.js in production. lecture 4