6 ms·
The Ambassador Pattern
- the_sleaze9 3y agoWow - I had no idea Microsoft has put together such a deep learning resource. Fantastic.
- timeagain 3y agoI understand the need for such a thing, but the wild amount of indirection that is needed in microservices world is astounding. Hmm, that request didn’t make it through! I wonder if it was dropped by the database, the business logic, the spring http-handling framework, the retry annotation, nginx reverse proxy, the authentication sidecar, the “ambassador service”, the SQS queue, the internal VPN, or cloudflare? Just writing it out makes my brain hurt.
- MPSimmons 3y agoInfrastructure like this is overkill for the vast majority of cases. When you do need something like this, you're probably using a service mesh that also provides introspection and observability into the pipeline to be able to help debug and diagnose issues.
- AYBABTME 3y agoThis type of infra only makes sense when you have Scaling People Problems to solve using technical solutions. Say you're MSFT and you need to let thousands of people of various skillset and skill levels, ship locally useful software at decent velocity, but while preserving important cross-cutting stuff like TLS, telemetry, wtv. Or when dealing with legacy software. But otherwise it's not required.
- tjoff 3y agoThe weird part is the hype around it, because that extends well beyond that particular scenario. Or maybe scale doesn't matter. Even if you replace thousands with tens you still often have a huge variety in skillset and focus.
- AYBABTME 3y agoThe hype is career development driven development.
- H8crilA 3y agoRule of thumb: if you cannot staff a team (even a small one) for a service - it cannot be a standalone service. This rule is sometimes a bit too aggressive, but only a bit - for example it doesn't apply to an off-the-shelf database.
- iamthepieman 3y agoDid you get this rule of thumb somewhere or make it up? If the latter, can you please share a source?
- H8crilA 3y agoI made it up myself, and I think it's a good rule.
- iamthepieman 3y agoI agree that it's a good rule. Of course the people responsible for staffing aren't usually the people building services.
- notatoad 3y agoi don't think you can really say this is ever necessary. or at least, not that microservices make it necessary. this is a business thing. you need this when you're hiring a contractor to add some functionality, and you don't want them to touch the service behind the ambassador. probably because you've hired a different contractor to build the original service, nobody at your company knows how it works anymore, and making the new contractor figure it out is out of budget.
- ctvo 3y ago> I understand the need for such a thing, but the wild amount of indirection that is needed in microservices world is astounding. What does this have to do with microservices? I'm trying to debug my monolithic service: Was it the database? My own business logic? The HTTP framework? The reverse proxy we run to terminate TLS? Was it an authentication or authorization issue? The network appliance in front of all of this? Did the queue fail to persist it at a layer above this? Was it the hosting provider? You outlined any distributed service.
- haolez 3y agoI can't help but think that, when past teams programmed mostly in assembly, a "Function" could be explained as a pattern. Having such "design patterns" seem like a side effect of our current tools' limitations. Maybe new technologies like Wing[0] (no affiliation) will help pushing us to the next generation of tools. [0] https://www.winglang.io/ https://www.winglang.io/
- bobbiechen 3y agoAbsolutely. Take something like the Builder pattern in Java for handling large numbers of possibly-optional arguments - in Python rarely-if-ever used due to named keyword arguments.
- devbent 3y ago> I can't help but think that, when past teams programmed mostly in assembly, a "Function" could be explained as a pattern. Actually it was an entire new paradigm. Procedural programming!
- eladbenisrael 3y ago(elad, winglang maintainer here) i like this observation - it's not uncommon for patterns to turn into language primitives when they end up becoming a very common thing in your language. this is reflected both in wing as a language but also in the fact that wing's preflight phase in a sense is a programming model for turning infrastructure patterns into composable components.
- bzbz 3y ago> An ambassador service can be thought of as an out-of-process proxy that is co-located with the client. > This pattern can be useful for offloading common client connectivity tasks such as monitoring, logging, routing, security (such as TLS), and resiliency patterns in a language agnostic way. It is often used with legacy applications, or other applications that are difficult to modify, in order to extend their networking capabilities. It can also enable a specialized team to implement those features. Not surprised this is a Microsoft page, given their legacy of long lifetime support for their software products. It’s not for microservices, but rather for software maintenance of systems that other vendors would consider past EOL.
- fulafel 3y agoUnless you view systems that consist of microservices as "applications that are difficult to modify".
- bzbz 3y agoIf anything, an obfuscated microservice-based application is easier to understand than a monolithic version: network data transfer is easier for observers to understand than memory modification.
- fulafel 3y agoThis could be argued, but obfuscated apps are a land of their own. (You could also argue that obfuscated monolithic programs are be easier to reverse engineer, breakpoint, replay, emulate, time-travel-debug, trace, etc because you can completely control them in your test bench and aren't then working against a hostile distributed system)
- xyzzy_plugh 3y agoIt's similar to a thick client, what Google does by eschewing language agnosticism. It's a reasonable approach, really: thin clients of course work, and you have to provide them across popular languages, making them thicker adds value.
- kcb 3y agoSeems like something you can do with Istio External Services.
- er4hn 3y agoIs this what envoy (by Ambassador Labs?) is named after? https://www.getambassador.io/learn/envoy-proxy https://www.getambassador.io/learn/envoy-proxy
- justincormack 3y agoEnvoy is not by Ambassador Labs, they just ship it. I am not sure if that is where the naming of both of them (independently) comes from but may be.
- mkleczek 3y agoWhat's old is new again but in new clothes. 20 something years ago "mobile objects" and "agent systems" were a thing and one of the practical incarnations was Jini: https://jan.newmarch.name/java/jini/tutorial/Jini.html https://jan.newmarch.name/java/jini/tutorial/Jini.html
- mdhb 3y agoSpeaking of this has anyone had much experience with Dapr (https://dapr.io/ https://dapr.io/) before? I always thought this was a particularly interesting approach from Microsoft where they use this pattern to essentially take the complexity of micro services and instead try and keep it as simple as a normal .NET application but (and I think this is the clever part) in both a vendor and language neutral way. But all of a sudden it means you can start removing all kinds of cruft and random SDKs from your codebase and push almost all of your interactions with the outside world into something like this .
- jiggawatts 3y agoI saw that Dapr was a side-car instead of an SDK, so I've avoided it for now. For comparison, most other microservices frameworks such as Service Fabric or Azure Functions generally ship as an in-process SDK. The problem with having Dapr being a separate thing that my code has to communicate with over the network is that this basically triples the number of hops in an environment that already has too many network hops. As a former game developer used to replacing divisions by multiplications with a reciprocal to save precious clocks, the design of Dapr makes me... itchy.
- valzam 3y agoThe difference between Game (engine) dev and modern microservice development is pretty staggering. It actually cuts both ways. As a webdev when I dabbled with some OpenGL programming it actually felt amazing how much stuff you can cram into 1/60th of a second when it's all in-process or at worse has to be shuffled between CPU and GPU. When you are used to anything useful taking 10-100 seconds due to network hops and/or having to access a RDBMS it's very reassuring to know that actually, computers are really fast.
- lijok 3y agoYou wouldn't use dapr for game dev. You would use it in systems where the added latency (very little by the way) does not matter.
- 3y ago
- rvdginste 3y agoI understand what this pattern does, but it makes me wonder how useful it is in practice. I am focusing specifically on the retry and circuit breaker functionality. If the call is done in a synchronous context (for example original client executes a REST call), you are adding latency by inserting an extra service in between. When the remote service is not immediately available or responsive or fails, and you do a retry, in the end your call might take too long and the caller might cancel the request. I have seen this behavior in practice and it makes me wonder how useful this implementation is in a synchronous context. You add complexity (on the infra level) and you add latency in the happy path. When a retry is needed, most of the time (in my experience) the call to the remote service does not succeed in time, and the original call still fails. If the call is done in an asynchronous context (for example the original client picks up a message from a queue and processes it), you are adding latency and complexity by inserting an extra service and extra logic. However, when the remote service is not immediately available, you can just let the processing of the message fail. The queue or bus should contain retry logic that could be finetuned based on the type of error you get. So, in that case, you should already have a retry mechanism out of the box, then is the added latency and complexity really worth it? I understand about the circuit breaker, and I understand that might be useful, because it could prevent the remote service being overloaded with requests (well, at least if every caller to the remote service implements circuit breaker... but then, the ambassador service would better be placed on the side of the remote service and every client should be forced to pass through it, and then it might just be implemented inside the remote service instead of in a separate service adding extra latency/complexity/... basically, the remote service should protect itself against this). Thoughts? Does it make sense what I am thinking?
- somerando7 3y agoIt's pretty useful when you have some distribution layer (i.e. some pubsub system) Consider 10-15 applications running on a host, and all of them are listening to data being distributed by another service. Instead of all of them opening a connection to that service, instead they would all be connected to this sidecar, and the sidecar would merge the distribution of data (and subscriptions) to the pubsub system
- ablob 3y ago
- onetimeuse92304 3y agoWhen I build some kind of API, I would usually also provide a library for the clients. This library would to an extent perform the function of "ambassador". It captures my intended logic to handle certain situations that are not described by purely functional part of API contract. And yes, this library usually also covers things like retries and handling errors and outages. Maintaining an entire service to achieve the same seems like really expensive way to achieve this...
- nezirus 3y agoSo when I "sideload" HAProxy with my application, handling (incoming!) and outgoing http(s) and tcp connections, balanving, failover, logging and what not, that is cool now and I get to call it Ambassador Sandwich Pattern.
- robryk 3y agoI'm surprised that making sure the service does not trust the ambassador is not listed in the list of issues to consider.
- camgunz 3y agoI want to try and avoid snark etc. here but, good god like 99% of microservices this should be a library. Honestly I feel like microservices has just lost the plot entirely.
- xg15 3y agoHonestly, I only kow this stuff to be a library. I can see some advantage in offloading this to a separate process, so you can update both processes separately, don't trample over the other's heap, etc. (Especially if the original executable can't be modified, as seems to be their rationale) But it should obviously run in the same container/pod/etc.
- lijok 3y agoHow would you build and keep in sync the same library with the same functionality in 10 different languages? Every new feature would have to be implemented 10 times. Sounds quite foolish
- from-nibly 3y agoWhy would a single project need to be in charge of this for every language?
- lijok 3y agoTo handle cross-cutting concerns for all supported languages in a polyglot environment
- camgunz 3y agoI think what happens outside of microservices shops is that "the Java people" write their own library, "the Python people" write their own, etc. Is that a little bonkers? No more bonkers than wrapping services with other services to get them to behave reasonably.
- camgunz 3y agoThis is a big thing that happens w/ microservices: your system is implemented as a Tower of Babel (it's oddly touted as a feature). In that scenario, you no longer have good choices, you're constantly reimplementing things with slight differences in multiple languages, the maintenance overhead and defect rate is sky high, etc. The big bad here is having the "10 different languages" problem in the 1st place.
- xg15 3y ago> Resilient cloud-based applications require features such as circuit breaking, routing, metering and monitoring, and the ability to make network-related configuration updates. I understand that at different points, you'll frequently run into situations where you need one or several of those, but the way this sentence is phrased, it sounds more like chastizing people for not following the latest fad (the components of which they are conveniently selling too). "what, your deployment doesn't have advaned metering and circuitbreaking abilities and I have to restart the service to make config changes? get back to me when you have a real deployment..."