Post on 14-Apr-2017
Patterns for Asynchronous Microservices
Raül Pérez - @repejota NATS London - 10/05/2016
Who am I?Raül PérezLead Software Engineer at R3 Labs Ltd.
Twitter: @repejotaGithub: https://github.com/repejotaEmail: repejota@gmail.com
2Raül Pérez - @repejota NATS London - 10/05/2016
Who am I?Raül PérezLead Software Engineer at R3 Labs Ltd.
Twitter: @repejotaGithub: https://github.com/repejotaEmail: repejota@gmail.com
3
● Almost 4 years working on devops & distributed projects.
Raül Pérez - @repejota NATS London - 10/05/2016
Who am I?Raül PérezLead Software Engineer at R3 Labs Ltd.
Twitter: @repejotaGithub: https://github.com/repejotaEmail: repejota@gmail.com
4
● Almost 4 years working on devops & distributed projects.
● Still more a dev than op dude.
Raül Pérez - @repejota NATS London - 10/05/2016
Who am I?Raül PérezLead Software Engineer at R3 Labs Ltd.
Twitter: @repejotaGithub: https://github.com/repejotaEmail: repejota@gmail.com
5
● Almost 4 years working on devops & distributed projects.
● Still more a dev than op dude.
● Proud to be a Gopher after a looong PHP/Ruby/Python/Node.js past experience. :P
Raül Pérez - @repejota NATS London - 10/05/2016
Who am I?Raül PérezLead Software Engineer at R3 Labs Ltd.
Twitter: @repejotaGithub: https://github.com/repejotaEmail: repejota@gmail.com
6
● Almost 4 years working on devops & distributed projects.
● Still more a dev than op dude.
● Proud to be a Gopher after a looong PHP/Ruby/Python/Node.js past experience. :P
● Based in Barcelona.Raül Pérez - @repejota NATS London - 10/05/2016
Who am I?Raül PérezLead Software Engineer at R3 Labs Ltd.
Twitter: @repejotaGithub: https://github.com/repejotaEmail: repejota@gmail.com
7
● Almost 4 years working on devops & distributed projects.
● Still more a dev than op dude.
● Proud to be a Gopher after a looong PHP/Ruby/Python/Node.js past experience. :P
● Based in Barcelona.
● Love startups & love remote work!
Raül Pérez - @repejota NATS London - 10/05/2016
Summary
8Raül Pérez - @repejota NATS London - 10/05/2016
● Why microservices?
● Synchronous vs. Asynchronous communication.● Pattern: Broker approach & NATS● Pattern: Autonomy of services vs. Coordination between services.
Why microservices?
9Raül Pérez - @repejota NATS London - 10/05/2016
● Loosely coupled components.● Specific responsibility, each one delivers a capability.● Designed to be defensive against failures.
Why microservices?
10Raül Pérez - @repejota NATS London - 10/05/2016
● Loosely coupled components.● Specific responsibility, each one delivers a capability.● Designed to be defensive against failures.
● Designed around business needs.● Decentralised governance.● Decentralised data management.● Connected through a common interface.
Pattern: Sync vs. Async communication.
11Raül Pérez - @repejota NATS London - 10/05/2016
● The most common interface to communicate is HTTP.● But HTTP is “mostly” synchronous.● Once the number of services grow, HTTP is sometimes not enough.
Pattern: Sync vs. Async communication.
12Raül Pérez - @repejota NATS London - 10/05/2016
● The most common interface to communicate is HTTP.
● But HTTP is “mostly” synchronous.● Once the number of services grow, HTTP is
not enough.
● It also has a complex error management.
Pattern: Sync vs. Async communication.
13Raül Pérez - @repejota NATS London - 10/05/2016
● Synchronous communication is simple but….○ Drawback: Suffers from latency on each connection.
● Asynchronous communication is faster but…○ Drawback: Increases the complexity.○ Drawback: Snowball effect, difficult to manage and orchestrate.
So, Is there a better communication interface?
Pattern: Sync vs. Async communication.
14Raül Pérez - @repejota NATS London - 10/05/2016
● Pattern: Use a broker to orchestrate your communication needs.○ AMPQ, RabbitMQ, NSQ, etc ….○ NATS :)
● A broker is flexible, allows you to use:○ Work queues.○ Publish/Subscribe.○ Request/Response.○ Message routing.○ etc...
Pattern: Broker approach & NATS
15Raül Pérez - @repejota NATS London - 10/05/2016
● Loosely coupled clients and servers.● Multiple patterns: Publish/Subscribe,
Request/Response.● Easy to scale.
Pattern: Broker approach & NATS
16Raül Pérez - @repejota NATS London - 10/05/2016
● Loosely coupled clients and servers.● Multiple patterns: Publish/Subscribe,
Request/Response.● Easy to scale.
● NATS is fast!
Pattern: Broker approach & NATS
17Raül Pérez - @repejota NATS London - 10/05/2016
● Loosely coupled clients and servers.● Multiple patterns: Publish/Subscribe,
Request/Response.● Easy to scale.
● NATS is fast!● Just a message system, no
assumptions, no extra features. Easy to deploy, easy to use.
Pattern: Broker approach & NATS
18Raül Pérez - @repejota NATS London - 10/05/2016
● Loosely coupled clients and servers.● Multiple patterns: Publish/Subscribe,
Request/Response.● Easy to scale.
● NATS is fast!● Just a message system, no
assumptions, no extra features. Easy to deploy, easy to use.
● It is also secure: SSL, password ...
Pattern: Broker approach & NATS
19Raül Pérez - @repejota NATS London - 10/05/2016
● Loosely coupled clients and servers.● Multiple patterns: Publish/Subscribe,
Request/Response.● Easy to scale.
● NATS is fast!● Just a message system, no
assumptions, no extra features. Easy to deploy, easy to use.
● It is also secure: SSL, password ...● Simple protocol, it is just text.
Pattern: Autonomy vs. Coordination.
20Raül Pérez - @repejota NATS London - 10/05/2016
● Make your services autonomous.● Avoid coordination between different services.● The minimal coordination the more optimal autonomy.● Increased autonomy gives it freedom to evolve.
Pattern: Autonomy vs. Coordination.
21Raül Pérez - @repejota NATS London - 10/05/2016
● Make your services autonomous.● Avoid coordination between different services.● The minimal coordination the more optimal autonomy.● Increased autonomy gives it freedom to evolve.
● Your services delivers “capabilities”
Pattern: Autonomy vs. Coordination.
22Raül Pérez - @repejota NATS London - 10/05/2016
● Make your services autonomous.● Avoid coordination between different services.● The minimal coordination the more optimal autonomy.● Increased autonomy gives it freedom to evolve.
● Your services delivers “capabilities”
● What is a capability?A complete business capability is a process that can be finished consecutively without interruptions or excursions to other services.
Resources● http://microservices.io
● https://en.wikipedia.org/wiki/Cloud_computing
● http://nats.io
23
● http://repejota.com
● http://r3labs.io
● http://ernest.io
● http://apcera.com Raül Pérez - @repejota NATS London - 10/05/2016
Questions?
Raül Pérez - @repejota NATS London - 10/05/2016
Thank you!
25Raül Pérez - @repejota NATS London - 10/05/2016