EdgeRoutine (ER) is a JavaScript code runtime environment that runs on globally distributed Dynamic Route for CDN (DCDN) points of presence (POPs). ER supports the ES6 syntax and standard Web Service Worker APIs. You can deploy your JavaScript code to ER, which then propagates your code across the global DCDN network. This allows DCDN to process requests on the POPs that are closer to the clients.

EdgeRoutine

Service activation

ER is in Beta release and available only to selected users. If the daily peak bandwidth of your DCDN service exceeds 500 Mbit/s, you can submit a ticket. to activate ER. We apologize for the inconvenience this may have caused. For more information about public previews, see Announcements and Updates.

Benefits

  • Global deployment, near-site scheduling, and ultra-low latency: Unlike common 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 points of presence (POPs) all over the world. Client requests are automatically scheduled to the nearest POPs, which immediately trigger your code and serve client requests. ER can significantly reduce the server response time. This allows 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 that consists of more than 3,200 POPs around the world. These POPs offer unparalleled scalability. When the number of client requests in a region spikes, these requests are automatically scheduled to the nearest POPs 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 by using the console or API to implement application deployment. Serverless development can effectively reduce your development and O&M costs.

How it works

How ER works
  • Scenarios in which ER 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.DCDN
  • Scenarios in which ER is used: 1. Clients initiate requests to the gateways of the POPs. → 4. The requests are managed by ER and trigger the relevant JavaScript code. → Fetch requests are sent to the cache and origin server (No.5 or No.3), or to other Internet services (No.6).DCDN
    Note In the preceding figure, ER is executed behind the gateway. Therefore, DCDN-accelerated domain settings (such as HTTPS configuration, access control, performance optimization, and cache settings) that are configured in the console will continue to take effect.

Basic concepts

  • Routine: ER is a JavaScript code runtime environment that runs on Alibaba Cloud POPs. You can upload and run JavaScript code in ER. You must create a routine before you can use ER. A routine consists of two parts: 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, and domain whitelist. Routine
  • Version: Routine supports version management. In the process of developing a routine, the JavaScript code is constantly modified and updated. When you finish 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. Version
  • Environment: ER provides the staging environment, production environment, and canary release environment. These environments are provided to facilitate development, testing, and deployment.Environment
    • 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, which does not affect the production environment. The staging 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 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. ER automatically adds or removes POPs based on your request volume. The actual POP 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 the scale of your business is large or you want to control risks when you make code or configuration changes, we recommend that you use the canary release environment to control the deployment scope. The canary release environment is relatively complex. We recommend that you understand the basics 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 CDN- and DCDN-accelerated domain names as portals. You can associate ER with domain names in the Alibaba Cloud CDN or DCDN console. Domain name
  • POPs: They are used by Alibaba Cloud CDN and DCDN for content delivery. Client requests are scheduled to the nearest POPs.

Limits

FeatureLimitDescription
CPU time5 ms, 50 ms, and 100 msThe 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 rules.
Memory128 MBThe 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)120sThe response time of a single execution for ER cannot exceed 120s. I/O wait is also calculated into RT.
Waiting time10sThe time during which the gateway waits for ER. If ER does not return data within 10s, the gateway disconnects from the server and returns the HTTP 504 status code to the client.
Code package size4 MBThe maximum size of the JavaScript code file for each routine.
Number of fetch requests4The number of fetch requests allowed by ER in a single execution.
Executable code or filesJavaScript code or WebAssembly filesOnly JavaScript code and WebAssembly files are supported. You must know how to use JavaScript or convert the source code to WebAssembly files.
Number of routines50You can create up to 50 routines for each Alibaba Cloud account.
Number of versions10Up to 10 versions can be reserved for each routine.
Supported protocolOnly HTTPSWebSocket, TCP, and UDP are not supported.
SubrequestsNoneYou cannot initiate a fetch request to an ER domain name in a routine. For example, if a.com and b.com are ER domain names, you cannot initiate a fetch request to a.com or b.com in a routine.