Sunday, November 27, 2022
HomeSoftware DevelopmentExtending assist for App Engine bundled companies (Module 17)

Extending assist for App Engine bundled companies (Module 17)

Posted by Wesley Chun (@wescpy), Developer Advocate, Google Cloud


App Engine initially launched in 2008, offering a suite of bundled companies making it handy for purposes to entry a database (Datastore), caching service (Memcache), impartial process execution (Activity Queue), Google Signal-In authentication (Customers), or giant “blob” storage (Blobstore), or different companion companies. Nevertheless, apps leveraging these companies can solely run their apps on App Engine.

To extend app portability and assist Google transfer in direction of its objective of getting probably the most open cloud available on the market, App Engine launched its 2nd-generation service in 2018, initially eradicating these legacy companies. The newer platform permits builders to improve apps to the most recent language runtimes, resembling transferring from Python 2 to three or Java 8 to 11 (and at the moment, Java 17). One of many main drawbacks to the 1st-generation runtimes is that they are personalized, proprietary, and restrictive in what you should utilize or cannot.

As a substitute, the 2nd-generation platform makes use of open supply runtimes, which means capacity to comply with customary growth practices, use frequent/identified idioms, and have fewer restrictions of Third-party libraries, and obviating the necessity to copy or “vendor” them along with your code. Sadly, to make use of these newer runtimes, migrating away from App Engine companies have been required as a result of whilst you might improve language releases, there was no entry to bundled companies, breaking apps or requiring full rewrites, making it a showstopper for a lot of customers.

Because of their recognition and the will to ease the improve course of for patrons, the App Engine crew restored entry to most (however not all) of these companies in Fall 2021. As we speak’s Serverless Migration Station video demonstrates learn how to proceed utilization of bundled companies out there to Python 3 builders.

Exhibiting App Engine customers learn how to use bundled companies on Python 3

Performing the improve

Modernizing the standard Python 2 App Engine app seems one thing like this:

  1. Migrate from the webapp2 framework (not out there in Python 3)
  2. Port from Python 2 to three, protect use of bundled companies
  3. Non-compulsory migration to Cloud standalone or related Third-party companies

Step one is to maneuver to a regular Python net framework like Flask, Django, Pyramid, and so on. Beneath is a few pseudocode from Migration Module 1 demonstrating learn how to migrate from webapp2 to Flask:

codeblocks for porting Python 2 sample app from webapp2 to Flask
Step 1: Port Python 2 pattern app from webapp2 to Flask

The important thing modifications are bolded within the above code snippets. Discover how the App Engine NDB code [the Visit class definition plus store_visit() and fetch_visits() functions] are unaffected by this net framework migration. The total webapp2 code pattern may be discovered within the Module 0 repo folder whereas the finished migration to Flask pattern is positioned within the Module 1 repo folder.

After your app has ported frameworks, you are free to improve to Python 3 whereas preserving entry to the bundled companies in case your app makes use of any. Beneath is pseudocode demonstrating learn how to improve the identical pattern app to Python 3 in addition to the code modifications wanted to proceed to make use of App Engine NDB:

codeblocks for porting sample app to Python 3, preserving use of NDB bundled service
Step 2: Port pattern app to Python 3, preserving use of NDB bundled service
The unique app was designed to work below each Python 2 and three interpreters, so no language modifications have been required on this case. We added an import of the brand new App Engine SDK adopted by the important thing replace wrapping the WSGI object so the app can entry the bundled companies. As earlier than, the important thing updates are bolded. Some updates to configuration are additionally required, and people are outlined within the documentation and the (Module 17) codelab.

The NDB code can also be left untouched on this migration. Not the entire bundled companies characteristic such a hands-free migration, and we hope to cowl a few of the extra complicated ones forward in Module 22. Java, PHP, and Go customers have it even higher, requiring fewer or no code modifications in any respect. The Python 2 Flask pattern is positioned within the Module 1 repo folder, and the ensuing Python 3 app may be discovered within the Module 1b repo folder.

The rapid advantage of step two is the flexibility to improve to a extra present model of language runtime. This leaves the third step of migrating off the bundled companies as optionally available, particularly when you plan on staying on App Engine for the long-term.

Further choices

In the event you resolve emigrate off the bundled companies, you are able to do so by yourself timeline. It needs to be a consideration do you have to ever need to transfer to fashionable serverless platforms resembling Cloud Features or Cloud Run, to lower-level platforms since you need extra management, like GKE, our managed Kubernetes service, or Compute Engine VMs.

Step three can also be the place the remainder of the Serverless Migration Station content material could also be helpful:

*code samples and codelabs out there; movies forthcoming

So far as transferring to fashionable serverless platforms, if you wish to break aside a big App Engine app into a number of microservices, take into account Cloud Features. In case your group has added containerization as a part of your software program growth workflow, take into account Cloud Run. It is appropriate for apps when you’re acquainted with containers and Docker, however even when you or your crew haven’t got that have, Cloud Buildpacks can do the heavy lifting for you. Listed below are the related migration modules to discover:


Early App Engine customers respect the comfort of the platform’s bundled companies, and after listening to person suggestions, including them again to 2nd-generation runtimes is one other approach we may also help builders modernize their apps. Whether or not upgrading to newer language runtimes to remain on App Engine and proceed to make use of its bundled companies, migrating to Cloud standalone merchandise, or shifting to different serverless platforms, the Google Cloud crew goals to offer the instruments to assist streamline your modernization efforts.

All Serverless Migration Station content material (codelabs, movies, supply code [when available]) may be accessed at its open supply repo. Whereas our content material initially focuses on Python customers, the Cloud crew is engaged on protecting different language runtimes, so keep tuned. As we speak’s video incorporates a particular visitor to offer a teaser of what to anticipate for Java. For added video content material, try the broader Serverless Expeditions sequence.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments