App Engine vs. Cloud Run: Part 3 - Post deployment challenges and solutions

Developer Blogs | 4 min read

App Engine vs. Cloud Run Part 3 - Post deployment challenges and solutions

In the previous blog post, I explained how to start using Google Cloud Platform, how to deploy and host your project on App Engine and Cloud Run, and explained the challenges and solutions for the same. This is the final blog post of the three-part blog series, where I will explain and resolve the challenges you may face post deployment of projects on both App Engine and Cloud Run.

Table of contents
• Challenges post deployment of a project and their solutions
 
   • Challenge 1: System not working as expected 
   • Challenge 2: Memory space usage 
   • Challenge 3: Startup latency 
   • Challenge 4: Application does not update after deployment

 • Best practices to avoid issues post deployment 

Challenges post deployment of a project and their solutions
To understand the challenges and resolve them, I used the project that I deployed in the last blog post. I found solutions to all the challenges that I faced (which you may face too). So, read on further, follow along, and perform the operations as I have illustrated.
Challenge 1: System not working as expected
While you run your app on the cloud platform, the system may face some issues and stop working properly. But how do you resolve it if your system isn’t working in the expected manner?
Solution:
Do as suggested below:
1. When the app is deployed to App Engine , the system automatically restarts itself when it encounters issues. App Engine automatically detects the issue and takes steps to mitigate it. In cases of runtime errors like buffer overflow, you need to monitor the error and fix the bug in your code:
    • Check the logs by clicking the logs beside the version on version control page 
    • You may      change the severity to ‘Warning’, ‘Error’, ‘Critical’, ‘Alert’ or ‘Emergency’ for better filtering of issues.

2. When the app is deployed to Cloud Run , if it encounters any problems, Cloud Run restarts itself to troubleshoot them. However, in case of runtime errors, you need to monitor the logs and fix the bugs in your code:
   • Go to the Cloud Run console page and select the project. 
   • Select the ‘LOGS’ tab.
   • You may change the severity to ‘Warning’, ‘Error’, ‘Critical’, ‘Alert’ or ‘Emergency’ for better filtering of issues.

Challenge 2: Memory space usage
In both App Engine and Cloud Run environments, files written to a disk consume memory, which you could use for other purposes. They may interrupt system functions or lead to an out-of-memory error, which may be followed by a cold start.
Solution:
To manage memory space more effectively:
    • Delete unnecessary files and free up space for
    • Adjust the memory limit along with the concurrency of requests because handling each request requires 

Challenge 3: Startup latency
In App Engine as well as Cloud Run environments, as the number of requests scales up, the latency in fulfilling them increases as processes and containers take a lot of time. It affects the rate of app response and service.
Solution:
You can reduce latency by:
  • Optimizing the source code 
  • Boosting CPU allocation to the processes
  • Minimizing the number and size of dependencies

Challenge 4: Application does not update after deployment
Suppose you change the code of an app after deploying it to App Engine or Cloud Run. Then, the deployed app may not update by itself. Even if you deploy the new version of the app and set it as the default version, the output may be of the old version.
Solution:
To immediately see the changed output as per the new version of the app, first change the app’s version, then change the default in the admin console.
 
Best practices to avoid issues post deployment
1. Maintain a debug mode in which you print the error statements in the console, then turn it off after bug 
2. Handle all exceptions and do not let your service crash on errors, as a crash leads to a cold start while 
3.Keep an eye on the billing section of the GCP console to /* monitor the usage */ and avoid any overuse of resources.

I hope our three-part series of blog posts has helped you gain knowledge about on App Engine and Cloud Run. I presented the challenges and solutions that I encountered while using App Engine and Cloud Run, so that you don’t have to struggle (like I did). We hope that developers find this series of blog posts useful. Bugsmirror team will keep publishing more such blog posts to help the developer community and also provide curious readers with informative articles to read.

- Avani, Member of Technical Staff III

Comments

Popular posts from this blog

Security Best Practices for Secure Fintech App Development

Bugsmirror Defender - Pioneering the Future of Mobile App Security

Bugsmirror Defender's Security Breakthrough: Redefining Protection

Security Best Practices in Healthtech App Development

Bugsmirror's Vegas Chronicles: Black Hat and Google BugSWAT

A Cautionary Tale of Android Security Bug CVE-2022-20004