Skip to content

Commit

Permalink
Update engine regions guide.
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanvugt committed Dec 10, 2023
1 parent 6c435b0 commit 5aee46d
Showing 1 changed file with 17 additions and 46 deletions.
63 changes: 17 additions & 46 deletions docs/guides/tips/engine-regions.md
Expand Up @@ -5,70 +5,41 @@ description: Tips and suggestions for choosing your Battlesnake's engine region.

# Choosing an Engine Region

### Why Engine Regions?
You can control where Battlesnake API requests originate from by selecting an appropriate engine region. This can be helpful when trying to minimize latency between your Battlesnake server and the game engine.

There are developers from all over the world in the Battlesnake community, and we've heard that latency can be a big issue. The main Battlesnake servers are currently located in the us-west2 (Oregon) datacenter operated by Amazon Web Services (AWS), and by default the response time of a Battlesnake request is measured from there. Although you can deploy your Battlesnake into a hosting provider that's close to Oregon, local development can end up being difficult if you're located on a different continent. Many services that make hosting easier, like Replit, also don't operate in regions that are nearby.
Choice of engine region does not affect which Battlesnakes you can play against, the rules of the game, or the matchmaking in arenas. The region selected is just used to measure the response time from your Battlesnake to each APi request.

### What are engine regions?
### What regions are available?

We've deployed servers around the world that can handle making the requests to your Battlesnake, and we can measure the response time of your Battlesnake as seen by a server that's geographically closer to where it's deployed. So if your snake is hosted on your home network somewhere in Europe, you can change a setting on your Battlesnake to send requests through the region in the Netherlands, and avoid losing several hundred milliseconds every turn in network latency between the main Battlesnake servers and your Battlesnake.
There are three engine regions available, all hosted on Google Cloud Platform.
* US-WEST (Oregon)
* US-EAST (Virginia)
* EUROPE (Netherlands)

Using these alternate regions does not affect which Battlesnakes you can play against, the rules of the game, or the matchmaking in arenas. The region is just used to measure the response time from your Battlesnake as seen from a different geographic location.

### How do I change my Battlesnake's region?

Go to your profile at [http://play.battlesnake.com/me](http://play.battlesnake.com/me), find the Battlesnake you want to change, and click "Edit". You'll see a dropdown called "Engine Region", which will default to the primary region in AWS US-WEST-2 (Oregon).

![Editing your Battlesnake](/img/wip/engine-region-1.png)

![Options for a Battlesnake's Engine Region](/img/wip/engine-region-2.png)

Selecting one of the other regions and clicking "Save" will refresh your Battlesnake's metadata through the region. If it's reachable and returns a valid response, you'll be able to see the new latency next to your Battlesnake. Hover your cursor over the "Latency" element to see the exact number in milliseconds. From now on, all [Battlesnake API requests](api/index.md) will go through the new engine region, hopefully giving your Battlesnake more time to think!

:::note
Sometimes persistent HTTP connections, DNS lookups, and other factors can cause the first request to a snake from a region to be slower than subsequent requests. If the latency seems higher than expected, try refreshing your Battlesnake again to get a more realistic estimate of the latency for most of the turns in a game.
:::
Each region is considered equal in terms of performance and availability.

### How should I choose an Engine Region?

Choosing the right Engine Region might be a little confusing depending on where you are, and where your Battlesnake is hosted. We highly encourage testing with a few different Engine Regions to see how it affects your latency. If you're worried about affecting your snake in a Leaderboard or Arena, you can make a new snake and re-use the URL.
Choosing the right engine region can depend on where you are located, and where your Battlesnake is hosted. We highly encourage testing with a few different regions to see how it impacts your latency to the game engine. If you're worried about testing different regions with a competitive Battlesnake, you can always make a second Battlesnake and re-use your production URL.

Here are some tips for common hosting setups:
Here are some tips for common hosting setups.

#### Running on [Replit](https://replit.com)

* Replit decides where to run your repl based on your geographic location. They have several datacenters around the world, and pick one automatically for you when you create the repl.
* If you're in North America, Replit currently seems to deploy in a region on the east coast. As a result, the "GCP US-EAST4" or "DigitalOcean TOR" regions may have lower latency.
* Otherwise, you should pick the region that's closest to you geographically.
* If you're traveling, or using a VPN, Replit might not detect your location accurately. In that case, test out the other regions and see if you get a better result.
Replit decides where to run your repl based on **your geographic location**, meaning you should choose the region that's closest to you geographically. If you're traveling, or using a VPN, Replit may not detect your location accurately. In that case, test out the other regions and see if you get a better result.

**Running locally with** [**Ngrok**](https://ngrok.com/)
#### Running locally with [Ngrok](https://ngrok.com/)

* Choose a region that's close to what Ngrok shows in the "Region" field in your terminal.
* You can force Ngrok to use a different region for a tunnel with the `--region` option.
Choose a region that's close to what Ngrok shows in the "Region" field in your terminal. You can force Ngrok to use a different region for a tunnel with the `--region` option.

#### Running on AWS, GCP, DigitalOcean
#### Running on AWS, GCP, or DigitalOcean

* Pick the region that's closest to the cloud provider's location/region you've deployed your code into.
* e.g. for AWS us-east-1, use "GCP US-EAST4".
Pick the region that's closest to the cloud provider's location/region you've deployed your code into. (e.g. for AWS us-east-1, use US-WEST)

#### Running on Railway

* Railway deployments run on GCP US-WEST, use the "GCP US-WEST1" engine region for optimal latency.
Railway deployments run on GCP US-WEST, use the US-WEST engine region for optimal latency.

#### Running on Heroku

* If you're using the "United States" Heroku region, use the "GCP US-EAST4" region.
* If you're using the "Europe" Heroku region, use the "GCP EUROPE-WEST4" region.

### Currently supported engine regions

* **Google Cloud Platform (GCP)**
* GCP US-WEST1 (Oregon)
* GCP US-EAST4 (Virginia)
* GCP EUROPE-WEST4 (Netherlands)
* GCP ASIA-SOUTH1 (Mumbai)
* GCP FRA (Frankfurt)
* GCP SGP (Singapore)
* GCP TOR (Toronto)

If you're using the "United States" Heroku region, use the US-EAST region. If you're using the "Europe" Heroku region, use the EUROPE region.

0 comments on commit 5aee46d

Please sign in to comment.