Manage App Engine costs  |  Google App Engine standard environment docs  |  Google Cloud (2024)

With App Engine, you only pay for the resources that you use beyond thefree quotas. After you exceed the free quotas, your costsscale with the amount of traffic that your application receives.

To limit the costs of your App Engine app, you can use any of thefollowing mechanisms:

  • Specify the maximum number of instances
  • Create budget alerts
  • Disable your app manually
  • Disable your app programmatically

Specify the maximum number of instances

Since App Engine costs usually scale based on the amount of traffic yourapp receives, you can limit your costs by limiting thenumber of instancesApp Engine can create.

Setting the maximum to 1 instance usually keeps your instance hour usage withinthe free tier. However, setting the maximum too low may prevent your app fromhaving enough instances to adequately serve incoming requests.

To specify the maximum number of instances, use the max_instancessettingin your app's app.yaml file.

Create budget alerts

Budget alerts send a notification when your costs rise above a threshold youspecify. When you receive a notification, you can limit costs by lowering thevalue of the max_instances setting or disabling your app.

To get started with budget alerts, see Set budget alerts.

Select the scope of a budget alert

You can create budget alerts for the total cost of all Google Cloud servicesin one or more projects, or just for the cost of App Engine.

To create a budget alert just for costs fromApp Engine, in the Budget alert's Products field, select App Engine.The alert will trigger when the total cost from all App Engine resourcesexceed the amount you specify, including:

  • Instance hours in the App Engine standard environment
  • Instance hours and RAM in the App Engine flexible environment
  • Bundled App Engine services

For the full list of billable App Engine resources, seeApp Engine SKUs.

Disable your app manually

Disabling your app temporarily stops it from serving and incurring billingcharges related to serving your app. All of your app's data and configurationsettings remain unchanged, and when you are ready to start running your appagain, you can enable it.

While the app is disabled, requests to your app will fail. You may continue toincur charges from other Google Cloud products. For example, if your projecthas exceeded the free quota forCloud Storage, you will continueto incur charges for storage.

For more information, seeDisable an app.

Disable your app programmatically

You can use Budget Alerts, Pub/Sub, and Cloud Run functions toautomatically disable your app when your costs exceed a threshold you specify.

As with manually disabling an app:

  • All of your app's data and configuration settings remain unchanged.
  • When you are ready to start running your app again, you can enable it.
  • Requests to your app will fail while the app is disabled.
  • You may continue to incur charges from other Google Cloud products whileyour app is disabled.

To programmatically disable your app:

  1. Create a budget alert that sends a notification to a Pub/Subtopic. For details, see Manage programmaticnotifications.

    To create a budget alert just for costs from App Engine, in theBudget's Products field, select App Engine. For information about theresources that can trigger this alert, seeCreate budget alerts.

  2. In Cloud Run functions create a function that is triggered by thePub/Sub topic. For details, see Create a CloudFunction.

    When creating the function:

    1. Use the following source code:

      import base64import jsonimport osfrom googleapiclient import discoveryAPP_NAME = os.getenv("GCP_PROJECT")def limit_use_appengine(data, context): pubsub_data = base64.b64decode(data["data"]).decode("utf-8") pubsub_json = json.loads(pubsub_data) cost_amount = pubsub_json["costAmount"] budget_amount = pubsub_json["budgetAmount"] if cost_amount <= budget_amount: print(f"No action necessary. (Current cost: {cost_amount})") return appengine = discovery.build("appengine", "v1", cache_discovery=False) apps = appengine.apps() # Get the target app's serving status target_app = apps.get(appsId=APP_NAME).execute() current_status = target_app["servingStatus"] # Disable target app, if necessary if current_status == "SERVING": print(f"Attempting to disable app {APP_NAME}...") body = {"servingStatus": "USER_DISABLED"} apps.patch(appsId=APP_NAME, updateMask="serving_status", body=body).execute()
    2. Add the following dependencies to your function's requirements.txt file:

      google-api-python-client==2.131.0
    3. Under Function to execute enter limit_use_appengine.

    4. Click Environment variables, networking, timeouts and more.

    5. Select a service account that has the App Engine Admin role.The App Engine default serviceaccount has this roleby default.

  3. Test the function.

When the budget alert is triggered, an email is sent to users in yourCloud Billing account, andyour function starts disabling your app. It may take few minutes to completethis process.

To verify that the function ran successfully, view the App Enginedashboard. A message appears near the top to indicate that your app is disabled.

Go to the App Engine dashboard

When you want your app to continue serving requests, go toApplication settings and click Enable application.

Go to Application settings

Manage App Engine costs  |  Google App Engine standard environment docs  |  Google Cloud (2024)
Top Articles
How to save your dying plants when they've got root rot
Reclaim My Losses Reviews - 3.7 Stars
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Selly Medaline
Latest Posts
Article information

Author: Pres. Carey Rath

Last Updated:

Views: 6283

Rating: 4 / 5 (41 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Pres. Carey Rath

Birthday: 1997-03-06

Address: 14955 Ledner Trail, East Rodrickfort, NE 85127-8369

Phone: +18682428114917

Job: National Technology Representative

Hobby: Sand art, Drama, Web surfing, Cycling, Brazilian jiu-jitsu, Leather crafting, Creative writing

Introduction: My name is Pres. Carey Rath, I am a faithful, funny, vast, joyous, lively, brave, glamorous person who loves writing and wants to share my knowledge and understanding with you.