> 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-cloud/farms.md). Agents can also search and read this documentation through its [MCP server](https://docs.devolutions.net/~gitbook/mcp).

# Gateway farms in Devolutions Cloud

Group Devolutions Gateway instances in a farm in Devolutions Cloud 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 a member is picked for each new session:

* **Load distribution**: sessions are spread over the members according to their relative weight.
* **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.

{% hint style="warning" %}
Gateway farms in Devolutions Cloud need the PAM Service installed and running on your network. See [Install the Devolutions Cloud Services to enable PAM and encryption integration](https://docs.devolutions.net/pam/pam-with-devolutions-cloud/install-the-devolutions-cloud-services-to-enable-pam-and-encryption-integration).
{% endhint %}

## Create a farm

1. Install and register each gateway: see [Register and configure the gateway in Devolutions Cloud](https://docs.devolutions.net/gateway/guides/devolutions-cloud/register-and-configure.md).
2. In the Devolutions Cloud 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***, select the gateways and set each member's ***Relative weight***.
6. In ***Vaults***, ***Groups*** and ***Users***, choose where and by whom the farm can be used.
7. Click ***Add***.

You can also add a gateway to a farm by editing it and choosing the farm in ***General*** – ***Gateway farm***. ***Farm information*** shows the farm ***ID***.

{% hint style="info" %}
Only one gateway, farm or Gateway Ruleset is the default at a time: setting a farm as default replaces the previous default. A gateway belongs to one farm at a time.
{% endhint %}

## Security of the members

The farm's ***Vaults***, ***Groups*** and ***Users*** apply to all its members. A member's own security tabs show "This Gateway is currently in a farm. Its security can be defined in the farm." A member 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***. 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, the PAM Service reads the number of running sessions of every available 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 unavailable, 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*** tab. The member receives no new sessions; its running sessions continue until they end. Turn ***Drain*** off to put it back in rotation.

## Monitor and delete a farm

* **Health**: "All Devolutions Gateways in the farm are up.", "Some Devolutions Gateway in the farm is down.", "All Devolutions Gateways in the farm are down." 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 row – ***More*** – ***Sessions*** lists the sessions of all members.
* **Which member was used**: the session's activity log names the gateway and the farm.
* **Delete**: "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.

## Good to know

* Choosing a Devolutions Agent on an entry is not supported with a farm: "Choosing an agent is not supported when the gateway is a farm. Select a gateway that is not part of a farm." See [Agent tunnel](https://docs.devolutions.net/gateway/guides/connect/agent-tunnel.md).
* Update the members one by one from their own rows: see [Register and configure the gateway in Devolutions Cloud](https://docs.devolutions.net/gateway/guides/devolutions-cloud/register-and-configure.md).
* "There is no usable Devolutions Gateway in the farm." means no member is available for a new session.


---

# 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-cloud/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.
