App Engine makes it easy for you to have multiple versions of the same application in the cloud. This is a very handy feature and allows you to create a new version of your application that you can test without your normal users getting affected by it.
But it is important to understand what is going on behind the scenes. Once you get it, you will find yourself using this feature a lot more. First thing to keep in mind is that the following 2 points:
- Application ID is a unique way to identify your application. For e.g. if your Application ID is gaetips123, then users go to your application by gaetips123.appspot.com
- Application versioning allows you to have different versions of the same application. In fact all of them are running in the cloud, except that only one version is the default version. So when people visit your application i.e. gaetips123.appspot.com , they are in fact visiting the version that is marked as the default version of your application.
Let us understand this via an example:
- I have an application that I have deployed for the first time. It is present at http://gaetips123.appspot.com
- To check out the current versions of your application, you should log in to http://appengine.google.com and visit the Versions option in the Main section as shown below:
- You will notice that there is only one version “1” and it has been marked as default. Now when you visit http://gaetips123.appspot.com, it will lead to this default version. In fact you can also get to any specific version by specifying <versionid>.appid.appspot.com. In this case, since the version is “1”, I can access it via http://1.gaetips123.appspot.com
Now, let me deploy another version of the application. To do that:
- I make some local changes to the files.
- Then I select Google -> Deploy to App Engine. This brings up the Deploy dialog as shown below. If you simply choose to click on the Deploy button now, it will overwrite the same version i.e. 1 of the application with the latest code.
- Let us not overwrite the version “1” of the application. Instead click on the App Engine project settings link and you will be presented Properties dialog. Notice that in the Deployment section, there is the Application ID and the Version. The version is currently at “1” .. but let us make it to 2. In fact, you can even use names like qa or test or dev or private or whatever, that makes more logical sense to you.
- I will change the version to 2 and then deploy the application.
Once it is deployed, the important thing to note is that by default the new version of your application will NOT be made the default version. This is a common trap that newbies can fall into.
To understand that, let us visit our Admin console again and look at the versions. You will find the following:
- You will find that both 1 and 2 versions are deployed but 1 is still the default version. This is the right thing to do because you do not want the new version to suddenly become the default version being served to users. Users might confused and you want to maybe test things out before making the new version as the default version.
- You can still access both the versions by specifying their version prefixes. So 1.gaetips123.appspot.com and 2.gaetips123.appspot.com will get you to the respective versions.
- To make version 2 as the default version, you will need to select the radio button next to that version and click on the Make Default button.
- This will ensure that any visits now to gaetips123.appspot.com will lead to the default version, which is version 2.
Few other key points for Versions:
- The Datastore is common to all the versions. It is not specific to each version. So be aware of that. In fact be very careful.
- The Logs are available for each version separately. So when you visit the Logs section, you can select the specific version to see its logs.
- The Scheduler is only for the default version and not other versions.
Now that you have understood how versions work, do use it smartly to keep multiple versions running. It is ideally suited to a Testing scenario for your new version, where you want to ensure that everything works fine in the real cloud environment before you can make the final version available.
Check out all the App Engine Development Tips.