SlideShare a Scribd company logo
1 of 51
Download to read offline
HOW TO DEPLOY NODE
without getting fired
@seanhess
seanhess.github.com
Try it yourself
      deploynode.tk
           user public
           pass public
ssh public@deploynode.tk
WHO
  ARE
YOU?
from FIRST STEPS
    to MISSTEPS
          toSCALE
Ratinatorly
who RATES the RATE-MEN?
SALARY is for chumps


100,000
shares of sweat-equity
you decide to try
Your First Node
“but my brother says
that .NET is the best
      language”
var express = require('express')
var app = express.createServer()

app.get('/', function(req, res) {
    res.send("Hello World!")
})

app.listen(3333)
console.log("Listening on 3333")
your app is a
LONG RUNNING
PROCESS
it handles all the requests
                  ...if it’s on
the PROTOTYPE
       ONLINE
 must be


“Sequoia is going to LOVE this”
SHARED HOSTING FAIL *




you need to run a
    PROGRAM
VPS         WIN!
  like a cheap
DEDICATED SERVER
sudo make me a server
        okay...
> ssh root@ratinator.ly
root@ratinatorly's password:
Welcome to Ubuntu 11.04 (GNU/Linux

# adduser node
# adduser node sudo

#   sudo   apt-get install python-software-properties
#   sudo   apt-add-repository ppa:chris-lea/node.js
#   sudo   apt-get update
#   sudo   apt-get install nodejs npm
MAKE IT GO
•copy our code
• node app.js
DON’T CLOSE
   the
       LID!!
“I didn’t do anything... Check
         Energy Saver”
your
 app   BELONGS
         to your
   ssh session
LOG OUT     ==   DIE
SCREEN you
    keeps
  LOGGED IN
Undo! Rollback!
“I know enough HTML to be
       dangerous”
let’s add
VERSION CONTROL
      use GIT to deploy
manage your
DEPENDENCIES
 package.json
               > npm install
a PROCESS emerges
• git commit and push
• log in to server
• pull
• npm install
• restart
LAUNCH!
“I’ve got Techcrunch right where I
            want them”
port 80

•   must run as root
This is where I stop trying
   to design my slides
It keeps DYING!
  “Maybe we should try
windows servers instead”
upstart
•   OS will start on boot
•   Respawn
monitoring

•   know if it goes down
It works for me!
or, when the cracks first
     began to show...
logging

•   keep your output
uncaughtException
process.on(“uncaughtException”,
  function(err) {

     console.log(err.message)
})
Don’t forget step 6!
“Will you put my changes
       up for me?”
complicated deploy

•   it can get easy to miss a step
automated
•   keep the knowledge in your code
    base
•   put extra stuff in package.json
    “install”
Too Slow!
“Let’s just throw more
    money at this"
Multiple Processes

•   cluster up to your cores
Varnish Cache
       •  avoid repeating work
       • set headers and go
sudo   apt-get install varnish
sudo   vim /etc/default/varnish       # port 80
sudo   vim /etc/varnish/default.vcl   # point to our app at port 3333
sudo   /etc/init.d/varnish start
Staging Box
cheat with Heroku

•   it’s easy, but can be expensive
Scale
“We should aim for... 100
     million users”
Multiple Servers
• more app servers
• varnish and db on separate box
• use node-control to deploy
• smart db = good for a long time
automate



                  rem
                     em
with




                      erb
 UPSTARTand GIT
or CHEATwith
   HEROKU
seanhess.github.com
         @seanhess
> npm install express
...
> ls
app.js        node_modules
> node app.js
Listening on 3333

More Related Content

What's hot

The Php Life Cycle
The Php Life CycleThe Php Life Cycle
The Php Life Cycle
Xinchen Hui
 
Assurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring frameworkAssurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring framework
Gosuke Miyashita
 
PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?
Nick Belhomme
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
julien pauli
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshop
julien pauli
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
Elizabeth Smith
 

What's hot (20)

SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)SDPHP - Percona Toolkit (It's Basically Magic)
SDPHP - Percona Toolkit (It's Basically Magic)
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Mysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extensionMysqlnd, an unknown powerful PHP extension
Mysqlnd, an unknown powerful PHP extension
 
The Php Life Cycle
The Php Life CycleThe Php Life Cycle
The Php Life Cycle
 
PHP7 is coming
PHP7 is comingPHP7 is coming
PHP7 is coming
 
Assurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring frameworkAssurer - a pluggable server testing/monitoring framework
Assurer - a pluggable server testing/monitoring framework
 
Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2Zend Framework Study@Tokyo #2
Zend Framework Study@Tokyo #2
 
Php 7 hhvm and co
Php 7 hhvm and coPhp 7 hhvm and co
Php 7 hhvm and co
 
PHP 7 new engine
PHP 7 new enginePHP 7 new engine
PHP 7 new engine
 
Better detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 codeBetter detection of what modules are used by some Perl 5 code
Better detection of what modules are used by some Perl 5 code
 
PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?
 
PHP Tips for certification - OdW13
PHP Tips for certification - OdW13PHP Tips for certification - OdW13
PHP Tips for certification - OdW13
 
Fighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnitFighting Fear-Driven-Development With PHPUnit
Fighting Fear-Driven-Development With PHPUnit
 
eZ Publish Caching Mechanisms
eZ Publish Caching MechanismseZ Publish Caching Mechanisms
eZ Publish Caching Mechanisms
 
Php extensions workshop
Php extensions workshopPhp extensions workshop
Php extensions workshop
 
"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy
 
関西アンカンファレンス PHP ではじめるテストコード
関西アンカンファレンス PHP ではじめるテストコード関西アンカンファレンス PHP ではじめるテストコード
関西アンカンファレンス PHP ではじめるテストコード
 
Socket programming with php
Socket programming with phpSocket programming with php
Socket programming with php
 
第1回PHP拡張勉強会
第1回PHP拡張勉強会第1回PHP拡張勉強会
第1回PHP拡張勉強会
 
Perlmania_Study - CPAN
Perlmania_Study - CPANPerlmania_Study - CPAN
Perlmania_Study - CPAN
 

Similar to How to deploy node to production

Тарас Кирилюк та Олена Пустовойт — CI workflow у веб-студії
Тарас Кирилюк та Олена Пустовойт — CI workflow у веб-студіїТарас Кирилюк та Олена Пустовойт — CI workflow у веб-студії
Тарас Кирилюк та Олена Пустовойт — CI workflow у веб-студії
LEDC 2016
 
From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011
Carlos Sanchez
 
Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)
Puppet
 

Similar to How to deploy node to production (20)

Debugging webOS applications
Debugging webOS applicationsDebugging webOS applications
Debugging webOS applications
 
Madison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small TeamsMadison PHP 2015 - DevOps For Small Teams
Madison PHP 2015 - DevOps For Small Teams
 
ZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small TeamsZendCon 2015 - DevOps for Small Teams
ZendCon 2015 - DevOps for Small Teams
 
DevOps For Small Teams
DevOps For Small TeamsDevOps For Small Teams
DevOps For Small Teams
 
Toplog candy elves - HOCM Talk
Toplog candy elves - HOCM TalkToplog candy elves - HOCM Talk
Toplog candy elves - HOCM Talk
 
CI workflow in a web studio
CI workflow in a web studioCI workflow in a web studio
CI workflow in a web studio
 
What we Learned Implementing Puppet at Backstop
What we Learned Implementing Puppet at BackstopWhat we Learned Implementing Puppet at Backstop
What we Learned Implementing Puppet at Backstop
 
Midwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small teamMidwest PHP 2017 DevOps For Small team
Midwest PHP 2017 DevOps For Small team
 
Тарас Кирилюк та Олена Пустовойт — CI workflow у веб-студії
Тарас Кирилюк та Олена Пустовойт — CI workflow у веб-студіїТарас Кирилюк та Олена Пустовойт — CI workflow у веб-студії
Тарас Кирилюк та Олена Пустовойт — CI workflow у веб-студії
 
Ops for NoOps - Operational Challenges for Serverless Apps
Ops for NoOps - Operational Challenges for Serverless AppsOps for NoOps - Operational Challenges for Serverless Apps
Ops for NoOps - Operational Challenges for Serverless Apps
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011From Dev to DevOps - ApacheCON NA 2011
From Dev to DevOps - ApacheCON NA 2011
 
Large-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 MinutesLarge-scaled Deploy Over 100 Servers in 3 Minutes
Large-scaled Deploy Over 100 Servers in 3 Minutes
 
Docker and Containers for Development and Deployment — SCALE12X
Docker and Containers for Development and Deployment — SCALE12XDocker and Containers for Development and Deployment — SCALE12X
Docker and Containers for Development and Deployment — SCALE12X
 
Docker, c'est bonheur !
Docker, c'est bonheur !Docker, c'est bonheur !
Docker, c'est bonheur !
 
Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)Getting started with puppet and vagrant (1)
Getting started with puppet and vagrant (1)
 
Getting started with developing Nodejs
Getting started with developing NodejsGetting started with developing Nodejs
Getting started with developing Nodejs
 
Open shift
Open shiftOpen shift
Open shift
 
Boxen: How to Manage an Army of Laptops and Live to Talk About It
Boxen: How to Manage an Army of Laptops and Live to Talk About ItBoxen: How to Manage an Army of Laptops and Live to Talk About It
Boxen: How to Manage an Army of Laptops and Live to Talk About It
 
Web 3, Week 1: Amazon Web Services for Beginners
Web 3, Week 1: Amazon Web Services for BeginnersWeb 3, Week 1: Amazon Web Services for Beginners
Web 3, Week 1: Amazon Web Services for Beginners
 

Recently uploaded

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Recently uploaded (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 

How to deploy node to production

Editor's Notes

  1. quick intro to topic\n
  2. long-time consultant\nCofounder of i.TV\n
  3. make TV amazing. \ncool announcements\nused node in production for 2 years. STORY. We picked it because we thought it was cool.\n\n
  4. this is going to be a walk-through\ninterrupt me\n
  5. front-end developers?\ngotten a node app working on your computer?\ndeployed a node or ruby app to production by hand before?\n\n
  6. WALKTHROUGH. \nfollow a company. some of the steps are wrong, but we will explain why and show how to correct them.\nWe’re going to follow the story of a budding young entreprenuer\nBegin the story: local js meetup. talk on semicolons\n\n
  7. \n
  8. \n
  9. because you know and like javascript, and you heard it scales\nDOES have a big advantage: JS Skills\n
  10. All the real companies use .NET\nAfter a 3 hour meeting with your partner, you finally convince him to leave the decision to you and head out to learn. \n
  11. \n
  12. you don’t make a new one each time a requests. Only will work if it’s on and plugged in, ready to go. Listens on a socket. Different than PHP.\nIf we Control-C the program stops. \n
  13. \n
  14. * we’ll show off some cool stuff later\n
  15. nice thing is they are all the same, so you can jump between providers depending on cost\n
  16. domain name? (hosts file)\nSet up the server, and show how to log in. \nSwitch to VM?\n\n
  17. \n
  18. \n
  19. \n
  20. \n
  21. Add a non-root user\ninstall nodejs (source: google)\n
  22. Add a non-root user\ninstall nodejs (source: google)\n
  23. Add a non-root user\ninstall nodejs (source: google)\n
  24. Add a non-root user\ninstall nodejs (source: google)\n
  25. Add a non-root user\ninstall nodejs (source: google)\n
  26. Add a non-root user\ninstall nodejs (source: google)\n
  27. Add a non-root user\ninstall nodejs (source: google)\n
  28. Add a non-root user\ninstall nodejs (source: google)\n
  29. Add a non-root user\ninstall nodejs (source: google)\n
  30. Add a non-root user\ninstall nodejs (source: google)\n
  31. Add a non-root user\ninstall nodejs (source: google)\n
  32. Add a non-root user\ninstall nodejs (source: google)\n
  33. Add a non-root user\ninstall nodejs (source: google)\n
  34. Add a non-root user\ninstall nodejs (source: google)\n
  35. get it running online\n
  36. \n
  37. demo it!\neven if you run it in the background\n
  38. DEMO!\n
  39. The “boss” makes you tell him how to edit the app. He breaks it. \n
  40. Demo using git to deploy. (checkout, public)\ngit clone git://github.com/seanhess/ratinatorly.git\n
  41. intro to npm\nshow how to deploy without copying node_modules\nuse npm init\nexpress: \n
  42. \n
  43. \n
  44. \n
  45. tell the story\n
  46. \n
  47. DEMO init script\nDEMO deploying with init script\n
  48. montastic.com\n
  49. when it crashes\nuncaught exception\nlogs\n
  50. DEMO redirect with upstart\nDEMO track down the bug\nCan add fancy log analysis later\n
  51. DEMO: show the uncaughtException code\n
  52. \n
  53. \n
  54. DEMO: bash automated deploy\nNOPASSWD in sudoers (sudo visudo)\nsave fancier stuff for later when you have multiple servers (node-control, capistrano)\n
  55. \n
  56. DEMO: paste in the cluster code from the real one and check it closely\n\nvar os = require('os')\nvar cluster = require('cluster')\nif (cluster.isMaster) {\n\n for (var i = 0; i < os.cpus().length; i++) {\n cluster.fork()\n }\n}\nelse {\n app.listen(3333)\n console.log("Listening on 3333")\n}\n\n
  57. DEMO\nsudo apt-get install varnish\nsudo vim /etc/default/varnish\nsudo vim /etc/varnish/default.vcl\nsudo /etc/init.d/varnish start\n\n
  58. \n
  59. heroku create --stack cedar\ngit push heroku master\nchange the port! (check the logs)\n
  60. \n
  61. \n
  62. \n
  63. \n
  64. DEMO IT!\n
  65. DEMO IT!\n
  66. DEMO IT!\n
  67. DEMO IT!\n
  68. DEMO IT!\n
  69. DEMO IT!\n