All Products
Search
Document Center

Edge Security Acceleration:Edge Routin overview

Last Updated:Dec 03, 2024

Edge Routine is a serverless runtime environment that allows you to write JavaScript code and deploy and execute it on Alibaba Cloud points of presence (POPs) worldwide. Edge Routine supports ES6 syntax and standard Web Service Worker APIs. With Edge Routine, user requests can be responded to and processed by the POP that is closest to users. This significantly reduces latency, accelerates response, and enhances user experience.

image

Benefits

  • Global deployment, near-site scheduling, and ultra-low latency: Compared with common cloud computing services, such as Function Compute and Elastic Compute Service (ECS), Edge Routine does not need to be deployed in a specific region. Edge Routine runs on POPs around the globe. Client requests are automatically scheduled to the nearest POPs, which immediately run your code and process client requests. Edge Routine can significantly reduce the server response time, which helps you deliver low-latency services to your users.

  • Automatic scale-out and pay-as-you-go billing: Alibaba Cloud has constructed an edge network that consists of more than 3,200 POPs around the world. These POPs provide unparalleled scalability. If the number of client requests in a region surges, these requests are automatically redirected to the nearest POPs that have sufficient computing resources. You are charged for Edge Routine based on the number of calls that are made to the service.

  • Easy-to-use serverless environment: Edge Routine allows you to focus on your business logic without having to manage underlying resources, such as the CPU, memory, network, and operating system. You can upload your code by using the console or API to deploy applications. Serverless development can effectively cut your development and O&M costs.

How it works

image
  • Scenarios in which Edge Routine is not used: 1. Clients initiate requests to the gateways of the POPs. → 2. The POPs search for the requested content in the cache. If a request is a cache hit, the requested content is returned to the client. → 3. If a request is a cache miss, the request is redirected to the origin server.

  • Scenarios in which Edge Routine is used: 1. Clients initiate requests to the gateways of the POPs. → 4. The requests are managed by Edge Routine, and the relevant JavaScript code is triggered. → Fetch requests are sent to the cache (Step 5) and origin server (Step 3 → Step 5), or to other publicly-accessible services (Step 6).

    Note

    In the preceding figure, Edge Routine is executed behind the gateway. In this case, the settings of Edge Security Acceleration (ESA)-accelerated domain names that are configured in the console, such as HTTPS configurations, access control, performance optimization, and cache settings, will continue to take effect.

Terms

  • routine: Edge Routine is a JavaScript code runtime environment that runs on Alibaba Cloud POPs. You can upload and run JavaScript code in Edge Routine. You need to create a routine before you can use Edge Routine. A routine consists of configurations and the JavaScript code script that you upload. The configurations specify information about the routine, such as the name, description, CPU, and memory caps.

    image
  • version: Routines support version management. During the development of a routine, JavaScript code is constantly modified and updated. After you complete testing for a stage, you can create a code version by taking a snapshot of the current state of the code. When you release a routine, you need to select a code version. The system allows you to select earlier versions and manage historical code. Each version has a version number, which is automatically generated by the system.

    image
  • environment: Edge Routine provides the staging environment, production environment, and canary environment.

    image
    • staging environment: A staging environment is an independent POP that is used to test code. The staging environment simulates the production environment but is isolated from the production environment. You can modify the routine configuration or code in the staging environment. This does not affect the production environment. You can access the staging environment only after you add the IP address that is provided on the page to your hosts file.

    • Production environment: The production environment, also known as the deployment environment, consists of a large number of POPs that are distributed worldwide. After you test your code in the staging environment, you can deploy the code to the production environment. The preceding figure is provided for reference only. Edge Routine automatically adds or removes POPs based on your request volume. The POP distribution may vary according to actual scenarios.

  • trigger: the invocation method of the function. You can associate a domain with a routine to redirect requests destined for the domain to the associated routine. Alternatively, you can create a route that maps a URL pattern to a routine. When an incoming request matches the defined URL pattern, the mapped routine is triggered. For more information, see Configure a trigger.

Limits

Feature

Limit

Description

CPU time

5 ms, 50 ms, and 100 ms

The CPU time slice that is allocated by Edge Routine for an execution. I/O wait is not included in the calculated CPU time. You can select one of the three options: 5 ms, 50 ms, and 100 ms.

Memory

128 MB

The allocated memory for a domain name on a physical machine. All requests for the domain name share the memory. For example, the maximum JavaScript sandbox memory on a physical machine is 128 MB.

Real time

120s

The response time of an execution for Edge Routine cannot exceed 120s. I/O wait is included in the calculated real time.

Waiting time

10s

The time during which the gateway waits for Edge Routine. If Edge Routine does not return data within 10s, the gateway disconnects from the server and returns HTTP status code 504 to the client.

Code package size

4 MB

The maximum size of the JavaScript code file for each routine.

Number of fetch requests

4

The number of fetch requests that is allowed by Edge Routine in an execution.

Programming language

JavaScript (ES6 syntax)

Only JavaScript is supported. You need to know how to use JavaScript.

Number of routines

50

You can create up to 50 routines for each Alibaba Cloud account.

Number of versions

10

You can save up to 10 versions for each routine.