Nanoservices

Written by

in

Description

A nano service is a fine-grained service with a simple operation that implements only a part of an abstraction and exchanges a large amount of information with a group of services to complete an abstraction task.

Context

Derived from: “Nanoservices”
A SOA is often created by combining several relatively simple services. These services may not have been built with an SOA scenario in mind, but may rely more on simple RPC interaction. This may produce a large number of calls between services.

Cause

Hidden or unclear requirements make it very hard to identify fitting abstractions. Sometimes, individual use cases are therefore mapped to separate services. Misunderstanding or wrongly applying patterns may also lead to nanoservices.

Consequences

Bad performance, fragmented logic, and an overhead in maintenance efforts. The functionality of one core abstraction is scattered across multiple services. This means multiple services may have to be changed to address a single feature or concept. Testing such a feature therefore also involves several services.

Detection

A nanoservice interface provides only one or very few operations. A nanoservice generally implements an incomplete subset of one abstraction.

Solution

Consolidate and merge the scattered, but related functionality into a single service.

Example

Single services for creating an order, delivering an order, updating an order, and approving an order.

Cypher query

MATCH (a)-[r:CompositionRelationship]-(n) <br />  WITH a, COUNT(n) AS cnt  WHERE cnt >= $nanoServiceCount <br /> MATCH p=(a)-[r:CompositionRelationship]-(n) <br /> RETURN p <br /> UNION <br /> MATCH (a)-[r:CompositionRelationship]-(n) <br /> WITH a, COUNT(n) AS cnt <br /> WHERE cnt >= $nanoServiceCount <br /> MATCH p1=(a)-[r:CompositionRelationship]-(n) <br /> WITH p1, nodes(p1) AS nodes CALL apoc.nodes.cycles(nodes, {maxDepth: $nanoServiceCount}) YIELD path WITH path AS p2, p1 <br /> UNWIND [p1,p2] AS p <br /> RETURN p

Cypher count query

MATCH (a)-[r:CompositionRelationship]->(n) WITH a, COUNT(n) AS cnt WHERE cnt >= $nanoServiceCount MATCH p1=(a)-[r:CompositionRelationship]->(n) return count (distinct n)

Diagram

Diagram for Nanoservices

Aliases

Solution Sprawl, Fine-Grained Services

Tags

microservices, soa, business, application, technology, abstraction, The Dispensables, between elements

Query parameters

[
    {
        "name": "nanoServiceCount",
        "type": "number",
        "default": 3,
        "description": "Number of nanoservices."
    }
]

Related smells

All smells