mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-09-08 04:17:26 +00:00
docs: Content SEO updates (#2990)
* update yaml frontmatter format * update abstract document * update abstract factory * use the new pattern template * acyclic visitor seo * adapter seo * ambassador seo * acl seo * aaa seo * async method invocation seo * balking seo * bridge seo * builder seo * business delegate and bytecode seo * caching seo * callback seo * chain seo * update headings * circuit breaker seo * client session + collecting parameter seo * collection pipeline seo * combinator SEO * command seo * cqrs seo * commander seo * component seo * composite seo * composite entity seo * composite view seo * context object seo * converter seo * crtp seo * currying seo * dao seo * data bus seo * data locality seo * data mapper seo * dto seo * decorator seo * delegation seo * di seo * dirty flag seo * domain model seo * double buffer seo * double checked locking seo * double dispatch seo * dynamic proxy seo * event aggregator seo * event-based asynchronous seo * eda seo * event queue seo * event sourcing seo * execute around seo * extension objects seo * facade seo * factory seo * factory kit seo * factory method seo * fanout/fanin seo * feature toggle seo * filterer seo * fluent interface seo * flux seo * flyweight seo * front controller seo * function composition seo * game loop seo * gateway seo * guarded suspension seo * half-sync/half-async seo * health check seo * hexagonal seo * identity map seo * intercepting filter seo * interpreter seo * iterator seo * layers seo * lazy loading seo * leader election seo * leader/followers seo * lockable object seo * rename and add seo for marker interface * master-worker seo * mediator seo * memento seo * metadata mapping seo * microservice aggregator seo * api gw seo * microservices log aggregration seo * mvc seo * mvi seo * mvp seo * mvvm seo * monad seo * monitor seo * monostate seo * multiton seo * mute idiom seo * naked objects & notification seo * null object seo * object mother seo * object pool seo * observer seo * optimistic locking seo * page controller seo * page object seo * parameter object seo * partial response seo * pipeline seo * poison pill seo * presentation model seo * private class data seo * producer-consumer seo * promise seo * property seo * prototype seo * proxy seo * queue-based load leveling seo * reactor seo * registry seo * repository seo * RAII seo * retry seo * role object seo * saga seo * separated interface seo * serialized entity seo * serialized lob seo * servant seo * server session seo * service layer seo * service locator seo * service to worker seo * sharding seo * single table inheritance seo * singleton seo * spatial partition seo * special case seo * specification seo * state seo * step builder seo * strangler seo * strategy seo * subclass sandbox seo * table module seo * template method seo * throttling seo * tolerant reader seo * trampoline seo * transaction script seo * twin seo * type object seo * unit of work seo * update method seo * value object seo * version number seo * virtual proxy seo * visitor seo * seo enhancements * seo improvements * SEO enhancements * SEO improvements * SEO additions * SEO improvements * more SEO improvements * rename hexagonal + SEO improvements * SEO improvements * more SEO stuff * SEO improvements * SEO optimizations * SEO enhancements * enchance SEO * improve SEO * SEO improvements * update headers
This commit is contained in:
+21
-21
@@ -1,25 +1,23 @@
|
||||
---
|
||||
title: Ambassador
|
||||
title: "Ambassador Pattern in Java: Simplifying Remote Resource Management"
|
||||
shortTitle: Ambassador
|
||||
description: "Explore the Ambassador Pattern in Java, its benefits, use cases, and practical examples. Learn how to decouple and offload common functionalities to improve system performance and maintainability."
|
||||
category: Integration
|
||||
language: en
|
||||
tag:
|
||||
- API design
|
||||
- Decoupling
|
||||
- Fault tolerance
|
||||
- Proxy
|
||||
- Resilience
|
||||
- Scalability
|
||||
- API design
|
||||
- Decoupling
|
||||
- Fault tolerance
|
||||
- Proxy
|
||||
- Resilience
|
||||
- Scalability
|
||||
---
|
||||
|
||||
## Intent
|
||||
## Intent of Ambassador Design Pattern
|
||||
|
||||
Provide a helper service instance on a client and offload common functionality away from a shared resource.
|
||||
The Ambassador Pattern in Java helps offload common functionalities such as monitoring, logging, and routing from a shared resource to a helper service instance, enhancing performance and maintainability in distributed systems.
|
||||
|
||||
## Also known as
|
||||
|
||||
* Sidecar
|
||||
|
||||
## Explanation
|
||||
## Detailed Explanation of Ambassador Pattern with Real-World Examples
|
||||
|
||||
Real-world example
|
||||
|
||||
@@ -35,7 +33,9 @@ Microsoft documentation states
|
||||
|
||||
> An ambassador service can be thought of as an out-of-process proxy which 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.
|
||||
|
||||
**Programmatic Example**
|
||||
## Programmatic Example of Ambassador Pattern in Java
|
||||
|
||||
In this example of the Ambassador Pattern in Java, we demonstrate how to implement latency checks, logging, and retry mechanisms to improve system reliability.
|
||||
|
||||
A remote service has many clients accessing a function it provides. The service is a legacy application and is impossible to update. Large numbers of requests from users are causing connectivity issues. New rules for request frequency should be implemented along with latency checks and client-side logging.
|
||||
|
||||
@@ -175,9 +175,9 @@ Failed to reach remote:(3)
|
||||
Service result:-1
|
||||
```
|
||||
|
||||
## Applicability
|
||||
## When to Use the Ambassador Pattern in Java
|
||||
|
||||
* Cloud Native and Microservices Architectures: Especially useful in distributed systems where it's crucial to monitor, log, and secure inter-service communication.
|
||||
* The Ambassador Pattern is particularly beneficial for Cloud Native and Microservices Architectures in Java. It helps in monitoring, logging, and securing inter-service communication, making it ideal for distributed systems.
|
||||
* Legacy System Integration: Facilitates communication with newer services by handling necessary but non-core functionalities.
|
||||
* Performance Enhancement: Can be used to cache results or compress data to improve communication efficiency.
|
||||
|
||||
@@ -189,7 +189,7 @@ Typical use cases include:
|
||||
* Offload remote service tasks
|
||||
* Facilitate network connection
|
||||
|
||||
## Consequences
|
||||
## Benefits and Trade-offs of Ambassador Pattern
|
||||
|
||||
Benefits:
|
||||
|
||||
@@ -204,7 +204,7 @@ Trade-offs:
|
||||
* Potential Performance Overhead: The additional network hop can introduce latency and overhead, particularly if not optimized.
|
||||
* Deployment Overhead: Requires additional resources and management for deploying and scaling ambassador services.
|
||||
|
||||
## Known uses
|
||||
## Real-World Applications of Ambassador Pattern in Java
|
||||
|
||||
* Service Mesh Implementations: In a service mesh architecture, like Istio or Linkerd, the Ambassador pattern is often employed as a sidecar proxy that handles inter-service communications. This includes tasks such as service discovery, routing, load balancing, telemetry (metrics and tracing), and security (authentication and authorization).
|
||||
* API Gateways: API gateways can use the Ambassador pattern to encapsulate common functionalities like rate limiting, caching, request shaping, and authentication. This allows backend services to focus on their core business logic without being burdened by these cross-cutting concerns.
|
||||
@@ -216,14 +216,14 @@ Trade-offs:
|
||||
* Network Optimization: For services deployed across different geographical locations or cloud regions, Ambassadors can optimize communication by compressing data, batching requests, or even implementing smart routing to reduce latency and costs.
|
||||
* [Kubernetes-native API gateway for microservices](https://github.com/datawire/ambassador)
|
||||
|
||||
## Related patterns
|
||||
## Related Java Design Patterns
|
||||
|
||||
* [Circuit Breaker](https://java-design-patterns.com/patterns/circuit-breaker/): Often used in conjunction to manage fault tolerance by stopping calls to an unresponsive service.
|
||||
* [Decorator](https://java-design-patterns.com/patterns/decorator/): The decorator pattern is used to add functionality to an object dynamically, while the ambassador pattern is used to offload functionality to a separate object.
|
||||
* [Proxy](https://java-design-patterns.com/patterns/proxy/): Shares similarities with the proxy pattern, but the ambassador pattern specifically focuses on offloading ancillary functionalities.
|
||||
* Sidecar: A similar pattern used in the context of containerized applications, where a sidecar container provides additional functionality to the main application container.
|
||||
|
||||
## Credits
|
||||
## References and Credits
|
||||
|
||||
* [Building Microservices: Designing Fine-Grained Systems](https://amzn.to/43aGpSR)
|
||||
* [Cloud Native Patterns: Designing Change-tolerant Software](https://amzn.to/3wUAl4O)
|
||||
|
||||
Reference in New Issue
Block a user