# Tuning configuration

These Liberator configuration items enable you to tune Liberator’s performance.

Other configuration items related to tuning are documented elsewhere. See the links at the foot of this page.

## buf-cache-size

`buf-cache-size` specifies the overall size of Liberator’s buffer cache in megabytes.

**📌 NOTE**\
We suggest a maximum value of 512 megabytes

**Syntax:** `buf-cache-size <size-in-megabytes>`

**Type:** integer

**Default value:** `16` megabytes

## buf-elem-len

`buf-elem-len` specifies the length of of a standard buffer element, in bytes. Increasing this improves performance if using very large messages, but it will considerably affect memory usage.

**📌 NOTE**\
We recommend using the default value of 4096 bytes.

**Syntax:** `buf-elem-len <length-in-bytes>`

**Type:** integer

**Default value:** `4096` bytes

## object-hash-size

`object-hash-size` specifies the size of the hashtable that Liberator uses to manage its objects. Increasing this item makes Liberator use extra memory, but it speeds up updates and requests if the value is high enough to ensure there aren’t too many hash collisions.

In addition to requested objects, Liberator allocates an internal object for each client session. So, at a minimum, set `object-hash-size` to: `max_num_objects + max_concurrent_users`.

We recommend that you set `object-hash-size` to _twice_ the maximum number of objects that Liberator is likely to handle. 

**Syntax:** `object-hash-size <size-in-table-entries>`

**Type:** integer

**Default value:** `16384`

## output-queue-size

`output-queue-size` specifies the number of update messages the Liberator stores per client. The main use for this item is when a client loses its connection to Liberator; while the connection is down, Liberator stores updates that are received for the client’s subscriptions and sends them to the client when the connection is re-established.

**💡 TIP**\
Increase the queue size if there are lots of reconnects, or if the data updates fast and the queue fills up quickly.

**Syntax:** `output-queue-size <size-in-messages>`

**Type:** integer

**Default value:** `64` messages

**Values accepted:** Maximum `4096` messages

## response-batch-size

`response-batch-size` specifies the maximum size in bytes of RTTP response messages. It only applies when the StreamLink connection type is "Streaming JavaScript via IFrame" ("type 5" connections).

**Syntax:** `response-batch-size <size-in-bytes>`

**Type:** integer

**Default value:** `0` (no maximum size is set)

## threads-num

threads-num specifies the number of client threads (session threads) that Liberator should use to serve RTTP clients.

If the value of threads-num is greater than the maximum number of threads supported by Liberator (see 'Values accepted' below), then Liberator logs a warning to the console and the event log, and reduces the number of client threads to 1.

When Liberator needs to handle a high number of user connections, increasing `threads-num` can improve performance, but this must take into account the number of CPUs on the machine running the Liberator. For more about this, see [Threading](liberator-threading.md) in Liberator Features and Concepts.

Liberator also uses additional threads for DataSource peer connections; see How can I... [Configure threads for peer communication](../datasource/datasource-configure-threads-for-peer-communication.md).

**Syntax:** `threads-num <max-number>`

**Type:** integer

**Default value:** `1`

**Values accepted:**

* Liberator 6.2.15 and higher: `1–64`
* Liberator 6.2.14 and lower: `1–10`

## thread-queue-notify-always

`thread-queue-notify-always` is a boolean item that, when set to `TRUE`, causes Liberator to record the size of Liberator’s threads queue in the event log every [thread-queue-notify-period](#thread-queue-notify-period) seconds.

**📌 NOTE**\
Only set this item when debugging a Liberator installation.

Alternatively, you can just configure Liberator to log the size of the threads queue when it exceeds a given size – see [thread-queue-notify-levels](#thread-queue-notify-levels).

An event log entry about the threads queue, typically looks like this:

```
2014/11/24-16:33:41.123 +0000: NOTIFY: Thread 0: Queue size is 0
```

**Syntax:** `thread-queue-notify-always <boolean>`

**Type:** boolean

**Default value:** `FALSE` (no time-based logging of the threads queue)

For more about the event log, see [Liberator logging](liberator-logging.md).

## thread-queue-notify-levels

`thread-queue-notify-levels` specifies an array of queue sizes at which Liberator logs information about the size of Liberator’s threads queue to the event log.

For example:

```
thread-queue-notify-levels 10 100
```

With the above configuration, Liberator reports the initial size of the threads queue, and if the size subsequently exceeds `10` entries, it logs the size. If after this, the queue size exceeds `100` entries, it logs the size again.

**📌 NOTE**\
Only set this item when debugging a Liberator installation.

Alternatively, you can just configure Liberator to log the size of the threads queue at regular intervals by setting [thread-queue-notify-always](#thread-queue-notify-always) and [thread-queue-notify-period](#thread-queue-notify-period).

If you specify `thread-queue-notify-levels` together with `thread-queue-notify-always` and `thread-queue-notify-period`, Liberator first logs the queue size when it exceeds the first level in `thread-queue-notify-levels`, and then writes log entries every `thread-queue-notify-period`.

**Syntax:** `thread-queue-notify-levels level-1 level-2 level-3 ...`

**Type:** integer

**Default value:** `10000 100000 1000000`

For more about the event log, see [Liberator logging](liberator-logging.md).

## thread-queue-notify-period

`thread-queue-notify-period` specifies the interval at which Liberator records the size of Liberator’s threads queue in the event log when [thread-queue-notify-always](#thread-queue-notify-always) is `TRUE`.

**📌 NOTE**\
Only set this item when debugging a Liberator installation.

**Syntax:** `thread-queue-notify-period <interval-in-seconds>`

**Type:** float

**Default value:** `0` seconds (timer is disabled)

For more about the event log, see [Liberator logging](liberator-logging.md).

## user-hash-size

`user-hash-size` specifies the size of the user hashtable for authorizing users who log in to Liberator.

**💡 TIP**\
We recommend setting `user-hash-size` to twice the expected maximum number of usernames.

**Syntax:** `user-hash-size <size-in-table-entries>`

**Type:** integer

**Default value:** `8192` entries

---

**See also:**

* [burst-increment](liberator-bursting-configuration.md#burst-increment) (in [Bursting configuration](liberator-bursting-configuration.md))
* [burst-max](liberator-bursting-configuration.md#burst-max) (in [Bursting configuration](liberator-bursting-configuration.md))
* [burst-min](liberator-bursting-configuration.md#burst-min) (in [Bursting configuration](liberator-bursting-configuration.md))
* [datasrc-tcp-nodelay-off](../datasource/datasource-datasource-peers-configuration-part-2.md#datasrc-tcp-nodelay-off) (in [DataSource peers configuration](../datasource/datasource-datasource-peers-configuration-part-2.md))
* [direct-tcp-nodelay-off](liberator-direct-connections-configuration.md#direct-tcp-nodelay-off) (in [Direct connections configuration](liberator-direct-connections-configuration.md))
* [http-tcp-nodelay-off](liberator-http-configuration-part-1.md#http-tcp-nodelay-off) (in [HTTP configuration](liberator-http-configuration-part-1.md))
* [object-delete-batchtime](liberator-object-configuration-part-2.md#object-delete-batchtime) (in [Object configuration](liberator-object-configuration-part-2.md))
* [object-delete-time](liberator-object-configuration-part-2.md#object-delete-time) (in [Object configuration](liberator-object-configuration-part-2.md))
* [object-throttle-default-level](liberator-throttling-configuration.md#object-throttle-default-level) (in [Throttling configuration](liberator-throttling-configuration.md))
* [object-throttle-off](liberator-throttling-configuration.md#object-throttle-off) (in [Throttling configuration](liberator-throttling-configuration.md))
* [object-throttle-times](liberator-throttling-configuration.md#object-throttle-times) (in [Throttling configuration](liberator-throttling-configuration.md))
* [session-absolute-max-queue-length](liberator-session-configuration.md#session-absolute-max-queue-length) (in [Session configuration](liberator-session-configuration.md))
* [session-hash-size](liberator-session-configuration.md#session-hash-size) (in [Session configuration](liberator-session-configuration.md))
* [session-max-queue-count](liberator-session-configuration.md#session-max-queue-count) (in [Session configuration](liberator-session-configuration.md))
* [session-max-queue-length](liberator-session-configuration.md#session-max-queue-length) (in [Session configuration](liberator-session-configuration.md))
* [thread-name](../datasource/datasource-datasource-peers-configuration-part-1.md#thread-name) option of [add-peer](../datasource/datasource-datasource-peers-configuration-part-1.md#add-peer) (in [DataSource peers configuration](../datasource/datasource-datasource-peers-configuration-part-1.md))
