r/cloudcomputing • • Aug 27 '23

Composition vs Aggregation design pattern w.r.t. to microservices?

Can someone please help me understand the difference between these two? Whatever I have read makes them sound exactly the same! Can you please provide an example to understand the difference?

TIA!!

4 Upvotes

3 comments sorted by

View all comments

Show parent comment

1

u/difftool Aug 28 '23

Thank you for explaining it in detail! Really appreciate it.

I understood the difference, however, let's say I add an API gateway. How does it change the dynamics now? Wouldn't the API gateway take care of both composition and aggregation now making the client feel it's the same thing?

1

u/Obsidian743 Aug 28 '23

The API gateway pattern doesn't do the domain work. It's context agnostic. It just handles routing and cross-cutting concerns like security and content negotiation. In terms of composition and aggregates, we're talking in terms of the worker services within their respective domains/contexts.