API to inspect task queue length from app engine flex? - google-app-engine

Is there an API to inspect a task queue's backlog from within app engine flex? App Engine Standard has the com.google.appengine.api.taskqueue.Queue.fetchStatistics API but that seems to fail in App Engine Flex with error:
com.google.apphosting.api.ApiProxy$CallNotFoundException: Can't make API call taskqueue.FetchQueueStats in a thread that is neither the original request thread nor a thread created by ThreadManager

The Task Queue API was deprecated and is currently only available for App Engine Standard 1st generation runtime.
For App Engine Flex, Standard 2nd gen and other applications, you should use the Cloud Tasks API

Related

Google Cloud Scheduler: Cost of required App Engine instance?

I would like to use google cloud scheduler to invoke a Google Cloud Run function on a routine schedule.
On google cloud scheduler documentation it states:
Cloud Scheduler is currently available in all App Engine supported
regions. To use Cloud Scheduler your Cloud project must contain an App
Engine app that is located in one of the supported regions. If your
project does not have an App Engine app, you must create one.
I have never used app engine as a deployment target and don't really want to. This one cloud run function meets my needs.
Beyond the stated costs of cloud scheduler pricing will I also incur google app engine costs for a service I don't otherwise use?
You can definitely create an scheduler job that runs your Cloud function on a timed interval.
However, App Engine needs to be at least enabled since Cloud scheduler requires it (see point 4 of the before you begin section):
Cloud Scheduler uses App Engine cron jobs, so Cloud Scheduler requires App Engine enablement and configuration.
You would only need to set up the region of App Engine, not deploy an App Engine app which incurs costs.

Ktor: Can't call App Engine Standard APIs

I'm trying to run a simple Ktor server on Google App Engine Standard. If I run their sample code on github it works well, but fails as soon as I call any App Engine API with the following message:
Can't make API call memcache.Set in a thread that is neither the original request thread nor a thread created by ThreadManager
All App Engine APIs trigger similar error messages. Is this related to how Ktor handles requests, and is there a way to make them work?
I think that the Google Cloud java library doesn't have this threading limitation, but unfortunately I can't use it. I need to access the App Engine Memcache service, which is only available through the App Engine APIs.

Google App Engine Standard to App Engine Flex

I am new to Google App Engine services. I have a Java Maven project with one module running on app engine flex and other on app engine standard. I am using JWT authentication for App Engine Flex APIs. I want to make a post request from App Engine Standard to App Engine Flex. What should be the best way to authenticate the service?
Also, I have a cron service hitting a particular URL I am using for some backend stuff. How can I authenticate that the request has came from Cron service only?
For checking if the job is coming from the Cron service (assuming you are using the requests module):
is_cron = request.headers.get('X-Appengine-Cron', False)
if not is_cron:
return 'Bad Request', 400
If you are using another module, you just have to check the header from the cron job to make sure it is 'X-Appengine-Cron'
Source: https://cloud.google.com/appengine/docs/standard/python/config/cronref#cron_requests

Firebase Admin SDK in App Engine with Java 8

Previously the Firebase Admin SDK would not run on App Engine with automatic scaling. Probably it will create some threads and the Thread class or something like that is not whitelisted.
Now that Google has given us support for Java 8 on App Engine (and removed the whitelist), would this problem be gone? Will the Firebase Admin SDK work on App Engine with automatic scaling?
Firebase Admin SDK still won't work in the AppEngine Java 8 runtime without manual scaling, for several reasons:
The threads support available in the Java 8 runtime comes with some limitations. For instance, any thread not created using the AppEngine's ThreadManager interface cannot call AppEngine APIs. This means these threads cannot make outgoing network calls.
The database client code in the SDK spawns long-running threads. The only way to do that in the AppEngine environment is via background thread support. The SDK specifically looks for this feature when deployed in AppEngine. I've tried to run the SDK with this requirement relaxed, but it doesn't work. It seems request-scoped threads cannot outlive the request even in the new Java 8 runtime.
However, you should be able to use the FirebaseAuth interface (used for custom token minting, ID token verification and user management) in the AppEngine, without manual scaling. This part of the SDK supports running on request-scoped threads.

Is Clojure concurrency support still disabled on App Engine?

In a recent blog post, Adrian Mouat said that App Engine doesn't support Clojure concurrency, such as agents. However, GAE Java supports threads as of the App Engine 1.6.4 release.
Is the Clojure concurrency model fully supported on App Engine?
I know one would have to use their Thread Manager API for thread creation. For appengine front ends each created thread would still be tied to the current request. On an appengine back end you would be able to make background thread would persist after the request was handled. I do not know about other libraries,but appengine-magic has not been updated since Google App Engine SDK 1.6.3.1 release with little activity on the forks,but updating it to the latest appengine api was a summer of code project proposal for 2012.

Resources