Skip to content

Instantly share code, notes, and snippets.

@adamloving
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamloving/87ce126741cfdc1709dd to your computer and use it in GitHub Desktop.
Save adamloving/87ce126741cfdc1709dd to your computer and use it in GitHub Desktop.
Node.js hosting best practices. How to host node in production.

Hosting Node.js

We need to host node ourselves (Rackspace server) to have access to the file system (temp files for image processing) and (legacy) local database.

Have you hosted node in production? If so, what was the web server setup? Currently, we're using nginx + a unix socket file + forever or upstart. My inclination is to stop hosting it ourselves and go for a PaaS (like heroku) - but that's because I wish this stuff was not my problem. What I'm looking for is a clear recipe for best practices.

Issues

Hosting node is hard because unhandled errors force the node.js v8 process to die and need a restart.

  • unix socket file and web server configuration ... do I need a unix socket file?
    • unix file keeps port private (but you could also block it with a firewall)
    • Lots of EMFILE errors restarting
  • nginx or apache?
    • nginx seems to be most accepted answer
  • forever or upstart...? *
  • multiple node processes

Good description of nginx setup

Problems hosting our own servers

  • cloning servers (instead of deploying app instances)
  • managing resources on servers (checking on available memory, disk space)
  • auto-restart when OS restarts

Hosted platforms

These guys use their own web server and application hosting stacks, which are worth investigating to see if there are any open source components we can re-use.

nodejitsu heroku openshift

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment