Application Network Functions With ESBs, API Management, and Now...Service Mesh?
This article takes a look at how service meshes relate to ESBs, message brokers, and API management, and how applications and networks connect.
Join the DZone community and get the full member experience.Join For Free
i’ve talked quite a bit recently about the evolution of microservices patterns and how service proxies like envoy from lyft can help push the responsibility of resilience, service discovery, routing, metrics collection, etc. down a layer below the application. otherwise, we risk hoping and praying that the various applications will correctly implement these critical functionalities or depend on language-specific libraries to make this happen. interestingly, this service mesh idea is related to other concepts that our customers in the enterprise space know about, and i’ve gotten a lot of questions about this relationship. specifically, how does a service mesh relate to things like esbs, message brokers, and api management? there definitely is overlap in these concepts, so lets dig in. feel free to follow along @christianposta on twitter for more on this topic!
1) services communicate over a network
first point to make: we’re talking about services communicating and interacting with each other over asynchronous, packet-switched networks. this means they are running in their own processes and in their own “time boundaries” (thus the notion of asynchronicity here) and communicate by sending packets across a network. unfortunately, there are no guarantees about asynchronous network interaction : we can end up with failed interactions, stalled/latent interactions, etc, and these scenarios are indistinguishable from each other.
2) if we look closely, these interactions are non-trivial
second point to make: how these services interact with each other is non-trivial; we have to deal with things like failure/partial success, retries, duplicate detection, serialization/deserialization, transformation of semantics/formats, polyglot protocols, routing to the correct service to handle our messages, dealing with floods of messages, service orchestration, security implications, etc, etc. many things can, and do, go wrong.
3) there is a lot of value in understanding the network
third: there is a lot of value in understanding how applications communicate with each other, how message get exchanged, and potentially a way to control this traffic; this point is very similar to how we look at layer 3/4 networking; it’s valuable to understand what tcp segments and ip packets are transversing our networks, controlling the rules around how to route them, what’s allowed, etc.
4) it’s ultimately the application’s responsibility
lastly: as we know through the end to end argument , it’s the applications themselves that are responsible for the safety and correct semantic implementation of their purported business logic – no matter what reliability we get from underlying infrastructure (retries, transactions, duplicate detection etc) our applications must still guard against user’s doing silly things (submitting an order twice) – anything that helps support this is implementation/optimization details. unfortunately, there is no way around this.
application network functions
i think no matter what services architecture you prefer (microservices, soa, object request brokers, client/server, etc) these points are all valid – however, in the past we’ve blurred the lines about what optimizations belong where. in my mind, there are horizontal application networking functions that are fair game to optimize out of our applications (and put into infrastructure – just like we do at lower levels of the stack), and there are others that are more closely related to our business logic that should not be so readily “optimized” out.
let’s take a quick step back and understand what the networking looks like (at a super trivial and high level :)) below our applications. when we send a “message” from one service to another, we pass it to the networking stack of our operating system which then figures out how to put it onto the network. the network, depending on what level, deals with transmission units (frames, datagrams, packets) etc. these transmission units usually consist of a structure that includes a “header” and a “payload” with the “header” containing enough metadata about the unit that we can do basic things like routing, ack tracking / de-duplication, etc.
these transmission units are sent through different points in the network which decide things like whether or not to allow the unit through, whether to route it to a different network, or to deliver it to its intended recipient. at any point along the path, these transmission units can be dropped, duplicated, reordered, or delayed. we have higher-level “reliability” functions like tcp that exist in the networking stack in our os that can track things like duplicates, acknowledgments, timeouts, ordering, lost units etc and can retry on failures, re-order packets and so on.
these types of functions are provided by the infrastructure and are not mixed with business logic – and this scales quite well (internet scale!) i just ran into a wonderful blog from phil calcado that explains this nicely, as well .
at the application level, we do something similar. we split up conversations with our collaborator services into transmission units of “messages” (requests, events, etc). when we make calls over the network, we have to be able to do things like timeout, retry, acknowledge, apply backpressure and so on for our application messages. these are universal application-level problems and will always crop up when we build services-style architectures. we need to solve them somehow. we need a way to implement application network functions.
for example: in the past, we tried solving these problems with messaging brokers. we had a centralized set of messaging oriented middleware (maybe even with multi-protocol support so we could transform message payloads and “integrate” clients) that was responsible for delivery of messages between clients. in a lot of examples i’ve seen, the pattern was to basically do request/reply (rpc) over the messaging system.
this tacitly helped solve some of these problems around application network functionality: things like load balancing, service discovery, back pressure, retries, etc were all delegated to the messaging brokers. since all traffic was intended to flow through these brokers we had a central spot from which to observe and control network traffic. however, as @tef_ebooks points out on twitter this approach is quite heavy handed/overkill. it also tends to be a big bottleneck in an architecture and wasn’t really as easy as we thought when it came to traffic control, routing, policy enforcement, etc.
so we tried to do that too. we thought “well, let’s just add routing, transformation, policy control” to the centralized message bus we already had. this was a natural evolution actually – we could use the messaging backbone to provide centralization/control and application network functions like service discovery, load balancing, retries, etc – but, we’d also layer on top more things like protocol mediation, message transformation, message routing, orchestration, etc. we felt if we could push these seemingly horizontal things down into the infrastructure, our applications could be lighter/leaner/more agile, etc. these concerns were definitely real the esb evolved to helped fill those.
for example, in the days of soa as envisioned by the big vendors (writing endless specs upon specs via committee etc, rebranding eai etc.), what we found was three things that contributed to the undelivered promises of the “esb”:
"the enterprise service bus (esb) is a silent partner in the soa logical architecture. its presence in the architecture is transparent to the services of your soa application. however, the presence of an esb is fundamental to simplifying the task of invoking services – making the use of services wherever they are needed, independent of the details of locating those services and transporting service requests across the network to invoke those services wherever they reside within your enterprise."
- organization structure (let’s build another silo!).
- technology was complicated (soap/ws-*, jbi, canonical xml, proprietary formats, etc).
- business logic was needed to implement things like routing, transformation, mediation, orchestration, etc.
the last bullet point is what overdid things. we wanted to be agile but we distributed vital business logic away from our services and into an integration layer owned by another team. now when we wanted to make changes (agile) to our services, we couldn’t; we had to stop and synchronize significantly with the esb team (brittle). as this team, and this architecture, became the center of the universe for many applications we can understand how the esb team became inundated with requests (agile) but were unable to keep up (brittle). so although the intentions were good, we found that mixing core application networking functions with functions that are much more related to business logic is not a good idea. we end up with bloat and bottlenecks.
then along came the rest revolution and the api-first mindset. this movement was partly a backlash against the complexity of soap/esb/soa coupled with a new way to think about turning our data inside out (via apis) to spark new business models and scale existing ones. we also introduced a new piece of infrastructure to our architecture: the api management gateway. this gateway provided us a centralized way of controlling outside access to our business apis through security acls, access quotas and plans for api usage, metrics collection, billing, documentation etc. however, just like we saw in the previous examples with the message brokers, when we have some kind of centralized governance we run the risk of wanting to accomplish too many things with it. for example, as api calls are coming through our gateway why don’t we just add things like routing, transformation, and orchestration? the problem with this is we start going down the path of building an esb which combines infrastructure level networking concerns with business logic. and this is a dead end.
but we still had to solve for the points listed above between our services even for the rest / non-soap era (not just the so-called “north-south” traffic, but we needed to solve for the “east-west” traffic interactions). even more challenging, we needed to figure out a way to use commodity infrastructure environments (aka, cloud) which tended to exacerbate these problems. traditional message brokers, esbs, etc would not fit this model very well. instead, we ended up writing the application networking functions inside our business logic. … we started seeing things like the netflix oss stack , twitter finagle , and even our own fuse fabric crop up to solve some of these problems. these were typically libraries or frameworks that aimed to solve some of the points made above but they were language specific and were intermingled in our business logic (or our business logic spread throughout our infrastructure). there were problems with this model as well. this approach required a massive amount of investment in each language/framework/runtime. we basically had to duplicate efforts across languages/frameworks and expect all of the different implementations to work efficiently, correctly, and consistently.
what has emerged through these trials and tribulations is something that allows us to push application network functions down into the infrastructure with minimal overhead and high decentralization with the ability to control/configure/monitor application-level requests – tackling some of the earlier issues. we’ve been calling this the “service mesh”. a nice example of this is the istio.io project based on envoy proxy . this lets us architecturally separate the concerns of application networking functions from those that are focused on differentiating business logic:
as phil calcado explains , this is very similar to what we do with the tcp/ip networking layer; networking functions are pushed out into the operating system and are not directly part of the application.
so how is this related to…
with the service mesh, we’re explicitly separating application network functions from application code, from business logic, and we’re pushing it down a layer (into the infrastructure – similar to how we’ve done with the networking stack, tcp, etc.).
the network functions in question include:
- simple, metadata-based routing.
- adaptive/client-side load balancing.
- service discovery.
- circuit breaking.
- rate limiting.
- fault injection.
- a/b testing/traffic shaping/request shadowing.
things that are specifically not included (and are more appropriate in your business logic/applications/services, not some centralized infrastructure):
- message transformation.
- message routing (content-based routing).
- service orchestration.
so how’s a service mesh different than…
- overlap in some of the network functions.
- decentralized control points.
- application-specific policies.
- does not try to deal with business-logic concerns (mapping, transformation, content-based routing, etc).
- overlap (from a 30,000 ft level) in service discovery, load balancing, retries, backpressure.
- decentralized control points.
- application-specific policies.
- does not take responsibility for messages.
- overlap in certain aspects of policy control, rate limiting, acls, quotas security.
- does not deal with the business aspects of apis (pricing, documentation, user-to-plan mapping, etc).
- similar in that it does not implement business logic.
with respect to api management, there does seem to be some overlap but i like to think of these things as highly complementary. api management provides higher-order semantics about apis (like documentation, user sign up/access, lifecycle management, api plans for developers, metering for billing and chargeback, etc). lower-level application networking like circuit breakers, timeouts, retries, etc are crucial when calling apis but these fit nicely in the service-mesh layer. the points of overlap like acls, rate limiting, quotas, and policy enforcement etc can be defined by the api management layer but actually enforced by the service mesh layer. in this way, we can have full end-to-end policy and access control as well as enforce resilience for north/south traffic and east/west traffic. as @zackbutcher (from the istio team) on twitter pointed out “as you get larger, east-west traffic starts to look more like north-south from the perspective of producing and managing your service.”
bringing it all together
we need to take an api-first approach to our systems architectures. we must also solve for things like resiliency. we also find we have integration challenges. and in many ways, an architecture built on asynchronous event passing and event processing as a backplane for your apis and microservice interactions can help to increase availability, resilience, and reduce brittleness. in the past, solving these problems has been challenging as competing products and solutions overlapped and conflated concerns – as we move to cloud architectures it’s becoming apparent we need to tease apart these concerns and put them into the proper spots in our architecture otherwise we’ll succumb to some of the same lessons learned.
from the diagram above, we see a few things:
- api management for ingress north/south traffic.
- service mesh (control + data plane) for application network functions between services.
- service mesh enforcing api management policies for east/west traffic.
- integration (orchestration, transformation, anti-corruption layers) as part of the applications.
- event-driven message back plane for truly asynchronous/event-driven interactions.
if we hearken back to the four assumptions i made up front, here’s how we push to solve them:
- point one: services interact over the network – we use a service mesh data plane/service .proxies.
- point two: interactions are non-trivial – implement business integration in the services themselves.
- point three: control and observability – use api management + service mesh control plane.
- point four: your specific business logic; use service mesh / messaging / etc for optimizations.
can you really separate out the business logic?
i think yes. there will be blurry lines, however. in a service mesh, we’re saying that our application should be aware of application network functions but they should not be implemented in the application code. there is something to be said about making the application smarter about what exactly the application network function / service mesh layer is doing. i think we’ll see libraries/frameworks building in some of this context. for example, if istio service mesh raises a circuit breaker, retries some requests, or fails for a specific reason, it would be nice for the application to get more understanding or context about these scenarios. we would need a way to capture this and communicate it back to the service. another example would be to propagate tracing context (distributed tracing like opentracing) between services and have this done transparently. what we may see is these thin application/language specific libraries that can make the application/services smarter and allow them to take error-specific recourse.
where do we go from here?
each of the parts of this architecture are at varying levels of maturity today. even so, taking a principled approach to our services architecture is key. separate business logic from application networking. use the service mesh to implement application networking, the api management layer to handle higher-order api-centric concerns, business specific integration lives in the services layer, and we can build data intensive/available systems through the event-driven backplane. i think as we go forward, we’ll continue to see these principles unfold in specific technology implementations. at red hat (where i work) we see technologies like 3scale , istio.io on kubernetes , apache camel , and messaging technology like activemq artemis / apache qpid dispatch router (including non-red hat technologies like apache kafka imho) as strong building blocks to build your services architecture that adhere to these principles.
Published at DZone with permission of Christian Posta, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.