Armagan Amcalar
FullStack 2017
July 13th, 2017
Node.js (get it via brew or http://nodejs.org)
cote (npm install cote)
Docker (https://docs.docker.com/engine/installation)
Armagan Amcalar
Head of Software Engineering @ unu GmbH
Founder @ Lonca Works
dashersw dashersw
Microservices overview
An example e-commerce application
Properties of a modern microservices approach
Brief intro to a Node.js microservice
How Docker helps
The real deal
dashersw
Async operations with queue (and other) systems
Having 50 different queue consumers (for notifications, logging, reconciliation services, e-mailing etc) doesn’t mean you have 50 microservices
Multiple programs running on a single machine and communicating over HTTP
dashersw
dashersw
If you are breaking down the fulfillment of a client request into multiple collaborating services that run in their own memory space, then you are doing microservices.
THE BASELINE
The quality of your approach depends on how well you apply Domain Driven Design and other best practices.
You have to —
Embrace change
Give autonomy to teams, to services
Automate testing, configuration, deployment, monitoring and more
Favor cattle over pets
dashersw
dashersw
dashersw
dashersw
dashersw
dashersw
dashersw
dashersw
const cote = require('cote'),
models = require('./models');
const userResponder = new cote.Responder({ name: 'user responder' });
userResponder.on('list', req => models.User.find(req.query));
userResponder.on('get', req => models.User.get(req.id));
userResponder.on('create', req => models.User.create(req.user));
const cote = require('cote'),
router = express.Router();
const userRequester = new cote.Requester({ name: 'user requester' });
router.get('/users/:id', (req, res, next) => {
userRequester.send({type: 'get', id: req.params.id})
.then(user => res.send(user))
.catch(next);
});
router.get('/users', (req, res, next) => {
userRequester.send({type: 'list'})
.then(users => res.send(users))
.catch(next);
});
module.exports = router;
dashersw
Immutable environment
Overlay network
Auto-restart on failure
Docker Swarm — orchestration capabilities, scaling, rollbacks, secrets management, highly-available
dashersw
By the way, here's the demo for the previous example:
Source code & Docker configuration available at
dashersw
Armagan Amcalar
dashersw
slides: tr.im/fs2017
demo: tr.im/dcmd