Enhance Your Edge Native Apps with Low Latency Using Multiple EdgeWorkers

Akamai Wave Blue

Written by

Hitoshi Kaneko and Yo Nishiyama

June 11, 2025

Hitoshi Kaneko

Written by

Hitoshi Kaneko

Hitoshi Kaneko is a Senior Technical Solutions Architect within the Compute and Delivery Division at Akamai. His primary focus is helping customers develop computing strategies and improve website performance.

Yo Nishiyama

Written by

Yo Nishiyama

Yo Nishiyama is a Solutions Architect within the APJ Services Professional Service Division at Akamai. He leads the technical integration of Akamai solutions with customers' web applications.

Flexible Composition makes it easier than ever to build edge native applications.
Flexible Composition makes it easier than ever to build edge native applications.

Akamai's powerful edge computing solution, Akamai EdgeWorkers, allows you to enhance your applications by running JavaScript code with low latency on edge servers closer to your end users. In this blog post, I will explain how to deploy multiple EdgeWorkers even more effectively in your applications by using Flexible Composition.

Executive summary

  • Flexible Composition allows you to deploy multiple EdgeWorkers within a single request, which enables you to build edge native applications with greater flexibility.

  • Flexible Composition enhances application performance by processing requests closer to users.

  • Flexible Composition reduces load on your cloud infrastructure by offloading tasks to the edge.

Why it matters

As Akamai expands its network of qualified computing partners, you may find yourself relying on EdgeWorkers more frequently. And as more edge -native applications are integrated into your web services, efficiently managing multiple EdgeWorkers within a single request becomes essential for maintaining performance and scalability.

For example, Harper offers a real-time distributed application and data platform that can enhance your application's performance by processing requests closer to users, thereby reducing response times and improving the overall user experience (Figure 1). It also reduces the load on your cloud infrastructure by executing distributed application logic directly on Harper, running within Akamai Cloud.

Another example is Queue-it, a virtual waiting room solution that enables you to create a visually rich waiting room experience on edge servers and the Queue-it platform without requiring integration on your origin servers. This offloads significant traffic from your back-end systems, ensuring higher availability and scalability during peak times.

How Harper and Queue-it rely on EdgeWorkers to enhance performance and create a better user experience Fig. 1: How Harper and Queue-it rely on EdgeWorkers to enhance performance and create a better user experience

Flexible Composition efficiently manages multiple EdgeWorkers in a simple and secure way by allowing you to keep EdgeWorker logic modular and separated. It also makes it easier to orchestrate specialized EdgeWorkers without introducing latency or operational complexity. 

How it’s done

For example, let’s look at how to implement both Queue-it logic and a custom cookie setting.

You can prepare two EdgeWorkers in advance: One is the parent EdgeWorker, which is associated with Property Manager, and the other is the child EdgeWorker, which is linked through the EdgeWorker bundle JSON file (Figure 2).

Preparing the parent and child EdgeWorkers in advance Fig. 2: Preparing the parent and child EdgeWorkers in advance

I will begin with the parent EdgeWorker. Similarly to setting up a regular EdgeWorker, you can add an EdgeWorker behavior in Property Manager (Figure 3).

Adding an EdgeWorker behavior in Property Manager Fig. 3: Adding an EdgeWorker behavior in Property Manager

In the parent EdgeWorker configuration (EWID: 1 in this example), you can specify the bundle JSON file to establish the connection with the child EdgeWorker. In Figure 4, the EdgeWorker with ID 2 contains the Queue-it code bundle. You can reference it in the bundle.json file.

  {
    "edgeworker-version": "0.1",
    "description" : "Flexible composition for Queue-it",
    "dependencies": {
        "queueit": {
            "edgeWorkerId": 2,
            "version": "active"
        }
    }
}

Fig. 4: Adding dependencies to a bundle JSON file

In main.js, you can add your custom logic without modifying the original Queue-it code bundle, as it is imported, as shown in Figure 5.

  import * as queueit from "queueit";

export async function onClientRequest(request) {
  await queueit.onClientRequest(request);
}

export async function onClientResponse(request, response) {
  await queueit.onClientResponse(request, response);
  //custom code after QueueIt
  const cookies = new Cookies(request.getHeader('Cookie'));
  
  if (!cookies.get('mycookie')) {
    const value = Math.random().toString(36).slice(-8);
    const setCookie = new SetCookie({
      name: 'mycookie',
      value,
      path: '/',
      maxAge: 10
    });
    response.setHeader('Set-Cookie', setCookie.toHeader());
  }
}

Fig. 5: Adding custom logic without modifying the original code bundle

Figure 6 is a quick test using the cURL command to verify that both logics work correctly in a single request. As you can see, the Akamai edge server responds with a 302 redirect to route traffic to a virtual waiting room, while at the same time, a custom cookie (in this case, mycookie) is also set.

Test to verify that both logics work correctly in a single request Fig. 6: Test to verify that both logics work correctly in a single request

Easier builds and smoother deployments

Flexible Composition makes it easier than ever to build edge native applications. This approach also allows you to logically separate responsibilities among different teams or divisions, ensuring smoother development and deployment processes.

Get started

You can find more details about Flexible Composition in the technical documentation. If you would like to try Flexible Composition, please contact your Akamai account representative to help you get started.



Akamai Wave Blue

Written by

Hitoshi Kaneko and Yo Nishiyama

June 11, 2025

Hitoshi Kaneko

Written by

Hitoshi Kaneko

Hitoshi Kaneko is a Senior Technical Solutions Architect within the Compute and Delivery Division at Akamai. His primary focus is helping customers develop computing strategies and improve website performance.

Yo Nishiyama

Written by

Yo Nishiyama

Yo Nishiyama is a Solutions Architect within the APJ Services Professional Service Division at Akamai. He leads the technical integration of Akamai solutions with customers' web applications.