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.
Some situations where Node.js may not be the best choice.
Node.js Platform-as-a-Service offerings:
Infrastructure-as-a-Service providers. Host it yourself!
Heroku provides an excellent Node.js guide that can get you up and running. (devcenter.heroku.com/articles/nodejs)
Here is everyone's first Node.js application:
Let's try it in development...
And, let's see a slightly more enhanced version...
We have to package things up appropriately.
package.json
" file.Procfile
" file.web: node server-hello.js
This tells Heroku to run "server-hello.js
"
as a Node.js web application.
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
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
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
"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...
$ 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
And we're up at novanode.herokuapp.com.
However, we're now using AJAX long-polling, which leads us into...
Sometimes you have to go with an IAAS or self-managed system.
But you can get a lot done in the Node.js PAAS ecosphere.
/
#