4 ms·
As someone who's familiar with the API gateway pattern, is it fair to say this is just another API gateway for internal services? Seems like it is but its also
by jayd16 7y ago
As someone who's familiar with the API gateway pattern, is it fair to say this is just another API gateway for internal services? Seems like it is but its also described in an extremely convoluted way with 'control planes' and such.
- tptacek 7y agoNot really. API gateways are typically single-point-deployment proxies, designed to create a coherent public interface out of a disparate group of services. An API gateway change is almost always going to be a PR for the application team. Service meshes are proxies deployed alongside all the services, and used as much by devops (and potentially security) as by the application developers.
- jayd16 7y agoSo a goal of the service mesh is to keep it an api agnostic appliance. I'm not sure that concept requires all this nomenclature. It seems like a very thin API Gateway that forwards calls directly to the microservice API without enforcing much would be much easier to manage and have all the same benefits. Whats the purpose of deploying the reverse proxy alongside the microservice?
- tptacek 7y agoYeah, you haven't grokked the concept yet. The idea behind a service mesh is that no matter how you design and implement a microservice architecture, you still have all these little services talking to each other somehow. By "default", they're communicating using native sockets and HTTP or gRPC. There's lots that can go wrong any time you have a bunch of things talking to each other on a network (see Tanenbaum's "Critique of RPCs" for a classic explanation). If everything was written in the same language, what you'd probably do is come up with a common networking/RPC library for all your services to use. That library would give you a common interface, so everything used the network the same way, and some measure of observability (maybe just by doing a standard log format), and maybe some security controls like a standard HTTPS connection and a standard token format. But if you've got multiple languages, that option isn't very attractive anymore, because even if it's feasible to build that library once for each platform, now you're keeping an additional component (the library) in sync between the platforms, and that's a drag. The insight behind a service mesh is that containers make it cheap and easy to just stack a tiny out-of-process proxy alongside your services. So you can just move all the logic you would have had in that common service library into the proxy. The proxy will give you the same features no matter whether your service is a Rust binary, Clojure running on the JVM, or a shell script. And, because it's an out-of-process standalone component, it can be built and maintained by a third party, which means the features it provides can be a lot more ambitious than you'd build in your own library. So now instead of just hoping to get some TLS and maybe a standard token, everything can be mTLS with client certificates, a standard dashboard for managing certificates, rule systems for what client certs will allow you to talk to which systems, graphical maps of who's communicating with who and trace collection for specific pairs of services, etc. This is all very un- like what an API gateway does, and the whole concept sort of revolves around having little reverse proxies running alongside the services.
- erik_seaberg 7y agoIt's an RPC plugin but doing it out-of-process is weird (I need an RPC client to talk to my RPC client?). If you don't need a trust boundary or separate ulimits, loopback network traffic and context switches and reserialization are a really expensive way to mitigate a language having poor FFI plugin support. If it were in-kernel and supported scatter-gather and zero-copy, that might be different (though some people even avoid going through the kernel).
- tptacek 7y agoThe "RPC" that the proxy in Linkerd is doing is radically different and more expressive than the "RPC" that is running between the Linkerd proxy and your application, which is the whole point of the architecture.
- jayd16 7y agoI think I get it. Its underpinned by the assumption that the application doesn't need robust logic around connecting to a local proxy like it would connecting to a remote one. In this sense its going back to the days when instances had a local HAProxy running. That assumption didn't really pan out and we all decided service LBs were better but ok, sure. We can have both. I still think describing the concept more plainly would help a lot of the confusion.
- tptacek 7y agoI think this is right, yes. We're not worried about the connectivity between the service and the local proxy because they're (always) cotenants of a container and using localhost to communicate. A more general way to think about service meshes is that the network layer we code to right now is actually really primitive; its service model was fixated in the 1980s, and its programming interface hasn't much evolved from the early 1990s. We'd be happier if we could level up the whole network, so that it had QoS controls, a really expressive security model that didn't rely on magic-number ports and address ranges, and observation capabilities that communicated application-layer details and didn't just try to approximate them the way flow logs do. You can get all that stuff, internally at least, by putting all your services on the same service mesh. Another thing to look at is Slack's Nebula, which was just released last week: https://slack.engineering/introducing-nebula-the-open-source-global-overlay-network-from-slack-884110a5579 https://slack.engineering/introducing-nebula-the-open-source... Nebula is a service mesh that runs at the IP layer (where Istio and Linkerd ride on top of HTTPS proxies, Nebula rides on top of a somewhat Wireguard-ish VPN). Slack has been using it internally for 2 years now. It's solving the same problems Linkerd is, but with a radically different implementation. You can get your laptop connected to a Nebula service mesh in ways that would be clunky to do with a Linkerd mesh.
- hardwaresofton 7y agoThe service mesh is a bit different from an API gateway -- in it's current most popular implementations (linkerd[0] & Istio[1]), there are basically small programs that run next to each individual instance of the programs you want to run. Linkerd has been around for a while and IMO there weren't that many companies that were at a scale where they needed it (I didn't see it deployed that often), but it's basically that same concept, but on a more granular level -- if you delegate all your requests to some intermediary, then the intermediaries can deal with the messy logic and tracing so your program doesn't have to. A better way to describe is "smart pipes, dumb programs". Imagine that all your circuit-breaking/retry/etc robustness logic was moved into another process that happened to be running right next to the program actually doing the work. You can have both an API gateway and a service mesh deployment -- for example Kong's Service Mesh[2] works this way. They're saying stuff like "inject gateway functionality in your service", but that only make sense if you sent literally every request (whether intra-service or to/from the outside world) through the gateway. Maybe that's how some people used Kong but I don't think everyone thought of API gateways as a place to send every single request through. You'll have a Kong API gateway at the edge and the kong proxies (little programs that you send all your requests through) next to every compute workload. [0]: https://linkerd.io/ https://linkerd.io/ [1]: https://istio.io/ https://istio.io/ [2]: https://konghq.com/solutions/service-mesh/ https://konghq.com/solutions/service-mesh/
- jayd16 7y agoHmm, is the assumption that, because you're deploying an instance of the mesh as close to the application as possible, you don't need robust logic between the application and the service mesh? I can buy that I suppose.
- hardwaresofton 7y agoYes kind of -- except not in between the application and the service mesh, it's between application and application. Imagine that for every application there is one small binary that runs and serves all it's traffic, like a chauffeur. Your application stops talking to the outside world completely and sends all messages to the small chauffeur binary -- which then talks to other chauffeurs, over the network. Keeping with the chauffeur analogy, there is a "head office" which calls the chauffeurs on CB radio at regular intervals that lets them know which cars go where and how to start them/etc. "head office" => "control plane" "chauffeur" => "side-car proxy"/"data plane" In the end what this means for your application is that you just make calls to external services (whether your own or others) and since all your communication goes through this other binary, you get monitoring, traffic shaping, enhanced security, and robustness for free. Another interesting feature is that if the side-car proxy can actually understand your traffic, it can do even more advanced things. For example you can prevent `DELETE`s from being sent to Postgres instances at the network level.
- fosk 7y agoService Mesh really is about connectivity among all the service you are deploying in your architecture. Some of these services are going to be databases, some of them will be APIs, some of them will be caches and so on. Once you have this underlying grid of services all connecting via a service mesh - in a reliable, secure and observable way - for some of these services you want to define governance and on-boarding rules, or you want to expose them externally as products that developer can consume and you then use an API GW to do those things. In this regards, an API GW is just a service among the services you are running inside the service mesh.
- skywhopper 7y agoThese get mixed up a lot but wrongly, I think. They can be related, but not necessarily. API Gateway pattern is at the application layer, and builds on top of the Service Mesh, which is at the transport layer. Think of API Gateway as HTTP and Service Mesh as TCP/IP. Just with more flexible hooks for authentication, observability, and reliability.
- graphememes 7y agoIt is.