Sample Application Demonstrating Ratio based Routing to a legacy and a modern app
This app demonstrates using Zuul to route to a "legacy" and a "pcf" based app based on user specified ratios.
Additionally it understands sessions - if say the user is routed to the legacy app and the app is session based then further requests from the user will be pinned to the legacy app.
Starting it up Locally
In three terminal windows:
cd zuulgateway ../gradlew bootRun
cd legacyapp ../gradlew bootRun
cd pcfapp ../gradlew bootRun
Testing the routing behavior
Access an endpoint - http://localhost:8080/routes/message, the request will be routed to either "pcfapp" or "legacyapp" based on this property:
routing: ratio: old-percent: 50
Access another session based endpoint in an "Incognito" window - http://localhost:8080/routes/withsession, the behavior now will be once the user is directed to one of the versions of the app, subsequent requests should stick to the same app.
Deploying to CloudFoundry using SCS Tile
All the libraries relevant to getting it to work with SCS tile is already present with the app, just bind to Eureka, specify the name of the "pcfapp" via properties in zuulgateway, for eg:
pcf: ribbon: DeploymentContextBasedVipAddresses: myeurekaappname
Challenges with Sticky session
If Zuul and the target app are hosted on PCF then the call will go via gorouter twice. If there is JSESSIONID being set, then the gorouter tends to add the VCAP_ID twice
We add a custom token to route to "legacy" or "pcf" app - however we don’t have a good mechanism to expire this currently. Short term we plan to just add the same expiry as the JSESSIONID cookie, but we will never know if the session has been invalidated manually.