Skip to content

Nats[2.10.21] inaccessible consumers in nats with 3 node cluster, slowness in publishing messages, high CPU and memory, idle consumers #6296

@ayush3890

Description

@ayush3890

Observed behavior

Experiencing extreme slowness in nats 3 nodes cluster.
Following are observations:

Output of nats consumer report stream_name:

╭────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                             Consumer report for stream_name with 17 consumers                                                            │
├─────────────────────────────────┬──────┬────────────┬──────────┬─────────────┬─────────────┬─────────────┬────────────┬────────────────────────────────────────────┤
│ Consumer                          │ Mode │ Ack Policy │ Ack Wait │ Ack Pending │ Redelivered │ Unprocessed │ Ack Floor  │ Cluster                                    │
├─────────────────────────────────  ┼──────┼────────────┼──────────┼─────────────┼─────────────┼─────────────┼────────────┼────────────────────────────────────────────┤
│ stream_name_consumer_C1           │ Pull │ Explicit   │ 30.00s   │ 0           │ 0           │ 0           │ 35,467,403 │ commonnats-0*, commonnats-1, commonnats-2  │
│ stream_name_consumer_C2           │ Push │ Explicit   │ 30.00s   │ 0           │ 0           │ 0           │ 35,454,304 │ commonnats-0*, commonnats-1, commonnats-2  │
│ stream_name_consumer_C3           │ Pull │ Explicit   │ 30.00s   │ 0           │ 0           │ 0           │ 29,837,246 │ commonnats-0, commonnats-1, commonnats-2*  │
│ stream_name_consumer_C4           │ Pull │ Explicit   │ 30.00s   │ 0           │ 0           │ 0           │ 19,441,635 │ commonnats-0, commonnats-1*, commonnats-2  │
│ stream_name_consumer_C5           │ Pull │ Explicit   │ 30.00s   │ 3           │ 425         │ 6,011 / 3%  │ 35,458,893 │ commonnats-0*, commonnats-1, commonnats-2  │
│ stream_name_consumer_C5           │ Pull │ Explicit   │ 30.00s   │ 0           │ 0           │ 0           │ 0          │ commonnats-0*, commonnats-1, commonnats-2! │
│ stream_name_consumer_C6           │ Pull │ Explicit   │ 10m0s    │ 0           │ 0           │ 0           │ 0          │ commonnats-0!, commonnats-1, commonnats-2* │
│ stream_name_consumer_C7           │ Pull │ Explicit   │ 10m0s    │ 0           │ 0           │ 0           │ 0          │ commonnats-0*, commonnats-1, commonnats-2! │
│ stream_name_consumer_C8           │ Push │ Explicit   │ 30.00s   │ 0           │ 0           │ 0           │ 35,454,281 │ commonnats-0, commonnats-1, commonnats-2*  │
│ stream_name_consumer_C9           │ Pull │ Explicit   │ 30.00s   │ 0           │ 10          │ 0           │ 35,454,322 │ commonnats-0, commonnats-1, commonnats-2*  │
│ stream_name_consumer_C10          │ Pull │ Explicit   │ 10m0s    │ 0           │ 0           │ 0           │ 0          │ commonnats-0!, commonnats-1*, commonnats-2 │
│ stream_name_consumer_C11          │ Pull │ Explicit   │ 10m0s    │ 0           │ 0           │ 0           │ 0          │ commonnats-0*, commonnats-1, commonnats-2  │
│ stream_name_consumer_C12          │ Pull │ Explicit   │ 10m0s    │ 0           │ 0           │ 0           │ 19,441,635 │ commonnats-0*, commonnats-1, commonnats-2  │
│ stream_name_consumer_C13          │ Pull │ Explicit   │ 30.00s   │ 0           │ 0           │ 0           │ 29,701,253 │ commonnats-0, commonnats-1, commonnats-2*  │



╭─────────────────────────────────────────────────────────────────────────────────────────   ╮
│                                  Inaccessible Consumers                                    │
├────────────────────────   ┬────────────────────────────────────┬────────────────────────┬──┤
│ stream_name_consumer_CF1  │ stream_name_consumer_CF2           │ stream_name_consumer_CF3  │
╰────────────────────────   ┴────────────────────────────────────┴────────────────────────┴──╯

Output of nats server ls from all 3 nodes:

➜  ~ nats server ls --context=n0
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                            Server Overview                                                            │
├──────────────┬────────────┬──────┬─────────┬─────┬───────┬───────┬────────┬─────┬─────────┬───────┬───────┬──────┬────────────┬───────┤
│ Name         │ Cluster    │ Host │ Version │ JS  │ Conns │ Subs  │ Routes │ GWs │ Mem     │ CPU % │ Cores │ Slow │ Uptime     │ RTT   │
├──────────────┼────────────┼──────┼─────────┼─────┼───────┼───────┼────────┼─────┼─────────┼───────┼───────┼──────┼────────────┼───────┤
│ commonnats-0 │ commonnats │ 0    │ 2.10.21 │ yes │ 8     │ 1,129 │      8 │   0 │ 3.4 GiB │ 200   │     8 │    0 │ 32d1h1m51s │ 220ms │
│ commonnats-1 │ commonnats │ 0    │ 2.10.21 │ yes │ 1     │ 1,130 │      8 │   0 │ 2.9 GiB │ 204   │     8 │    0 │ 5d2h22m38s │ 395ms │
├──────────────┼────────────┼──────┼─────────┼─────┼───────┼───────┼────────┼─────┼─────────┼───────┼───────┼──────┼────────────┼───────┤
│              │ 1          │ 2    │         │ 2   │ 9     │ 2,259 │        │     │ 6.3 GIB │       │       │    0 │            │       │
╰──────────────┴────────────┴──────┴─────────┴─────┴───────┴───────┴────────┴─────┴─────────┴───────┴───────┴──────┴────────────┴───────╯

╭───────────────────────────────────────────────────────────────────────────────╮
│                                Cluster Overview                               │
├────────────┬────────────┬───────────────────┬───────────────────┬─────────────┤
│ Cluster    │ Node Count │ Outgoing Gateways │ Incoming Gateways │ Connections │
├────────────┼────────────┼───────────────────┼───────────────────┼─────────────┤
│ commonnats │          2 │                 0 │                 0 │           9 │
├────────────┼────────────┼───────────────────┼───────────────────┼─────────────┤
│            │          2 │                 0 │                 0 │           9 │
╰────────────┴────────────┴───────────────────┴───────────────────┴─────────────╯
➜  ~ nats server ls --context=n1
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                            Server Overview                                                            │
├──────────────┬────────────┬──────┬─────────┬─────┬───────┬───────┬────────┬─────┬─────────┬───────┬───────┬──────┬────────────┬───────┤
│ Name         │ Cluster    │ Host │ Version │ JS  │ Conns │ Subs  │ Routes │ GWs │ Mem     │ CPU % │ Cores │ Slow │ Uptime     │ RTT   │
├──────────────┼────────────┼──────┼─────────┼─────┼───────┼───────┼────────┼─────┼─────────┼───────┼───────┼──────┼────────────┼───────┤
│ commonnats-1 │ commonnats │ 0    │ 2.10.21 │ yes │ 3     │ 1,131 │      8 │   0 │ 2.9 GiB │ 102   │     8 │    0 │ 5d2h23m20s │ 31ms  │
│ commonnats-2 │ commonnats │ 0    │ 2.10.21 │ yes │ 8     │ 1,132 │      8 │   0 │ 715 MiB │ 200   │     8 │    0 │ 32d1h2m33s │ 64ms  │
│ commonnats-0 │ commonnats │ 0    │ 2.10.21 │ yes │ 7     │ 1,130 │      8 │   0 │ 3.0 GiB │ 204   │     8 │    0 │ 32d1h2m33s │ 163ms │
├──────────────┼────────────┼──────┼─────────┼─────┼───────┼───────┼────────┼─────┼─────────┼───────┼───────┼──────┼────────────┼───────┤
│              │ 1          │ 3    │         │ 3   │ 18    │ 3,393 │        │     │ 6.6 GIB │       │       │    0 │            │       │
╰──────────────┴────────────┴──────┴─────────┴─────┴───────┴───────┴────────┴─────┴─────────┴───────┴───────┴──────┴────────────┴───────╯

╭───────────────────────────────────────────────────────────────────────────────╮
│                                Cluster Overview                               │
├────────────┬────────────┬───────────────────┬───────────────────┬─────────────┤
│ Cluster    │ Node Count │ Outgoing Gateways │ Incoming Gateways │ Connections │
├────────────┼────────────┼───────────────────┼───────────────────┼─────────────┤
│ commonnats │          3 │                 0 │                 0 │          18 │
├────────────┼────────────┼───────────────────┼───────────────────┼─────────────┤
│            │          3 │                 0 │                 0 │          18 │
╰────────────┴────────────┴───────────────────┴───────────────────┴─────────────╯
➜  ~ nats server ls --context=n2
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                            Server Overview                                                            │
├──────────────┬────────────┬──────┬─────────┬─────┬───────┬───────┬────────┬─────┬─────────┬───────┬───────┬──────┬────────────┬───────┤
│ Name         │ Cluster    │ Host │ Version │ JS  │ Conns │ Subs  │ Routes │ GWs │ Mem     │ CPU % │ Cores │ Slow │ Uptime     │ RTT   │
├──────────────┼────────────┼──────┼─────────┼─────┼───────┼───────┼────────┼─────┼─────────┼───────┼───────┼──────┼────────────┼───────┤
│ commonnats-2 │ commonnats │ 0    │ 2.10.21 │ yes │ 8     │ 1,130 │      8 │   0 │ 724 MiB │ 201   │     8 │    0 │ 32d1h2m35s │ 131ms │
├──────────────┼────────────┼──────┼─────────┼─────┼───────┼───────┼────────┼─────┼─────────┼───────┼───────┼──────┼────────────┼───────┤
│              │ 1          │ 1    │         │ 1   │ 8     │ 1,130 │        │     │ 724 MIB │       │       │    0 │            │       │
╰──────────────┴────────────┴──────┴─────────┴─────┴───────┴───────┴────────┴─────┴─────────┴───────┴───────┴──────┴────────────┴───────╯

╭───────────────────────────────────────────────────────────────────────────────╮
│                                Cluster Overview                               │
├────────────┬────────────┬───────────────────┬───────────────────┬─────────────┤
│ Cluster    │ Node Count │ Outgoing Gateways │ Incoming Gateways │ Connections │
├────────────┼────────────┼───────────────────┼───────────────────┼─────────────┤
│ commonnats │          1 │                 0 │                 0 │           8 │
├────────────┼────────────┼───────────────────┼───────────────────┼─────────────┤
│            │          1 │                 0 │                 0 │           8 │
╰────────────┴────────────┴───────────────────┴───────────────────┴─────────────╯
➜  ~

Output of nats server report jetstream:

➜  ~ nats server report jetstream --context=n0
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                JetStream Summary                                                │
├──────────────┬────────────┬─────────┬───────────┬──────────┬─────────┬────────┬─────────┬─────────┬─────────────┤
│ Server       │ Cluster    │ Streams │ Consumers │ Messages │ Bytes   │ Memory │ File    │ API Req │ API Err     │
├──────────────┼────────────┼─────────┼───────────┼──────────┼─────────┼────────┼─────────┼─────────┼─────────────┤
│ commonnats-2 │ commonnats │ 8       │ 43        │ 182,288  │ 121 MiB │ 0 B    │ 121 MiB │ 632,900 │ 84 / 0.013% │
├──────────────┼────────────┼─────────┼───────────┼──────────┼─────────┼────────┼─────────┼─────────┼─────────────┤
│              │            │ 8       │ 43        │ 182,288  │ 121 MIB │ 0 B    │ 121 MIB │ 632,900 │ 84          │
╰──────────────┴────────────┴─────────┴───────────┴──────────┴─────────┴────────┴─────────┴─────────┴─────────────╯


WARNING: No cluster meta leader found. The cluster expects 3 nodes but only 1 responded. JetStream operation require at least 2 up nodes.
➜  ~ nats server report jetstream --context=n1
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                JetStream Summary                                                │
├──────────────┬────────────┬─────────┬───────────┬──────────┬─────────┬────────┬─────────┬─────────┬─────────────┤
│ Server       │ Cluster    │ Streams │ Consumers │ Messages │ Bytes   │ Memory │ File    │ API Req │ API Err     │
├──────────────┼────────────┼─────────┼───────────┼──────────┼─────────┼────────┼─────────┼─────────┼─────────────┤
│ commonnats-2 │ commonnats │ 8       │ 43        │ 182,285  │ 121 MiB │ 0 B    │ 121 MiB │ 632,904 │ 84 / 0.013% │
├──────────────┼────────────┼─────────┼───────────┼──────────┼─────────┼────────┼─────────┼─────────┼─────────────┤
│              │            │ 8       │ 43        │ 182,285  │ 121 MIB │ 0 B    │ 121 MIB │ 632,904 │ 84          │
╰──────────────┴────────────┴─────────┴───────────┴──────────┴─────────┴────────┴─────────┴─────────┴─────────────╯


WARNING: No cluster meta leader found. The cluster expects 3 nodes but only 1 responded. JetStream operation require at least 2 up nodes.
➜  ~ nats server report jetstream --context=n2
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                JetStream Summary                                                │
├──────────────┬────────────┬─────────┬───────────┬──────────┬─────────┬────────┬─────────┬─────────┬─────────────┤
│ Server       │ Cluster    │ Streams │ Consumers │ Messages │ Bytes   │ Memory │ File    │ API Req │ API Err     │
├──────────────┼────────────┼─────────┼───────────┼──────────┼─────────┼────────┼─────────┼─────────┼─────────────┤
│ commonnats-2 │ commonnats │ 8       │ 43        │ 182,284  │ 121 MiB │ 0 B    │ 121 MiB │ 632,906 │ 84 / 0.013% │
├──────────────┼────────────┼─────────┼───────────┼──────────┼─────────┼────────┼─────────┼─────────┼─────────────┤
│              │            │ 8       │ 43        │ 182,284  │ 121 MIB │ 0 B    │ 121 MIB │ 632,906 │ 84          │
╰──────────────┴────────────┴─────────┴───────────┴──────────┴─────────┴────────┴─────────┴─────────┴─────────────╯


WARNING: No cluster meta leader found. The cluster expects 3 nodes but only 1 responded. JetStream operation require at least 2 up nodes.

Output of nats stream subjects:

╭─────────────────────────────────────╮
│      6 Subjects in stream cy_co     │
├────────────────────────────┬────────┤
│ Subject                    │ Count  │
├────────────────────────────┼────────┤
│ S1                        │ 1      │
│ S2                        │ 21     │
│ S3                        │ 1,322  │
│ S4                        │ 19,755 │
│ S5                        │ 53,608 │
│ S5                        │ 85,620 │
╰────────────────────────────┴────────╯

Sudden increase in Cluster NTT
image

Sudden increase in Poll Time
image

CPU usage:
image

Memory usage:
image

Resource and limit:

      resources:
        limits:
          cpu: '2'
          memory: 6Gi
        requests:
          cpu: '2'
          memory: 6Gi

Env variables:

        - name: GOMEMLIMIT
          value: 5GiB

Nats configuration:

{
  "accounts": {
    "acc1": {
      "jetstream": "enabled",
      "users": [
        {
          "password": <PASS>,
          "user": "<USER>"
        }
      ]
    },
    "SYS": {
      "users": [
        {
          "password": <ADMIN_PASS>,
          "user": "<ADMIN_USER>"
        }
      ]
    }
  },
  "cluster": {
    "name": "commonnats",
    "no_advertise": true,
    "port": 6222,
    "routes": [
      "nats://commonnats-0.commonnats-headless:6222",
      "nats://commonnats-1.commonnats-headless:6222",
      "nats://commonnats-2.commonnats-headless:6222"
    ]
  },
  "debug": true,
  "http_port": 8222,
  "jetstream": {
    "max_file_store": 150Gi,
    "max_memory_store": 0,
    "store_dir": "/data"
  },
  "lame_duck_duration": "30s",
  "lame_duck_grace_period": "10s",
  "pid_file": "/var/run/nats/nats.pid",
  "ping_interval": "2m",
  "ping_max": 2,
  "port": 4222,
  "server_name": $SERVER_NAME,
  "system_account": "SYS"
}

Expected behavior

Under load, nats should deliver messages to consumer without any slowness

Server and client version

Nats Server Version 2.10.21
Nats Client Version 1.37.0 (Golang Application)

Host environment

  1. K8's cluster
  2. helm chart:
  - repoURL: 'https://nats-io.github.io/k8s/helm/charts/'
    targetRevision: 1.2.5
    chart: nats

Steps to reproduce

No steps to reproduce. Happening randomly. Happened 3 times in last 3 months

  • I am available to hop on a quick call to get this issue debugged

Metadata

Metadata

Assignees

No one assigned

    Labels

    defectSuspected defect such as a bug or regressionstaleThis issue has had no activity in a while

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions