May 13, 20244 minute read
Introducing: Region selection

Modal now allows you to select which cloud region you’d like your Functions to run in! As a reminder, Modal is a serverless compute platform that makes it easy for developers to run cloud workloads without managing the underlying infrastructure.

Modal region map

You can specify regions from around the world to run your Modal Functions in.

How to specify region(s)

Cloud region selection is available on the Team plan (for limited CPU use cases) and the Enterprise plan. Please email support@modal.com to get access to the feature. Once you’ve been granted access, specifying the cloud region for a Function requires just a line of code!

import os
import modal

app = modal.App("...")

@app.function(region="us-east") # also supports a list of options, for ex. region=["us-central", "us-east"]
def function():
    print(f"running in {os.environ['MODAL_REGION']}") # us-east-1, us-east-2, us-ashburn-1, etc.

In the example above, function will run on instances located in "us-east".

Region options

You can specify your desired region using varying levels of granularity. At the most granular level, you can directly specify the actual underlying region, like region=["eu-west-1", "eu-paris-1"]. We recommend using broader levels when possible, however, as this increases the pool of possible resources your Function can be assigned to and makes for faster cold starts.

Sampling of possible region strings below. Please see our docs for the full list.

  Broad              ->             Specific
 =====================================================
  "us"          "us-east"           "us-east-1"
                "us-central"        "us-east-2"
                "us-west"           "us-central1"
                                    "us-chicago-1"
                                    "us-west-1"
                                    ...
 -----------------------------------------------------
  "eu"          "eu-west"           "eu-central-1"
                "eu-north"          "eu-west-1"
                                    "eu-north-1"
                                    ...
 -----------------------------------------------------
  "ap"          "ap-northeast"      "asia-northeast3"
                "ap-southeast"      "asia-southeast1"
                "ap-melbourne"      "ap-southeast-3"
                                    "ap-melbourne-1"
                                    ...

Specifying regions also works when specifying the underlying cloud. For example, if you’re interested in running in AWS specifically, cloud="aws", region="us-east" would automatically filter for just "us-east-1" or "us-east-2" .

Use cases

There are a few reasons why you might want to specify a region for your Modal Functions:

  1. Regulatory requirements: your company may be subject to local regulation around where user data can be processed. GDPR, for example, places strict guardrails on when user data can leave the EU. Even if you can prove that you and your sub-processors provide an adequate level of data protection, some of your customers may still insist that their data never leaves a certain region. Specifying region="eu" will ensure that Functions run within EU datacenters.
  2. Reducing egress fees: if your Function needs to read data from a dependency like S3, you may be charged egress fees by the provider hosting that service if the data has to move across regions. This could add up to $100+/TB depending on which region your dependency is in!
  3. Reducing latency: if your applications are latency sensitive (e.g. real-time inference), you might want your app’s endpoints to be running near your users and/or near an external DB. In these cases, you can set your Functions to run in a region that is geographically proximate to your users and your existing control plane.

Have questions on region selection? Please reach out in our community Slack.

Ship your first app in minutes.

Get Started

$30 / month free compute