Chatty Service

Written by

in

Description

When a service requires multiple interactions with other services to complete a single task, it is considered “chatty” and leads to increased overhead. A high number of operations is required to complete one abstraction. Such operations are typically rather simple tasks that needlessly slow down an entire process.

Context

Derived from: “Chatty Service”

Consequences

Maintenance becomes harder, like e.g. changing the order of invocations. Many interactions are required, which leads to overall higher time consumption. This can be especially harmful when synchronous tasks are chained together.

Detection

A chatty service may have many fine-grained operations/responsibilities. It is suspicious when a service relates to many other services and makes use of them, especially when the provided functionality is rather simple. We count the number of edges between services and set a threshold as an acceptable number for interactions. If the number of edges exceeds the given threshold, it couod be a sign of “Chatty Service”. The threshold is set to three, though enterprise architects can adjust this based on their specific criteria.

Solution

Simple operations should not be made available to other elements. Instead, a more coarse-grained operation should be created to fulfill an abstraction.

Cypher query

MATCH (a)-[r]-(b) <br /> WHERE toLower(a.ClassName) contains 'service' and toLower(b.ClassName) contains 'service' <br /> WITH b, count(r) as cnt <br />WHERE cnt> $interactionCnt <br />MATCH p =(a)-[r1]-(b) <br />WHERE  toLower(a.ClassName) contains 'service' and toLower(b.ClassName) contains 'service'  <br />RETURN p

Cypher count query

MATCH (a)-[r]-(b) <br /> WHERE toLower(a.ClassName) contains 'service' and toLower(b.ClassName) contains 'service' <br /> WITH b, count(r) as cnt <br />WHERE cnt> $interactionCnt <br />MATCH p =(a)-[r1]-(b) <br />WHERE  toLower(a.ClassName) contains 'service' and toLower(b.ClassName) contains 'service'  <br /> RETURN COUNT (DISTINCT a)

Diagram

Diagram for Chatty Service

Tags

microservices, soa, business, application, technology, abstraction, data management, automatic detection

Query parameters

[
    {
        "name": "interactionCnt",
        "type": "number",
        "default": 3,
        "description": "The permissible count of related operation for a service that the chatty service communicate with."
    }
]

Related smells

All smells