title: Google App Engine: Backend vs Frontend Instances
body: <p>GAE allows different restrictions depending on whether or not the code is running on a frontend instance or a backend instance. For example, it permits you to kick off long-running background threads on a backend, whereas this would timeout and throw a runtime exception if the code was running on a frontend instance.</p>
  
  <p>I am very confused about how to engineer an app so that you know that only certain code executes on a backend instance (and not a frontend instance).</p>
  
  <p>My <em>understanding</em> of how GAE works is that you upload your app (a WAR file) and that it scales (creates clustered instances of) that app as needed or until it exceeds a ceiling that you define (for budgeting, etc.).</p>
  
  <p>But unless I'm mistaken, it doesn't allow you to upload different modules (multiple WARs) for the same app, and thus have 1 WAR to be ran on frontend instance, and another WAR to be ran on backend instance (to guarantee that you only run background threads on backends!).</p>
  
  <p>So my question is: how do you develop, package and deploy GAE apps so that the right code always executes on the right instance? Tangential to this is the question of how to specify different long-running jobs be ran on specific backends. For instance if you have a background thread that should be cronned to run nightly at midnight, but you have 10 backends, wouldn't this mean you would have the same background thread kicking off on all ten instances every night? Obviously, there are situations where you only want 1 backend to run the job, and other instances when each backend should behave the same.</p>
  
  <p>Again, it all comes back to: <strong>how do you make sure the right code deploys and executes on the correct instance?</strong> Thanks in advance!</p>