A/B Testing With Kubernetes and Istio
See how you can use Kubernetes and Istio together to implement A/B testing in your app so that you can measure user response and make the best decisions.
Join the DZone community and get the full member experience.
Join For Freelast week i gave a presentation “ when to use serverless? when to use kubernetes? ” one of the weaknesses of serverless platforms is that you currently cannot do things like a/b testing well since there is no notion of versions.
a/b testing allows running multiple variants of functionality in parallel, so that through analytics of user behavior, the better variant can be determined. similar to ‘dark launches,’ new features can be made available to only certain users to test features in production environments before these features will be released to the masses.
these traffic flow management capabilities are one of the advantages of kubernetes and istio . istio is an open platform to manage microservices.
some of my colleagues have documented how to do traffic flow management with istio for the book info sample that is part of the istio documentation . the current documentation is for istio 0.1.6 and doesn’t work for the later version 0.5.0, which i use. i’ve sent a pull request , since some urls have changed.
the diagram shows the architecture of the book info sample app. books have reviews and can have ratings. the application has three versions of the review service. the gray components on the left-hand side are the istio components. when the sample application is deployed, further istio components, the envoy containers, are automatically added to each pod. these envoy components are proxies (also called sidecars) through which containers communicate with each other which is the basis for istio’s traffic management capabilities.
check out the bookinfo.yaml file to see how to define and deploy the three versions of the review service.
in order to route traffic to version 1 for 50% of the invocations and to version 3 for the other half, this route rule can be used.
apiversion: config.istio.io/v1alpha2
kind: routerule
metadata:
name: reviews-default
spec:
destination:
name: reviews
precedence: 1
route:
- labels:
version: v1
weight: 50
- labels:
version: v3
weight: 50
in order to expose version 2 to only users with the name ‘jason’, a regular expression can be used.
apiversion: config.istio.io/v1alpha2
kind: routerule
metadata:
name: reviews-test-v2
spec:
destination:
name: reviews
precedence: 2
match:
request:
headers:
cookie:
regex: "^(.*?;)?(user=jason)(;.*)?$"
route:
- labels:
version: v2
Published at DZone with permission of Niklas Heidloff, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments