In this feature guide, you will learn how to globally distribute your deployment in order to minimize the latency your visitors are experiencing when accessing your content from around the globe.
First of all, it is very important to understand that – if you decide to scale your deployment to a certain region – you need to ensure that all other parts of your system are optimized for this region as well.
If you are using a database service, for example, make sure that your data is available in the region that you would like to enable on ZEIT Now. The same goes for all the APIs your deployment is consuming.
Once you have ensured all of these services are running in your desired region, you can expect the maximum out of performance when scaling your deployment to this region.
When scaling deployments on ZEIT Now, it is necessary that you understand the meaning of the following terms (sorted by least granular to most granular):
After you have decided to enable your deployment in a certain part of the world, regions are the best way to tell Now where exactly it should scale your deployment to.
Now provides a number of regions, each of which consists of one or more data centers.
Now 1.0 runs in two regions:
bru1- Brussels, Belgium
sfo1- San Francisco, USA
However, static content is cached in all edge regions. You can find the full list of regions in the regions and providers documentation.
As the previous section describes it, data centers are the next level of granularity when talking about deployments: Every region consists of multiple data centers.
If you choose to enable your deployment in a specific region, it will be enabled in one data center within that region. In most cases, this will be the best choice, because it fulfills the promise of providing visitors in that region with the most minimal latency possible.
In some cases, you might want to enable your deployment in multiple data centers within the same region (if you are experiencing significant load or require even higher availability, for example).
When making this decision, however, it is essential to keep in mind that you can also scale your deployment to multiple instances within the same data center:
Once your deployment is enabled in a specific data center, multiple copies ("Instances") of that deployment might be automatically created if the following statements are true:
- The personal account or team you have created the deployment with is currently on a paid plan and not restricted in any way.
- Your deployment is receiving a lot of traffic from the outside or you have configured scaling rules for the datacenter.
By default, your deployment will only be enabled in the region that is the closest to your current location.
For example: If you are currently somewhere in the USA, your deployment will be enabled in the SFO region by default.
In order to enable a new deployment in a different region, however, you can
--regions option to
Running the above command will result in your new deployment getting enabled only in the BRU region. To enable it in both BRU and SFO, pass both regions to the command:
In cases where you want to enable every new deployment of a specific project in multiple regions, you can pre-define scaling rules in your local configuration file like this.
Once that has been done, these rules will be automatically
now is run. In turn,
--regions to the command
scale is defined in your
configuration file will lead to an error.
You only need one of the two.
If you want to manually set scaling rules for your deployment
after it has been created, you can do so by using
now scale command.
By default, every deployment receives the following scaling rules from our system:
- Minimum: 0 (freezes if no requests come in)
- Maximum: 10 (if created on a paid plan, the deployment may be automatically scaled to up to 10 instances if a significant amount of requests come in)
In order to lock the number of instances of a specific deployment, you can run this command:
In order to let ZEIT Now scale the deployment within a range, pass another argument with the maximum number of instances:
After running this command, the deployment you passed will always have at least 4 instances running, but never exceed 7 instances.
To revert back to the default scaling rules and
let ZEIT Now scale your deployment automatically
as requests come in, pass
This also works for just one of the two scaling rules. As an example, this command will ensure your deployment always has at least 1 instance running (therefore never freezes) but allows it to scale indefinitely:
now scale, you can
also scale your deployment to additional regions
or data centers after it has been created.
As an example, this command will scale your deployment to the SFO region:
Alternatively, you can also scale to all available regions...
...or specify multiple:
You can also use this command to enable your deployment in a specific data center of your choice, by passing the data center name instead of the region name.
- Minimum: 0 (freezes if no requests come in)
- Maximum: 10 (if created on a paid plan, the deployment may be automatically scaled to up to 10 instances if a lot of requests come in)
In order to lock a region or data center to specific scaling rules, you can still append them as you would do without passing a location:
As an example, the above command would set the following rules:
- Minimum: 1 (never freezes, even if no requests come in)
- Maximum: 5 (no more than 5 instances can be running)
Once you have executed such a command, the copy of your deployment running in the location of your choice can only scale automatically in between those boundaries.