Load Shedding

This article describes an automatic load shedding configuration for an A record, in which NS1 is configured to automatically shift traffic to a secondary IP if certain load thresholds are met.

There are four steps:

  1. Create a record that will use the load shedding configuration
  2. Setup a new API data feed where you can send your load data
  3. Send load data updates via the API
  4. Configure the record to use the Shed Load filter

This example will be illustrated using an A Record (test.example.web) with two answers configured. The first, 1.1.1.1, is located in Buffalo, New York. The second, 2.2.2.2, is located in London, UK.

Create an A record

  1. Click on the Zones tab and select the Zone you will be working under.
  2. Click on the Add Record button.
  3. Enter the domain (e.g. test.example.web)
  4. Select the record type as A
  5. Enter your desired TTL. We recommend 60 seconds. A much lower TTL will be ignored by some DNS recursors; and a much higher one will limit the effectiveness of your failover.
  6. Set the Answers for this record
  7. Click on the Save Changes button

Setup a New API Data Feed to Accept Your Load Data

  1. Go to the Integrations tab
  2. In the "Supported Devices" section select NS1 API. Autofail1
  3. Create an Incoming Datafeed and enter a name for the feed that you will be able to easily identify when connecting to record metadata. Choose a Label for your feed that will be used as an identifier in the API call. (Note: this field does not allow spaces.) Autofail2
  4. Click Create Datafeed from nsone_v1, which will send you to the Incoming screen, where you will see this new feed now lives.

Send NS1 Your Load Metrics

On the Incoming page under the Integrations tab, you'll see there's a Feed URL for each Data Feed:


You can send us load metrics for each server with the following call, replacing the asterisks with your API key, and the example value "5" with whatever the current load is:

curl -X POST -H "X-NSONE-Key: **********************" -d '{"London-UK":{"loadavg":5}}' 
https://api.nsone.net/bc77e8436ef984bb4a0f1e44ba002e8b

For the Buffalo server you'll just replace London-UK with the label of the Buffalo feed: Buffalo-NY. If you're testing and you'd like to see what response our API is giving you can add -i to curl.
Additional ways and examples of interacting with our API can be found at https://nsone.net/api

Configure the Record

  1. Choose which of the three metrics you'd like the Shed Load filter to act on (load average, average connections or average requests). In this example we'll use load average.
  2. Add the Shed Load filter and make sure it is configured for Load Average.
  3. Add load average metadata to each answer. Also add low watermark and high watermark metadata to each of your answers (in this example we'll use 3 and 8, respectively)
  4. Connect the applicable Load Metrics Data Feeds we created earlier as Up metadata for each answer
  5. Add any other filters you wish to use in conjunction with Shed Load (in our example we have added Up, Geotarget Country and Select First N)
  6. Click the Save button