Change a health check or sticky sessions
Change how a service checks its targets, or pin each client to one target with a cookie.
Only the health check and sticky sessions of a service can change. Protocol, ports and certificate cannot: remove the service and add it again.
Prerequisites
- Permission for
lb:UpdateService.
Change the settings
Only the fields you send change; the rules across fields are checked against the service as it then is.
Not available in Console. The console cannot change a service; use the CLI, API or Terraform.
dcloud lb services update lb-id service-id \
--health-check-interval 3 --health-check-timeout 2 --health-check-retries 1Sticky sessions on an http or https service of an lb11–lb31 or application load balancer
(a dedicated one accepts the setting but does not apply it):
dcloud lb services update lb-id service-id --sticky-sessions \
--sticky-cookie-lifetime 3600PATCH /lb/api/load-balancers/lb-id/services/service-id
{ "healthCheckInterval": 3, "healthCheckTimeout": 2, "healthCheckRetries": 1 }Change health_check_* or sticky_* on the dcloud_lb_service and apply: these change in
place.
| Field | Values | Default |
|---|---|---|
healthCheckProtocol |
http or tcp |
http |
healthCheckPath |
starts with /, at most 256 characters |
/ |
healthCheckInterval |
1–60 s; at least 3 on lb11–lb31 |
15 |
healthCheckTimeout |
1–60 s, at most the interval | 10 |
healthCheckRetries |
0–5 | 3 |
stickySessions |
true or false; http and https only |
false |
stickyCookieName |
letters, digits, - and _, at most 64 |
EWSLB |
stickyCookieLifetime |
60–604800 seconds | 300 |
With sticky sessions, the load balancer sets the cookie on a client's first response and sends the client's later requests carrying it to the same target.
Result
200 with the service as now set. On application and dedicated the fleet picks up the change
within seconds. On lb11–lb31 it is sent to the provider in the background, and a refusal
there is recorded as an event on the load balancer; an https service still waiting for its
certificate gets the settings when the certificate is served.
When it is refused
400Nothing to change: send at least one field.400healthCheckInterval must be at least 3s on …for an interval under 3 seconds onlb11–lb31.400healthCheckTimeout (…s) must not exceed healthCheckInterval (…s).400Sticky sessions work on http and https services only: a tcp service cannot set a cookie.404Service not found.409for a load balancer another service owns.