EdgeRoutine (ER) is a JavaScript code runtime environment that runs on Alibaba Cloud edge nodes around the world. It supports the ES6 syntax and standard Web Service Worker APIs. You can deploy your JavaScript code to ER to take advantage of the global network coverage of ER. This allows you to process requests at the edge nodes closest to the client.

ER

Benefits

  • Global deployment, near-site scheduling, and ultra-low latency: Unlike cloud computing services such as Function Compute and Elastic Compute Service (ECS), ER does not need to be deployed in a specified region. ER runs on edge nodes all over the world. Client requests are automatically scheduled to the nearest edge nodes, which immediately trigger your code and serve client requests. ER can significantly reduce the server response time, allowing you to deliver low-latency services to your customers.
  • Automatic scale-out and pay-as-you-go billing: Alibaba Cloud has constructed an edge network consisting of more than 2,800 nodes around the world, offering unparalleled scalability. If the number of client requests in a region spikes, these requests are automatically scheduled to the nearest edge nodes that have sufficient compute resources. You are charged for ER based on the number of calls made to the service.
  • Easy-to-use serverless mode: ER allows you to focus on your business logic without having to manage underlying resources such as CPU, memory, network, and operating system. You can upload your code in the console or use APIs to implement application deployment. Serverless development can effectively reduce your development and O&M costs.

How ER works

How ER works
  • Scenarios where Alibaba Cloud CDN or Dynamic Route for CDN (DCDN) processes requests without using ER: 1. The client initiates a request to the edge node gateway. → 2. Alibaba Cloud CDN or DCDN searches for the requested content in the cache. If the requested content is cached on edge nodes, the requested content is directly returned to the client. → 3. If the requested content is not cached on edge nodes, the request is redirected to the origin server to retrieve the requested content.
  • Scenarios where Alibaba Cloud CDN or DCDN processes requests by using ER: 1. The client initiates a request to the edge node gateway. → 4. ER runs JavaScript code to compute and process the request. → ER initiates a fetch request to access the cache, to retrieve content from the origin server (Arrow 5 or 3), or to access other Internet services (Arrow 6).
    Note The preceding figure shows that ER runs scripts after the request passes the gateway. Therefore, configurations of CDN or DCDN-accelerated domain names, including HTTPS settings, access control settings, performance optimization settings, and cache settings, that are specified in the console remain in effect.

Basic concepts

  • Routine: ER is a JavaScript code runtime environment that runs on Alibaba Cloud edge nodes. You can upload and run JavaScript code in ER. You must create a routine before you use ER. A routine consists of two parts: configurations and the JavaScript code script that you uploaded. The configurations specify information about the routine such as the name, description, CPU and memory caps, and whitelist.
  • Version: Routine supports version management. In the process of developing a routine, the JavaScript code is constantly modified and updated. When you complete testing for a stage, you can take a snapshot of the current state of the code by creating a code version. When you deploy a routine, you must 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.
  • Environment: ER provides the test environment, production environment, and canary release environment. These environments are provided to facilitate development, testing, and deployment.
    • Test environment: A test environment is an independent edge node that is used to test code. The test environment simulates the production environment, but is isolated from the production environment. You can freely modify the routine configuration or code in the test environment, which does not affect the production environment. The test environment can be accessed only after you add the IP address provided on the page to your hosts file.
    • Production environment: The production environment, also known as the online environment, consists of numerous edge nodes all over the world. After you test your code in the test environment, you can deploy the code to the production environment. The preceding figure is provided for reference only. ER automatically increases or decreases the nodes based on your request volume. The actual node distribution may vary based on multiple factors.
    • Canary release environment: The canary release environment allows you to gradually expand the scope of your deployment. It is risky to deploy code or configuration changes directly to the production environment. If errors exist in your code or configurations, they may affect your users. If your business has a wide scope, or you want to control risks when deploying changes, we recommend that you use the canary release environment. The canary release environment is relatively complex. We recommend that you have a basic understanding of the environment before you use it. For more information, see Canary release environment (optional).
  • Domain name: After you create a routine and deploy code, you must use a domain name as the portal of the routine for clients to access. ER only supports Alibaba Cloud CDN and DCDN-accelerated domain names as portals. You can associate ER with CDN or DCDN domain configurations.
  • Edge nodes refer to CDN or DCDN nodes for whole site acceleration, which are also nodes that are closest to your users.

Limits

Feature Limit Description
CPU time 5 ms, 50 ms, and 100 ms The CPU time slice allocated by ER for a single execution. I/O wait is not calculated into CPU time. You can select one of the three options: 5 ms, 50 ms, and 100 ms. For more information, see Billing.
Memory size 128 MB The memory size of a domain name on a single physical machine (PM). All requests for the domain name share the memory. For example, the maximum JavaScript sandbox memory size on a PM is 128 MB.
Real time (RT) 120s The response time of a single execution for ER cannot exceed 120s. I/O wait is also calculated into RT.
Waiting time 5s The time during which the gateway waits for ER. If ER does not return data within 5s, the gateway disconnects from the server and returns a 504 status code 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 allowed by ER in a single 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 Up to 10 versions can be reserved for each routine.