> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/operations/performance.md).

# Performance & limits

DNotifier enforces plan limits at authentication and at runtime. Understanding caps, chunking, and transport characteristics helps you design apps that stay within quota and feel responsive.

***

## Plan limits from auth

After `connect()`, read limits with `getPlanLimits()`:

| Field                   | Meaning                                            |
| ----------------------- | -------------------------------------------------- |
| `messagesHardLimit`     | Maximum messages per billing period                |
| `messageSizeLimit`      | Max single-message size in bytes (also chunk size) |
| `maxAIRequestsPerMonth` | AI call quota                                      |
| `maxAIWordsPerMonth`    | AI word quota                                      |
| `knowledgeBaseMaxWords` | Total indexed words allowed                        |
| `aiEnabled`             | Whether AI APIs are available                      |
| `maxUsers`              | Concurrent or registered user cap (per plan)       |
| `maxRowsPerUser`        | Per-user row limits where applicable               |

```js
await notifier.connect();
const limits = notifier.getPlanLimits();
console.log(limits.messageSizeLimit, limits.aiEnabled);
```

```dart
await notifier.connect();
final limits = notifier.getPlanLimits();
print('${limits?.messageSizeLimit}, AI: ${limits?.aiEnabled}');
```

Also available as instance properties after connect: `messageSizeLimit`, `aiEnabled`.

→ [Plan limits & quotas](/product-docs/realtime-communication/plan-limits.md) · [Pricing & plans](/product-docs/platform-overview/pricing.md)

***

## Message size and chunking

Payloads larger than `messageSizeLimit` are **split into chunks** on send and **reassembled** on receive. This is transparent for most apps if you use `send()` with structured `data`.

{% hint style="info" %}
Chunk size equals `messageSizeLimit` from your plan (commonly 32 KB). You do not configure chunk size manually.
{% endhint %}

| Practice                                                 | Why                              |
| -------------------------------------------------------- | -------------------------------- |
| Prefer structured `send()` over raw binary when possible | SDK handles framing and metadata |
| Handle reassembled messages only in `onMessage`          | Partial chunks are internal      |
| Test with files near and above the limit                 | Verify UI latency and memory     |

→ [Large messages & chunking](/product-docs/realtime-communication/chunking.md)

***

## Transport performance characteristics

| Transport            | Latency                     | Throughput                   | Best for                      |
| -------------------- | --------------------------- | ---------------------------- | ----------------------------- |
| **WebSocket (`ws`)** | Low — persistent connection | High for many small messages | Chat, live sync, push         |
| **HTTP (`http`)**    | Per-request overhead        | Good for bursty AI/RAG calls | `sendAI`, `search`, workflows |

### WebSocket tips

* One connection per user session — avoid opening duplicate sockets
* Batch UI updates from `onMessage` (e.g. debounce React state) under heavy traffic
* Reconnect with exponential backoff — do not hammer `connect()` in a tight loop

### HTTP tips

* Reuse one authenticated `DNotifier` instance — `connect()` is lightweight for HTTP
* Parallel `sendAI` calls count against monthly quotas — queue or rate-limit on your side
* Large document indexing: batch `addDocument` with backoff if you hit word limits

→ [Choose your transport](/product-docs/getting-started/choose-transport.md)

***

## AI and RAG quotas

| API                              | Quota impact                                   |
| -------------------------------- | ---------------------------------------------- |
| `sendAI`                         | AI requests and words                          |
| `addDocument` / `updateDocument` | Knowledge-base word count                      |
| `search`                         | Typically lighter; still subject to plan rules |
| `runWorkflow` with `ctx.sendAI`  | Each AI step counts                            |

Check `aiEnabled` before exposing AI features in your UI.

```js
if (!notifier.aiEnabled) {
  showUpgradePrompt();
  return;
}
```

→ [AI overview](/product-docs/ai/overview.md)

***

## Connection and memory

| Concern                   | Guidance                                                                   |
| ------------------------- | -------------------------------------------------------------------------- |
| **Mobile background**     | Disconnect when app is backgrounded to save battery                        |
| **Many concurrent users** | Scale horizontally — each user is one connection on your client fleet      |
| **Server workers**        | One `DNotifier` per worker process; scale workers, not sockets per worker  |
| **Binary payloads**       | Release `Blob` / buffer references after processing to avoid memory growth |

***

## Workflow performance

| Factor                             | Impact                                                 |
| ---------------------------------- | ------------------------------------------------------ |
| Sequential agents                  | Total time = sum of agent steps                        |
| `observability: true`              | Small HTTP overhead per recorded step                  |
| `ctx.search` + `ctx.sendAI` chains | Network-bound; minimize round trips where logic allows |

Design workflows with parallelizable work at the application level when latency matters.

→ [Workflow observability](/product-docs/workflows-and-agents/observability.md)

***

## Monitoring recommendations

| Metric                   | Source                                      |
| ------------------------ | ------------------------------------------- |
| Connect success rate     | Your app logs                               |
| Time to `onConnected`    | Client-side timing                          |
| Messages sent / received | Your analytics                              |
| AI usage                 | DNotifier dashboard + `getPlanLimits()`     |
| Workflow duration        | Workflow dashboard when observability is on |

***

## When you hit a limit

| Symptom                            | Likely cause                         | Action                                                               |
| ---------------------------------- | ------------------------------------ | -------------------------------------------------------------------- |
| Send fails or truncates            | `messageSizeLimit`                   | Compress media; use smaller payloads                                 |
| `sendAI` error                     | Monthly AI cap or `aiEnabled: false` | Upgrade plan or throttle usage                                       |
| `addDocument` rejected             | Knowledge-base word cap              | Prune old documents                                                  |
| Auth succeeds but features missing | Plan tier                            | Review [Pricing & plans](/product-docs/platform-overview/pricing.md) |

→ [Troubleshooting](/product-docs/operations/troubleshooting.md)

***

## Related guides

* [Production checklist](/product-docs/operations/production-checklist.md)
* [Debugging](/product-docs/operations/debugging.md)
* [FAQ](/product-docs/operations/faq.md)
