Blog

How to Set Up EdgeWorkers

May 5, 2021 · by Javier Garza ·
Categories:

This short blog will guide you through the process of setting up Akamai EdgeWorkers. The EdgeWorkers service makes it possible for you to run serverless code closer to your end users and improve your application performance — all while accelerating deployment times by applying solutions on a massive scale.

Setting up EdgeWorkers takes 5–10 minutes and consists of a few easy steps:

  1. Create an EdgeWorker ID

  2. Add the EdgeWorker to a property

  3. Activate the property in the Akamai platform

This initial setup is often done by an admin within your company who manages the Akamai service and has the right access to create EdgeWorkers and update existing properties in the Akamai Control Center. You’ll also need entitlements for Akamai EdgeWorkers and a delivery product.

Once you’ve completed the initial setup, a developer can create and deploy the JavaScript EdgeWorkers code, which we’ll cover in a separate blog.

Note: Although we’ll be using the Akamai Control Center, you can do everything we’re showing here with APIs.

Create an EdgeWorker ID

Log into the Akamai Control Center as an admin (or any other role that has access to EdgeWorkers), click the hamburger menu on the top left, and select CDN > EdgeWorkers (or just type EdgeWorkers into the search box).

EdgeWorkers

The EdgeWorkers management application will show all the different EdgeWorkers that have been created, along with their associated IDs. (IDs are just auto-generated numbers for each EdgeWorker.)

Click the Create EdgeWorker ID button. 

EdgeWorkers

Enter a short name that will help you identify the purpose of the EdgeWorker. 

Groups are optional and segregate user access. You can select the top-level group if you want the EdgeWorker to be visible to all users in your organization, or you can select a sub-group to limit visibility to the users in that sub-group. Then click the Create EdgeWorker ID button. 

Create EdgeWorker ID

You should get a confirmation message and see the new EdgeWorker listed with the auto-generated ID and name. Note that you can edit your EdgeWorker at any time and rename it, but the ID won’t change. (In the picture below, you can see that my EdgeWorker ID is 5357 and the name is hello-world.)

EdgeWorkers

Note: Make sure you remember the name and EdgeWorker ID, as we’ll need them in the next step.

Add the EdgeWorker to a property

Next, we need to add our EdgeWorker to a property. To do this, click the hamburger menu on the top left and select CDN > Properties (or just type “properties” into the search box). Then select the property you want and click the Edit New Version button. This will open the Property Manager, which is used to edit and activate Akamai properties.

Click the Add Rule button, select Blank Rule Template and give it a meaningful name that will help you identify the functionality of the rule, and click Insert Rule. 

EdgeWorkers

Next, we’ll add a match condition so the EdgeWorker function applies to a limited number of pages. Make sure you’re only using EdgeWorkers where they’re needed, which is important for performance and pricing. Let’s click the Add Match button to add match criteria and define the scope for the EdgeWorker. 

In this example, I’m going to enable my EdgeWorker code to run only when the path in the URL matches /hello-world.

Note: If you want the EdgeWorker to execute for all available URLs, you can just remove the match criteria.  

Next, click the Add Behavior button, search for EdgeWorkers, and click Insert. Now we’ll use the Identifier drop-down menu to search for and select the EdgeWorker we created earlier (in this case, 5357).

EdgeWorkers

Scroll to the top, add a version note that indicates what kind of change you made, like “adding Hello World EdgeWorker,” and click the Save button. 

Activate the property in the Akamai Platform

Switch to the Activate tab and activate our new configuration version to the staging network (you should get a notification email a few minutes after the deployment is complete).

EdgeWorkers

The EdgeWorkers setup process is now complete, and you’re ready to create and deploy JavaScript EdgeWorkers. 

Note: A hostname that points to the Akamai Staging Network will make testing easier. My property has two associated hostnames:

  • Edgeworkers-staging.akamaidevelopers.com (which resolves to the Akamai staging network)

  • Edgeworkers.akamaidevelopers.com (which resolves to the Akamai production network)

Summary

Now that you know how to create an EdgeWorker and add it to the delivery property where you want to use it, you’re ready to run serverless code, improve application performance, and accelerate deployment. Watch our video to run through each step, and refer back to it whenever you need a quick refresh.

Find more resources about EdgeWorkers by visiting developer.akamai.com/edgeworkers. And don’t forget to subscribe to the Akamai Developer YouTube channel for more developer videos!

Resources

About the author

JavierJavier Garza is a developer advocate at Akamai Technologies where he helps the largest companies on the internet run fast and secure apps by leveraging web performance, security, and DevOps best practices. Javier has written many articles on HTTP/2 and web performance, and is the co-author of the O’Reilly Book, Learning HTTP/2. In 2018, Javier spoke at more than 20 developer-related events around the world, including well-known conferences like Velocity, AWS Re:Invent, and PerfMatters. His life’s motto is: share what you learn, and learn what you don’t. In his free time he enjoys challenging workouts and volunteering for non-profits that support children and education.