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
Get a preapproval letter | Consumer Financial Protection Bureau
Capital Cost Allowance(CCA) Explained - IDM Professional Corporation
Evil Dead Movies In Order & Timeline
Where are the Best Boxing Gyms in the UK? - JD Sports
Truist Bank Near Here
Www.1Tamilmv.cafe
Promotional Code For Spades Royale
Belle Meade Barbershop | Uncle Classic Barbershop | Nashville Barbers
La connexion à Mon Compte
Flights to Miami (MIA)
270 West Michigan residents receive expert driver’s license restoration advice at last major Road to Restoration Clinic of the year
Joe Gorga Zodiac Sign
Tamilblasters 2023
Wunderground Huntington Beach
Aces Fmc Charting
Kaomoji Border
2015 Honda Fit EX-L for sale - Seattle, WA - craigslist
Hellraiser III [1996] [R] - 5.8.6 | Parents' Guide & Review | Kids-In-Mind.com
How do I get into solitude sewers Restoring Order? - Gamers Wiki
Publix Super Market At Rainbow Square Shopping Center Dunnellon Photos
Grimes County Busted Newspaper
Evil Dead Rise Showtimes Near Regal Sawgrass & Imax
Brazos Valley Busted Newspaper
R&S Auto Lockridge Iowa
Craigslist Wilkes Barre Pa Pets
1145 Barnett Drive
Shelby Star Jail Log
Bad Business Private Server Commands
Home Auctions - Real Estate Auctions
Ucm Black Board
Vlocity Clm
Pillowtalk Podcast Interview Turns Into 3Some
Chilangos Hillsborough Nj
450 Miles Away From Me
Elizaveta Viktorovna Bout
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
15 Best Things to Do in Roseville (CA) - The Crazy Tourist
Low Tide In Twilight Manga Chapter 53
60 X 60 Christmas Tablecloths
Unblocked Games Gun Games
Nami Op.gg
Login
Nu Carnival Scenes
Rocket Lab hiring Integration &amp; Test Engineer I/II in Long Beach, CA | LinkedIn
705 Us 74 Bus Rockingham Nc
Okta Login Nordstrom
Stephen Dilbeck, The First Hicks Baby: 5 Fast Facts You Need to Know
Craiglist.nj
Spn 3464 Engine Throttle Actuator 1 Control Command
sin city jili
Escape From Tarkov Supply Plans Therapist Quest Guide
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.