Anti corruption layer
When a legacy system is rearchitected to a a modern system it typcaily may need to interact with legacy systems . To interact with the legacy system, the new application may need to support outdated communication protocols , apis. or other features .
This problem can be solved by anit corruption layer which allows the modern system to communicate with the legacy system through the anti corruption layer. The legacy system reamins unchanged and the modern system can avoid corrupting its design (eg supporting legacy communication protocol)
Side car/side kick pattern
A service is split into two containers /process. One container may will handle the primary business logic where as the second container can handle common/cross cutting/supporting functions which is indepedent of business logic. This pattern is named Sidecar because it resembles a sidecar attached to a motorcycle.The sidecar also shares the same lifecycle as the parent application (created/dies along with the parent process). In otherwords Sidecars are supporting processes or services that are deployed with the primary application . Typically the side car would be deployed on the same host.
Common /supporting functions which can be handled using this pattern.
- log shipping
- monitoring
- configuration
- networking
- proxy to other services.
Advantages of side car pattern , rather than implement some thing as a library and run in the primary process space
- The side car can be coded in a different language than the primary service hence can be used by services coded in different languages , ie a common set of features for process coded in multiple languages/frameworks. If this is not the case then a library can also be considered.
- Since the side car is on the same host, there are no siginificant communication over heads.
- You get strong control over limiting resouce usage, eg you may not want log shipping to be part of primary process as it could hog memory. If limiting resource usage is not an issue then a library approach can be considered.
- Better fault isolation.
Ambassador pattern
The ambassador pattern is a speical case of side car pattern where a sidecar process acts as a out of process, colocated proxy server which makes network requests for the main process (which may be a legacy process hence hard to modify) . The ambassador may be a single proxy for multiple cleints or proxy per client . (This choice for example would depend on load and fault isolation) .The ambassador can be used for
- security,authentication,authorization
- routing
- circuit breaker pattern
- retries
- metering
- monitoring (eg network latency)
- updating network related configurations
note that legacy process can be hard to modify as
- the code base may not be actively maitained.
- coded in a language stack no longer actively used within the organization
- no developer is actively familiar with the code base