Akamai EdgeWorkers
Starter Kit hosted on GitHub for running Optimizely Full Stack feature flags and experiments on the Akamai EdgeWorkers service.
Akamai EdgeWorkers
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 having to learn 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 allow you to write and deploy JavaScript functions at the edge. For example use cases, refer to the EdgeWorkers documentation.
Restrictions and Limitations
There are various restrictions and limitations to EdgeWorkers to keep in mind when running Full Stack 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 starter kit for Akamai's Edge Workers embeds and extends our 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 our platform more generally, this can be combined with the steps outlined in our Javascript Quickstart.
Identity Management
Out of the box, Optimizely's Full Stack SDKs require a user-provided identifier to be passed in 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
You can view more information on how Optimizely Full Stack SDKs assign users to feature flags and experiments with this documentation on how bucketing works.
How to use
Prerequisites
You should 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
- Setup Authentication credentials.
- Create a new 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
or
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 SDK key and flag in
src/main.js
. Your SDK keys can be found 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 in bundle.json
. This should be updated on every new deployment.
- Enable Advanced debug headers to receive debug logs in the response headers.
Additional resources
Updated about 1 year ago