> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/gateway/guides/devolutions-server/farms.md). Agents can also search and read this documentation through its [MCP server](https://docs.devolutions.net/~gitbook/mcp).

# Gateway farms in Devolutions Server

Group Devolutions Gateway instances in a farm in Devolutions Server to spread sessions by weight, skip down gateways and drain one for maintenance.

A gateway farm groups several Devolutions Gateway instances that reach the same networks. Entries select the farm instead of one gateway, and Devolutions Server picks a member for each new session:

* **Load distribution**: sessions are spread over the members according to their relative weight, so no single gateway is overloaded.
* **High availability**: a member that is down is skipped, so sessions still open while at least one member is available.
* **Maintenance without interruption**: drain a member to stop sending it new sessions while its running sessions continue, then update or restart it.

## Create a farm

1. Install and register each gateway: see [Register and configure the gateway in Devolutions Server](https://docs.devolutions.net/gateway/guides/devolutions-server/register-and-configure.md).
2. In the Devolutions Server web interface, go to ***Administration*** – ***Devolutions Gateway***.
3. Click ***Add*** – ***Gateway farm***.
4. In ***General***, enter a ***Name*** and, optionally, a ***Description***. Select ***Set as default*** to make the farm the default gateway, or ***Force Gateway rulesets*** to allow the farm only through Gateway rulesets.
5. In ***Members***, click ***Select farm members*** and select the gateways.
6. Set each member's ***Relative weight***.
7. In ***Role assignments***, assign the ***Gateway user*** role to the users and user groups that can use the farm. In ***Security***, choose the vaults in which the farm can be used.
8. Save.

You can also add a gateway to a farm from the gateway itself: edit it and choose the farm in ***General*** – ***Gateway farm***.

In Remote Desktop Manager, the same dialog opens from ***Administration*** – ***Privileged access*** – ***Devolutions Gateway*** – ***Add*** – ***Gateway farm***. With PowerShell, use `New-DSGatewayFarm` (`-Name`, `-MemberGateways`, `-Description`, `-Security`, `-IsDefault`), `Update-DSGatewayFarm` and `Remove-DSGatewayFarm`.

{% hint style="info" %}
Only one gateway, farm or Gateway Ruleset is the default at a time. If a farm is set as default while a gateway is the default, the farm becomes the default. A gateway belongs to one farm at a time: adding it to another farm moves it.
{% endhint %}

## Farm settings

<table><thead><tr><th width="250">SECTION</th><th>SETTINGS</th></tr></thead><tbody><tr><td><strong>General</strong></td><td><em><strong>Name</strong></em> (required), <em><strong>Description</strong></em>, <em><strong>Set as default</strong></em>, <em><strong>Force Gateway rulesets</strong></em>.</td></tr><tr><td><strong>Members</strong></td><td><em><strong>Select farm members</strong></em>, then per member: <em><strong>Name</strong></em>, <em><strong>Description</strong></em>, <em><strong>Relative weight</strong></em> and <em><strong>Drain</strong></em>.</td></tr><tr><td><strong>Role assignments</strong></td><td>The <em><strong>Gateway user</strong></em>, <em><strong>Gateway viewer</strong></em> and <em><strong>Gateway owner</strong></em> roles assigned on the farm. See <a href="https://docs.devolutions.net/gateway/guides/devolutions-server/register-and-configure.md">Register and configure the gateway in Devolutions Server</a>.</td></tr><tr><td><strong>Security</strong></td><td>The same options as a gateway: <em><strong>Permissions</strong></em> – <em><strong>Can use</strong></em>, <em><strong>Vaults</strong></em> (<em><strong>All</strong></em>, <em><strong>Custom</strong></em>, <em><strong>Never</strong></em>), <em><strong>Allow user vault</strong></em>, <em><strong>Allow dynamic connections</strong></em>, <em><strong>Allow RDP reconnection</strong></em> and <em><strong>RDP token reuse window (Minutes)</strong></em> (1 to 15).</td></tr><tr><td><strong>Farm information</strong></td><td><em><strong>ID</strong></em> of the farm.</td></tr></tbody></table>

The ***Gateway user*** role assignments and the security of the farm apply to all its members; those of a member have no effect while it is in the farm. The ***Gateway owner*** and ***Gateway viewer*** roles assigned on the farm do not apply to its members. A member's own ***Security*** section is hidden while it is in the farm: "This Gateway is currently in a farm. Its security can be defined in the farm." A member cannot be the default and cannot be selected alone in an entry: entries select the farm.

## How sessions are distributed

Each member has a target share of the farm's running sessions, set by its ***Relative weight*** (default 100, minimum 0). Only the ratio between weights matters: weights 1, 2 and 3 behave like 100, 200 and 300.

<table><thead><tr><th width="200">MEMBER</th><th width="150">WEIGHT</th><th>TARGET SHARE OF RUNNING SESSIONS</th></tr></thead><tbody><tr><td>Gateway1</td><td>100</td><td>100 / 600 = 16.7%</td></tr><tr><td>Gateway2</td><td>200</td><td>200 / 600 = 33.3%</td></tr><tr><td>Gateway3</td><td>300</td><td>300 / 600 = 50%</td></tr></tbody></table>

For each new session, Devolutions Server reads the number of running sessions of every usable member and sends the session to the member whose share of the running sessions is furthest below its target share. When several members are equally far below, one of them is picked at random. The split therefore follows the weights through the running sessions, not through chance.

A member is left out when it is down, when its configuration is not in sync, when it is draining, or when its weight is 0: a member with a weight of 0 never receives sessions. The target shares are then computed among the remaining members. With weights 1, 2 and 3 and Gateway2 down, Gateway1 aims at 25% of the running sessions and Gateway3 at 75%.

## Drain a member

Turn on ***Drain*** for a member in the farm's ***Members*** section. The member receives no new sessions, and its running sessions continue until they end. The gateway list shows it in the ***Draining*** column. Turn ***Drain*** off to put it back in rotation.

## Monitor, update and delete a farm

* **Health**: the farm's indicator reads "All Devolutions Gateways in the farm are up.", "Some Devolutions Gateway in the farm is down.", "All Devolutions Gateways in the farm are down.", "There is no usable Devolutions Gateway in the farm." or "There is no Devolutions Gateway in the farm." In an entry, ***Check health*** on a farm succeeds when at least one member is available.
* **Sessions**: the farm menu – ***Sessions*** lists the running sessions of all members; the ***Active Sessions*** column shows their total.
* **Update**: the farm menu – ***Update version*** updates every member that can be updated through Devolutions Agent. See [Register and configure the gateway in Devolutions Server](https://docs.devolutions.net/gateway/guides/devolutions-server/register-and-configure.md).
* **Which member was used**: the activity log of the session names the gateway and the farm ("A Devolutions Gateway token has been generated from the gateway '…' towards the host '…'", with the farm).
* **Delete**: the farm menu – ***Delete*** asks "Do you want to delete the Devolutions Gateway farm '{0}'?" Select ***Also, delete all Devolutions Gateways in the farm.*** to delete the members too; otherwise they become standalone gateways.

## Limits and messages

<table><thead><tr><th width="420">MESSAGE OR LIMIT</th><th>MEANING</th></tr></thead><tbody><tr><td>"There is no usable Devolutions Gateway in the farm."</td><td>No member is available for a new session: all are down, out of sync, draining or set to a weight of 0, or the farm is empty.</td></tr><tr><td>"The Devolutions Gateway associated farm cannot be found."</td><td>The farm was deleted. Choose another gateway in the entry.</td></tr><tr><td>"{0} is a Gateway Farm. Session recordings cannot be deleted."</td><td>Recordings cannot be deleted through a farm. See <a href="https://docs.devolutions.net/gateway/guides/recording.md">Record sessions</a>.</td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/gateway/guides/devolutions-server/farms.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
