ロードバランサーの管理
A load balancer distributes traffic among pools according to pool health and traffic steering policies. Each load balancer is identified by its DNS hostname (lb.example.com, dev.example.com, etc.).
ロードバランサーの詳細については、ロードバランサーを参照してください。
To create a load balancer in the dashboard:
-
Go to Traffic > Load Balancing.
-
Select Create Load Balancer.
-
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.
- Toggle the orange cloud icon to update the proxy mode, which affects how traffic is routed and which IP addresses are advertised.
- If you want session-based load balancing, toggle the Session Affinity switch.
-
Select Next.
-
On the Add a Pool page:
- Select one or more existing pools or create a new pool.
- If you are going to set traffic steering to Off, re-order the pools in your load balancer to adjust the fallback order.
- If needed, update the Fallback Pool.
- If you choose to set traffic steering to Random, you can set Weights (via the API) to your pools to determine the percentage of traffic sent to each pool.
-
Select Next.
-
On the Monitors page:
- Review the monitors attached to your pools.
- If needed, you can attach an existing monitor or create a new monitor.
-
Select Next.
-
On the Traffic Steering page, choose an option for Traffic steering and select Next.
-
On the Custom Rules page, select an existing rule or create a new rule.
-
Select Next.
-
On the Review page:
- Review your configuration and make any changes.
- Choose whether to Save as Draft or Save and Deploy.
For a full list of properties, refer to Create Load Balancer. If you need help with API authentication, refer to Cloudflare API documentation.
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.
{ "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 } }}アカウント内の他のサイトとロードバランサーを共有するには、正引き名(CNAME)レコードを作成します。これにより、複数の他のドメインと設定を共有できるため、各サイトごとに新しいロードバランサーを作成する必要がなくなります。
また、各ドメインごとに別々のロードバランサーを設定し、モニターやプールを再利用することもできます。これは、example.co.ukサーバーのフェイルオーバー優先度がexample.comやexample.com.auとは異なる場合など、異なるドメインのフェイルオーバー順序を変更する際に特に便利です。
ダッシュボードでロードバランサーを編集するには:
- トラフィック > ロードバランシングに移動します。
- 特定のロードバランサーで編集をクリックします。
- 作成ワークフローを進めながら、必要に応じて設定を更新します。
- レビューステップで保存をクリックします。
APIを使用してロードバランサーを編集する場合、リクエストの種類は編集したい内容によって異なります。
全体の設定を再提出することなく特定の設定を更新するには、PATCHリクエストを使用します。より広範な変更には、PUTリクエストを使用します。
ロードバランサーを削除または無効にすると、エンドポイントのリクエストに対する応答は、既存のDNSレコードに依存します。
ダッシュボードでロードバランサーを削除するには:
- トラフィック > ロードバランシングに移動します。
- 特定のロードバランサーで削除をクリックします。
APIを使用してロードバランサーを削除するには、DELETEリクエストを送信します。
プールやエンドポイントの健康状態の変化に対する通知を受け取るために、アラートを設定できます。
Load Balancing Health Alert
Who is it for?Customers who want to be warned about changes in health status in their pools or origins.
Other options / filtersAvailable filters include:
- You can search for and add pools from your list of pools, as well as Include future pools (if all pools are selected).
- You can choose the trigger that fires the notification when the health status becomes unhealthy, healthy, or either unhealthy or healthy
- You can choose the trigger that fires the notification when the event source health status changes in pool, origin, or either pool or origin.
Purchase of Load Balancing.
What should you do if you receive one?Evaluate load balancing analytics to review changes in health status over time.
Refer to Cloudflare Notifications for more information on how to set up an alert.