# Remote endpoints

With always-on tunnels you can put the front door of your CrushMFT server near your users, on other continents, while the data stays in one place.

## The idea

Your server is in the USA. Users in Europe and Australia reach it slowly, because every connection crosses an ocean. Put a small machine in each region. It accepts the users' connections nearby and carries them to the main server through an always-on tunnel.

| Name | Points to | Latency to the main server |
|---|---|---|
| `us.example.com` | the main server in the USA | 0 ms |
| `eu.example.com` | the endpoint machine in Europe | 120 ms |
| `au.example.com` | the endpoint machine in Australia | 220 ms |

- The main server has a **wildcard certificate**, `*.example.com`. The endpoints pass connections straight through to it, so the browser always gets that one certificate, and it matches every one of the names.
- **No data is stored on the endpoints.** Everything streams through. There is one storage location and one set of users.
- A user in Australia connects to `au.example.com`. Their own latency to that machine is perhaps 40 ms or less, so their connection is fast; the long distance is covered by the tunnel with its many channels.

## What it gains

One connection with 220 ms of latency reaches about 2.4 Mbit, with default TCP settings on both ends. A tunnel with 20 channels reaches about 48 Mbit. Set the number of channels to what your line can carry ([Server setup](Server-Setup.md)).

## Setting it up

1. On the main server, define the tunnel and the internal ports, and make a user for the endpoints with that tunnel ([Server setup](Server-Setup.md)).

   ![The tunnel granted to the endpoint's user](Remote-Endpoints/user_tunnel_client.png)

2. On each endpoint machine, run the tunnel as a service, pointed at the main server ([Always on](Always-On.md)).
3. Point each region's DNS name at its endpoint machine.

## Sizing the endpoints

The tunnel uses the CPU heavily, for the HTTPS encryption and for managing the channels, and the disk hardly at all (only for logging). Choose the endpoints' locations for the lowest latency to the users they serve.
