From the course: Google Cloud Platform (GCP) Essential Training for Developers

Traffic splitting and rolling back deployments - Google Cloud Tutorial

From the course: Google Cloud Platform (GCP) Essential Training for Developers

Start my 1-month free trial

Traffic splitting and rolling back deployments

- [Presenter] Sometimes when you deploy a new version of your application, you might want to roll it out to a small subset of your users initially in case something goes wrong. Or you might want to test it first with a subset of users to see if it gets a positive response, you can do this with App Engine Traffic Splitting. In traffic splitting, we can set that incoming traffic requests get routed to different versions of our application. First, we go to the App Engine versions page. You can see all the different versions that we have deployed in our app. For now, we can see that all traffic is being served through only one version of the app. Now we can split some of that incoming traffic to the other versions of the app. To do this, we press the split traffic option over here. Now we have three options on how we can split traffic. The first one is by IP address. This means that the traffic will be routed depending on the IP address of the request. This is recommended when your users don't use cookies by default, like apps or non-browser-based HTTP clients. The second one is by cookie. This option is easier to implement for browser based apps. As cookies are already set up by default, though we would have to add a cookie ourselves to make this work. The third one is random which basically just routes requests to a random version, depending on the percentage that version is set to receive. This one however will mean that the user doing multiple requests could hit a different version at different times even within the same session. Let's try random, let's select it. Now we can add as many versions as we want, but let's just stick with two. Now we set how much traffic we want the split to be. Let's go at 50/50 and press save. Let's press back over here. And as you can see, our traffic allocation is now set to 50% for version one which is the background color, deep sky blue and version background color pale red 50% as well. Let's try it out and see if it works. Let's visit our site and as you can see it has the red background version, press refresh, still the red one, refresh again. And now we got the blue, refresh, refresh back to red and we keep pressing refresh and we get 50% approximately of the time randomly, the red and the blue. Now I think the blue version is better. So let's go back an migrate 100% of our traffic to the blue version. So let's select the background color, deep sky blue version and press migrate traffic, yes migrate. Now all traffic should be routed to the blue version of our app. Let's check and see. Let's hit refresh, refresh, refresh, and let's keep refreshing and it's blue all the way. All right, now you know how to perform traffic splits, migrations and using the same principle you can do rollbacks to previous versions of your application if necessary. And that's all there is to it.

Contents