All Products
Search
Document Center

Server Load Balancer:Associate an Anycast EIP with an NLB instance for nearest access

Last Updated:May 14, 2026

A public-facing Network Load Balancer (NLB) instance typically provides internet access through an Elastic IP Address (EIP). However, an EIP is a regional resource, which can cause high latency for users outside your service's deployment region. An Anycast EIP is not restricted to a specific region and can be announced across an entire access area. By associating an Anycast EIP with your NLB instance, you can provide access from the nearest access point for your multi-region services and improve public access for your users.

How it works

A Network Load Balancer (NLB) instance acts as an entry point for high-concurrency traffic, providing Layer 4 load balancing to improve the performance and availability of your backend services. An Anycast EIP provides public access across an entire access area, which reduces cross-region latency. Combining an NLB instance with an Anycast EIP leverages the strengths of both products to deliver a low-latency, highly stable global service to create a competitive advantage.

Key features

  • NLB provides high availability, high performance, and auto-scaling at Layer 4.

  • Anycast EIP provides global coverage with low latency, reduced network jitter, and high stability through automatic failover.

Use cases

  • Improve global user experience: For applications with a global user base, such as online gaming, an Anycast EIP automatically directs traffic to the nearest access point. This configuration reduces latency and improves access speed, ensuring that players in different regions connect to the nearest server.

  • High availability and disaster recovery: An Anycast EIP supports access from multiple points of presence (PoPs). If an ISP line or route in one region fails, traffic is automatically rerouted to another PoP to ensure service stability. This is critical for industries such as finance, where a single PoP outage cannot disrupt service.

  • Simplified security management: In the security industry, you can use a single Anycast EIP in your allowlists. This simplifies security maintenance across a distributed environment.

Limitations

  • You can create an NLB instance and associate an Anycast EIP with it only in an origin region that supports Anycast EIP. The supported origin regions are: China (Hong Kong), Singapore, US (Silicon Valley), US (Virginia), Germany (Frankfurt), and Japan (Tokyo).

  • An Anycast EIP that is associated with an NLB instance cannot be added to an Internet Shared Bandwidth instance.

  • For a dual-stack NLB instance, you can associate an Anycast EIP only with its IPv4 address. IPv6 addresses are not supported.

  • When an Anycast EIP instance is associated with an Application Load Balancer (ALB) instance or an NLB instance, the Anycast EIP instance can be associated with only one region. For more information, see Anycast EIP limitations.

Example scenario

A gaming company deploys its game servers in the Singapore region. When users from the UK (London) try to access the game, their traffic is routed across multiple public ISP networks to reach the servers in Singapore. This results in significant latency from multiple routing hops. To optimize the global user experience, Alibaba Cloud provides Anycast EIPs that are deployed at global points of presence (PoPs). This technology intelligently routes user requests to the nearest PoP, significantly reducing network latency and improving global access speeds. This allows the company's game service in Singapore to provide a smoother and more responsive experience for global users, including those in the UK. This helps improve user satisfaction and retention in the global market. As shown in the following figure, a user in London is routed to the London PoP through their local ISP. The traffic then travels to the game servers in Singapore through the Alibaba Cloud internal network, reducing access latency.

Prerequisites

  • You have created a Virtual Private Cloud (VPC) in the Singapore region, and two VSwitches, VSW1 and VSW2, in different zones. For more information, see Create and manage a VPC.

  • You have created two Elastic Compute Service (ECS) instances: ECS01 in VSW1 and ECS02 in VSW2. Application services are deployed on both instances.

    Example commands to deploy a test service on the ECS instances

    Example command for ECS01

    yum install -y nginx
    systemctl start nginx.service
    cd /usr/share/nginx/html/
    echo "Hello World ! This is ECS01." > index.html

    Example command for ECS02

    yum install -y nginx
    systemctl start nginx.service
    cd /usr/share/nginx/html/
    echo "Hello World ! This is ECS02." > index.html
  • You have created an NLB instance. For more information, see Create and manage an NLB instance.

  • You have created a server group for the NLB instance and added backend servers to it. For more information, see Server groups for NLB.

  • You have configured a listener for the NLB instance. For more information, see Add a TCP listener, Add a UDP listener, or Add a TCP-over-SSL listener.

Procedure

Step 1: Associate an Anycast EIP with the NLB instance

Note

To reuse an existing public-facing NLB instance, first change its network type to internal-facing. You can then associate an Anycast EIP with it. For more information, see Change the network type of an NLB instance.

  1. Log on to the Network Load Balancer (NLB) console.

  2. In the top navigation bar, select the region where the instance is deployed.

  3. On the Instances page, find the target internal-facing NLB instance and click its ID.

  4. On the Instance Details tab, find the Basic Information section. To the right of IPv4 under Network Type, click Change Network Type.

  5. In the Change Network Type dialog box, set IP Type to Anycast EIP. From the Assign Anycast EIP drop-down list, select Purchase Anycast EIP or an existing Anycast EIP. Then, click OK.

    Note
    • You must assign an Anycast EIP to each zone in the list.

    • If you select Purchase Anycast EIP, the EIP is released when you release the NLB instance or change the network type from public to private. If you select an existing Anycast EIP, the EIP is retained when you release the NLB instance or change the network type from public to private.

    • You can view your purchased Anycast EIPs on the Anycast Elastic IP Addresses page in the VPC console.

  6. On the Instance Details > Zone page, you can view the associated Anycast EIP.

Step 2: Test the configuration

  1. Test access latency

    Note

    The network quality of an Anycast EIP is affected by the public network quality of ISPs. The results in this example are for reference only. You must perform tests based on your actual business requirements. This example shows how latency is reduced.

    1. Create an ECS instance (ECS03) in the UK (London) region and associate an EIP with it. This instance serves as the test client.

    2. Log on to the test client ECS03 and run the following command to test access latency.

      curl -i http://<Anycast EIP> -s -w "time_connect: %{time_connect}\ntime_starttransfer: %{time_starttransfer}\ntime_total: %{time_total}\n" 

      Parameter description:

      • time_connect: Connection time. The time, in seconds, to establish the TCP connection.

      • time_starttransfer: Start transfer time. The time, in seconds, from sending a request until the backend server returns the first byte.

      • time_total: Total time. The total time, in seconds, for the request to complete.

    3. Verify that access latency is reduced after you associate the Anycast EIP.

      Request response time before you associate the Anycast EIP:

      before.png

      Request response time after you associate the Anycast EIP:

      after.png

  2. Test high availability

    1. Stop the application service on ECS01 by running the systemctl stop nginx.service command.

    2. Log on to ECS03 and run the following command to test connectivity:

      curl -i http://<Anycast EIP>
    3. The service remains accessible.

      1.png

FAQ

  • What should I know before purchasing my first Anycast EIP?

    If you are purchasing an Anycast EIP for the first time, a Note dialog box appears. After you confirm the information and select the service agreement, click Activate Now to activate Cloud Data Transfer (CDT). For more information, see Purchase and manage an Anycast EIP instance.

  • How am I billed after I associate an Anycast EIP with an NLB instance?

    After you associate an Anycast EIP with an NLB instance, your total bill includes three components: NLB instance fees, Load Balancer Capacity Unit (LCU) fees, and public network fees for the Anycast EIP. For more information, see Billing. For information about NLB instance and LCU fees, see NLB billing rules.

References