Akamai EdgeWorkers
Starter Kit hosted on GitHub for running Optimizely Feature Experimentation feature flags and experiments on the Akamai EdgeWorkers service.
The Akamai EdgeWorkers service makes it possible to deploy JavaScript functions at the edge and create customized experiences for your website visitors.
Advantages of Akamai EdgeWorkers
-
Innovation – Development teams can freely build logic safeguarded against unwanted usage through security protections provided by Akamai.
-
Improved time to market – Developers can manage Akamai and deliver their code in JavaScript without learning a new, proprietary language.
-
Logic is executed close to users – Code is sent across the world's largest distributed network, the Akamai Edge.
-
Decreased overhead at origin – Developers can create code and not worry about internal infrastructure or increased traffic at the origin.
Akamai EdgeWorkers use cases
EdgeWorkers let you write and deploy JavaScript functions at the edge. For use cases, refer to the EdgeWorkers documentation.
Restrictions and limitations
There are various restrictions and limitations to EdgeWorkers to keep in mind when running Optimizely Feature Experimentation feature flags and experiments. Refer to the official Akamai documentation for the most recent product limits and specific resource tier limitations. Also, review the known issues with EdgeWorkers.
Optimizely + Akamai EdgeWorkers starter kit
The Optimizely Feature Experimentation starter kit for Akamai's Edge Workers embeds and extends the Javascript Node SDK to provide a starting point for you to implement experimentation and feature flagging for your experiences at the Edge. For a guide to getting started with the Optimizely platform more generally, this can be combined with the steps outlined in the Javascript SDK Quickstart.
Identity management
Optimizely's Feature Experimentation SDKs require passing a user-provided identifier at runtime to drive experiment and feature flag decisions. This example generates a unique ID, stores it in a cookie, and reuses it to make the decisions sticky. Alternatively, you can use an existing unique identifier available within your application and pass it in as the value for the OPTIMIZELY_USER_ID cookie.
Bucketing
See How bucketing works for information on how Optimizely Feature Experimentation SDKs assign users to feature flags and experiments.
How to use
Prerequisites
You must have these prerequisites to use this starter kit:
- An Optimizely account. If you do not have an account, you can register for a free account.
- An Akamai account with EdgeWorkers added to your contract.
- The Akamai CLI.
Get started
-
Create an EdgeWorker ID.
-
Add the EdgeWorker Behavior.
-
Install the Akamai CLI.
-
Install the EdgeWorkers CLI.
akamai install edgeworkers
-
Set up Akamai Authentication credentials.
-
Create a folder and download the Optimizely and Akamai Edgeworkers starter kit code from GitHub for the starter kit into it.
curl -L https://github.com/optimizely/akamai-edgeworker-starter-kit/tarball/main | tar --strip-components=1 -zx
wget --no-check-certificate https://github.com/optimizely/akamai-edgeworker-starter-kit/tarball/main -O - | tar --strip-components=1 -zx
-
Install the node modules.
npm install
-
Add your Optimizely Feature Experimentation SDK key and flag in
src/main.js
. Your SDK keys are in the Optimizely application under Settings. -
Build the bundle.
npm run build
-
Upload the bundle.
akamai edgeworkers upload --bundle="dist/bundle.tgz" {WORKER_ID}
-
Activate the version
akamai edgeworkers upload --bundle="dist/bundle.tgz" {WORKER_ID}
WORKER_ID
– Unique ID for your EdgeWorker. This can be obtained from the Akamai control center.ENVIRONMENT
– The environment the EdgeWorker is being deployed on.EDGEWORKER_VERSION
– The custom version of the EdgeWorker as mentioned inbundle.json
. This should be updated on every deployment.
- Enable Advanced debug headers to receive debug logs in the response headers.
Additional resources
Updated 6 months ago