All Products
Search
Document Center

Serverless App Engine:Enable Internet access for SAE instances based on EIPs

最終更新日:Aug 16, 2023

If you associate each instance of a Serverless App Engine (SAE) application with elastic IP addresses (EIPs), the instances can be accessed and access other services over the Internet. This topic describes how to associate and disassociate EIPs in the SAE console and how to view application events.

Prerequisites

  • You are familiar with the limits of EIPs. For more information, see Limits.
  • EIPs are requested. For more information, see Apply for an EIP.
  • The number of available EIPs in a region is greater than or equal to the number of SAE application instances in the same region.

Background information

Solutions to enable access over the Internet

You can use one of the following solutions to access the SAE applications that are deployed in a virtual private cloud (VPC) over the Internet:
  • Solution 1: Configure a NAT gateway and an EIP

    The source network address translation (SNAT) feature allows application instances that are deployed in a VPC to access the Internet even when no public IP addresses are associated with the application instances. If multiple applications in a VPC require access to the Internet, you need to configure only one EIP. For more information, see Configure a NAT gateway for an SAE application to enable Internet access. This solution is suitable for the following scenarios:

    • Applications require auto scaling policies, and each instance must be associated with the EIP.
    • Fixed outbound public IP addresses are required. For example, outbound public IP addresses must be added to a whitelist in WeChat mini programs.
  • Solution 2: Associate EIPs with application instances

    If multiple applications in a VPC require access to the Internet, you must associate at least one instance in each application with an EIP. Up to 20 instances can be configured in a VPC. EIP provides lower costs than NAT Gateway. When you create or deploy an application, each instance of the application is automatically associated with an EIP. This solution is suitable for the following scenarios:

    • Access to the Internet from the application: SAE services need to access external services over the Internet. EIPs are not fixed, and auto scaling policies are not required.
    • Access to the application from the Internet: The client uses the EIP of each instance to access the application. EIPs that are not associated are used when you deploy and update an application in SAE. Therefore, this solution is not suitable for scenarios in which external services need to access SAE services by using fixed IP addresses.
Note If you purchase EIPs and use Solution 2 when you create or deploy an application, SAE automatically associates an EIP with each application instance that requires access to the Internet. After EIPs are associated with the instances of an application, you can configure an auto scaling policy. However, you cannot use or enable the auto scaling policy. If your application needs to use the auto scaling feature and access the Internet, we recommend that you use Solution 1.

Billing

You are charged only when you purchase EIPs. No additional charges are included into your SAE bills. For more information, see Billing overview of EIP and Billing overview of SAE.

Usage notes

  • If you associate EIPs when you deploy an application, SAE creates instances and then releases the original instances. During this process, the original EIPs are not released. In this case, you must prepare additional EIPs for the new instances.
  • After EIPs are associated with the application instances, view the security group to check whether a port whitelist is configured. For more information, see Add a security group rule.

Configure EIPs when you create an application

  1. Log on to the SAE console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click Create Application.

  3. In the Basic Information step, configure the parameters and click Next: Application Deployment Configurations.
  4. In the Deployment Configurations step, configure the Technology Stack Programming Language and Application Deployment Method parameters and the corresponding settings.
    1. In the Application Outbound/Inbound Internet Access section, turn on the switch in the Solution 2: Associate EIPs text box.
      If you do not turn on the switch when you create an application, EIPs are not associated with the application instances during manual scaling. In this case, you must configure the settings when you deploy the application. bt_bind_EIP
    2. Click Next: Confirm Specifications.
  5. In the Specification Confirmation step, view the details of the application and the fee for the selected specifications. Then, click Confirm.
    The Creation Completed step appears. You can click Application Details to go to the Basic Information page of the application.
  6. Verify the result.
    In the left-side navigation pane, click Basic Information. On the Basic Information page, click the Instance Deployment Information tab. In the Default Group section, view the IP Address of the instances.

Configure EIPs when you deploy an application

Warning After you redeploy an application, the application is restarted. To prevent unpredictable errors such as business interruptions, we recommend that you deploy applications during off-peak hours.

The procedure that can be performed to update an application varies based on the number of instances in the application. This section provides an example on how to configure the required features for an application in which the number of instances is greater than or equal to 1. For information about how to update an application in which the number of instances is 0, see Update an application.

  1. Log on to the SAE console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.
  3. In the upper-right corner of the Basic Information page, click Deploy Application.
  4. In the Application Outbound/Inbound Internet Access section of the Deploy Application page, configure the parameters. bt_bind_EIP
    The deployment method of an application is based on the deployment method that you selected for the application for the first time. Configure the parameters based on the selected method.
    You can configure EIPs in the following scenarios:
    • Scenario 1: No auto scaling policy is configured or enabled.
      • Associate EIPs.

        Turn on the switch in the Solution 2: Associate EIPs text box.

      • Disassociate EIPs.
        1. Turn off the switch in the Solution 2: Associate EIPs text box.
        2. In the Disassociate EIPs message, click OK.
    • Scenario 2: An auto scaling policy is enabled.
      1. In the Resume Auto Scaling After Application Deployment section, select Manual.
        Note If you select Automatic when you deploy an application, the application cannot be associated with EIPs.
      2. Associate or disassociate EIPs.
        • Associate EIPs.

          Turn on the switch in the Solution 2: Associate EIPs text box.

        • Disassociate EIPs.
          1. Turn off the switch in the Solution 2: Associate EIPs text box.
          2. In the Disassociate EIPs message, click OK.
        Note After an application is associated with EIPs, SAE disables the enabled auto scaling policy. The auto scaling feature cannot be enabled. If your application needs to use the auto scaling feature and access the Internet, we recommend that you use Solution 1. For more information, see Configure a NAT gateway for an SAE application to enable Internet access.
  5. After you configure the settings, click Confirm.
  6. Verify the result.
    In the left-side navigation pane, click Basic Information. On the Basic Information page, click the Instance Deployment Information tab. In the Default Group section, view the IP Address of the instances.

Configure EIPs when you roll back an application

If you want to roll back an application to an earlier version in which EIPs are associated and an auto scaling policy is enabled, perform the following steps to configure EIPs:

  1. Log on to the SAE console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.
  3. In the upper-right corner of the Basic Information page, click Back to Earlier Version.
  4. On the Back to Earlier Version page, configure the parameters.
    1. In the Select Earlier Version section, select the version to which you want to roll back the application.
      Note In this example, the selected application version is associated with EIPs.
    2. Optional:In the Resume Auto Scaling After Application Deployment section, select Manual.
      • If you do not enable an auto scaling policy before you roll back the application to an earlier version, you do not need to perform this step.
      • If you select Automatic, a message indicating that the auto scaling feature cannot be enabled because the application is associated with EIPs is returned. m_auto_scaling_cannot_open
    3. Select the Select Phased Release/Canary Release Policy check box and configure a release policy.
    4. Click OK.
  5. Verify the result.
    In the left-side navigation pane, click Basic Information. On the Basic Information page, click the Instance Deployment Information tab. In the Default Group section, view the IP Address of the instances.

Configure EIPs during manual scaling

  1. Log on to the SAE console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.
  3. In the upper-right corner of the Basic Information page, click Manual Scaling.
  4. In the Application Scaling dialog box, configure the parameters.
    You can configure application scaling in the following scenarios. For more information, see Manually scale instances.
    • Scenario 1: No auto scaling policy is configured or enabled before manual scaling.

      Configure the Expected Application Instances parameter.

      sc_pod_scaling_without_opening_autoscaling
    • Scenario 2: An auto scaling policy is configured and enabled before manual scaling.
      1. Configure the Expected Application Instances parameter.
      2. Select Manual.
      sc_pod_scaling_with_opening_autoscaling.png
      Note If you select Automatic when you deploy an application, the application cannot be associated with EIPs.
  5. Click OK.
  6. Associate or disassociate EIPs.
  7. Verify the result.
    In the left-side navigation pane, click Basic Information. On the Basic Information page, click the Instance Deployment Information tab. In the Default Group section, view the IP Address of the instances.

View application events

On the Application Events page, you can view the error information of application instances.

  1. Log on to the SAE console.
  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.
  3. In the left-side navigation pane, click Application Events, select Application Instance (Pod) from the All Source Types drop-down list, and then select Warning from the All Event Levels drop-down list. In the lower part of the page, view the detailed error information of the application instance.
    Troubleshoot the failure based on the value that is displayed in the Event Cause column.
    • EipNotEnough: indicates that the existing EIPs are insufficient. You must apply for the required number of EIPs or scale in the instances of the application. For more information, see Apply for an EIP and Manually scale instances.
    • EipNotReady: indicates that EIPs fail to be associated or disassociated. In this case, join the DingTalk group 32874633 for technical support.