SlideShare a Scribd company logo
1 of 21
Download to read offline
Strategies for maintaining
during read-only periods


            Jason Cooper
      Google Developer Programs
      jasonacooper@google.com
             April 6, 2010
Strategies

  Capabilities API
  Exception handling
  Read-only versions
Strategies

  Capabilities API
  Exception handling
  Read-only versions
Capabilities API - datastore

is_enabled method can be used to test whether a certain
capability is currently enabled.

datastore_writes = CapabilitySet(
  'datastore_v3',
  capabilities=['write'])

if not datastore_writes.is_enabled():
  # ...render form with form elements disabled
  # or, if a form is submitted, push a new task
  # to the task queue
else:
  # ...render form normally
Capabilities API - datastore

will_remain_enabled_for method can be used to learn whether
a component will be disabled within a certain number of
seconds

datastore_writes = CapabilitySet(
  'datastore_v3',
  capabilities=['write'])

if datastore_writes.will_remain_enabled_for(60):
  # ...render form normally
else:
  # ...render form with form elements disabled
Capabilities API - memcache

The capabilities API can be used with other services including
memcache...

memcache_set = CapabilitySet(
  'memcache',
  methods=['set'])

if memcache_set.is_enabled():
  # ...fetch from cache
else:
  # ...bypass cache
Capabilities API - images

... as well as the Images service.

images_capability = CapabilitySet('images')

if images_capability.is_enabled():
  my_image = images.resize(my_image, 64, 64)
Capabilities API

Pros:
   Automated -- no changes needed when read-only mode
   begins or ends
   Allows for datastore writes to be "deferred" by pushing a
   new task to the task queue instead of writing immediately;
   the task will be continually re-tried until the task succeeds,
   so the write should occur eventually.

Cons:
  Python-only (for now)
  Undocumented (for now)
      see google/appengine/api/capabilities SDK directory
Strategies

  Capabilities API
  Exception handling
  Read-only versions
Exception handling - Python

Python:
http://code.google.com/appengine/docs/python/howto/maintenance.html


from google.appengine.ext import db
import google.appengine.runtime.apiproxy_errors

myModel = db.Model()
try:
  myModel.put()
except apiproxy_errors.CapabilityDisabledError:
  # fail gracefully here or add a new task to the
  # task queue that writes the new entity when
  # the datastore is available
Datastore exception handling - Java

Java:
http://code.google.com/appengine/docs/java/howto/maintenance.html


import com.google.apphosting.api.ApiProxy.CapabilityDisabledException;


try {
  // JDO: pm.makePersistent(entity);
  // JPA: em.persist(entity);
  // low-level: ds.put(entity);
} catch (CapabilityDisabledException e) {
  // fail gracefully here
} finally {
  // ...
}
Memcache exception handling - Java

Java:
http://code.google.com/appengine/docs/java/howto/maintenance.html


As with Python, memcache is unavailable during read-only
mode and exceptions aren't thrown by default.

You can use a StrictErrorHandler if you want an exception
thrown when get and put aren't available.
Memcache exception handling - Java

Java:
http://code.google.com/appengine/docs/java/howto/maintenance.html


import com.google.appengine.api.memcache.MemcacheServiceException;


// ...
ms.setErrorHandler(new StrictErrorHandler());

try {
  ms.put(key, value);
} catch (MemcacheServiceException e) {
  // degrade gracefully
}
Exception handling

Pros:
   Automated -- no changes needed when read-only mode
   begins or ends
   Allows for datastore writes to be "deferred" by pushing a
   new task to the task queue instead of writing immediately;
   the task will be continually re-tried until the task succeeds,
   so the write should occur eventually.

Cons:
  Reactive -- exception is caught only after the read or write
  call is processed, unlike the first solution.
  Complicates code slightly -- the exception needs to be
  caught for every write attempt.
Note on using tasks to defer writes

The task queue allows you defer writes when the datastore is
unavailable -- you can add a new task instead, which the
system will automatically retry in the background until it
succeeds.

If you choose this approach, keep the following in mind:

   The number of tasks that you can add per day is currently
   limited to 1,000,000. If your app receives a lot of write traffic
   (e.g. > 350 QPS), you could exceed this quota unless the
   period of unavailability is short.
   Consider adding a timestamp field to your entities plus extra
   logic so you don't accidentally overwrite a later update when
   the tasks are applied.
Strategies

  Capabilities API
  Exception handling
  Read-only versions
Read-only versions

                       http://fredsa.appspot.com/


                                Version
                                  1.1

             App
            Engine                                     Datastore
  Use
   r       Frontend



                                Version
                                  2.1

                      http://2.1.fredsa.appspot.com/
Read-only versions

Python: app.yaml


application: helloworld
version: readonly
runtime: python
api_version: 1

handlers:
- url: .*
  script: main.py
Read-only versions

Java: appengine-web.xml


<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app>
 <application>helloworld</application>
 <version>readonly</version>

 <!-- ... -->
</appengine-web-app>
Read-only versions

Pros:
   Proactive -- e.g. users see a grayed-out form instead of an
   error on save

Cons:
  Manual -- it's your responsibility to be aware of and switch
  versions before read-only mode starts and after it ends
  Only useful for planned downtimes -- unless other mitigation
  strategies are in place, your app will still go down during
  unplanned downtimes.
  Maintenance
Thanks!



      Jason Cooper
Google Developer Programs
jasonacooper@google.com
       April 6, 2010

More Related Content

What's hot (20)

Eclipse - Single Source;Three Runtimes
Eclipse - Single Source;Three RuntimesEclipse - Single Source;Three Runtimes
Eclipse - Single Source;Three Runtimes
 
Java applets and working principles
Java applets and working principlesJava applets and working principles
Java applets and working principles
 
applet using java
applet using javaapplet using java
applet using java
 
Arjuna - The Case of Web UI Automation with Selenium
Arjuna - The Case of Web UI Automation with SeleniumArjuna - The Case of Web UI Automation with Selenium
Arjuna - The Case of Web UI Automation with Selenium
 
Java applets
Java appletsJava applets
Java applets
 
Java Applet
Java AppletJava Applet
Java Applet
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Java applet
Java appletJava applet
Java applet
 
VivaMP - a tool for OpenMP
VivaMP - a tool for OpenMPVivaMP - a tool for OpenMP
VivaMP - a tool for OpenMP
 
Gradle Again
Gradle AgainGradle Again
Gradle Again
 
Applets
AppletsApplets
Applets
 
Java Applet
Java AppletJava Applet
Java Applet
 
Jsp applet
Jsp appletJsp applet
Jsp applet
 
Applet programming in java
Applet programming in javaApplet programming in java
Applet programming in java
 
Automation With Appium
Automation With AppiumAutomation With Appium
Automation With Appium
 
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
 
Applets in Java
Applets in JavaApplets in Java
Applets in Java
 
Appium troubleshooting
Appium troubleshootingAppium troubleshooting
Appium troubleshooting
 
BCS Selenium Workshop
BCS Selenium WorkshopBCS Selenium Workshop
BCS Selenium Workshop
 
Api desgin
Api desginApi desgin
Api desgin
 

Viewers also liked (18)

Stickiness Of Training V4 3 (2)
Stickiness Of Training V4 3 (2)Stickiness Of Training V4 3 (2)
Stickiness Of Training V4 3 (2)
 
Joy of Conversation
Joy of ConversationJoy of Conversation
Joy of Conversation
 
The Wide World Of Google Developer Technologies (STLIC 02-10)
The Wide World Of Google Developer Technologies (STLIC 02-10)The Wide World Of Google Developer Technologies (STLIC 02-10)
The Wide World Of Google Developer Technologies (STLIC 02-10)
 
Mind the Gap
Mind the GapMind the Gap
Mind the Gap
 
Scale of the MTA: Passenger Count
Scale of the MTA: Passenger CountScale of the MTA: Passenger Count
Scale of the MTA: Passenger Count
 
Lymphatic And Immune Systems by Myrtle Acree
Lymphatic And Immune Systems by Myrtle AcreeLymphatic And Immune Systems by Myrtle Acree
Lymphatic And Immune Systems by Myrtle Acree
 
App Engine/GWT overview (STLIC 02-10)
App Engine/GWT overview (STLIC 02-10)App Engine/GWT overview (STLIC 02-10)
App Engine/GWT overview (STLIC 02-10)
 
Crisp about motivation
Crisp about motivationCrisp about motivation
Crisp about motivation
 
Fqm Brochure
Fqm BrochureFqm Brochure
Fqm Brochure
 
App Engine overview (Android meetup 06-10)
App Engine overview (Android meetup 06-10)App Engine overview (Android meetup 06-10)
App Engine overview (Android meetup 06-10)
 
Motivation
MotivationMotivation
Motivation
 
The making of pop cap's plants vs zombies
The making of pop cap's plants vs zombiesThe making of pop cap's plants vs zombies
The making of pop cap's plants vs zombies
 
Woolpresentation
WoolpresentationWoolpresentation
Woolpresentation
 
F & B control
F & B controlF & B control
F & B control
 
Menu analysis engineering382
Menu analysis engineering382Menu analysis engineering382
Menu analysis engineering382
 
Customer care for h.k
Customer care for h.kCustomer care for h.k
Customer care for h.k
 
当当网:从搜索到发现
当当网:从搜索到发现当当网:从搜索到发现
当当网:从搜索到发现
 
当当网 从搜索到发现
当当网 从搜索到发现当当网 从搜索到发现
当当网 从搜索到发现
 

Similar to Strategies For Maintaining App Engine Availability During Read Only Periods

Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with PythonBrian Lyttle
 
Plugins And Making Your Own
Plugins And Making Your OwnPlugins And Making Your Own
Plugins And Making Your OwnLambert Beekhuis
 
Marathon Testing Tool
Marathon Testing ToolMarathon Testing Tool
Marathon Testing Toolnarayan dudhe
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for JavaLars Vogel
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Mack Hardy
 
Azure Functions @ global azure day 2017
Azure Functions  @ global azure day 2017Azure Functions  @ global azure day 2017
Azure Functions @ global azure day 2017Sean Feldman
 
Mykola Kovsh - Functional API automation with Jmeter
Mykola Kovsh - Functional API automation with JmeterMykola Kovsh - Functional API automation with Jmeter
Mykola Kovsh - Functional API automation with JmeterIevgenii Katsan
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...Paul Jensen
 
Extent Test report v3 with Appium/Selenium
Extent Test report v3 with Appium/SeleniumExtent Test report v3 with Appium/Selenium
Extent Test report v3 with Appium/SeleniumRaman Gowda Hullur
 
B4usolution performance testing
B4usolution performance testingB4usolution performance testing
B4usolution performance testingHoa Le
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP Eric Johnson
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performanceAbhishek Sur
 
How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react MoonTechnolabsPvtLtd
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsMarcelo Pinheiro
 

Similar to Strategies For Maintaining App Engine Availability During Read Only Periods (20)

Introduction to Google App Engine with Python
Introduction to Google App Engine with PythonIntroduction to Google App Engine with Python
Introduction to Google App Engine with Python
 
Plugins And Making Your Own
Plugins And Making Your OwnPlugins And Making Your Own
Plugins And Making Your Own
 
Marathon Testing Tool
Marathon Testing ToolMarathon Testing Tool
Marathon Testing Tool
 
Automation using ibm rft
Automation using ibm rftAutomation using ibm rft
Automation using ibm rft
 
Google App Engine for Java
Google App Engine for JavaGoogle App Engine for Java
Google App Engine for Java
 
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
Strategies and Tips for Building Enterprise Drupal Applications - PNWDS 2013
 
Azure Functions @ global azure day 2017
Azure Functions  @ global azure day 2017Azure Functions  @ global azure day 2017
Azure Functions @ global azure day 2017
 
Mykola Kovsh - Functional API automation with Jmeter
Mykola Kovsh - Functional API automation with JmeterMykola Kovsh - Functional API automation with Jmeter
Mykola Kovsh - Functional API automation with Jmeter
 
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
End to end testing Single Page Apps & APIs with Cucumber.js and Puppeteer (Em...
 
inline function
inline functioninline function
inline function
 
Java 8 Overview
Java 8 OverviewJava 8 Overview
Java 8 Overview
 
Drupal development
Drupal development Drupal development
Drupal development
 
Extent Test report v3 with Appium/Selenium
Extent Test report v3 with Appium/SeleniumExtent Test report v3 with Appium/Selenium
Extent Test report v3 with Appium/Selenium
 
B4usolution performance testing
B4usolution performance testingB4usolution performance testing
B4usolution performance testing
 
Google App Engine for PHP
Google App Engine for PHP Google App Engine for PHP
Google App Engine for PHP
 
Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performance
 
How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react How to increase the ui performance of apps designed using react
How to increase the ui performance of apps designed using react
 
Node.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniquesNode.js Course 2 of 2 - Advanced techniques
Node.js Course 2 of 2 - Advanced techniques
 
Porting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability SystemsPorting Rails Apps to High Availability Systems
Porting Rails Apps to High Availability Systems
 
Lesson 4
Lesson 4Lesson 4
Lesson 4
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Recently uploaded (20)

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Strategies For Maintaining App Engine Availability During Read Only Periods

  • 1. Strategies for maintaining during read-only periods Jason Cooper Google Developer Programs jasonacooper@google.com April 6, 2010
  • 2. Strategies Capabilities API Exception handling Read-only versions
  • 3. Strategies Capabilities API Exception handling Read-only versions
  • 4. Capabilities API - datastore is_enabled method can be used to test whether a certain capability is currently enabled. datastore_writes = CapabilitySet( 'datastore_v3', capabilities=['write']) if not datastore_writes.is_enabled(): # ...render form with form elements disabled # or, if a form is submitted, push a new task # to the task queue else: # ...render form normally
  • 5. Capabilities API - datastore will_remain_enabled_for method can be used to learn whether a component will be disabled within a certain number of seconds datastore_writes = CapabilitySet( 'datastore_v3', capabilities=['write']) if datastore_writes.will_remain_enabled_for(60): # ...render form normally else: # ...render form with form elements disabled
  • 6. Capabilities API - memcache The capabilities API can be used with other services including memcache... memcache_set = CapabilitySet( 'memcache', methods=['set']) if memcache_set.is_enabled(): # ...fetch from cache else: # ...bypass cache
  • 7. Capabilities API - images ... as well as the Images service. images_capability = CapabilitySet('images') if images_capability.is_enabled(): my_image = images.resize(my_image, 64, 64)
  • 8. Capabilities API Pros: Automated -- no changes needed when read-only mode begins or ends Allows for datastore writes to be "deferred" by pushing a new task to the task queue instead of writing immediately; the task will be continually re-tried until the task succeeds, so the write should occur eventually. Cons: Python-only (for now) Undocumented (for now) see google/appengine/api/capabilities SDK directory
  • 9. Strategies Capabilities API Exception handling Read-only versions
  • 10. Exception handling - Python Python: http://code.google.com/appengine/docs/python/howto/maintenance.html from google.appengine.ext import db import google.appengine.runtime.apiproxy_errors myModel = db.Model() try: myModel.put() except apiproxy_errors.CapabilityDisabledError: # fail gracefully here or add a new task to the # task queue that writes the new entity when # the datastore is available
  • 11. Datastore exception handling - Java Java: http://code.google.com/appengine/docs/java/howto/maintenance.html import com.google.apphosting.api.ApiProxy.CapabilityDisabledException; try { // JDO: pm.makePersistent(entity); // JPA: em.persist(entity); // low-level: ds.put(entity); } catch (CapabilityDisabledException e) { // fail gracefully here } finally { // ... }
  • 12. Memcache exception handling - Java Java: http://code.google.com/appengine/docs/java/howto/maintenance.html As with Python, memcache is unavailable during read-only mode and exceptions aren't thrown by default. You can use a StrictErrorHandler if you want an exception thrown when get and put aren't available.
  • 13. Memcache exception handling - Java Java: http://code.google.com/appengine/docs/java/howto/maintenance.html import com.google.appengine.api.memcache.MemcacheServiceException; // ... ms.setErrorHandler(new StrictErrorHandler()); try { ms.put(key, value); } catch (MemcacheServiceException e) { // degrade gracefully }
  • 14. Exception handling Pros: Automated -- no changes needed when read-only mode begins or ends Allows for datastore writes to be "deferred" by pushing a new task to the task queue instead of writing immediately; the task will be continually re-tried until the task succeeds, so the write should occur eventually. Cons: Reactive -- exception is caught only after the read or write call is processed, unlike the first solution. Complicates code slightly -- the exception needs to be caught for every write attempt.
  • 15. Note on using tasks to defer writes The task queue allows you defer writes when the datastore is unavailable -- you can add a new task instead, which the system will automatically retry in the background until it succeeds. If you choose this approach, keep the following in mind: The number of tasks that you can add per day is currently limited to 1,000,000. If your app receives a lot of write traffic (e.g. > 350 QPS), you could exceed this quota unless the period of unavailability is short. Consider adding a timestamp field to your entities plus extra logic so you don't accidentally overwrite a later update when the tasks are applied.
  • 16. Strategies Capabilities API Exception handling Read-only versions
  • 17. Read-only versions http://fredsa.appspot.com/ Version 1.1 App Engine Datastore Use r Frontend Version 2.1 http://2.1.fredsa.appspot.com/
  • 18. Read-only versions Python: app.yaml application: helloworld version: readonly runtime: python api_version: 1 handlers: - url: .* script: main.py
  • 19. Read-only versions Java: appengine-web.xml <?xml version="1.0" encoding="utf-8"?> <appengine-web-app> <application>helloworld</application> <version>readonly</version> <!-- ... --> </appengine-web-app>
  • 20. Read-only versions Pros: Proactive -- e.g. users see a grayed-out form instead of an error on save Cons: Manual -- it's your responsibility to be aware of and switch versions before read-only mode starts and after it ends Only useful for planned downtimes -- unless other mitigation strategies are in place, your app will still go down during unplanned downtimes. Maintenance
  • 21. Thanks! Jason Cooper Google Developer Programs jasonacooper@google.com April 6, 2010