Armagan Amcalar
DevOps Pro Moscow
November 15th, 2017
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
Demo
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
npm install cote
Create an empty Node.js project and...
Immutable environment
Overlay network
Auto-restart on failure
Docker Swarm — orchestration capabilities, scaling, rollbacks, secrets management, highly-available
dashersw
Automated server cluster management with AWS, DigitalOcean, etc. and BYOD
Automated builds from GitHub or Bitbucket repos
Automated testing to Docker Hub
Service and stacks similar to docker-compose
Slack notifications!
Scaling containers / nodes
Terminal access
Security scans
dashersw
Source code & Docker Cloud configuration available at
dashersw
Armagan Amcalar
dashersw
slides: slides.com/armaganamcalar/devopspro-workshop
demo: tr.im/dcmd