Nodeday 2014: Micro-Services In Node.Js
NodeDay 2014: Micro-services in Node.js
Akbar S. Ahmed | Apr 25, 2014

Micro-services in Node.js

Stop repeating the mistakes of the past! JavaScript lets you do amazing things in very small amounts of code. Node.js lets you write server-side code in tiny mind-size pieces. We call them micro-services. Stop writing monolithic web apps! Break everything apart. Do one thing and do it well. You can run hundreds of Node processes. It’s cool.

Richard discussed a different way of structuring Node apps with something he termed micro-services. This talk is definitely worth listening to when the video come out.


He believes in micro-services which is something that he discovered by accident.

Micro-services are super small node services that pass messages between other services.

  • lots of processes also means you can run things in parallel
  • also get good isolation


  • micro-services are small
  • micro-services are single purpose
  • micro-services use messages to communicate
  • there are many of them
  • death of processes is expected


  • 100 lines of code = a few screens to scroll
  • can fit inside your head

use node modules

  • prefer composition of libraries vs. complete framework
  • do one thing and do it well!

anti-pattern: the orchestator

  • a service that mediates
  • a service that knows about other services
  • each service should only know about its inputs and outputs

solution - communicate with messages

  • what you should do is publish messages onto a service bus
  • standalone information
  • you can pattern match the message
  • messages define the interface
  • the transport mechanism is not important - instead think about messages going to/from services
  • transport could be http or message queue

pattern matching

  • no need for complex rules
  • do named keys have given values?
  • use MUST IGNORE semantics. This makes your world extendable.


  • write your services so they can restart cleanly
  • node best practice === die on uncaught exceptions. So expect to die.

How do you give node enterprise grade reliability?

setTimeout(function() {
}, (300*1000)*Math.rand());

Basically, randomly kill your process and ensure that your application is written such that the user sees no impact.

Netflix has a tool to simulate failure called Simian Army.

Micro service architecture

  • make decisions later, with more information
  • calibrate quality and performance
  • makes rewrites cheap
  • avoid project mgmt ceremony
  • services are the right size for humans
  • too many unit tests makes rewrites expensive

When you have more information later in the project you can:

  • split services
  • combine services
  • add services for special cases
  • extend messages with more context

services are a comfortable size

  • lets you focus effort where it counts


  • analyze time, scale, domains

Transport layer

  • keep everything in process during development
  • delay the choice of a transport layer
  • for direct connections use http
  • pubsub


Monitor business outcomes not technical information.

Subscribe to our newsletter

Contact Information


We specialize in helping professional developers, like you, expand your skill set. Our courses are focused on enabling you to learn everything necessary to use a new technology in a live, production application.


All courses are made with love in
Palo Alto, CA.

Subscribe to our newsletter