CAW
CAW

Reputation: 389

Programatically listing and sending requests to dynamic App Engine instances

I want to send a particular HTTP request (or otherwise communicate a message) to every (dynamic/autoscaled) instance which is currently running for a particular App Engine application.

My goal is to trigger each instance to discard some locally cached data (because I have just modified the underlying data and want them to reload it).

One possible solution is to store a value in Memcache, and have instances check this each time they handle a request to see if they should flush their cache. But this adds latency to every request.

Another possible solution would be to somehow stop all running instances. No fixed overhead, but some impact while instances are restarted.

An even less desirable solution would be to redeploy the application code in order to cause all instances to be stopped. This now adds additional delay on my end as a deployment takes some time.

Upvotes: 4

Views: 150

Answers (1)

E. Anderson
E. Anderson

Reputation: 3493

You could use the management API to list instances for a given version, but I'd suggest that you'd probably want to use something like the PubSub API to create a subscription on each of your App Engine instances. Since each instance has its own subscription, any messages sent to the monitored queue will be received by all instances.

You can create the subscription at startup (the /_ah/start endpoint may be useful), and then delete it at shutdown (using the /_ah/stop endpoint).

Upvotes: 0

Related Questions