Fork me on GitHub

Getting Started with Node.js in the Cloud

Node.js

The "Cloud"

Node.js in the Cloud

We can build scalable, efficient, and fast web applications and services.

At the micro-level, Node.js applications can support large numbers of connections and glue together many different services.

At the macro-level, the cloud allows us to scale out servers, and provide various backing components.

Use Cases

Application traffic

Anti-Use Cases

Some situations where Node.js may not be the best choice.

PAAS Providers

Node.js Platform-as-a-Service offerings:

IAAS Providers

Infrastructure-as-a-Service providers. Host it yourself!

Heroku

Heroku logo

Hooking up Heroku

Heroku provides an excellent Node.js guide that can get you up and running. (devcenter.heroku.com/articles/nodejs)

Hello World!

Here is everyone's first Node.js application:


Let's try it in development...

And, let's see a slightly more enhanced version...

Package the App

We have to package things up appropriately.

web: node server-hello.js

This tells Heroku to run "server-hello.js" as a Node.js web application.

Deployment

Now that we've developed our app, we're ready for prime time!

Create the Heroku application:
$ heroku create --stack cedar
Rename the application:
$ heroku rename novanode
Deploy!
$ git push heroku master

We're Live!

Get ready for "hello world" goodness at: novanode.herokuapp.com

Check Heroku processes:
$ heroku ps
Review our logs:
$ heroku logs
... and many other commands. For example, open a server shell:
$ heroku run bash

Let's Scale!

Scaling with Heroku is incredibly easy and fast.

"These go to eleven."
$ heroku ps:scale web=11
Review our massive service:
$ heroku ps
But let's not get carried away:
$ heroku ps:scale web=1

Chat Server

"Hello world" is scalable, but not useful. Let's try something that leverages Node.js's strengths: chat!

Let's try it out in development...

Prepare our Chat App

Add the Redis To Go add-on.
$ heroku addons:add redistogo:nano
Update our "Procfile" to point to the chat server:
web: node chat/app_redis.js
Deploy!
$ git push heroku master

Heroku Chat

And we're up at novanode.herokuapp.com.

However, we're now using AJAX long-polling, which leads us into...

Heroku / PAAS Gotcha's

Sometimes you have to go with an IAAS or self-managed system.

Heroku / PAAS Benefits

But you can get a lot done in the Node.js PAAS ecosphere.

Wrapping up the Cloud

Reflections of a Node Developer

Thanks!


slides: bit.ly/novanode-cloud-talk
source: bit.ly/novanode-cloud-source

@ryan_roemer   ryan@loose-bits.com
SpanishDict.com is hiring!

/

#