Tag Archives: developers

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.

Reach global markets as a Recommended for Google Workspace app

Posted by Elena Kingbo, Program Manager, Google Workspace

Today we announced our 2022 Recommended for Google Workspace apps. This program offers a distinct way for third-party developers to better reach Google Workspace users and attract new customers to their apps. So, for those developers who may be interested in it in the future, we wanted to walk through the basics of what the program is and how to apply for it.

What is the Google Workspace Marketplace?

The Google Workspace Marketplace is the first place Google Workspace administrators and users look when they want to extend or enhance their Google Workspace experience. The Marketplace can be accessed within most first-party Google Workspace apps, including Gmail, Drive, Docs, Sheets, Slides, Forms, Calendar, and Classroom, as well as at workspace.google.com/marketplace.

Launch Marketplace from your favorite Google Workspace app by clicking the “+”.

The Google Workspace Marketplace is the first place Google Workspace administrators and users look when they want to extend or enhance their Google Workspace experience. The Marketplace can be accessed within most first-party Google Workspace apps, including Gmail, Drive, Docs, Sheets, Slides, Forms, Calendar, and Classroom, as well as at workspace.google.com/marketplace.

Developers who want to build and deploy apps to the Marketplace can either use their own preferred coding language or leverage Google Apps Script, our serverless platform. You can learn more about building apps and publishing them to the Marketplace in our developer documentation.

What is the Recommended for Google Workspace program?

The Recommended for Google Workspace program identifies and promotes a select number of Google Workspace applications that are secure, reliable, well-integrated with Google Workspace, and loved by users.

Partners who submit their apps will be evaluated based on the quality of their solution, their strategic investment in Google Workspace integrations, and security and privacy posture. In addition, all partners will be required to complete a third-party security assessment in the final stage of the assessment. You can sign up for our Google Workspace developers newsletter to be notified when the next application window opens up.

What it means to be a Recommended app

Google Workspace customers are often looking for high-quality, secure apps they can install to enhance their Workspace experience. Since recommended apps have exceeded our highest security and reliability standards, they are the first apps we recommend to customers and among the first apps users see when they visit the Marketplace. Recommended partners will also receive new and enhanced benefits, including technical advisory services and early access to APIs.

There have been more than 4.8 billion app installs on the Marketplace. These apps are an integral part of the Google Workspace experience and users are continually looking for new ways to extend the value of Google Workspace. Creating a Google Workspace app is a fantastic opportunity for innovative developers interested in enhancing the Google Workspace experience. And, for those developers who truly want to be set apart as a trusted app on the Marketplace, the Recommended for Google Workspace program offers an unique way to reach new customers.

Explore our Recommended for Google Workspace apps on the Google Workspace Marketplace.

How this engineer got the career boost she needed

Saskia Bobinska was excited when she came across the application for the Women Developers Academy (WDA) program in Europe. After spending two years in isolation, thanks to the pandemic and having multiple back surgeries, she was looking for a way to advance her career in tech. She thought the WDA — a global program run by Women Techmakers to help technical women become better speakers and bring more diversity to tech stages — would be a great first step towards this goal.

One of the first assignments was to write her own speaker bio. As a self-taught frontend developer who uses JavaScript, NextJS and React, she felt a bit hesitant to share her story. “To be honest, I thought that my story was not important enough,” she tells us. But after a few WDA training sessions and encouragement from her mentors, business strategist Kamila Wosińska, Dart and Flutter Google Developer Expert (GDE) Majid Hajian and Web Technologies GDE Anuradha Kumarii, Saskia’s confidence was boosted. She excitedly set out to write a LinkedIn post about a mobile app on which she had been working.

Not long after the post went live, Saskia was approached by one of the companies she had mentioned. A few meetings lead to interviews and within a few months, Saskia was offered a job on their team. “I never would’ve thought that this was possible when I started coding three years ago,” Saskia says.

Looking back on the experience, Saskia is positively surprised by the speed with which she was able to transition her career from social media to engineering. “I’d have given myself two years before applying to Sanity, but WDA accelerated that,” she says. “I found my voice within the tech industry because of the community and WDA, which gave me a push toward it.”

Going through the WDA also helped Saskia realize that her “soft” skills — communication, leadership and confidence — are just as important as her hard skills for excelling in tech. “Having the ability to go out and speak gave me an approach to finding a more intermediate-level engineering role,” she says. “I have hard skills, but my soft skills are what brought me to this company that shares my priorities, because they knew who I was.”

She also recognized the importance of having a supportive community. During the WDA, she was excited to see women supporting each other so enthusiastically within the male-dominated tech industry. “Emotional support and empathy, especially in a professional environment, help you stay in balance and enable you to do your best,” she says. “Always help and support others, because safe communities are not just found, they are made.”

Learn more about Women Techmakersand become a member to stay up to date on all our initiatives including the Women Developers Academy.

A bigger piece of the pi: Finding the 100-trillionth digit

The 100-trillionth decimal place of π (pi) is 0. A few months ago, on an average Tuesday morning in March, I sat down with my coffee to check on the program that had been running a calculation from my home office for 157 days. It was finally time — I was going to be the first and only person to ever see the number. The results were in and it was a new record: We’d calculated the most digits of π ever — 100 trillion to be exact.

Calculating π — or finding as many digits of it as possible — is a project that mathematicians, scientists and engineers around the world have worked on for thousands of years, myself included. The well-known approximation 3.14 is believed to have been found by Archimedes around the year 250 BCE. Computer scientist Donald Knuth wrote "human progress in calculation has traditionally been measured by the number of decimal digits of π" in his book “The Art of Computer Programming” (Dr. Knuth even wrote about me in the book). In the past, people would manually — meaning without calculators or computers — determine the digits of pi. Today, we use computers to do this calculation, which helps us learn how much faster they’ve become. It’s one of the few ways to measure how much progress we're making across centuries, including before the invention of electronic computers.

An illustration of pie crust stretching from the Earth to the moon. Above it reads: "100 trillion inches of pie crust stretches from Earth to the moon an back ~3,304 times."

As a developer advocate at Google Cloud, part of my job is to create demos and run experiments that show the cool things developers can do with our platform; one of those things, you guessed it, is using a program to calculate digits of pi. Breaking the record of π was my childhood dream, so a few years ago I decided to try using Google Cloud to take on this project. I also wanted to see how much data processing these computers could handle. In 2019, I became the third woman tobreak this world record, with a π calculation of 31.4 trillion digits.

But I couldn’t stop there, and I decided to try again. And now we have a new record of 100 trillion decimal places. This shows us, again, just how far computers have come: In three years, the computers have calculated three times as many numbers. What’s more, in 2019, it took the computers 121 days to get to 31.4 million digits. This time, it took them 157 days to get to 100 trillion — more than twice as fast as the first project.

A illustrated chart showing how quickly we reached the new pi record compared to the last time in 2019.

But let’s look back farther than my 2019 record: The first world record of computing π with an electronic computer was in 1949, which calculated 2,037 decimal places. It took humans thousands of years to reach the two-thousandth place, and we've reached the 100 trillionth decimal just 73 years later. Not only are we adding more digits than all the numbers in the past combined, but we're spending less and less time hitting new milestones.

An illustration of a person holding a phone and tapping on the screen. Above it reads: "The 82,000 terabytes of data processed during calculations is the equivalent of 160,156 Pixel 6 Pros with max storage (512 GB)."

I used the same tools and techniques as I did in 2019 (for more details, we have a technical explanation in the Google Cloud blog), but I was able to hit the new number more quickly thanks to Google Cloud’s infrastructure improvements in compute, storage and networking. One of the most remarkable phenomena in computer science is that every year we have made incremental progress, and in return we have reaped exponentially faster compute speeds. This is what’s made a lot of the recent computer-assisted research possible in areas like climate science and astronomy.

An illustration of a person with a megaphone. Above it reads: "If you read all 100 trillion digits out loud, one second at a time, it would take you 3,170,929 years to read the whole thing."

Back when I hit that record in 2019 — and again now — many people asked "what's next?" And I’m happy to say that the scientific community just keeps counting. There's no end to π, it’s a transcendental number, meaning it can't be written as a finite polynomial. Plus, we don't see an end to the evolution of computing. Like the introduction of electronic computers in the 1940s and discovery of faster algorithms in the 1960-80s, we could still see another fundamental shift that keeps the momentum going.

So, like I said: I’ll just keep counting.

Why .app and .dev are perfect homes for developer tools

Back in the day, I remember when the main game in town was .com, and it was hard to find a short, memorable domain name that didn’t cost an arm and a leg. Fast forward to today, and we now have a wealth of descriptive top-level domains (TLDs) available to choose from. Not only do these TLDs offer better availability of high-quality names, they also do a great job of signaling purpose and content. So it’s no surprise the developer community has embraced them.

The Google Registry team showcases some of these developers in their ongoing #MyDomain video series, which highlights real-world examples of websites built on .app, .dev and .page. In these videos, developers share why they chose their domain and offer helpful tips for anyone who might be building their own website. Today, we’re sharing three new #MyDomain videos that feature teams using .dev and .app domain names to host their developer tools.

Netlify.app

Netlify offers web hosting and serverless backend services. Learn why they built their website on a .app domain.

Web.dev

Google launched web.dev to share best practices, case studies and how-tos for modern web development with the broader developer community.

Clerk.dev

Clerk handles user accounts and logins for websites so developers don’t have to. Learn why they built their website on a .dev domain.

As a developer, security is top of mind every time I create a web app. Fortunately, every .app, .dev and .page domain is automatically HTTPS-only from the moment of creation, which means one less security best practice to worry about when spinning up a new website.

If you’re feeling inspired or working on a new project, you can register your own domain name at get.app, get.dev or get.page.

Google Play helps indie games go further faster

Indie game developers are known for creating some of the most innovative titles to land on Google Play. It’s this creativity that captures the imagination of the more than 2.5 billion people using our platform each month.

At Google Play, it is our mission to help indie game developers reach their full potential, wherever they are in their journey.

This year, the Indie Games programs are back once again to help talented indie developers design, launch and grow high-quality games and reach new players. Find out more about how the 2022Indie Games Accelerator & Festival helps developers to go further faster.

Supercharge your growth with mentorship & live masterclasses

If you’re an indie developer who is early in your journey — either close to launching a new game or have recently launched a title — this high-impact program is designed for you.

With the help of our network of gaming experts, the Indie Game Accelerator provides education and mentorship for ambitious developers to help you build, launch and grow successfully.

Selected game studios will be invited to take part in the 10-week acceleration program starting inSeptember 2022 as the Accelerator Class of 2022.

This is a highly-tailored program for small game developers spanning 78 eligible countries, that includes a series of online masterclasses, talks and game development workshops. You’ll also get the chance to meet and connect with other developers from around the world who are looking to take their games to the next level.

Celebrating the top indie games in Europe, Japan & South Korea

If you're a passionate indie game developer and you have recently launched a high-quality game, enter your game to be showcased at the Indie Games Festival by Google Play.

Once again, we are hosting three international competitions in search of the most promising games from Japan, South Korea, and selected European countries, to celebrate the Top 20 indie games in each region.

The festival jury will consist of both gaming experts and Googlers, who are charged with finding creative indie games that are ready for the spotlight. As a finalist you will be able to join the Festival showcase and get your game discovered by top industry experts and players worldwide.

You can now enter your game to one of the Festival contests: Europe, Japan & South Korea.

For more updates and announcements about the Indie Games programs follow @GooglePlayBiz.

South African developers build web application to help local athletes

Posted by Aniedi Udo-Obong, Sub-Saharan Africa Regional Lead, Google Developer Groups

Lesego Ndlovu and Simon Mokgotlhoa have stayed friends since they were eight years old, trading GameBoy cartridges and playing soccer. They live three houses away from each other in Soweto, the biggest township in South Africa, with over one million residents. The two friends have always been fascinated by technology, and by the time the duo attended university, they wanted to start a business together that would also help their community.

Lesego Ndlovu and Simon Mokgotlhoa sitting at a desk on their computers

After teaching themselves to code and attending Google Developer Groups (GDG) events in Johannesburg, they built a prototype and launched a chapter of their own (GDG Soweto) to teach other new developers how to code and build technology careers.

Building an app to help their community

Lesego and Simon wanted to build an application that would help the talented soccer players in their community get discovered and recruited by professional soccer teams. To do that, they had to learn to code.

Lesego Ndlovu and Simon Mokgotlhoa holding their phones towards the screen showcasing the Ball Talent app

“We always played soccer, and we saw talented players not get discovered, so, given our interest in sports and passion for technology, we wanted to make something that could change that narrative,” Lesego says. “We watched videos on the Chrome Developers YouTube channel and learned HTML, CSS, and JavaScript, but we didn’t know how to make an app, deliver a product, or start a business. Our tech journey became a business journey. We learned about the code as the business grew. It’s been a great journey.”

After many all-nighters learning frontend development using HTML, CSS, and JavaScript, and working on their project, they built BallTalent, a Progressive Web App (PWA), that helps local soccer players in their neighborhood get discovered by professional soccer clubs. They record games in their neighborhood and upload them to the app, so clubs can identify new talent.

“We tested our prototype with people, and it seemed like they really loved it, which pushed us to keep coding and improving on the project,” says Simon. “The application is currently focused on soccer, but it’s built it in a way that it can focus on other sports.”

In 2019, when BallTalent launched, the project placed in the top 5 of one of South Africa’s most prestigious competitions, Diageo Social Tech Startup Challenge. BallTalent has helped local soccer players match with professional teams, benefiting the community. Simon and Lesego plan to release version two soon, with a goal of expanding to other sports.

Learning to code with web technologies and resources

Lesego and Simon chose to watch the Chrome Developers YouTube channel to learn to code, because it was free, accessible, and taught programming in ways that were easy to understand. Preferring to continue to use free Google tools because of their availability and ease of use, Lesego and Simon used Google developer tools on Chrome to build and test the BallTalent app, which is hosted on Google Cloud Platform.

BallTalent Shows Youth Talent to the Worlds Best Scouts and Clubs

They used NodeJS as their backend runtime environment to stay within the Google ecosystem–NodeJS is powered by the V8 JavaScript engine, which is developed by the Chromium Project. They used a service worker codelab from Google to allow users to install the BallTalent PWA and see partial content, even without an internet connection.

We are focused on HTML, CSS, JavaScript, frontend frameworks like Angular, and Cloud tools like Firebase, to be able to equip people with the knowledge of how to set up an application,” says Simon.

Moving gif of soccer players playing on a soccer field

BallTalent shares sample footage of a previous match: Mangaung United Vs Bizana Pondo Chiefs, during the ABC Motsepe Play Offs

“Google has been with us the whole way,” says Simon.

Contributing to the Google Developer community

Because of their enthusiasm for web technologies and positive experience learning to code using Google tools, Lesego and Simon were enthusiastic about joining a Google Developer Community. They became regular members at GDG Johannesburg and went to DevFest South Africa in 2018, where they got inspired to start their own GDG chapter in Soweto. The chapter focuses on frontend development to meet the needs of a largely beginner developer membership and has grown to 500+ members.

Looking forward to continued growth

The duo is now preparing to launch the second version of their BallTalent app, which gives back to their community by pairing local soccer talent with professional teams seeking players. In addition, they’re teaching new developers in their township how to build their own apps, building community and creating opportunities for new developers. Google Developer Groups are local community groups for developers interested in learning new skills, teaching others, and connecting with other developers. We encourage you to join us, and if you’re interested in becoming a GDG organizer like Simon and Lesego, we encourage you to apply.

Finding courage and inspiration in the developer community

Posted by Monika Janota

How do we empower women in tech and equip them with the skills to help them become true leaders? One way is learning from others' successes and failures. Web GDEs—Debbie O'Brien, Julia Miocene, and Glafira Zhur—discuss the value of one to one mentoring and the impact it has made on their own professional and personal development.

A 2019 study showed that only 25% of keynote speakers at tech events are women, meanwhile 70% of female speakers mentioned being the only woman on a conference panel. One way of changing that is by running programs and workshops with the aim of empowering women and providing them with the relevant soft skills training, including public speaking, content creation, and leadership. Among such programs are the Women Developer Academy (WDA) and the Road to GDE, both run by Google's developer communities.

With more than 1000 graduates around the world, WDA is a program run by Women Techmakers for professional IT practitioners. To equip women in tech with speaking and presentation skills, along with confidence and courage, training sessions, workshops, and mentoring meetings are organized. Road to GDE, on the other hand, is a three-month mentoring program created to support people from historically underrepresented groups in tech on their path to becoming experts. What makes both programs special is the fact that they're based on a unique connection between mentor and mentee, direct knowledge sharing, and an individualized approach.

Photo of Julia Miocene speaking at a conference Julia Miocene

Some Web GDE community members have had a chance to be part of the mentoring programs for women as both mentors and mentees. Frontend developers Julia Miocene and Glafira Zhur are relatively new to the GDE program. They became Google Developers Experts in October 2021 and January 2022 respectively, after graduating from the first edition of both the Women Developer Academy and the Road to GDE; whilst Debbie O'Brien has been a member of the community and an active mentor for both programs for several years. They have all shared their experiences with the programs in order to encourage other women in tech to believe in themselves, take a chance, and to become true leaders.

Different paths, one goal

Although all three share an interest in frontend development, each has followed a very different path. Glafira Zhur, now a team leader with 12 years of professional experience, originally planned to become a musician, but decided to follow her other passion instead. A technology fan thanks to her father, she was able to reinstall Windows at the age of 11. Julia Miocene, after more than ten years in product design, was really passionate about CSS. She became a GDE because she wanted to work with Chrome and DevTools. Debbie is a Developer Advocate working in the frontend area, with a strong passion for user experience and performance. For her, mentoring is a way of giving back to the community, helping other people achieve their dreams, and become the programmers they want to be. At one point while learning JavaScript, she was so discouraged she wanted to give it up, but her mentor convinced her she could be successful. Now she's returning the favor.

Photo of Debbie O'Brien and another woman in a room smiling at the camera

Debbie O'Brien

As GDEs, Debbie, Glafira, and Julia all mention that the most valuable part of becoming experts is the chance to meet people with similar interests in technology, to network, and to provide early feedback for the web team. Mentoring, on the other hand, enables them to create, it boosts their confidence and empowers them to share their skills and knowledge—regardless of whether they're a mentor or a mentee.

Sharing knowledge

A huge part of being a mentee in Google's programs is learning how to share knowledge with other developers and help them in the most effective way. Many WDA and Road to GDE participants become mentors themselves. According to Julia, it's important to remember that a mentor is not a teacher—they are much more. The aim of mentoring, she says, is to create something together, whether it's an idea, a lasting connection, a piece of knowledge, or a plan for the future.

Glafira mentioned that she learned to perceive social media in a new way—as a hub for sharing knowledge, no matter how small the piece of advice might seem. It's because, she says, even the shortest Tweet may help someone who's stuck on a technical issue that they might not be able to resolve without such content being available online. Every piece of knowledge is valuable. Glafira adds that, "Social media is now my tool, I can use it to inspire people, invite them to join the activities I organize. It's not only about sharing rough knowledge, but also my energy."

Working with mentors who have successfully built an audience for their own channels allows the participants to learn more about the technical aspects of content creation—how to choose topics that might be interesting for readers, set up the lighting in the studio, or prepare an engaging conference speech.

Learning while teaching

From the other side of the mentor—mentee relationship, Debbie O'Brien says the best thing about mentoring is seeing the mentees grow and succeed: "We see in them something they can't see in themselves, we believe in them, and help guide them to achieve their goals. The funny thing is that sometimes the advice we give them is also useful for ourselves, so as mentors we end up learning a lot from the experience too."

TV screenin a room showing and image od Glafira Zhur

Glafira Zhur

Both Glafira and Julia state that they're willing to mentor other women on their way to success. Asked what is the most important learning from a mentorship program, they mention confidence—believing in yourself is something they want for every female developer out there.

Growing as a part of the community

Both Glafira and Julia mentioned that during the programs they met many inspiring people from their local developer communities. Being able to ask others for help, share insights and doubts, and get feedback was a valuable lesson for both women.

Mentors may become role models for the programs' participants. Julia mentioned how important it was for her to see someone else succeed and follow in their footsteps, to map out exactly where you want to be professionally, and how you can get there. This means learning not just from someone else's failures, but also from their victories and achievements.

Networking within the developer community is also a great opportunity to grow your audience by visiting other contributors' podcasts and YouTube channels. Glafira recalls that during the Academy, she received multiple invites and had an opportunity to share her knowledge on different channels.

Overall, what's even more important than growing your audience is finding your own voice. As Debbie states: "We need more women speaking at conferences, sharing knowledge online, and being part of the community. So I encourage you all to be brave and follow your dreams. I believe in you, so now it's time to start believing in yourself."

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 American and Pacific Islander 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.