---
id: "read-heavy-path-without-cache"
type: "rule"
severity: "warning"
url: "https://localhost:3000/catalogue/rules/read-heavy-path-without-cache"
---

# Read-heavy datastore without a cache

The design states a read-heavy workload and application servers read a datastore directly, but no cache exists.

| | |
|---|---|
| Severity | warning |
| Selects | every node of kind sql-database or nosql-database |
| Components in scope | 123 |

## Why

The design states a read-heavy workload and application servers read this datastore directly, yet the design has no cache anywhere. Every read pays a database round trip.

## What it checks

It looks at every node of kind sql-database or nosql-database, and fires when:

- all of these hold:
  - the design requirement `traffic.readWriteRatio` is a number greater than 10
  - the node has at least one synchronous incoming edge from an app-server
  - this does not hold:
    - the design contains a node of kind cache

Message template:

```
Datastore '{{node.id}}' serves a read-heavy workload directly from application servers and the design has no cache.
```

## Applies to

- [NoSQL database](https://localhost:3000/catalogue/kinds/nosql-database.md) `nosql-database`
- [SQL database](https://localhost:3000/catalogue/kinds/sql-database.md) `sql-database`

123 catalogue components fall under it.

## Tripped by

Reference designs whose broken twin names this rule in its header:

- [object-storage](https://localhost:3000/d/zeema/object-storage)

## Source (`rule` YAML, verbatim)

```yaml
# yaml-language-server: $schema=../schema/rule.schema.json
# The design states a read-heavy workload and application servers read this datastore
# directly, yet no cache exists anywhere in the design. Every read pays a database round trip.
# Tripped by: designs/object-storage.broken.yaml
schemaVersion: "1"
type: "rule"
id: "read-heavy-path-without-cache"
severity: "warning"
select:
  node:
    kind: ["sql-database", "nosql-database"]
when:
  all:
    - requirement: "traffic.readWriteRatio"
      gt: 10
    - hasEdge:
        direction: "in"
        mode: "sync"
        peerKind: "app-server"
    - not:
        hasNode:
          kind: "cache"
message: "Datastore '{{node.id}}' serves a read-heavy workload directly from application servers and the design has no cache."
```

Human page: https://localhost:3000/catalogue/rules/read-heavy-path-without-cache
