Traffic splitting allows you to distribute site traffic for the purpose of:
- A/B testing (aka split testing).
- Iterative site migrations.
- Gradual site build-outs.
- Improving performance through region-based origin routing.
By default, a request identifies:
- A hostname (e.g., www.example.com) associated with your property. All traffic for this hostname is directed at a single origin configuration (e.g., web).
- A relative path (e.g,. /images/bunny.png).
Traffic splitting allows you to distribute a hostname’s traffic across multiple origin configurations. It also allows you to rewrite or redirect requests to an alternate path. This flexibility allows you to tailor traffic splitting to fit your implementation.
This article explains how to split a percentage of your traffic through the Random Integer feature. In the near future, we will introduce a streamlined workflow for defining traffic splitting within the Edgio Console. Upon the introduction of this new workflow, you may choose to update your configuration or continue using the workflow described below.
Quick Start
Setting up traffic spliting involves performing the following steps:
-
Create a rule that identifies a set of requests and how those requests will be handled.The specifics on how to set up this rule vary according to your implementation. For example, the following rule sends half of your site’s traffic to a different origin configuration:In this example, the Random Integer feature is configured to randomly assign each request that originates from within the United States to a random value from 0 to 100. If the value assigned to a request is less than
50
, this rule will override your default origin configuration and send it to a different one. As a result, your traffic will be evenly split between two origin configurations. -
Deploy your changes.
If you are splitting traffic for the purpose of A/B testing, iterative site migrations, or gradual site build outs, then you may need to split traffic based off a cookie to ensure a consistent experience throughout the user’s session.
Traffic Splitting by Session Tutorial
There are many situations under which you should split traffic for the entire user’s session. For example, if you are testing a new UI design, then certain resources (e.g., CSS, JS, and HTML files) should persist throughout a user’s session to ensure a consistent experience. One way of accomplishing this is to set a cookie on the initial request. You could then check for that cookie to ensure that only those requests are sent to an alternate path or origin configuration.
Create a Set Cookie Rule
Create a rule that sets a cookie for the desired set of users. In this case, we will create a rule that sets a cookie for 10% of requests directed to your site’s homepage.
This tutorial assumes that you have not defined rules for your property.
-
Create a rule.
- Navigate to the Rules page for the desired environment.
- Click + Add Rule.
-
Add a condition that identifies requests to your website.
- Click + Add Condition.
- From the Variable option, select
Path
. - Set the Value option to
/
. - Click Add Condition.
-
Add a condition that identifies 10% of your traffic.
-
Click + Add Condition.
-
From the Variable option, select
Random Integer
. -
Set the Random Integer Range (from 0 to ?) option to
100
.This configuration requires Edgio to assign a random integer from 0 to 100 to each request. -
Set the Operator option to
less than
. -
Set the Value option to
10
.This configuration will only be satisfied when the random integer assigned to a request is less than10
. This should only happen approximately 10% of the time when requests are randomly assigned 101 different values (i.e., 0 to 100). -
Click Add Condition.
-
-
Add a feature that sets a cookie.
- Click + Add Feature.
- Select
Set Response Headers
. - Set the Header Name option to
Set-Cookie
. - Set the Value option to
newExperience=true
. - Click Add Feature.
Create a URL Rewrite Rule
Create a rule that rewrites requests for an alternate UI experience.
-
Create a rule by clicking + Add Rule.
-
Add a condition that identifies requests for the new UI experience.
- Click + Add Condition.
- From the Variable option, select
Cookie
. - Set the Cookie Name option to
newExperience
. - Set the Value option to
true
. - Click Add Condition.
-
Add a feature that rewrites URLs to a path that contains resources for the new UI experience.
- Click + Add Feature.
- Select
Rewrite URL
. - Set the Source Path (Optional) option to
/:path*
. - Set the Destination Path option to the path where the resources for the new UI experience are located (e.g.,
/newexperience/:path*
). - Click Add Feature.
Your rules should now look similar to this: -
Deploy your changes by clicking Deploy Changes.
Once the deployment completes, approximately 10% of your homepage’s traffic will be sent to a different path.