Set up various environments in Google AppEngine

I have a web application running on Google AppEngine.

I have a single PRODUCT environment, STAGING env and lots of development and QA. There are many configuration options that should differ between PRODUCTION and other environments, such as API keys for the services with which we integrate (for example, GoogleAnalytics). Some of these parameters are defined in the code, others are defined in web.xml (for example, inside the init-param tag for filters) and other cases.

I know that there are several approaches for this:

  • Saving all parameters to the data warehouse (and their possible caching in each running instance / Memcached)

  • Deploying applications with various system properties / environment variables in web.xml

  • Other options ...?

In any case, I am interested in hearing your best practices for solving this problem.

+4
source share
2 answers

My favorite approach is to store them all in a data warehouse and have only one master record with all the various properties and it’s good to use memcache. By doing this, you do not need to have different configuration files or pollute your code with various configuration settings. Instead, you can expand and change these values ​​from the administrative form that you will need to create in order to update this master record.

In addition, if you save tokens and secret keys, then you are aware that it is definitely not recommended to have them in web.xml or elsewhere in the code, but rather to have it for an application for something more secure, like storage data.

After that, you can have one global function that will retrieve properties by name, and if you want to get the Google Analytics identifier from anywhere in your application, you should use it with something like this:

 getProperty('googleAnalyticsID') 

where this global getProperty() function will try to find this value using the following steps:

  • Check if memcache exists and returns
  • If not in memcache, upgrade memcache from the main object from the data store and return
  • If an object with default values ​​is not created in the data store, update memcache and return

Of course, there are different approaches to extracting data from this model, but the idea is the same: Store in one record and use memcache.

+2
source

You must have separate application identifiers for your production / production / qa envs. This should be tightly bound to your web.xml (or you have a script that updates your web.xml)

After that you can code in your settings based on appid. I assume the java equivalent is: https://developers.google.com/appengine/docs/python/appidentity/functions#get_application_id

You can put it in the data warehouse if these are parameters that change dynamically, but if they are static for the environment, it makes no sense to save the selection from the data warehouse.

0
source

All Articles