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 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 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.
provides a number of regions, each of which consists of one or more data centers
Currently, these regions are generally available:
- BRU (Brussels, Belgium, Europe)
- SFO (San Francisco, California, USA)
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.
Within each data center
, your deployment can consist of up to 10 instances. If you want to increase this limit, you can contact us
for a special offer.
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
In order to enable a new deployment in a different region, however, you can pass the
--regions option to Now CLI:
Running the above command will result in your new deployment getting enabled only
in the BRU region
. To enable it in both, pass both regions to the command:
If you want to scale to all regions, you can do it like this:
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 applied when
now is run. In turn, passing
--regions to the command while
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 the
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:
The above example will result in your deployment always having 4 instances
running in the data center
it was originally deployed to.
In order to let Now scale the deployment within a range, pass another argument with the maximum number of instances:
now scale <deployment> 4 7
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 Now scale your deployment automatically as requests come in, pass
now scale <deployment> auto
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 <deployment> 1 auto
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
now scale <deployment> sfo
Alternatively, you can also scale to all available regions
now scale <deployment> all
...or specify multiple:
now scale <deployment> sfo,bru
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.
No matter if you pass a region
or a data center
directly, the result will always be that your deployment gets the following scaling rules set in the target location:
- 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:
now scale <deployment> <regions|datacenters> 1 5
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.