title: Availability of resident backend instances in Google App Engine
body: <p>Our app extensively relies on <a href="https://developers.google.com/appengine/docs/java/backends/overview" rel="nofollow noreferrer">backend instances</a>. There is some logic that has to run every few seconds. The execution of this code cannot only be driven by requests arriving on the frontend because it needs to run regardless.</p>
  <p>We only considered using <a href="https://developers.google.com/appengine/docs/java/taskqueue/overview-push" rel="nofollow noreferrer">task queues</a> to solve this. But as far as we know, task queues only guarantee that tasks will be executed within 24 hours. I have not found a reference to back this up though.</p>
  <p>Our app uses a fixed number of <a href="https://developers.google.com/appengine/docs/java/config/backends#Backends_Definitions" rel="nofollow noreferrer">resident</a> <a href="https://developers.google.com/appengine/docs/java/config/backends#Instance_Classes" rel="nofollow noreferrer">B1</a> backend instances. We assume that each instance stays alive 24/7 after the backend version is deployed and started.</p>
  <ul>
  <li>Is this a valid assumption? If not, can our application be notified every time a backend instance will be shutdown?</li>
  <li>What is the SLA on the availability of a backend instance?</li>
  <li>Are backend instances restarted automatically after they are terminated? E.g. is an instance automatically restarted after it runs out of memory?</li>
  <li>How quickly will instances be brought up again if they every are terminated?</li>
  <li>We create a fixed size thread pool on each backend instance. Is there a maximum size for thread pools that we can have on a backend instance?</li>
  <li>Are there any other conditions under which a backend instance might die?</li>
  </ul>
  <p>Thanks!</p>
  <p><strong>UPDATES</strong></p>
  <p>Turns out a couple questions can be answered by reading <a href="https://developers.google.com/appengine/docs/java/backends/overview#Shutdown" rel="nofollow noreferrer">the</a> <a href="https://developers.google.com/appengine/docs/java/backends/overview#Backend_Uptime" rel="nofollow noreferrer">docs</a>.</p>
  <blockquote>
  <p>App Engine attempts to keep backends running indefinitely. However, at this time there is no guaranteed uptime for backends.</p>
  </blockquote>
  <ul>
  <li><strong>So what is the SLA for uptime? I am looking for a statement like: &quot;The guaranteed uptime for backends is 99.99%&quot;</strong></li>
  </ul>
  <blockquote>
  <p>The App Engine team will provide more guidance on expected backend uptime as statistics become available.</p>
  </blockquote>
  <ul>
  <li><strong>When will this statistics be available?</strong></li>
  </ul>
  <blockquote>
  <p>It's also important to recognize that the shutdown hook is not always able to run before a backend terminates. In rare cases, an outage can occur that prevents App Engine from providing 30 seconds of shutdown time.</p>
  <p>When App Engine needs to turn down a backend instance, existing requests are given 30 seconds to complete, and new requests immediately return 404.</p>
  <p>The following code sample demonstrates a basic shutdown hook:</p>
  </blockquote>
  <pre><code>LifecycleManager.getInstance().setShutdownHook(new ShutdownHook() {
    public void shutdown() {
      LifecycleManager.getInstance().interruptAllRequests();
    }
  });
  </code></pre>