BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Domain-Driven Design with Value-Added Services and Domain Gateways at SoundCloud

Domain-Driven Design with Value-Added Services and Domain Gateways at SoundCloud

This item in japanese

Lire ce contenu en français

Bookmarks

Two articles were recently published to describe SoundCloud's service architecture evolution towards implementing Domain Gateways, with a stop at Value-Added Services on the way. The authors describe how these Domain-Driven Design-based patterns helped reduce duplications and homogenise business and authorisation logic.

A value-added service is a service that is responsible for providing aggregate entities to its callers. Domain gateways allow managing the same entity across different domains.

According to the authors, SoundCloud's first service architecture had two service layers: the edge services retrieved all data from the foundation services. Each edge service orchestrated all its calls and was also responsible for authorisation. Eventually, this pattern led to duplications in code and logic when different services evolved to use the same data in slightly different ways.

The authors write that the company's service architecture's second evolutionary step consisted in adding a third intermediate layer implementing the Value-Added Services (VAS) pattern. Such a switch to value-added services allowed to split responsibilities better. The edge layer provides API gateway capabilities and fulfils specific client needs, whereas the VAS layer consumes data from the foundation services, processing it into aggregate entities. Edge layer services then consume these aggregates.

Source: https://developers.soundcloud.com/blog/service-architecture-2

A pattern such as VAS brings some downsides, which the authors identified as a more extensive service landscape and increased network latencies due to the extra hops introduced by the new intermediate services. They considered using shared libraries instead and concluded that a VAS layer is preferable in their case.

Support for partial responses in the value-added services allows tailoring the amount of data returned to each client's needs. Partial responses may also reduce the number of network calls, but the authors state that the focus at SoundCloud is to manage complexity at the edge layer.

The authors add that their value-added services eventually grew to include the ability to modify entity data. Distinct interfaces isolated write operations from reading operations using the concepts of "command" and "query", which constitute the core of the well-known Command Query Responsibility Segregation (CQRS) pattern.

As SoundCloud's VAS grew in scope, it became noticeable that the same entities were being used in different domains with different purposes and authorisation requirements, the authors point out. The Domain Gateway pattern was the solution chosen to avoid implementing all possible variations in the same service. The authors describe these gateway services as VAS implementations tied to specific business domains.

According to the authors, the duplication introduced by gateway services makes sense "in cases in which the different domains have very different access patterns and highly disjoint feature sets, or when communication and collaboration between teams are difficult".

These two SoundCloud blog articles follow an earlier article about the Backends For Frontends pattern, already covered on InfoQ. An aggregate is a Domain-Driven Design pattern and represents a group of domain objects that can be treated as a single unit. The Value-Added Services and Domain Gateway patterns are forms of domain-oriented architectures at use in the industry.

Rate this Article

Adoption
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

BT