• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Webconf nodejs-production-architecture
 

Webconf nodejs-production-architecture

on

  • 5,863 views

 

Statistics

Views

Total Views
5,863
Views on SlideShare
5,786
Embed Views
77

Actions

Likes
30
Downloads
173
Comments
0

9 Embeds 77

http://run.jsbin.com 51
http://www.plurk.com 8
http://nodeslide.herokuapp.com 8
https://twitter.com 4
http://jsbin.com 2
http://www.instapaper.com 1
http://www.diffbot.com&_=1358821765800 HTTP 1
http://azi.vwrd.org 1
http://geekconfs.dev 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Webconf nodejs-production-architecture Webconf nodejs-production-architecture Presentation Transcript

    • node.jsproduction site architecture
    • About me Ben LinA full time entrepreneur & JavaScript loverFall in love with node.js on Jun 2011 dreamerslab.com ben@dreamerslab.com twitter.com/dreamerslab github.com/dreamerslab
    • About meCOKE - Full stack node.js MVC frameworkVodka - Functional testing frameworkThunder - The lightning fast template engine https://github.com/dreamerslab
    • Agenda 1. Super brief intro to node.js 2. Run node as a service 3. What if it crashes? 4. Monit VS Forever 5. Nginx or not 6. Scaling node.js 7. Deployment 8. Cloud service 9. Some useful tips 10. Q & A
    • What is node? node is an evented, non-blocking I/O server-side Javascript built on chrome V8
    • What is node?Ryan Dahl talks about the history ofnode.js http://www.youtube.com/watch?v=SAc0vQCC6UQ
    • What is node? But why node? * node is fast * node handles a lot of connection with very little resources * You can develop your whole app with one language * Easy to scale
    • What is node? Achieves this by all making network I/O nonblocking and all file I/O asynchronous.
    • What is node? I/O latency L1: 3 cycles L2: 14 cycles RAM: 250 cycles DISK: 41,000,000 cycles NETWORK: 240,000,000 cycles
    • What is node? What’s wrong with PHP, Ruby, Python, etc...?
    • Run node as a service Run your node app as daemon with upstart
    • Run node as a service # Start your app start your_app_name # Stop your app stop your_app_name # Restart your app restart your_app_name
    • What if it crashes? Every little shit can fuck up your node app
    • Monitor your node app Installation on Ubuntu $ sudo apt-get install monit Edit configs * edit /etc/default/monit and set the "startup" variable to 1 * edit /etc/monit/monitrc and use the example file monitrc Run $ sudo /etc/init.d/monit start $ sudo monit start your_app_name
    • Monit VS Forever
    • Monit VS Forever With `forever` we kind of use an unstable tool to monitor another unstable project?!
    • Nginx or not?* Nginx runs faster with serving static files* Use it as a reverse proxy to load balance withmultiple nodes
    • Scaling node.js
    • Scaling node.jsStart small with built-in static server, node.js app & database all on the same server.
    • Scaling node.jsUse nginx as static server for better performance.
    • Scaling node.jsUse nginx as as proxy server as well to load balance requests.The number of node.js app instance depends on how many CPU cores on the machine.
    • Scaling node.jsSplit static files to different server for easier maintenance.
    • Scaling node.jsUse aws S3 for easier setup and maintenance.
    • Scaling node.jsSplit database to another server. Make the node.js app server an unit.
    • Scaling node.jsAdd a load balancer, add more app unit as the site scales up.
    • Scaling node.jsAdd replica set if the database hits its limit.
    • Scaling node.jsAdd CDN for static files for cross reign performance.
    • Scaling node.jsSplit app to difference services as it scales up. Previous scaling steps apply to those services too.
    • Deployment
    • DeploymentWith ssh, git; The server must stop during deployment.
    • DeploymentWith ssh, git; 0 downtime deployment is possible since we have more than 1 instance( repo ).
    • DeploymentWith ssh, git; Split static file makes it easier to deploy with multi instance( repo ) app.
    • DeploymentDeploying with multi machine it’s better to use image files on aws ec2.
    • Cloud service
    • Cloud service How about using services like Heroku, Nodejitsu, mongoHQ?
    • Some useful tips
    • Some useful tips Set your max file limit sudo vi /etc/security/limits.conf # add the following 4 lines root soft nofile 51200 root hard nofile 51200 * soft nofile 51200 * hard nofile 51200 sudo vi /etc/pam.d/common-session # add session required pam_limits.so sudo vi /etc/profile # add ulimit -SHn 51200
    • Some useful tipsThis ensure that your node app never dies butuse with care process.on(uncaughtException, function (e) { console.dir(e); });
    • THE END Thanks
    • QUESTIONS?
    • HIRING Web & iOS DevYour Github account speak for you, Please mail to job@woomoo.in