Custom routing listeners are ideal for scenarios in which you want to forward traffic from clients to specified backend servers. This topic describes how custom routing listeners work, the limits on custom routing listeners, and the differences between custom routing listeners and intelligent routing listeners. This topic also provides examples on how to use custom routing listeners.
How custom routing listeners work
After you configure a custom routing listener, Global Accelerator (GA) generates a port mapping table based on the port range of the listener, the protocol and port range of the endpoint group, and the IP addresses of the endpoint (vSwitch). Then, GA routes traffic from clients to backend servers with specific IP addresses and ports based on the port mapping table.
The following workflow describes how a custom routing listener works:
No. | Description |
1 | GA generates a port mapping table based on the port range of the custom routing listener, the destination port range of the endpoint group, and the IP addresses of the endpoint vSwitch. |
2 | The client sends a request to GA to query information about available ports (acceleration ports). |
3 | GA queries the port mapping table and selects a backend server that allows traffic based on the business logic. |
4 | GA returns information about the acceleration port that maps the port of the selected backend server. The accelerated port is selected from the port range of the listener. |
5 | The client uses the assigned acceleration port and accelerated IP address to access your service. |
6 | The custom routing listener forwards traffic from the client to the corresponding backend server based on the port mapping table. |
Limits
When you use custom routing listeners, take note of the following limits:
Limits on acceleration areas
Accelerated IP addresses support only IPv4.
Limits on the listener port range
You can specify ports that range from 1 to 65499 for a custom routing listener. Ports 25, 250, 4789, and 4790 are reserved by the system. When a port mapping table is generated, the system-reserved ports are ignored. You cannot configure port 6081 for pay-as-you-go Global Accelerator instances.
The listener port range you specify determines the number of ports in the endpoint group that is associated with the listener and the number of IP addresses of all vSwitches in the endpoint. The following requirement must be met:
Number of listening ports (minus the number of system-reserved ports) ≥ Number of all ports in the endpoint group × Number of IP addresses of all vSwitches in the endpoint
. We recommend that you specify a large port range for the listener.For example, if you set the destination port range of endpoint groups to 81-85 and all vSwitches that are used as endpoints provide 16 IP addresses, the listener port range must contain at least 80 ports. You can set the port range of the listener to 101-180. If you set the port range of the listener to 101-179, the listener cannot be created.
After you configure listener ports, you cannot remove ports that exist in the port mapping table when you modify the port range.
For example, the original listening port range is 100-10000, and a mapping is established between port 199 and the destination port 80 of the endpoint in the port mapping table. You can expand the listening port range to 20-10000. You cannot narrow the listening port range to 200-10000.
The listening ports of different listeners under the same GA instance cannot overlap.
Limits on the listener protocol
Only TCP and UDP are supported. You can specify the protocol when you configure the endpoint group. You can specify TCP, UDP, or both protocols.
Limits on backend services
You can specify only vSwitches as the endpoints of custom routing listeners. You can specify only the private IP addresses and ports of Elastic Compute Service (ECS) instances as traffic destinations.
The subnet mask of the vSwitch that serves as the endpoint must range from
/17
to/28
. The vSwitch must provide at least 16 IP addresses.When you specify a vSwitch as the endpoint, all traffic to the vSwitch is rejected by default. If you want an ECS instance in the vSwitch to receive traffic, you can modify the configuration of the listener to allow all traffic to the vSwitch, or specify the IP address and port of the ECS instance to allow traffic to the ECS instance.
The network access control list (ACL) that is associated with the vSwitch that serves as the endpoint and the security group rules of the destination ECS instance must allow traffic. For information about how to configure network ACLs and security group rules, see Create and manage a network ACL and Add a security group rule.
Health checks on endpoint groups and endpoints are not supported. A custom routing listener forwards traffic based on the port mapping table, regardless of the health status of the endpoints.
Examples
Custom routing listeners are ideal for scenarios in which you want to forward traffic from clients to specific backend servers. For example, if you use a custom routing listener in a multiplayer online game, the system can assign players with the same characteristics (such as geographical location and player level) to the same session on a backend server based on the port mapping table and business logic.
In this example, you use three ECS instances deployed on the same vSwitch to build a game application. The CIDR block of the vSwitch is 10.1.1.0/28. The IP addresses of the ECS instances are 10.1.1.1, 10.1.1.2, and 10.1.1.3. The ports that are used to provide services are TCP ports 80, 81, and 82. Only two ECS instances are used to provide services. The IP addresses of the ECS instances are 10.1.1.1 and 10.1.1.2.
You can configure the custom routing listener and the endpoint based on the following information to improve user experience:
Port range of the listener: 1001 to 1050.
Port range of the endpoint group: 80 to 82. Protocol: TCP.
Select the vSwitch as the endpoint. Allow traffic to the ECS instances with the IP addresses 10.1.1.1 and 10.1.1.2. Set the port range to 80-82.
After the configuration is complete, GA generates the following port mapping table:
In this example, the ports are mapped in sequence for easier understanding. The actual port mapping table may be different. You can call the ListCustomRoutingPortMappings and ListCustomRoutingPortMappingsByDestination operations to query the actual port mapping table.
Acceleration port | Destination IP address | Destination port | Traffic policy |
1001 | 10.1.1.1 | 80 | Allow |
1002 | 10.1.1.1 | 81 | Allow |
1003 | 10.1.1.1 | 82 | Allow |
1004 | 10.1.1.2 | 80 | Allow |
1005 | 10.1.1.2 | 81 | Allow |
1006 | 10.1.1.2 | 82 | Allow |
1007 | 10.1.1.3 | 80 | Deny |
1008 | 10.1.1.3 | 81 | Deny |
1009 | 10.1.1.3 | 82 | Deny |
As shown in the following figure, different players can access the game application through the accelerated IP addresses and ports assigned by GA. Player 1 accesses the game through port 1001 and the corresponding accelerated IP address. Player 2 accesses the game through port 1003 and the corresponding accelerated IP address. Traffic from Player 1 and Player 2 is routed to the ECS instance with the IP address 10.1.1.1. Player 3 accesses the game through port 1005 and the corresponding accelerated IP address, and the traffic is routed to the ECS instance with the IP address 10.1.1.2. Player 4 fails to access the ECS instance with the IP address 10.1.1.3 because the ECS instance does not receive traffic.
Differences between intelligent routing listeners and custom routing listeners
The following table describes the features of intelligent routing listeners and custom routing listeners.
Feature | Intelligent routing listener | Custom routing listener |
TCP, UDP, HTTP, and HTTPS are supported. | TCP and UDP are supported. You can specify the protocol when you configure the endpoint group. You can specify TCP, UDP, or both protocols. | |
Intelligent routing listeners consist of basic listeners and advanced listeners. The number of ports and the limits vary based on the type of the listener. | The listener port range that you specify determines the product of the number of ports in the endpoint group that is associated with the listener and the number of IP addresses in the endpoint. The following requirement must be met: After you configure listener ports, you cannot remove ports that exist in the port mapping table when you modify the port range. | |
Supported. | Not supported. | |
Supports IPv4, IPv6, and dual-stack. | Only IPv4 is supported. | |
The backend service types that are supported vary based on where your backend service is deployed:
| vSwitches on Alibaba Cloud You can specify the private IP addresses and destination ports of one or more ECS instances in the vSwitch to which you want to forward traffic. | |
Supported. | Not supported. | |
Supported. | Not supported. | |
Supported. | Supported. | |
Whether the feature is supported is based on the listener protocol:
| Not supported by default If you want to use this feature, contact your account manager. | |
Supported. | Not supported. |