Sign inSign up

diffy/example-service

By diffy

Updated about 8 years ago

A sample service to see Diffy in action

Image
3

2.4K

diffy/example-service repository overview

If you like the service, give us a star on this image or github :)

This is a sample service that is meant to test out the Diffy service.


TL;DR

> docker pull diffy/example-service
> docker run -d --name exd-primary -p 9990:5000 diffy/example-service:production
> docker run -d --name exd-secondary -p 9991:5000 diffy/example-service:production
> docker run -d --name exd-candidate -p 9992:5000 diffy/example-service:candidate

# run diffy
> docker run -d --name diffy-01 \
    --link exd-candidate:candidate --link exd-primary:primary --link exd-secondary:secondary 
    -p 8880:8880 -p 8881:8881 -p 8888:8888  diffy/diffy \
         -candidate=candidate:5000     -master.primary=primary:5000     -master.secondary=secondary:5000     
         -service.protocol=http     -serviceName=Test-Service
         -proxy.port=:8880     -admin.port=:8881     -http.port=:8888     -rootUrl=localhost:8888

# start sending diffy some data
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:8880/success?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:8880/noise?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:8880/regression?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:8880/noisy_regression?value=happy-tester

Visit: http://localhost:8888


More details

This image is for a service that spins up a server serving 4 endpoints:

  • success: we expect all good responses from this endpoint (no noisy information)
  • regression: we expect all responses to be different between primary and candidate, but be the same between primary and secondary
  • noise: we expect no behavioural changes between candidate and primary, but the responses will have noisy fields in them
  • noisy_regression: contains both noise and regression

Once data from all 4 endpoints is sent to diffy, you can enable the noise cancellation feature to see the real behavioural difference views.

Example Setup: Production service: primary

This is the production service we expect to be stable.

> docker pull diffy/example-service:production
> docker run -d --name exd-primary -p 9990:5000 diffy/example-service:production
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9990/success?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9990/noise?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9990/regression?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9990/noisy_regression?value=happy-tester
Example Setup: Production service: secondary

For Diffy we need 2 instances of this service running simultaneously (your primary and secondary services).

> docker pull diffy/example-service:production
> docker run -d --name exd-secondary -p 9991:5000 diffy/example-service:production
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9991/success?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9991/noise?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9991/regression?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9991/noisy_regression?value=happy-tester
Example Setup: Candidate service

The candidate service contains the changes you wish to push out in production, but should get a Diffy run in to get a clear picture of your behaviour changes.

> docker pull diffy/example-service:candidate
> docker run -d --name exd-candidate -p 9992:5000 diffy/example-service:candidate
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9992/success?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9992/noise?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9992/regression?value=happy-tester
> curl -s -i -H Canonical-Resource : endpoint-test http://localhost:9992/noisy_regression?value=happy-tester
Example Setup: Diffy

Finally we have all our service up and running, so we're ready to deploy a Diffy instance to test the candidate out:

> docker run -d --name diffy-01 \
    --link exd-candidate:candidate --link exd-primary:primary --link exd-secondary:secondary 
    -p 8880:8880 -p 8881:8881 -p 8888:8888  diffy/diffy \
         -candidate=candidate:5000     -master.primary=primary:5000     -master.secondary=secondary:5000     
         -service.protocol=http     -serviceName=Test-Service
         -proxy.port=:8880     -admin.port=:8881     -http.port=:8888     -rootUrl=localhost:8888

OR feel free to build your own image from the code and use that.

Example Setup: Sending data

Feel free to use the following script to generate some traffic:

#!/usr/bin/env bash
echo "Send some traffic to your Diffy instance"
declare -a endpoints=("success" "noise" "regression" "noisy_regression")
declare -a values=("mixpanel" "twitter" "airbnb" "paytm" "baidu")
for i in {1..10}
do
    for k in "${endpoints[@]}"
    do
        for v in "${values[@]}"
        do
            sleep 0.1
            curl -s -i -H "Canonical-Resource : endpoint-$k" http://localhost:8880/$k?value=$v > /dev/null
        done
    done
done

Tag summary

Content type

Image

Digest

Size

34.1 MB

Last updated

about 8 years ago

docker pull diffy/example-service:candidate