# Limits

> Size, count and time limits HotKV enforces, their defaults, and which ones you can configure.

URL: https://docs.hotkv.com/reference/limits/

These are the limits a HotKV server enforces. Where a limit comes from a
setting, the default is shown and the setting is linked to the
[configuration reference](https://docs.hotkv.com/reference/configuration/index.md). HotKV Cloud plans add
their own limits, such as memory and connections; see
[HotKV Cloud](https://docs.hotkv.com/quickstart-cloud/index.md).

## Keys and values

| Limit | Value | Setting |
| --- | --- | --- |
| Largest key or string value a client can send | 512 MB by default, up to 4294967295 bytes | [`proto-max-bulk-len`](https://docs.hotkv.com/reference/configuration/index.md#proto-max-bulk-len) |
| Largest string `APPEND` or `SETRANGE` can build | Same as above | `proto-max-bulk-len` |
| Highest bit offset (`SETBIT`, `GETBIT`, `BITFIELD`) | `proto-max-bulk-len` x 8 - 1 (4294967295 by default) | `proto-max-bulk-len` |
| Memory for `LCS` working data | Up to `proto-max-bulk-len`; past that the command fails with `ERR Insufficient memory, transient memory for LCS exceeds proto-max-bulk-len` | `proto-max-bulk-len` |
| Reply of `SRANDMEMBER`, `HRANDFIELD`, `ZRANDMEMBER` with a negative count | 512 MB; larger counts fail with `ERR count is too large, the reply would exceed 512 MB` | no |
| Total data | No limit by default; at the limit, writes fail with `OOM` or keys are evicted | [`maxmemory`](https://docs.hotkv.com/reference/configuration/index.md#maxmemory), [`maxmemory-policy`](https://docs.hotkv.com/reference/configuration/index.md#maxmemory-policy) |

## Commands and connections

| Limit | Value | Setting |
| --- | --- | --- |
| Elements in one command (name plus arguments) | 1,048,576 | no |
| Unprocessed input per client | 1 GB | [`client-query-buffer-limit`](https://docs.hotkv.com/reference/configuration/index.md#client-query-buffer-limit) (at least 1 MB) |
| Unprocessed input before a client authenticates | 1 MB | no |
| Unsent output before a client authenticates | 64 KB | no |
| Unsent output per client | `normal`: no limit; `replica`: 256 MB hard, 64 MB for 60 s; `pubsub`: 32 MB hard, 8 MB for 60 s | [`client-output-buffer-limit`](https://docs.hotkv.com/reference/configuration/index.md#client-output-buffer-limit) |
| Connected clients | 10,000 by default, 1 to 1,000,000 | [`maxclients`](https://docs.hotkv.com/reference/configuration/index.md#maxclients) |
| Addresses to listen on | 16 per `bind` (and per `tls-bind`) | no |
| Client names and library names | Printable characters, no spaces | no |

HotKV raises the process's open-file limit so that `maxclients` connections
fit. When the operating system does not allow that, `CONFIG SET maxclients`
fails and names the number of clients that fit.

A client that goes past an input or output limit is disconnected. A request
past the protocol limits gets `ERR Protocol error: invalid RESP data` and the
connection is closed (see [Protocol](https://docs.hotkv.com/reference/protocol/index.md#protocol-limits)).

## Databases and cluster

| Limit | Value | Setting |
| --- | --- | --- |
| Databases | 16 by default, 1 to 128 | [`databases`](https://docs.hotkv.com/reference/configuration/index.md#databases) |
| Databases on a cluster node | 1 by default, 1 to 128 with `cluster-databases` (set at startup) | [`cluster-databases`](https://docs.hotkv.com/reference/configuration/index.md#cluster-databases) |
| Hash slots | 16384 | no |
| Cluster node timeout | 15000 ms by default, up to 134217727 ms | [`cluster-node-timeout`](https://docs.hotkv.com/reference/configuration/index.md#cluster-node-timeout) |
| Announced address or name (`cluster-announce-ip`) | Shorter than 46 characters | [`cluster-announce-ip`](https://docs.hotkv.com/reference/configuration/index.md#cluster-announce-ip) |
| Announced host name | Shorter than 256 characters; letters, digits, `-` and `.` | [`cluster-announce-hostname`](https://docs.hotkv.com/reference/configuration/index.md#cluster-announce-hostname) |

For what these mean in practice, see [Clustering](https://docs.hotkv.com/clustering/index.md) and
[Cluster configuration](https://docs.hotkv.com/clustering/configuration/index.md).

## Scripts and functions

| Limit | Value | Setting |
| --- | --- | --- |
| Run time before other clients get `BUSY` | 5000 ms | [`busy-reply-threshold`](https://docs.hotkv.com/reference/configuration/index.md#busy-reply-threshold) |
| Scripts kept from `EVAL` | The 500 most recently used; older ones are dropped and `EVALSHA` of them gets `NOSCRIPT`. Scripts added with `SCRIPT LOAD` stay until `SCRIPT FLUSH`. | no |
| Run time of a library's top-level code during `FUNCTION LOAD` | 500 ms | no |
| Memory a running script may allocate | A script that allocates too much fails with Lua's `not enough memory` error. | no |
| Nesting of a script's reply | 1000 levels | no |

## Logs and introspection

| Limit | Value | Setting |
| --- | --- | --- |
| Slow log entries | 128 | [`slowlog-max-len`](https://docs.hotkv.com/reference/configuration/index.md#slowlog-max-len) |
| Arguments kept per slow log entry | 32 (the last one says how many more there were), each cut to 128 bytes | no |
| `ACL LOG` entries | 128, up to 1,000,000 with `CONFIG SET` | [`acllog-max-len`](https://docs.hotkv.com/reference/configuration/index.md#acllog-max-len) |
| `include` nesting in `hotkv.conf` | 16 levels | no |

## Probabilistic types

| Limit | Value |
| --- | --- |
| Bloom filter capacity (`BF.RESERVE`, `BF.INSERT`) | 1 to 1,073,741,824 items |
| Bloom filter expansion | 0 to 32768 |
| Size of one Bloom filter layer, Count-Min sketch or Top-K | 4 GB, and no more than the memory the server has free |

## Other settings with bounds

| Setting | Allowed values |
| --- | --- |
| [`maxmemory-samples`](https://docs.hotkv.com/reference/configuration/index.md#maxmemory-samples) | 1 to 64 |
| [`active-expire-effort`](https://docs.hotkv.com/reference/configuration/index.md#active-expire-effort) | 1 to 10 |
| [`hz`](https://docs.hotkv.com/reference/configuration/index.md#hz) | 1 to 500 with `CONFIG SET` |
| [`port`](https://docs.hotkv.com/reference/configuration/index.md#port), [`tls-port`](https://docs.hotkv.com/reference/configuration/index.md#tls-port) | 0 to 65535 |