Configuring Rate Limiting on a LoadBalancer Service for New and Concurrent Connections
This section describes how to use the kubernetes.io/elb.cps and kubernetes.io/elb.connection annotations of a Service to configure rate limiting for new and concurrent connections on an ELB listener. This prevents backend services from being overloaded by burst traffic.
Prerequisites
- A CCE standard or Turbo cluster is available, and the cluster version meets the following requirements:
- v1.30: v1.30.14-r100 or later
- v1.31: v1.31.14-r60 or later
- v1.32: v1.32.13-r30 or later
- v1.33: v1.33.12-r10 or later
- v1.34: v1.34.8-r10 or later
- v1.35: v1.35.5-r10 or later
- v1.36: v1.36.2-r0 or later
- Clusters of later versions
- An available workload has been deployed in the cluster for external access. If no workload is available, deploy a workload by referring to Creating a Deployment, Creating a StatefulSet, or Creating a DaemonSet.
- A Service for external access has been configured for the workload. Services Supported by LoadBalancer Ingresses lists the Service types supported by LoadBalancer ingresses.
Constraints
Only dedicated load balancers are supported.
Using kubectl
- Use kubectl to access the cluster. For details, see Accessing a Cluster Using kubectl.
- Create a YAML file named service-test.yaml. The file name can be customized.
vi service-test.yaml
The following shows an example configuration using an existing load balancer:
apiVersion: v1 kind: Service metadata: name: service-test labels: app: test version: v1 namespace: default annotations: kubernetes.io/elb.class: performance # A dedicated load balancer is required. kubernetes.io/elb.id: <your_elb_id> # Replace it with the ID of your existing load balancer. kubernetes.io/elb.port-ranges: '{"cce-service-0":["100,200", "300,400"], "cce-service-1":["500,600", "700,800"]}' # Configure ranges of listening ports. kubernetes.io/elb.connection: '10' # Rate limit on concurrent connections to the listener kubernetes.io/elb.cps: '100' # Rate limit on new connections to the listener spec: selector: app: test version: v1 externalTrafficPolicy: Cluster ports: - name: cce-service-0 targetPort: 80 # Replace it with your container port. nodePort: 0 port: 100 # If a port range is configured for listening, this parameter becomes invalid. However, it still needs to be assigned a unique value. By default, it is set to the starting port number of the range. protocol: TCP - name: cce-service-1 targetPort: 81 # Replace it with your container port. nodePort: 0 port: 500 # If a port range is configured for listening, this parameter becomes invalid. However, it still needs to be assigned a unique value. protocol: TCP type: LoadBalancer loadBalancerIP: <your_elb_ip> # Replace it with the private IP address of your existing load balancer.The involved parameters are described in the table below.
Parameter
Type
Description
kubernetes.io/elb.cps
Integer
Definition: The maximum number of new connections that a listener can handle per second.
Constraints: If this value exceeds the limit defined in the load balancer, the load balancer's limit takes precedence.
Range: 0 to 1000000
Default value: 0, indicating no limit.
kubernetes.io/elb.connection
Integer
Definition: The maximum number of concurrent connections that a listener can handle.
Constraints: If this value exceeds the limit defined in the load balancer, the load balancer's limit takes precedence.
Range: 0 to 1000000
Default value: 0, indicating no limit.
- Create the Service.
kubectl create -f service-test.yaml
If information similar to the following is displayed, the Service has been created:
service/service-test created
- Check the rate limit configuration of the ELB listener.



What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot