Microservices: What are smart endpoints and dumb pipes?
I have read an article "Microservices" by Martin Fowler and find it difficult to understand smart endpoint s and dumb pipes . Please explain these terms, examples are welcome.
I didn't read the article, so I can only speculate what he can mean exactly, but as he gives ESB as an example against microservices and ZeroMQ as an example for micro services I hope my speculation will be pretty exact:
One of the ideas of Unix (and Linux) is to build small independent applications and connect them via pipes. The probably most common set of two command which I'm using is ps
and grep
like this: ps aux | grep PROCESS_NAME
ps aux | grep PROCESS_NAME
- here you can see a dumb pipe which only forwards the output of ps
to stdin of grep
.
Other messaging systems like ZeroMQ work similarly, although they can have a little bit more complexity like round-robin distribution and reliable delivery. Erlang as a language is built on top of small smart endpoints sending messages between each other. The advantages here are obvious and also mentioned in the article, small applications are easier to maintain, decoupling makes it easier to scale.
On the other hand of Microservices are most commonly big enterprise applications, like the mentioned Enterprise Service Bus. I didn't really work with those enough to give you a specific example, but generally those busses contain a lot of functionality which is either included via scripts or configuration. Such functionality mostly includes a configureable Workflow with advanced routing and can even transform the messages, so different endpoints can handle them.
An example could be - if you want the perform some advance action in a system, for instance change the requirements in an already running project, this could start a workflow, where the ESB would send out automatically different notifications to different actors around those changed requirements and wait for 1 or more of those actors to confirm before this change would be applied. Which would be basically the opposite - dumb endpoints (which just send/receive the data to/from the bus) and a very smart pipe (the bus, which can be configured or scripted to handle all possible enterprise scenarios).
I'm pretty confident that there exist enterprise service busses which are handling similar scenarios and those are the opposite of simple “dumb” ZeroMQ-like message passing frameworks.
Basically the logic has to be implemented somewhere - either in the big ESB, or in the endpoints. The idea of microservices is to put it into the endpoints rather than into the bus and have a similar philosophy as unix applications.
I think Martin Fowlers' article falls woefully short by mischaracterising the 'ESB' concept. This mischaracterisation is widespread. How many time have you seen a diagram that represents the 'bus' as a pipe down which messages flow? I've certainly lost count and it makes me wince every time. A 'bus' is not a pipe. It is a mechanism for making 'enabling services' readily accessible across a distributed, service-orientated environment. The classic analogy is a bus bar in a factory. Although electricity flows through the bus bar, that's not why it a 'bus'. It is a 'bus' because it runs the full length of the manufacturing floor. Any machinery (service implementations) can tap easily into the bar to get power (from a generating service), wherever that machinery happens to be located. The bus is a ubiquitous enabler which supports flexibility and change over time.
The only things that live on a service bus are services, and as a general principle they are best implemented as microservices wherever possible or desirable. The mantra of 'smart endpoints, dumb pipes' goes back way before the advent of microservices. I first heard it from a member of the Microsoft BizTalk team many years ago in public debate with a leading advocate of ESB. The ESB guy was advocating the desirability of very fine-grained stand-alone transformation services (microservices) rather than the typical BizTalk approach where transformations are applied at endpoints (smart endpoints). The ESB guy was criticising BizTalk, claiming that it was 'monolithic' and therefore could not be used to implement such fine-grained, independently deployable services. The BizTalk guy pointed out that he was factually wrong (as demonstrated subsequently in the BizTalk ESB toolkit), but that the main point was the general desirability of doing transformation at the message endpoints (from an integration perspective) rather than downstream in some intermediate service invoked in the interchange (conceptually, further down the 'pipe').
This was a grown-up debate between serious practitioners. I agreed with the BizTalk guy on this point – smart endpoints, dumb pipes. Ironically, the ESB guy was effectively promoting a microservice approach in an ESB context. To me, it's a great example of how the microservice mantra, like any other philosophy, can be taken a step too far.
Components in a system use "pipes" (HTTP/S, queues, etc...) to communicate with each other. Usually these pipes flow through an ESB (Enterprise Service Bus) which does a number of things to the messages being passed between components.
It might do:
Once it's completed these tasks the message will be forwarded onto the "endpoint" component. This is an example of "smart pipes" as lots of logic and processing reside inside the ESB (part of the system of "pipes"). The endpoints can then be "dumb" as the ESB has done all the work.
"Smart endpoints and dumb pipes" advocates the opposite scenario. That the lanes of communication should be stripped of business processing and logic and should literally only distribute messages between components. It's then the components themselves that do processing / logic / validation etc... on those messages.
链接地址: http://www.djcxy.com/p/5826.html上一篇: 何时没有连接的AMQP / RabbitMQ通道何时死亡?
下一篇: 微服务:什么是智能端点和哑管?