---
title: Create load balancer on test domain · Cloudflare Learning Paths
description: Instead of starting on your production domain, you likely should create a load balancer on a test or staging domain. This may involve temporary changes to your monitors and pools, depending on your infrastructure setup.
lastUpdated: 2024-08-19T19:08:50.000Z
source_url:
  html: https://a74404c8.preview.developers.cloudflare.com/learning-paths/load-balancing/setup/test-load-balancer/index.md
  md: https://a74404c8.preview.developers.cloudflare.com/learning-paths/load-balancing/setup/test-load-balancer/
---

Instead of starting on your production domain, you likely should create a load balancer on a test or staging domain. This may involve temporary changes to your monitors and pools, depending on your infrastructure setup.

Starting with a test domain allows you to verify everything is working correctly before routing production traffic.

## Create a load balancer

* Dashboard

  To create a load balancer in the dashboard:

  1. Go to **Traffic** > **Load Balancing**.

  2. Select **Create Load Balancer**.

  3. On the **Hostname** page:

     * Enter a **Hostname**, which is the DNS name at which the load balancer is available. For more details on record priority, refer to [DNS records for load balancing](https://developers.cloudflare.com/load-balancing/load-balancers/dns-records/).
     * Toggle the orange cloud icon to update the [proxy mode](https://developers.cloudflare.com/load-balancing/understand-basics/proxy-modes/), which affects how traffic is routed and which IP addresses are advertised.
     * If you want [session-based load balancing](https://developers.cloudflare.com/load-balancing/understand-basics/session-affinity/), toggle the **Session Affinity** switch.

  4. Select **Next**.

  5. On the **Add a Pool** page:

     * Select one or more existing pools or [create a new pool](https://developers.cloudflare.com/load-balancing/pools/create-pool/#create-a-pool).
     * If you are going to set [traffic steering](https://developers.cloudflare.com/load-balancing/understand-basics/traffic-steering/steering-policies/standard-options/) to **Off**, re-order the pools in your load balancer to adjust the fallback order.
     * If needed, update the [**Fallback Pool**](https://developers.cloudflare.com/load-balancing/understand-basics/health-details/#fallback-pools).
     * If you choose to set traffic steering to **Random**, you can set [Weights](https://developers.cloudflare.com/load-balancing/understand-basics/traffic-steering/steering-policies/standard-options/#random-steering) (via the API) to your pools to determine the percentage of traffic sent to each pool.

  6. Select **Next**.

  7. On the **Monitors** page:

     * Review the monitors attached to your pools.
     * If needed, you can attach an existing monitor or [create a new monitor](https://developers.cloudflare.com/load-balancing/monitors/create-monitor/#create-a-monitor).

  8. Select **Next**.

  9. On the **Traffic Steering** page, choose an option for [Traffic steering](https://developers.cloudflare.com/load-balancing/understand-basics/traffic-steering/steering-policies/) and select **Next**.

  10. On the **Custom Rules** page, select an existing rule or [create a new rule](https://developers.cloudflare.com/load-balancing/additional-options/load-balancing-rules/).

  11. Select **Next**.

  12. On the **Review** page:

      * Review your configuration and make any changes.
      * Choose whether to **Save as Draft** or **Save and Deploy**.

* API

  For a full list of properties, refer to [Create Load Balancer](https://developers.cloudflare.com/api/resources/load_balancers/methods/create/). If you need help with API authentication, refer to [Cloudflare API documentation](https://developers.cloudflare.com/fundamentals/api/).

  Note

  Since load balancers only exist on a zone — and not an account — you may need to get the zone `id` with the [List Zones](https://developers.cloudflare.com/api/resources/zones/methods/list/) command.

  ```bash
  curl "https://api.cloudflare.com/client/v4/zones/{zone_id}/load_balancers" \
  --header "Authorization: Bearer <API_TOKEN>" \
  --header "Content-Type: application/json" \
  --data '{
    "description": "Load Balancer for lb.example.com",
    "name": "lb.example.com",
    "enabled": true,
    "ttl": 30,
    "fallback_pool": "17b5962d775c646f3f9725cbc7a53df4",
    "default_pools": [
      "17b5962d775c646f3f9725cbc7a53df4",
      "9290f38c5d07c2e2f4df57b1f61d4196",
      "00920f38ce07c2e2f4df50b1f61d4194"
    ],
    "proxied": true,
    "steering_policy": "random_steering",
    "session_affinity": "cookie",
    "session_affinity_attributes": {
      "samesite": "Auto",
      "secure": "Auto",
      "drain_duration": 100,
      "zero_downtime_failover": "sticky"
    },
    "session_affinity_ttl": 5000,
    "adaptive_routing": {
      "failover_across_pools": true
    },
    "location_strategy": {
      "prefer_ecs": "always",
      "mode": "resolver_ip"
    },
    "random_steering": {
      "pool_weights": {
        "de90f38ced07c2e2f4df50b1f61d4194": 0.3,
        "9290f38c5d07c2e2f4df57b1f61d4196": 0.5
      },
      "default_weight": 0.2
    }
  }'
  ```

  The response contains the complete definition of the new load balancer.

  ```json
  {
    "success": true,
    "errors": [],
    "messages": [],
    "result": {
      "id": "699d98642c564d2e855e9661899b7252",
      "created_on": "2021-01-01T05:20:00.12345Z",
      "modified_on": "2021-01-01T05:20:00.12345Z",
      "description": "Load Balancer for lb.example.com",
      "name": "lb.example.com",
      "enabled": true,
      "ttl": 30,
      "fallback_pool": "17b5962d775c646f3f9725cbc7a53df4",
      "default_pools": [
        "17b5962d775c646f3f9725cbc7a53df4",
        "9290f38c5d07c2e2f4df57b1f61d4196",
        "00920f38ce07c2e2f4df50b1f61d4194"
      ],
      "proxied": true,
      "steering_policy": "random_steering",
      "session_affinity": "cookie",
      "session_affinity_attributes": {
        "samesite": "Auto",
        "secure": "Auto",
        "drain_duration": 100,
        "zero_downtime_failover": "sticky"
      },
      "session_affinity_ttl": 5000,
      "random_steering": {
        "pool_weights": {
          "de90f38ced07c2e2f4df50b1f61d4194": 0.3,
          "9290f38c5d07c2e2f4df57b1f61d4196": 0.5
        },
        "default_weight": 0.2
      }
    }
  }
  ```
