Google App Engine upgrading part by part

2020-02-15 06:38发布

问题:

I have a complex appengine service that was written in PHP, now I want to migrate it to Python part by part.

Let's say that my service has 2 parts: /signIn/.... and /data/.... I just want to migrate /signIn/ part first, then /data/ later.

However, since my service is big, so I want to build new /signIn/ part in Python, then use Traffic Splitting to make some A/B Testing on this part.

My problem is that Traffic Splitting can be applied on versions only, so my old and new versions have to be in same module, and same module means that they have to written in same language (I was wrong here, see updated part). But I am migrating from PHP to Python.

What is the best solution for me?

Thanks,

Solution

With Dan Cornilescu's helping, this is what I do:

  1. Split the app into 2 modules: default and old-version.
  2. Dispatch /signIn/ into default module, the rest to old-version module.
  3. Make another version of /signIn/ (default module) in Python
  4. Configure Traffic Splitting to slowly increase requests percent into Python part. This will allow us to test and make sure there is no serious bug happen.

Note: The /signIn/ part must be default module, since GAE's traffic splitting works at default module only.

I confirmed that we can make 2 versions in different language for a module.

回答1:

One possible approach is to split your PHP app in modules in a 1st step. It's not a completely wasted effort, most of that will be needed anyways to just allow your app to work in multiple modules, not related to the language change. I suspect this is actually why you can't use A/B testing - mismatch between the modules. Unavoidable.

Once the split in modules is done then you can go on with your 2nd step - switching the language for selected module(s), with A/B testing as you intended.

A more brave approach is to mix the 2 and write the /signin/ module directly in python. On the PHP side you'd just remove the /signin/ portion (part of the earlier mentioned 1st step). Should work pretty well as long as you're careful to only use app language independent means for inter-module communication/operation: request paths, cookies, datastore/memcache keys, etc. A good module split would almost certainly ensure that.

You have testing options other than A/B, like this one: https://stackoverflow.com/a/33760403/4495081.

You can also have the new code/module able to serve the same requests as the old one, side-by-side/simultaneously and using a dispatch.yaml file to finely control which module actually serves which requests. This may allow a very focused migration, potentially offering higher testing confidence.

I'm also not entirely sure you can't actually have 2 versions of the same module in different languages - the versions should be pretty standalone instances, each serving their own requests in their own way using, at the lowest layer, the language-independent GAE infra services. AFAIK nothing stops a complete app re-write and deployment, with the same version or not - I've done that when learning GAE. But I didn't switch languages, it's true. I'd give it a try, but I don't have time to learn a new language right now :)