How to set up a staging environment on Google App Engine

16,012

Solution 1

I chose the second option in my set-up, because it was the quickest solution, and I didn't make any script to change the application-parameter on deployment yet.

But the way I see it now, option A is a cleaner solution. You can with a couple of code lines switch the datastore namespace based on the version, which you can get dynamically from the environmental variable CURRENT_VERSION_ID as documented here: http://code.google.com/appengine/docs/python/runtime.html#The_Environment

Solution 2

If separate datastore is required, option B looks cleaner solution for me because:

  1. You can keep versions feature for real versioning of production applications.
  2. You can keep versions feature for traffic splitting.
  3. You can keep namespaces feature for multi-tenancy.
  4. You can easily copy entities from one app to another. It's not so easy between namespaces.
  5. Few APIs still don't support namespaces.
  6. For teams with multiple developers, you can grant upload to production permission for a single person.

Solution 3

We went with the option B. And I think it is better in general as it isolates the projects completely. So for example playing around with some of the configurations on the staging server will not affect and wont compromise security or cause any other butterfly effect in your production environment.

As for the deployment script, you can have any application name you want in your app.yaml. Some dummy/dev name and when you deploy, just use an -A parameter:

appcfg.py -A your-app-name update .

That will simplify your deploy script quite much, no need to string replace or anything similar in your app.yaml

Solution 4

We use option B.

In addition to Zygmantas suggestions about the benefits of separating dev from prod at application level, we also use our dev application to test performance.

Normally the dev instance runs without much available in the way of resources, this helps to see where the application "feels" slow. We can then also independently tweak the performance settings to see what makes a difference (e.g. front-end instance class).

Of course sometimes we need to bite the bullet and tweak & watch on live. But it's nice to have the other application to play with.

Still use namespaces and versions, just dev is dirty and experimental.

Share:
16,012
systempuntoout
Author by

systempuntoout

I'm a software architect, living and working in Italy. My Google App Engine project: - StackPrinter

Updated on June 15, 2022

Comments

  • systempuntoout
    systempuntoout almost 2 years

    Having properly configured a Development server and a Production server, I would like to set up a Staging environment on Google App Engine useful to test new developed versions live before deploying them to production.

    I know two different approaches:

    A. The first option is by modifying the app.yaml version parameter.

    version: app-staging
    

    What I don't like of this approach is that Production data is polluted with my staging tests because (correct me if I'm wrong):

    1. Staging version and Production version share the same Datastore
    2. Staging version and Production version share the same logs

    Regarding the first point, I don't know if it could be "fixed" using the new namespaces python API.

    B. The second option is by modifying the app.yaml application parameter

    application: foonamestaging
    

    with this approach, I would create a second application totally independent from the Production version.
    The only drawback I see is that I'm forced to configure a second application (administrators set up).
    With a backup\restore tool like Gaebar this solution works well too.

    What kind of approach are you using to set up a staging environment for your web application?
    Also, do you have any automated script to change the yaml before deploying?

  • Cuga
    Cuga over 13 years
    I also went with the 2nd option in the question, but I started before separate namespaces were available as well.
  • Franck
    Franck over 13 years
    @systempuntoout I think it's possible : "The bulk loader supports a --namespace=NAMESPACE flag that allows you to specify the namespace to use. Each namespace is handled separately and, if you want to access all namespaces, you will need to iterate through them." from code.google.com/appengine/docs/python/multitenancy/…
  • systempuntoout
    systempuntoout over 13 years
    @Franck sounds interesting, so option A seems feasible and clean
  • systempuntoout
    systempuntoout over 13 years
  • Nick Johnson
    Nick Johnson about 12 years
    The only problem with this is if you want to move from 'staging' to 'production', you have to redeploy your app, since they use different namespaces. Of course, you have to do that with separate apps, too.
  • Campey
    Campey over 11 years
    +1 for 6. e.g. I save auth for my personal credentials that can deploy to dev, I have to type the live account & password in every time.
  • marianosimone
    marianosimone almost 10 years
    I also use option B. However, while trying to start using push-to-deploy, I find it hard to use this approach, as I need to keep one app.yaml per environment (before push-to-deploy, I just had a script that changed the application param before deploying, and then set it back), or use different branches, each with (potentially conflicting) app.yamls
  • morpheus
    morpheus about 3 years
    Is there an updated answer to this question as the application tag has been removed from app.yaml?
  • John Doe
    John Doe about 3 years
    While this may be a solution technically speaking, that's not what the Google documentation recommends