Install the Upstash Waiting Room integration
Install Upstash Waiting Room from Azion Marketplace and run it on a firewall to queue visitors when traffic surges past your site's capacity.
You install the Upstash Waiting Room integration from Azion Marketplace and run it on a Firewall, from Azion Console. The integration manages traffic surges and prevents overload on your websites and applications. It creates a waiting room that controls and redirects access according to your parameters, with a First-In, First-Out (FIFO) approach.
Five objects have to exist before a request is queued: the installed function, a firewall carrying the Functions module, a function instance holding the arguments, a Rules Engine rule with the Run Function behavior, and a workload deployment bound to the firewall. Each section below creates one of them.
Prerequisites
- An Azion account. To sign in, refer to How to access Azion Console.
- An application served by a workload, whose deployment you bind to the firewall in the last section.
- An Upstash account.
- A Global Database, created in the Upstash Console. Its URL and its token are arguments of the function instance.
- The Azion CLI installed and authorized, for the last section.
- Turning on a product or a module can generate usage costs. For more information, refer to Pricing.
Install the integration
The function is installed once per account. To install it:
Access Azion Console > Marketplace.
Enter Upstash Waiting Room in the Search on Marketplace field, then select the integration’s card. Browsing the cards and the categories reaches the same page.
The card shows Successfully installed! and Latest version installed!, and the function appears in the Function list of the Create Instance drawer.
Create the firewall
The firewall is where the function is instanced and where the rule that runs it lives. To create one:
Access Azion Console > Firewalls, then create a firewall.
In the General section, enter a Name. For example: waiting-room-firewall.
In the Modules section, turn on the Functions switch.
The firewall shows a Functions Instances tab while the Functions module stays on. To use an existing firewall instead, turn on its Functions module and save it. For every setting on this form, refer to Set a firewall’s main settings.
Create the function instance
The instance holds your Upstash credentials and the capacity of your site. To create it:
In Firewalls, select your firewall, then select the Functions Instances tab.
A firewall that has no instance shows the same action as Function Instance. The Create Instance drawer opens.
In Name, enter a name. For example: upstash-waiting-room.
In Function, select the Upstash Waiting Room function. The list holds only the functions that run on a firewall.
In Arguments, the editor is prefilled with the integration’s default arguments in JSON. Enter your Upstash credentials and your variables, as the next section describes.
The instance is listed in the Functions Instances tab.
Arguments
The instance takes your Upstash credentials and your variables:
| Variable | Required | Description |
|---|---|---|
url | Yes | The URL string that connects to Upstash Redis. In your Upstash Console, copy the UPSTASH_REDIS_REST_URL from your database page |
token | Yes | The token that accesses the Upstash Redis database. In your Upstash Console, copy the UPSTASH_REDIS_REST_TOKEN from your database page |
ttl | Yes | The maximum time, in seconds, a user can stay on your website. Example: 180 |
ttl_wait | Yes | The maximum time, in seconds, a user can stay inactive in the waiting room without losing their place, for example after closing the tab or window of the site. Example: 180 |
capacity | Yes | The maximum number of simultaneous connections allowed on your website. Example: 10 |
Create the rule
The instance queues nothing until a rule runs it. A Rules Engine for Firewall rule selects the requests that reach the instance, through a Run Function behavior. To create the rule:
In Firewalls, select your firewall, then select the Rules Engine tab.
In Name, enter a name. For example: Run Upstash Waiting Room.
In the Criteria section, select the domains that run the integration. For example: if Host matches yourdomain.com.
In the Behaviors section, select Run Function, then select the instance by the name you gave it.
The firewall runs the instance on every request to the domain in the criterion.
Bind the firewall to the workload
The binding is on the workload’s deployment, so create a deployment that names both the application and the firewall:
The command prints the id of the new deployment:
Requests to the workload’s domain reach the firewall, and the rule runs the Upstash Waiting Room instance on each one.
How it works
When your website receives a request, the firewall runs the integration. The integration checks whether there is space available:
- If there is space, the integration moves the request from the waiting queue to the release queue.
- If there is no space, the integration redirects the request to the waiting room, where it receives a number in the queue.
Monitor the waiting room
You can monitor the activity of the waiting room in the Upstash Dashboard.