How to use App Engine pull tasks (Module 18)

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

Introduction and background

The Serverless Migration Station mini-series helps App Engine developers modernize their apps to the latest language runtimes, such as from Python 2 to 3 or Java 8 to 17, or to sister serverless platforms Cloud Functions and Cloud Run. Another goal of this series is to demonstrate how to move away from App Engine’s original APIs (now referred to as legacy bundled services) to Cloud standalone replacement services. Once no longer dependent on these proprietary services, apps become much more portable, making them flexible enough to:

App Engine’s Task Queue service provides infrastructure for executing tasks outside of the standard request-response workflow. Tasks may consist of workloads exceeding request timeouts or periodic tangential work. The Task Queue service provides two different queue types, push and pull, for developers to perform auxiliary work.

Push queues are covered in Migration Modules 7-9, demonstrating how to add use of push tasks to an existing baseline app followed by steps to migrate that functionality to Cloud Tasks, the standalone successor to the Task Queues push service. We turn to pull queues in today’s video where Module 18 demonstrates how to add use of pull tasks to the same baseline sample app. Module 19 follows, showing how to migrate that usage to Cloud Pub/Sub.

Adding use of pull queues

In addition to registering page visits, the sample app needs to be modified to track visitors. Visits are comprised of a timestamp and visitor information such as the IP address and user agent. We’ll modify the app to use the IP address and track how many visits come from each address seen. The home page is modified to show the top visitors in addition to the most recent visits:

Screen grab of the sample app's updated home page tracking visits and visitors
The sample app’s updated home page tracking visits and visitors

When visits are registered, pull tasks are created to track the visitors. The pull tasks sit patiently in the queue until they are processed in aggregate periodically. Until that happens, the top visitors table stays static. These tasks can be processed in a number of ways: periodically by a cron or Cloud Scheduler job, a separate App Engine backend service, explicitly by a user (via browser or command-line HTTP request), event-triggered Cloud Function, etc. In the tutorial, we issue a curl request to the app’s endpoint to process the enqueued tasks. When all tasks have completed, the table then reflects any changes to the current top visitors and their visit counts:

Screen grab of processed pull tasks updated in the top visitors table
Processed pull tasks update the top visitors table

Below is some pseudocode representing the core part of the app that was altered to add Task Queue pull task usage, namely a new data model class, VisitorCount, to track visitor counts, enqueuing a (pull) task to update visitor counts when registering individual visits in store_visit(), and most importantly, a new function fetch_counts(), accessible via /log, to process enqueued tasks and update overall visitor counts. The bolded lines represent the new or altered code.

Adding App Engine Task Queue pull task usage to sample app showing 'Before'[Module 1] on the left and 'After' [Module 18] with altered code on the right
Adding App Engine Task Queue pull task usage to sample app

Wrap-up

This “migration” is comprised of adding Task Queue pull task usage to support tracking visitor counts to the Module 1 baseline app and arrives at the finish line with the Module 18 app. To get hands-on experience doing it yourself, do the codelab by hand and follow along with the video. Then you’ll be ready to upgrade to Cloud Pub/Sub should you choose to do so.

In Fall 2021, the App Engine team extended support of many of the bundled services to 2nd generation runtimes (that have a 1st generation runtime), meaning you are no longer required to migrate pull tasks to Pub/Sub when porting your app to Python 3. You can continue using Task Queue in your Python 3 app so long as you retrofit the code to access bundled services from next-generation runtimes.

If you do want to move to Pub/Sub, see Module 19, including its codelab. All Serverless Migration Station content (codelabs, videos, and source code) are available at its open source repo. While we’re initially focusing on Python users, the Cloud team is covering other runtimes soon, so stay tuned. Also check out other videos in the broader Serverless Expeditions series.

Extending support for App Engine bundled services (Module 17)

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

Background

App Engine initially launched in 2008, providing a suite of bundled services making it convenient for applications to access a database (Datastore), caching service (Memcache), independent task execution (Task Queue), Google Sign-In authentication (Users), or large “blob” storage (Blobstore), or other companion services. However, apps leveraging those services can only run their apps on App Engine.

To increase app portability and help Google move towards its goal of having the most open cloud on the market, App Engine launched its 2nd-generation service in 2018, initially removing those legacy services. The newer platform allows developers to upgrade apps to the latest language runtimes, such as moving from Python 2 to 3 or Java 8 to 11 (and today, Java 17). One of the major drawbacks to the 1st-generation runtimes is that they’re customized, proprietary, and restrictive in what you can use or can’t.

Instead, the 2nd-generation platform uses open source runtimes, meaning ability to follow standard development practices, use common/known idioms, and have fewer restrictions of 3rd-party libraries, and obviating the need to copy or “vendor” them with your code. Unfortunately, to use these newer runtimes, migrating away from App Engine services were required because while you could upgrade language releases, there was no access to bundled services, breaking apps or requiring complete rewrites, making it a showstopper for many users.

Due to their popularity and the desire to ease the upgrade process for customers, the App Engine team restored access to most (but not all) of those services in Fall 2021. Today’s Serverless Migration Station video demonstrates how to continue usage of bundled services available to Python 3 developers.

Showing App Engine users how to use bundled services on Python 3

Performing the upgrade

Modernizing the typical Python 2 App Engine app looks something like this:
  1. Migrate from the webapp2 framework (not available in Python 3)
  2. Port from Python 2 to 3, preserve use of bundled services
  3. Optional migration to Cloud standalone or similar 3rd-party services

The first step is to move to a standard Python web framework like Flask, Django, Pyramid, etc. Below is some pseudocode from Migration Module 1 demonstrating how to migrate from webapp2 to Flask:

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

The key changes are bolded in the above code snippets. Notice how the App Engine NDB code [the Visit class definition plus store_visit() and fetch_visits() functions] are unaffected by this web framework migration. The full webapp2 code sample can be found in the Module 0 repo folder while the completed migration to Flask sample is located in the Module 1 repo folder.

After your app has ported frameworks, you’re free to upgrade to Python 3 while preserving access to the bundled services if your app uses any. Below is pseudocode demonstrating how to upgrade the same sample app to Python 3 as well as the code changes needed to continue to use App Engine NDB:

codeblocks for porting sample app to Python 3, preserving use of NDB bundled service
Step 2: Port sample app to Python 3, preserving use of NDB bundled service
The original app was designed to work under both Python 2 and 3 interpreters, so no language changes were required in this case. We added an import of the new App Engine SDK followed by the key update wrapping the WSGI object so the app can access the bundled services. As before, the key updates are bolded. Some updates to configuration are also required, and those are outlined in the documentation and the (Module 17) codelab.

The NDB code is also left untouched in this migration. Not all of the bundled services feature such a hands-free migration, and we hope to cover some of the more complex ones ahead in Module 22. Java, PHP, and Go users have it even better, requiring fewer or no code changes at all. The Python 2 Flask sample is located in the Module 1 repo folder, and the resulting Python 3 app can be found in the Module 1b repo folder.

The immediate benefit of step two is the ability to upgrade to a more current version of language runtime. This leaves the third step of migrating off the bundled services as optional, especially if you plan on staying on App Engine for the long-term.

Additional options

If you decide to migrate off the bundled services, you can do so on your own timeline. It should be a consideration should you ever want to move to modern serverless platforms such as Cloud Functions or Cloud Run, to lower-level platforms because you want more control, like GKE, our managed Kubernetes service, or Compute Engine VMs.

Step three is also where the rest of the Serverless Migration Station content may be useful:

*code samples and codelabs available; videos forthcoming

As far as moving to modern serverless platforms, if you want to break apart a large App Engine app into multiple microservices, consider Cloud Functions. If your organization has added containerization as part of your software development workflow, consider Cloud Run. It’s suitable for apps if you’re familiar with containers and Docker, but even if you or your team don’t have that experience, Cloud Buildpacks can do the heavy lifting for you. Here are the relevant migration modules to explore:

    Wrap-up

    Early App Engine users appreciate the convenience of the platform’s bundled services, and after listening to user feedback, adding them back to 2nd-generation runtimes is another way we can help developers modernize their apps. Whether upgrading to newer language runtimes to stay on App Engine and continue to use its bundled services, migrating to Cloud standalone products, or shifting to other serverless platforms, the Google Cloud team aims to provide the tools to help streamline your modernization efforts.

    All Serverless Migration Station content (codelabs, videos, source code [when available]) can be accessed at its open source repo. While our content initially focuses on Python users, the Cloud team is working on covering other language runtimes, so stay tuned. Today’s video features a special guest to provide a teaser of what to expect for Java. For additional video content, check out the broader Serverless Expeditions series.

    Google Cloud & Kotlin GDE Kevin Davin helps others learn in the face of challenges

    Posted by Kevin Hernandez, , Developer Relations Community Manager

    Kevin Davin speaking at the SnowCamp Conference in 2019
    Kevin Davin has always had a passion for learning and helping others learn, no matter their background or unique challenges they may face. He explains, “I want to learn something new every day, I want to help others learn, and I’m addicted to learning.” This mantra is evident in everything he does from giving talks at numerous conferences to helping people from underrepresented groups overcome imposter syndrome and even helping them become GDEs. In addition to learning, Kevin is also passionate about diversity and inclusion efforts, partly inspired by navigating the world with partial blindness.
    Kevin has been a professional programmer for 10 years now and has been in the field of Computer Science for about 20 years. Through the years, he has emphasized the importance of learning how and where to learn. For example, while he learned a lot while he was studying at a university, he was able to learn just as much through his colleagues. In fact, it was through his colleagues that he picked up lessons in teamwork and the ability to learn from people with different points of view and experience. Since he was able to learn so much from those around him, Kevin also wanted to pay it forward and started volunteering at a school for people with disabilities. Guided by the Departmental Centers for People with Disabilities, the aim of the program is to teach coding languages and reintegrate students into a technical profession. During his time at this center, Kevin helped students practice what they learned and ultimately successfully transition into a new career.

    During these experiences, Kevin was always involved in the developer community through open-source projects. It was through these projects that he learned about the GDE program and was connected to Google Developer advocates. Kevin was drawn to the GDE program because he wanted to share his knowledge with others and have direct access to Google in order to become an advocate on behalf of developers. In 2016, he discovered Kubernetes and helped his company at the time move to Google Cloud. He always felt like this model was the right solution and invested a lot of time to learn it and practice it. “Google Cloud is made for developers. It’s like a Lego set because you can take the parts you want and put it together,” he remarked.

    The GDE program has given him access to the things he values most: being a part of a developer community, being an advocate for developers, helping people from all backgrounds feel included, and above all, an opportunity to learn something new every day. Kevin’s parting advice for hopeful GDEs is: “Even if you can’t reach the goal of being a GDE now, you can always get accepted in the future. Don’t be afraid to fail because without failure, you won’t learn anything.” With his involvement in the program, Kevin hopes to continue connecting with the developer community and learning while supporting diversity efforts.

    Learn more about Kevin on Twitter & LinkedIn.

    The Google Developer Experts (GDE) program is a global network of highly experienced technology experts, influencers, and thought leaders who actively support developers, companies, and tech communities by speaking at events and publishing content.

    Grow your coding skills and your confidence – Coding Practice with Kick Start

    Posted by Julia DeLorenzo, Program Manager, Coding Competitions

    Coding Practice with Kick Start is a four-day practice session where you’ll have the chance to learn more about the Kick Start platform, utilize starter code to help frame your solutions, and interact with Google engineers.

    It’s not a timed round and there is no scoreboard! No one else will be able to view your scores from the session. This is just for fun and a great way to hone your coding skills, and get better acquainted with Kick Start.

    So, why should you join the session? We’re glad you asked!

    About Coding Practice with Kick Start

    The problems you’ll see in Coding Practice with Kick Start range in difficulty. The concepts covered in these problems align very closely with concepts covered in introductory CS courses like Data Structures and Algorithms, and topics you may encounter in Google interviews.

    You can solve the problems in any order you like. Looking at a problem does not start any timers, so feel free to read all of them at the start of the session, and then solve them in the order of your choice. We also provide starter code at the top of each problem statement to get you started with your solution.

    Stuck on a problem? Don’t worry! You can use the “Ask a question” button on the problem overview page.

    At the end of the session, tune in for a livestream where Kick Start engineers will walk through each of the problems featured during the round!

    Grow your coding skills and your confidence

    Still need to be convinced to give Coding Practice with Kick Start Session 3 a try?

    Hear from some past participants how Coding Practice with Kick Start helped them along their competitive programming journey.

    Session 2 Participants: Tell us why you enjoyed your experience!

    Balla says:

    “At first I used to think that the Kick Start coding rounds were very tough and I couldn’t solve them. But the level of the initial questions are such that it boosts us to give it a try, and increases our confidence level. I feel that this is the best part that every coder hopes for. After attempting the session, I felt like I could solve the problems if I worked a little harder.

    My favorite problem in Coding Practice with Kick Start Session 2 is ‘Irregular Expressions’. The problem is very interesting; I couldn’t write up the logic, but it made me think a lot. It’s the best problem I faced in the round.”

    Mbalire says:

    “I personally had problems with test samples not catering for some cases, and that I failed to understand the questions. The answers and support from the Google engineers during Coding Practice with Kick Start was good. I felt as if different people at Google were reading my code and seeing my development, and that boosted my confidence.

    While solving the problem, I could see my own development while creating my own solution. I hope to do much more and participate in the coming Kick Start competition rounds. It may be because I started programming this year or because most of the code I know is from my research, but getting these algorithms right has been a huge accomplishment for me.

    My favorite problem was ‘Building Palindromes’ from Coding Practice with Kick Start Session 2.”

    Nandini says:

    “Coding Practice with Kick Start was very engaging and I had a lot of fun. It reminded me how much I enjoy computer science and math and solving problems!

    My favorite problem from the past coding practice session has been the ‘Building Palindromes‘ problem. This is because I had fun trying to come up with an optimal solution to this problem and it pushed me to learn new techniques for optimizing my solution: prefixing sums/pre-calculation.

    I also really enjoyed solving the ‘Parcels’ problem since it involved search algorithms which I love! I found that it was the right amount of ‘challenging’ to keep me thinking about it all day. Thanks, Google!”

    Joining Coding Practice with Kick Start Session 3

    With the third and final session for the year coming up, we encourage you to join us. Coding Practice with Kick Start is the perfect opportunity to practice and grow your skills without the pressure of a public scoreboard or timed round.

    Learn new skills, grow your confidence as a coder, and we’ll see you in one of our upcoming Kick Start rounds.

    We hope you’ll give it a try! → https://goo.gle/codingpracticewks

    Migrating from App Engine Blobstore to Cloud Storage (Module 16)

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

    Introduction and background

    The most recent Serverless Migration Station video demonstrated how to add use of the App Engine’s Blobstore service to a sample Python 2 App Engine app, kicking off the first of a 2-part series on migrating away from Blobstore. In today’s Module 16 video, we complete this journey, arriving at Cloud Storage. Moving away from proprietary App Engine services like Blobstore makes apps more portable, giving them enough flexibility to:

    Showing App Engine users how to migrate to Cloud Storage

    As described previously, a Blobstore for Python 2 dependency on webapp made the Module 15 content more straightforward to implement if it was still using webapp2. To completely modernize this app here in Module 16, the following migrations should be carried out:

    • Migrate from webapp2 (and webapp) to Flask
    • Migrate from App Engine NDB to Cloud NDB
    • Migrate from App Engine Blobstore to Cloud Storage
    • Migrate from Python 2 to Python (2 and) 3

    Performing the migrations

    Prior to modifying the application code, a variety of configuration updates need to be made. Updates applying only to Python 2 feature a “Py2” designation while those migrating to Python 3 will see “Py3” annotations.

    1. Remove the built-in Jinja2 library from app.yaml—Jinja2 already comes with Flask, so remove use of the older built-in version which may possibly conflict with the contemporary Flask version you’re using. (Py2)
    2. Use of Cloud client libraries (such as those for Cloud NDB and Cloud Storage) require a pair of built-in libraries, grpcio and setuptools, so add those to app.yaml (Py2)
    3. Remove everything in app.yaml except for a valid runtime (Py3)
    4. Add Cloud NDB and Cloud Storage client libraries to requirements.txt (Py2 & Py3)
    5. Create an appengine_config.py supporting both built-in (those in app.yaml) and non built-in (those in requirements.txt) libraries used (Py2)

    The Module 15 app already migrated away from webapp2‘s (Django) templating system to Jinja2. This is useful when migrating to Flask because Jinja2 is Flask’s default template system. Switching from App Engine NDB to Cloud NDB is fairly straightforward as the latter was designed to be mostly compatible with the original. The only change visible in this sample app is to move Datastore calls into Python with blocks.

    The most significant changes occur when moving the upload and download handlers from webapp to Cloud Storage. The video and corresponding codelab go more in-depth into the necessary changes, but in summary, these are the updates required in the main application:

    1. webapp2 is replaced by Flask. Instead of using the older built-in version of Jinja2, use the version that comes with Flask.
    2. App Engine Blobstore and NDB are replaced by Cloud NDB and Cloud Storage, respectively.
    3. The webapp Blobstore handler functionality is replaced by a combination of the io standard library module plus components from Flask and Werkzeug. Furthermore, the handler classes and methods are replaced by Flask functions.
    4. The main handler class and corresponding GET and POST methods are all replaced by a single Flask function.

    The results

    With all the changes implemented, the original Module 15 app still operates identically in Module 16, starting with a form requesting a visit artifact followed by the most recents visits page:
    The sample app’s artifact prompt page


    The sample app’s most recent visits page.

    The only difference is that four migrations have been completed where all of the “infrastructure” is now taken care of by non-App Engine legacy services. Furthermore, the Module 16 app could be either a Python 2 or 3 app. As far as the end-user is concerned, “nothing happened.”

    Migrating sample app from App Engine Blobstore to Cloud Storage

    Wrap-up

    Module 16 featured four different migrations, modernizing the Module 15 app from using App Engine legacy services like NDB and Blobstore to Cloud NDB and Cloud Storage, respectively. While we recommend users move to the latest offerings from Google Cloud, migrating from Blobstore to Cloud Storage isn’t required, and should you opt to do so, can do it on your own timeline. In addition to today’s video, be sure to check out the Module 16 codelab which leads you step-by-step through the migrations discussed.

    In Fall 2021, the App Engine team extended support of many of the bundled services to 2nd generation runtimes (that have a 1st generation runtime), meaning you are no longer required to migrate to Cloud Storage when porting your app to Python 3. You can continue using Blobstore in your Python 3 app so long as you retrofit the code to access bundled services from next-generation runtimes.

    If you’re using other App Engine legacy services be sure to check out the other Migration Modules in this series. All Serverless Migration Station content (codelabs, videos, source code [when available]) can be accessed at its open source repo. While our content initially focuses on Python users, the Cloud team is working on covering other language runtimes, so stay tuned. For additional video content, check out our broader Serverless Expeditions series.

    Migrating from App Engine Memcache to Cloud Memorystore (Module 13)

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

    Introduction and background

    The previous Module 12 episode of the Serverless Migration Station video series demonstrated how to add App Engine Memcache usage to an existing app that has transitioned from the webapp2 framework to Flask. Today’s Module 13 episode continues its modernization by demonstrating how to migrate that app from Memcache to Cloud Memorystore. Moving from legacy APIs to standalone Cloud services makes apps more portable and provides an easier transition from Python 2 to 3. It also makes it possible to shift to other Cloud compute platforms should that be desired or advantageous. Developers benefit from upgrading to modern language releases and gain added flexibility in application-hosting options.

    While App Engine Memcache provides a basic, low-overhead, serverless caching service, Cloud Memorystore “takes it to the next level” as a standalone product. Rather than a proprietary caching engine, Cloud Memorystore gives users the option to select from a pair of open source engines, Memcached or Redis, each of which provides additional features unavailable from App Engine Memcache. Cloud Memorystore is typically more cost efficient at-scale, offers high availability, provides automatic backups, etc. On top of this, one Memorystore instance can be used across many applications as well as incorporates improvements to memory handling, configuration tuning, etc., gained from experience managing a huge fleet of Redis and Memcached instances.

    While Memcached is more similar to Memcache in usage/features, Redis has a much richer set of data structures that enable powerful application functionality if utilized. Redis has also been recognized as the most loved database by developers in StackOverflow’s annual developers survey, and it’s a great skill to pick up. For these reasons, we chose Redis as the caching engine for our sample app. However, if your apps’ usage of App Engine Memcache is deeper or more complex, a migration to Cloud Memorystore for Memcached may be a better option as a closer analog to Memcache.

    Migrating to Cloud Memorystore for Redis featured video


    Performing the migration

    The sample application registers individual web page “visits,” storing visitor information such as IP address and user agent. In the original app, the most recent visits are cached into Memcache for an hour and used for display if the same user continuously refreshes their browser during this period; caching is a one way to counter this abuse. New visitors or cache expiration results new visits as well as updating the cache with the most recent visits. Such functionality must be preserved when migrating to Cloud Memorystore for Redis.

    Below is pseudocode representing the core part of the app that saves new visits and queries for the most recent visits. Before, you can see how the most recent visits are cached into Memcache. After completing the migration, the underlying caching infrastructure has been swapped out in favor of Memorystore (via language-specific Redis client libraries). In this migration, we chose Redis version 5.0, and we recommend the latest versions, 5.0 and 6.x at the time of this writing, as the newest releases feature additional performance benefits, fixes to improve availability, and so on. In the code snippets below, notice how the calls between both caching systems are nearly identical. The bolded lines represent the migration-affected code managing the cached data.

    Switching from App Engine Memcache to Cloud Memorystore for Redis

    Wrap-up

    The migration covered begins with the Module 12 sample app (“START”). Migrating the caching system to Cloud Memorystore and other requisite updates results in the Module 13 sample app (“FINISH”) along with an optional port to Python 3. To practice this migration on your own to help prepare for your own migrations, follow the codelab to do it by-hand while following along in the video.

    While the code migration demonstrated seems straightforward, the most critical change is that Cloud Memorystore requires dedicated server instances. For this reason, a Serverless VPC connector is also needed to connect your App Engine app to those Memorystore instances, requiring more dedicated servers. Furthermore, neither Cloud Memorystore nor Cloud VPC are free services, and neither has an “Always free” tier quota. Before moving forward this migration, check the pricing documentation for Cloud Memorystore for Redis and Serverless VPC access to determine cost considerations before making a commitment.

    One key development that may affect your decision: In Fall 2021, the App Engine team extended support of many of the legacy bundled services like Memcache to next-generation runtimes, meaning you are no longer required to migrate to Cloud Memorystore when porting your app to Python 3. You can continue using Memcache even when upgrading to 3.x so long as you retrofit your code to access bundled services from next-generation runtimes.

    A move to Cloud Memorystore and today’s migration techniques will be here if and when you decide this is the direction you want to take for your App Engine apps. All Serverless Migration Station content (codelabs, videos, source code [when available]) can be accessed at its open source repo. While our content initially focuses on Python users, we plan to cover other language runtimes, so stay tuned. For additional video content, check out our broader Serverless Expeditions series.

    Experts.Anyone.Anywhere

    Posted by Janelle Kuhlman, Developer Relations Program Manager

    Click above to meet our community of Experts

    The Google Developer Experts program is a global network of highly experienced technology experts, developers and thought leaders. GDEs share their expertise with other developers and tech communities through a variety of ways such as speaking engagements, mentorship and content writing. The community has access to an exclusive network of experts that span across different Google technologies including Android, Cloud, Machine Learning and more.

    Get to know our diverse community and subscribe to the Google Developers YouTube Channel to stay informed on the latest updates across our products and platforms!

    How to use App Engine Memcache in Flask apps (Module 12)

    Posted by Wesley Chun

    Background

    In our ongoing Serverless Migration Station series aimed at helping developers modernize their serverless applications, one of the key objectives for Google App Engine developers is to upgrade to the latest language runtimes, such as from Python 2 to 3 or Java 8 to 17. Another objective is to help developers learn how to move away from App Engine legacy APIs (now called “bundled services”) to Cloud standalone equivalent services. Once this has been accomplished, apps are much more portable, making them flexible enough to:

    In today’s Module 12 video, we’re going to start our journey by implementing App Engine’s Memcache bundled service, setting us up for our next move to a more complete in-cloud caching service, Cloud Memorystore. Most apps typically rely on some database, and in many situations, they can benefit from a caching layer to reduce the number of queries and improve response latency. In the video, we add use of Memcache to a Python 2 app that has already migrated web frameworks from webapp2 to Flask, providing greater portability and execution options. More importantly, it paves the way for an eventual 3.x upgrade because the Python 3 App Engine runtime does not support webapp2. We’ll cover both the 3.x and Cloud Memorystore ports next in Module 13.

    Got an older app needing an update? We can help with that.

    Adding use of Memcache

    The sample application registers individual web page “visits,” storing visitor information such as the IP address and user agent. In the original app, these values are stored immediately, and then the most recent visits are queried to display in the browser. If the same user continuously refreshes their browser, each refresh constitutes a new visit. To discourage this type of abuse, we cache the same user’s visit for an hour, returning the same cached list of most recent visits unless a new visitor arrives or an hour has elapsed since their initial visit.

    Below is pseudocode representing the core part of the app that saves new visits and queries for the most recent visits. Before, you can see how each visit is registered. After the update, the app attempts to fetch these visits from the cache. If cached results are available and “fresh” (within the hour), they’re used immediately, but if cache is empty, or a new visitor arrives, the current visit is stored as before, and this latest collection of visits is cached for an hour. The bolded lines represent the new code that manages the cached data.

    Adding App Engine Memcache usage to sample app

    Wrap-up

    Today’s “migration” began with the Module 1 sample app. We added a Memcache-based caching layer and arrived at the finish line with the Module 12 sample app. To practice this on your own, follow the codelab doing it by-hand while following the video. The Module 12 app will then be ready to upgrade to Cloud Memorystore should you choose to do so.

    In Fall 2021, the App Engine team extended support of many of the bundled services to next-generation runtimes, meaning you are no longer required to migrate to Cloud Memorystore when porting your app to Python 3. You can continue using Memcache in your Python 3 app so long as you retrofit the code to access bundled services from next-generation runtimes.

    If you do want to move to Cloud Memorystore, stay tuned for the Module 13 video or try its codelab to get a sneak peek. All Serverless Migration Station content (codelabs, videos, source code [when available]) can be accessed at its open source repo. While our content initially focuses on Python users, we hope to one day cover other language runtimes, so stay tuned. For additional video content, check out our broader Serverless Expeditions series.

    Celebrating leaders in AAPI communities

    Posted by Google Developer Studio

    In recognition of Asian Americans and Pacific Islanders Heritage Month, we are speaking with mentors and leaders in tech and who identify as part of the AAPI community. Many of the influential figures we feature are involved with and help champion inclusivity programs like Google Developer Experts and Google Developer Student Clubs, while others work on leading in product areas like TensorFlow and drive impact through their line of work and communities.

    On that note, we are honoring this year’s theme of “Advancing Leaders Through Collaboration” by learning more about the power of mentorship, advice they’ve received from other leaders, and their biggest accomplishments.

    Read more about leads in the AAPI community below.

    Ben Hong

    Senior Staff Developer Experience Engineer at Netlify

    What’s the best piece of advice you can offer new/junior developers looking to grow into leadership roles?

    There is a lot of advice out there on how to get the most out of your career by climbing the ladder and getting leadership roles. Before you embark on that journey, first ask yourself the question “Why do I want this?”

    Becoming a leader comes with a lot of glitz and glamor, but the reality is that it carries a huge weight of responsibility because the decisions and actions you take as a leader will impact the lives of those around you in significant ways you can’t foresee.

    As a result, the key to becoming the best leader you can be is to:

    1. Establish what your values and principles are
    2. Align them to the actions you take each and every day

    Because at the end of the day, leaders are often faced with difficult decisions that lead to an uncertain future. And without core values and principles to guide you as an individual, you run the risk of being easily swayed by short term trade offs that could result in a long term loss.

    This world needs leaders who can stand their ground against the temptations of short-term wins and make the best decisions they can while fighting for those that follow them. If you stand firm in your values and listen to those around you, you’ll be able to create profound impact in your community.

    Taha Bouhsine

    Data Scientist and GDSCUIZ Lead

    What’s the best piece of advice you can offer new/junior developers looking to grow into leadership roles?

    Create a journey worth taking. You will face many challenges and a new set of problems. You will start asking a lot of questions as everything seems to be unfamiliar.

    Things get much lighter if you are guided by a mentor, as you will get guidance on how to act in this new chapter of life. In your early days, invest as much as you can in building and nurturing a team, as it will save you a lot of time along the road. Surround yourself with real people who take the initiative, get to the action, and are willing to grow and learn, nurture their skills and guide them towards your common goal. Don’t try to be a people pleaser as it’s an impossible mission.

    Your actions will offend some people one way or the other. That’s ok as you should believe in your mission, create a clear plan with well-defined tasks and milestones, and be firm with your decision. In the end, responsibility is yours to bear, so at least take it on something you decided, not something that was forced upon you by others.

    Finally, when there is fire, look for ways to put it out. Take care of your soul, and enjoy the journey!

    Huyen Tue Dao

    Android Developer, Trello

    What do you love most about being a part of the developer community?

    It has been the most rewarding and critical part of my career to meet other developers, learning and sharing knowledge and getting to know them as human beings.

    Development is a job of constant learning, whether it is the latest technology, trends, issues, and challenges or the day-to-day intricacies and nuances of writing specialized code and solving problems in efficient and elegant ways. I don’t think I’d have the tools to solve issues large and small without the sharing of knowledge and experience of the developer community. If you’re having a problem of any kind, chances are that someone has had the same challenges. You can take comfort that you can probably find the answer or at least find people that can help you. You can also feel confident that if you discovered something new or learned important lessons, someone will want to hear what you have to say.

    I love seeing and being part of this cycle and interchange; as we pool our experience, our knowledge, and insights, we become stronger and more skilled as a community. I would not be the engineer or person that I am without the opportunities of this exchange.

    Just as important, though, is the camaraderie and support of those who do what I do and love it. I have been so fortunate to have been in communities that have been open and welcoming, ready to make connections and form networks, eager to celebrate victories and commiserate with challenges. Regardless of the technical and personal challenges of the everyday that may get to me, there are people that understand and can support me and provide brilliantly diverse perspectives of different industries, countries, cultures, and ages.

    Malak Magdy Ali

    Google Developer Student Club Lead at Canadian International College, Egypt

    What’s the best piece of advice you can offer new/junior developers looking to grow into leadership roles?

    The best piece of advice I can give to new leaders is to have empathy. Having empathy will make you understand people’s actions and respect their feelings. This will make for stronger teams.

    Also, give others a space to lead. Involve your team in making decisions; they come up with great ideas that can help you and teammates learn from each other. In this process, trust is also built, resulting in a better quality product.

    Finally, don’t underestimate yourself. Do your best and involve your team to discuss the overall quality of your work and let them make recommendations.

    How can App Engine users take advantage of Cloud Functions?

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

    Introduction

    Recently, we discussed containerizing App Engine apps for Cloud Run, with or without Docker. But what about Cloud Functions… can App Engine users take advantage of that platform somehow? Back in the day, App Engine was always the right decision, because it was the only option. With Cloud Functions and Cloud Run joining in the serverless product suite, that’s no longer the case.

    Back when App Engine was the only choice, it was selected to host small, single-function apps. Yes, when it was the only option. Other developers have created huge monolithic apps for App Engine as well… because it was also the only option. Fast forward to today where code follows more service-oriented or event-driven architectures. Small apps can be moved to Cloud Functions to simplify the code and deployments while large apps could be split into smaller components, each running on Cloud Functions.

    Refactoring App Engine apps for Cloud Functions

    Small, single-function apps can be seen as a microservice, an API endpoint “that does something,” or serve some utility likely called as a result of some event in a larger multi-tiered application, say to update a database row or send a customer email message. App Engine apps require some kind web framework and routing mechanism while Cloud Function equivalents can be freed from much of those requirements. Refactoring these types of App Engine apps for Cloud Functions will like require less overhead, helps ease maintenance, and allow for common components to be shared across applications.

    Large, monolithic applications are often made up of multiple pieces of functionality bundled together in one big package, such as requisitioning a new piece of equipment, opening a customer order, authenticating users, processing payments, performing administrative tasks, and so on. By breaking this monolith up into multiple microservices into individual functions, each component can then be reused in other apps, maintenance is eased because software bugs will identify code closer to their root origins, and developers won’t step on each others’ toes.

    Migration to Cloud Functions

    In this latest episode of Serverless Migration Station, a Serverless Expeditions mini-series focused on modernizing serverless apps, we take a closer look at this product crossover, covering how to migrate App Engine code to Cloud Functions. There are several steps you need to take to prepare your code for Cloud Functions:

    • Divest from legacy App Engine “bundled services,” e.g., Datastore, Taskqueue, Memcache, Blobstore, etc.
    • Cloud Functions supports modern runtimes; upgrade to Python 3, Java 11, or PHP 7
    • If your app is a monolith, break it up into multiple independent functions. (You can also keep a monolith together and containerize it for Cloud Run as an alternative.)
    • Make appropriate application updates to support Cloud Functions

      The first three bullets are outside the scope of this video and its codelab, so we’ll focus on the last one. The changes needed for your app include the following:

      1. Remove unneeded and/or unsupported configuration
      2. Remove use of the web framework and supporting routing code
      3. For each of your functions, assign an appropriate name and install the request object it will receive when it is called.

      Regarding the last point, note that you can have multiple “endpoints” coming into a single function which processes the request path, calling other functions to handle those routes. If you have many functions in your app, separate functions for every endpoint becomes unwieldy; if large enough, your app may be more suited for Cloud Run. The sample app in this video and corresponding code sample only has one function, so having a single endpoint for that function works perfectly fine here.

      This migration series focuses on our earliest users, starting with Python 2. Regarding the first point, the app.yaml file is deleted. Next, almost all Flask resources are removed except for the template renderer (the app still needs to output the same HTML as the original App Engine app). All app routes are removed, and there’s no instantiation of the Flask app object. Finally for the last step, the main function is renamed more appropriately to visitme() along with a request object parameter.

      This “migration module” starts with the (Python 3 version of the) Module 2 sample app, applies the steps above, and arrives at the migrated Module 11 app. Implementing those required changes is illustrated by this code “diff:”

      Migration of sample app to Cloud Functions

      Next steps

      If you’re interested in trying this migration on your own, feel free to try the corresponding codelab which leads you step-by-step through this exercise and use the video for additional guidance.

      All migration modules, their videos (when published), codelab tutorials, START and FINISH code, etc., can be found in the migration repo. We hope to also one day cover other legacy runtimes like Java 8 as well as content for the next-generation Cloud Functions service, so stay tuned. If you’re curious whether it’s possible to write apps that can run on App Engine, Cloud Functions, or Cloud Run with no code changes at all, the answer is yes. Hope this content is useful for your consideration when modernizing your own serverless applications!

    Celebrating global women in tech and trailblazers

    Posted by Google Developer Studio

    In honor of Women’s History Month, we are featuring tech trailblazers who have made significant contributions to developer communities close to Google and beyond. Many of the women we spoke to work directly with some of our educational outreach and inclusivity programs like Google Developer Experts and Women Techmakers, while others are Google Developer Student Clubs participants or Googlers who do incredible work around the globe.

    They all share a passion for making the developer community more accessible and inclusive for generations of women to come. Read about them below to learn more about these individuals whose drive contributes to a better workplace and world.

    We’re proud to celebrate #WHM22 with them.

    Google Developer Experts

    Laura Morillo-Velarde Rodríguez

    Guest’s location: Zaragoza, Spain

    Tell us more about your role.

    I work as a Tech Lead at Seedtag, a contextual advertising company, where I help build an amazing tech team to go through all the technical challenges that we have to face. Besides that, I’m also a Women Techmakers Ambassador and Cloud Google Developer Expert.

    Is there a project you’ve worked on recently that you’re excited to share?

    During the pandemic I started recording podcasts (in Spanish) with some friends (GDG Spain Podcast, Cloud Español) and one of those is Tech & Ladies Podcast. Every two weeks Cristina Pampín, Silvia García and I talk with other women in tech about their careers, different technologies or other topics related to the tech space.

    What makes you passionate about being in the tech space?

    I’m passionate about the tech space because you always have something new to learn. I think that this can be a bit overwhelming sometimes, as you need to find the time and it usually involves a lot of self-study, but it also prevents our work from becoming boring.

    What is the biggest piece of advice you would offer professionals starting in the tech space?

    I would recommend them to make the most of the technical communities that we have. There, you can learn a lot, meet amazing people and contribute to the growth of others with your knowledge and experience.

    Luz Maria Maida Claude

    Guest’s Location: Ingelheim, Germany

    Tell us more about your role.

    I’ve been a Software Engineer for the last 7 years. Right now, I’m working at BIX that is the Digital Lab of Boehringer Ingelheim. Although my job description is “Frontend Engineer,” the reality is that every day I have different challenges that involve a great diversity of technologies and tools.

    Is there a project you’ve worked on recently that you’re excited to share?

    With my team I created some prototypes using hardware oriented to the healthcare systems. In my free time I’m creating a project to collect funds for stray animals.

    What makes you passionate about being in the tech space?

    Technology gives us the power to turn our ideas into reality, but many of the things that are in our lives today are there because we share our knowledge with others. Thanks to many communities and groups we have more opportunities to improve our environments and grow step by step, something that is important in this time where we need to create changes.

    What is the biggest piece of advice you would offer professionals starting in the tech space?

    Be curious, trust in yourself and enjoy the journey. It is important to understand that every day counts to reach the objectives that we have. We’ll never have all the knowledge, but your current version knows something more than yesterday and the last week. Don’t stop and continue growing.

    Google’s Coding Competitions

    Chu-Ling Ko

    Guest’s Location: Palo Alto, California

    Tell us more about your role

    I am a software engineer at Google for Clinicians of Google Health. Also, I am a volunteer for Google’s Coding Competitions. We develop the coding competition problems for Kick Start, Code Jam, and Code Jam to I/O for Women!

    Is there a project you’ve worked on recently that you’re excited to share?

    Recently, a group of women volunteers including me are working together to develop the problem sets for Code Jam to I/O for Women 2022. We prepare input verifiers, test case generators, various solutions (and some fake ones), and solution articles. It is so exciting that we are all a part of this amazing event!

    What makes you passionate about being in the tech space?

    I am so passionate about this work because it is something that helps people. Google’s Coding Competition team produces plenty of high-quality problem sets every year, along with comprehensible, educational solution articles. We hope the participants can enjoy and learn new things from each of our coding competitions!

    What is the biggest piece of advice you would offer professionals starting in the tech space?

    Enjoy and take everything you are doing seriously, and appreciate the people you meet in the adventure!

    Tatiyana Mishtal

    Guest’s Location: Zurich, Switzerland

    Tell us more about your role.

    I’m a Senior Software Engineer at YouTube Content ID, also TL of our team. We are working on detection of copyright violations on YouTube. Due to the specifics of our product, we have a very intensive Quality focus – I spend a lot of time on data analysis and cross-team collaboration to improve automated decisions made. At the same time reliability requirements, new signals development and continuous improvements to YouTube infrastructure bring endless interesting engineering challenges as well.

    Is there a project you’ve worked on recently that you’re excited to share?

    In addition to my main project, I’m also part of the Hash Code team. For several years already we have organized this coding competition for developers of all levels from all around the world. And just a few weeks ago we held the 2022 Qualification Round, which was especially challenging for us. Not only did we need to prepare a hard and exciting problem for the competition as we do every year, but also we had migrated to the new Google Coding Competitions platform and it was our debut there. Thanks to ours and the Coding Competitions team’s joint effort everything went smoothly!

    What makes you passionate about being in the tech space?

    I really like making things work. I enjoy solving problems, overcoming challenges and in the end seeing how results impact people’s lives. I especially value personal time and it delights me that technology can both improve the quality of people’s lives and cut the “time cost” of many mundane things.

    What is the biggest piece of advice you would offer professionals starting in the tech space?

    Ask “why” instead of “how”. Why something works the way it does, why people came to particular ideas and why would one use the technology in a way they do. There are a lot of options of “how” for everything in tech, but you need to know “why” to take the most out of it.

    Google Developer Groups

    Michelle Mannering

    Guest’s Location: Melbourne, Victoria

    Tell us more about your role.

    The GitHub DevRel team gets to do some of the most amazing things in the Developer Relations space. We showcase the products and services that GitHub has, but more importantly we highlight the awesome things our community is doing. Whether someone is a maintainer, an open source contributor, student, or developer working within a company, everyone has a unique and interesting experience. By showcasing these cool developers and projects we can show how people are building better things for the world.

    Is there a project you’ve worked on recently that you’re excited to share?

    We’re always doing such fun and awesome things at GitHub. One of the things I’ve been working on a lot is the Release Radar. It’s a monthly blog post that goes out showcasing awesome open source projects. We also have a video that goes out featuring some of the projects, talking about what they do, and how others can use them. It’s a really awesome way to get the word out about what developers are building. You can find out more on releaseradar.github.com

    What makes you passionate about being in the tech space?

    I really love talking to others and hearing about their journey and experience. The best thing about the tech space is listening to someone get really excited about the thing they are building and then showing it to as many people as possible. I’m always so blown away by what people can create. I’ve been in this boat a few times and when you’re learning or building something and you get it right, and it deploys and doesn’t break, it’s not just you that gets excited, but everyone around you!

    What is the biggest piece of advice you would offer professionals starting in the tech space?

    Don’t think that this is a space where you have to be a genius and know everything. Everyone, all developers, from the most junior to the most senior, still use Stack Overflow to find answers. Never think you are not enough, and on the flip side, never think that you know it all. You can always learn more. So my best advice is “no matter what your role or your experience, always be learning!”

    Cassidy Williams

    Guest’s Location: Chicago, Illinois

    Tell us more about your role.

    In short: I build open source and educational content to help people get jobs!

    Is there a project you’ve worked on recently that you’re excited to share?

    I’ve been working on my newsletter full of web news, practice interview questions, and jokes! It’s at cassidoo.co/newsletter and I’m about to hit my 5-year-anniversary writing it!

    What makes you passionate about being in the tech space?

    Tech is such a creative, logical, exciting field that can change peoples’ lives. I love helping people get jobs in tech to afford and build the lives and ideas they want to.

    What is the biggest piece of advice you would offer professionals starting in the tech space?

    Look for people who are where you want to be. Look at their paths, and see how you can try to mimic it. Make yourself available for people to mimic you. One of my favorite quotes is to “lift as you climb”! If you help others as you move forward in their careers as you move forward in yours, you’ll build a wonderful community of people around you, and make the tech community a better place!

    How to get started in cloud computing

    Posted by Google Cloud training & certifications team

    Validated cloud skills are in demand. With Google Cloud certifications, employers know that certified individuals have proven knowledge of various professional roles within the cloud industry. Google Cloud certifications have also been recognized as some of the highest-paying IT certifications for the past several years. This year, the Google Cloud Certified Professional Data Engineer topped the list with an average salary of $171,749, while the Google Cloud Certified Professional Cloud Architect came in second place, with an average salary of $169,029.

    You may be wondering what sort of background you need to take advantage of these opportunities: What sort of classes should you take? How exactly do you get started in the cloud without experience? Here are some tips to start learning about Google Cloud and build your cloud computing skills.

    Get hands-on experience with cloud computing

    Google Cloud training offers a wide range of learning paths featuring comprehensive courses and hands-on labs, so you get to practice with the real Google Cloud console. For instance, If you wanted to take classes to prepare for the Professional Data Engineer certification mentioned above, there is a complete learning path featuring four courses and 31 hands-on labs to help familiarize you with relevant topics like BigQuery, machine learning, IoT, TensorFlow, and more.

    There are nine learning paths providing you with a launch pad to all major pillars of cloud computing, from networking, cloud security, database management, and hybrid cloud infrastructure. Each broader learning path contains specific learning paths to help you specifically train for job roles like Machine Learning Engineer. Visit the Google Cloud training page to find the right path for you.

    Learn live from cloud experts

    Google Cloud regularly hosts a half-day live training event called Cloud OnBoard which features hands-on learning led by experts. All sessions are also available to watch on-demand after the event.

    If you’re a developer new to cloud computing, we recommend you start with Google Cloud Fundamentals, an entry-level course to learn about the basics of Google Cloud. Experts guide you through hands-on labs where you can practice using the Google Console, Google Cloud Shell, and more.

    You’ll be introduced to core components of Google Cloud and given an overview of how its tools impact the entire cloud computing landscape. The curriculum covers Compute Engine and how to create VM instances from scratch and from existing templates, how to connect them together, and end with projects that can talk to each other safely and securely. You will also learn about the different storage and database options available on Google Cloud.

    Other Cloud OnBoard event topics include cloud architecture, Kubernetes, data analytics, and cloud application development.

    Explore Google Cloud infrastructure

    Cloud infrastructure is the backbone of the internet. Understanding cloud infrastructure is a good starting point to start digging deeper into cloud concepts because it will give you a taste of the various aspects of cloud computing to figure out what you like best, whether it’s networking, security, or application development.

    Build your foundational Google Cloud knowledge with our on-demand infrastructure training in the cloud infrastructure learning path. This learning path will provide you with practical experience through expert-guided labs which dive into Cloud Storage and other key application services like Google Cloud’s operations suite and Cloud Functions.

    Show off your skills

    Once you have a strong grasp on Google Cloud basics, you can start earning skill badges to demonstrate your experience.

    Skill badges are digital credentials that recognize your ability to solve real-world problems with your cloud knowledge. You can share them on your resume or social profile so your professional network sees your technical skills. This can be useful for recruiters or employers as you transition to cloud computing work.Skill badges also enable you to get in-depth, hands-on experience with different Google Cloud offerings on the way to earning the credential.

    You can also use them to start preparing for Google Cloud certifications which are more intensive and show employers that you are a cloud expert. Most Google Cloud certifications recommend having at least 6 months or up to several years of industry experience depending on the material.

    Ready to get started in the cloud? Visit the Google Cloud training page to see all your options from in-person classes, online courses, special events, and more.