scaling and managing
node.js applications
WITH MICROSERVICES

 

Armagan Amcalar

Online Webinar
Feb 2nd, 2016

who am i?

Armagan Amcalar
Head of Software Engineering @ unu GmbH
Founder @ Lonca Works

        dashersw

hobby projects

pedals.io
trax.io

Node.js

We love it.

We develop all kinds of software with it.

Programming model encourages stateful app design.

We love to daemonize it, all apps are running as daemons.

the problem

It doesn't scale well as a monolith.

 

Works great as single process.

Works OK as a cluster.

what's next?

What if you need more computing power?

How about horizontal scalability?

First solution

nginx

node-http-proxy

REVERSE PROXY

we need a different solution.

Because we have more problems

We're not just building express apps

Where's the flexibility and agility in that?

more problems?

Be fast with your API response

Asynchronous processing (e.g., analytics)

You may need to scale very dynamically

High availability (fault tolerance)

WHERE ARE MODULAR, COMPOSABLE DESIGN AND EVENTS?

Two approaches To Architecture

monolithic apps
vs
service oriented architecture & microservices

Microservices

Separate code base
Multi processes for each service
A bug in a service crashes only that service
Consumes minimal resources
Scales well, needs minimal additional resources

Supports event-driven architecture

Request–response flow breakdown

 

Hard to manage

Problems of microservices

Communication between services

Transactional processes

Dynamic service configuration

Service registry & discovery

Health checks & monitoring

how can nginx help?

Use as service discovery

Update config on any change in services

Load balance between services

 

Needs a service registry! Consul can help!

SIMPLE EXAMPLE

Demo based on the technique presented here by Dr. Graham Jenson

enter cote.js

node.js framework for building;

zero-configuration,

scalable,

fault-tolerant,
distributed applications

cote.js features

auto-discovery
mesh network, peer-to-peer communication
pubsub pattern
requester/responder pattern
client-side communication with websockets
load balancing with different strategies
daemon monitor

example architecture

example pub-sub implementation

var Publisher = require('cote').Publisher,
    publisher = new Publisher({
        name: 'publisher',
        broadcasts: ['update']
    }),
    workId = 0;

publisher.on('ready', function() {
    setInterval(function() {
        console.log('emitting', ++workId);
        publisher.publish('update', workId);
    }, 3000);
});
var Subscriber = require('cote').Subscriber,
    subscriber = new Subscriber({
        name: 'subscriber'
    });

subscriber.on('update', function(message) {
    console.log('update', message);
});

Conclusion

With cote.js we can;

 

Apply sophisticated programming paradigms

Scale nearly infinitely

Have fault-tolerant systems

thank you!

Join cote.js community

Let's keep in touch!

Armagan Amcalar

armagan@amcalar.com
twitter: @dashersw
github: dashersw
blog: arm.ag

Scaling and Managing Node.js Applications with Microservices

By Armağan Amcalar

Scaling and Managing Node.js Applications with Microservices

In this talk, Armagan will briefly talk about microservices architecture and the state-of-the-art implementation using nginx. Then he will explore a method for implementing microservices via a Node.js framework, cote.js. You will learn how to implement an optimized, zero-conf, fault-tolerant, distributed scaling solution that plays extremely well with the microservices architecture. Finally, he will present a monitoring solution to help you manage your microservices in production.

  • 3,641