tencent cloud

Cloud Load Balancer

릴리스 정보 및 공지 사항
릴리스 노트
제품 공지
제품 소개
제품 개요
제품 장점
시나리오
기술 원리
Product Comparison
사용 제한
Service Regions and Service Providers
구매 가이드
과금 개요
비용 계산 항목
구매 방식
연체 안내
제품 속성 선택
시작하기
도메인 이름 기반 CLB 시작하기
CLB 시작하기
CentOS에서 Nginx 배포하기
CentOS에서 Java Web 배포하기
운영 가이드
CLB 인스턴스
CLB 리스너
리얼 서버
상태 확인
인증서 관리
로그 관리
모니터링 및 알람
액세스 관리
사례 튜토리얼
CLB에 인증서 배치(양방향 인증)
HTTPS 포워딩 구성
리얼 클라이언트 IP 가져오기
로드 밸런싱 구성 모니터링 및 알람에 대한 모범 사례
다중 가용존에서 HA 구현
로드 밸런싱 알고리즘 선택 및 가중치 구성 예시
CLB 수신 도메인 이름에 대한 WAF 보호 구성하기
OPS 가이드
과도한 TIME_WAIT 상태의 클라이언트에 대한 솔루션
CLB HTTPS 서비스 성능 테스트
스트레스 테스트 FAQ
CLB 인증서 작업 권한
문제 해결
UDP 상태 확인 예외 발생
API 참조
History
Introduction
API Category
Instance APIs
Listener APIs
Backend Service APIs
Target Group APIs
Redirection APIs
Other APIs
Classic CLB APIs
Load Balancing APIs
Making API Requests
Data Types
Error Codes
CLB API 2017
FAQ
과금 관련
CLB 구성
헬스체크 이상 점검
HTTPS
WS/WSS 프로토콜 지원
HTTP/2 프로토콜 지원
연락처
용어집

Use Cases

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2024-12-19 10:38:23
An example is given here to help you get started with CLB APIs. Before using the APIs, deploy TCP service on two CVMs and listen on port 80. If the service returns the “hello world” string, the deployment is successful. By creating a CLB instance, you can access CVM services through the CLB VIP.

Purchasing a Public Network CLB Instance

To use CLB services, you need to purchase a public network CLB instance (with static IP). For more information on CLB instance purchase, use the CreateLoadBalancer API.
This example shows you how to create a public network CLB instance (with static IP). The Action field in the common request parameters of this API is CreateLoadBalancer. The list below contains the API request parameters.
Parameter
Description
Value
loadBalancerType
CLB instance type.
2: public network CLB instance, the service of which is accessed via a public network.
By combining common request parameters and API request parameters, you can get the final request as follows:
https://lb.api.qcloud.com/v2/index.php?Action=CreateLoadBalancer
&Region=ap-guangzhou
&Timestamp=1465750149
&Nonce=46364
&SecretId=AKID****ugEY
&Signature=5umi****pTTyk18V2g%2FYi56hqls%3D
&loadBalancerType=2
Response of the request is as follows:
{
"code": 0,
"message": "",
"codeDesc": "Success",
"requestId": 3901941,
"dealIds": [
"3901941"
],
"unLoadBalancerIds": {
"3901941": [
"lb-lb-cjcy****"
]
}
}
Where, lb-cjcymkw5 is the unique ID of the CLB instance you just purchased. Next, use the DescribeLoadBalancers API to query whether the instance has been successfully created.

Creating a CLB Listener

This example shows you how to create a CLB listener with the unique ID of the CLB instance. For more information on the CLB listener creation, use the CreateLoadBalancerListeners API.
In this example, the table below lists the API request parameters.
Parameter
Description
Value
loadBalancerId
Unique ID of the CLB instance
This example uses the unique ID of the instance you’ve just created, i.e. lb-cjcy****
listeners.0.loadBalancerPort
Listening port of the CLB listener.
80
listeners.0.instancePort
Listening port on real server of the CLB instance.
80
listeners.0.protocol
Protocol listened by the CLB listener. 1: HTTP; 2: TCP; 3: UDP; 4: HTTPS
This example uses 2: TCP
listeners.0.healthSwitch
Whether to enable the health check for the CLB listener. 1: enable; 0: disable. The health check is enabled by default.
This example uses 1: enable
listeners.0.listenerName
Name of the CLB listener. This field is optional. Default value will be used if it is left empty.
This example uses listenerTest
By combining common request parameters and API request parameters, you can get the final request as follows:
https://lb.api.qcloud.com/v2/index.php?Action=CreateLoadBalancerListeners
&Region=ap-guangzhou
&Timestamp=1465750149
&Nonce=46364
&SecretId=AKID****ugEY
&Signature=5umi****pTTyk18V2g%2FYi56hqls%3D
&loadBalancerId=lb-cjcy****
&listeners.0.loadBalancerPort=80
&listeners.0.instancePort=80
&listeners.0.protocol=2
&listeners.0.healthSwitch=1
&listeners.0.listenerName=listenerTest

Response of the request is as follows:
{
"code" : 0,
"message" : "",
"codeDesc": "Success",
"requestId" : 12354
}
To query the execution result of the task with the request ID, use the asynchronous DescribeLoadBalancersTaskResult API.

Binding Real Server to the CLB Instance

You need to bind CVM to the CLB instance after creating the listener. For more information on the binding method, use the RegisterInstancesWithLoadBalancer API.
This example shows you how to bind two CVMs (with the unique ID of ins-5678test and ins-1234test respectively) on the CLB instance. The Action field in the common request parameters of this API is RegisterInstancesWithLoadBalancer. The list below contains the API request parameters.
Parameter
Description
Value
loadBalancerId
Unique ID of the CLB instance.
This example uses the unique ID of the instance you’ve just created: lb-abcdefgh
backends.0.instanceId
Unique ID of the CVM bound to the CLB instance.
This example uses the unique ID of the first CVM:ins-5678test
backends.0.weight
Weight of the CVM bound to the CLB instance.
This example uses the default value 10
backends.1.instanceId
Unique ID of the CVM bound to the load balancer instance
This example uses the unique ID of the second CVM: ins-1234test
backends.1.weight
Weight of the CVM bound to the CLB instance.
This example uses the default value 10
By combining common request parameters and API request parameters, you can get the final request as follows:
https://lb.api.qcloud.com/v2/index.php?Action=RegisterInstancesWithLoadBalancer
&Region=ap-guangzhou
&Timestamp=1465750149
&Nonce=46364
&SecretId=AKID****ugEY
&Signature=5umi****pTTyk18V2g%2FYi56hqls%3D
&loadBalancerId=lb-cjcy****
&backends.0.instanceId=ins-5678****
&backends.0.weight=10
&backends.1.instanceId=ins-1234****
&backends.1.weight=10
Response of the request is as follows:
{
"code" : 0,
"message" : "",
"codeDesc": "Success",
"requestId" : 1234
}
To query the execution result of the task with the request ID, use the asynchronous DescribeLoadBalancersTaskResult API.

Querying and Using the CLB Instance

This example shows you how to query the VIP or domain name of the CLB instance. For more information on the query method, use the DescribeLoadBalancers API.
The Action field in the common request parameters of the API is DescribeLoadBalancers. The list below contains the API request parameters.
Parameter
Description
Value
loadBalancerIds.0
Unique ID of the CLB instance.
This example uses the unique ID of the instance you’ve just created: lb-cjcy****
By combining common request parameters and API request parameters, you can get the final request as follows:
https://lb.api.qcloud.com/v2/index.php?Action=DescribeLoadBalancers
&Region=ap-guangzhou
&Timestamp=1465750149
&Nonce=46364
&SecretId=AKID****ugEY
&Signature=5umi****pTTyk18V2g%2FYi56hqls%3D
&loadBalancerIds.0=lb-cjcy****
Response
{
"code": 0,
"message": "",
"codeDesc": "Success",
"loadBalancerSet": [{
"loadBalancerId": "lb-cjcy****",
"unLoadBalancerId": "lb-cjcy****",
"loadBalancerName": "59b25ffb-0",
"loadBalancerType": 2,
"domain": "20de02-0.gz.1251000011.clb.myqcloud.com",
"loadBalancerVips": [
"119.28.168.196"
],
"status": 1,
"createTime": "2017-09-08 17:16:42",
"statusTime": "2017-09-20 13:37:55",
"vpcId": 0,
"uniqVpcId": "",
"subnetId": 0,
"projectId": 1005621,
"forward": 0,
"snat": false,
"openBgp": 0,
"isolation": 0,
"log": ""
}],
"totalCount": 1
}
As the query results suggest, you can use the VIP 119.28.168.XX or domain name 20****-0.gz.1251000011.clb.myqcloud.com of the CLB instance to forward the request to the associated backend CVMs according to the rule of CLB listener, thereby balancing the load.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백