Can someone help me understand what "/_ah/background" is in terms of google app engine (Python). I have a resident backend running, and I am seeing requests being made to that endpoint. They appear to be generated by something outside my code. They also appear to be being handled by my /_ah/start handler.
Thanks for any help you can provide.
I believe /_ah/background requests aren't actually HTTP requests, they're background threads. App Engine uses /_ah/background as a placeholder wherever it needs to group something by request, e.g. log messages. This matches what I see in my backends that use background threads.
(I could swear I read this in the docs somewhere recently, but I haven't found where yet.)
Any URL that starts with "/_ah/" is a reserved AppEngine URL. These are used for internal AppEngine tasks, you really shouldn't need to worry about them.
What does _ah mean in Google App Engine?
https://developers.google.com/appengine/docs/python/config/appconfig?hl=it-IT#Reserved_URLs
Related
I am currently working with MS Azure. There I have a worker role and a web role. In worker role I start an infinite loop to process some data continously. The web role is performing the interaction with the client. There I use a MVC Framework, which on server side is written in C# and on client side in Javascript.
Now I'm interested in GAE engine. I read a lot about the app engine. I want to build an application in Python. But I don't really understand the architecture. Is there a counterpart in the project structure like the worker and web role in Azure?
The closest thing to what you want is what Google App Engine calls modules. Modules are (roughly) pools of instances that can be set up with different runtimes and performance characteristics:
https://cloud.google.com/appengine/docs/python/modules/
I'm not an expert with Azure, but the big difference I see between GAE's approach and Azure's is that, unlike in Azure, "back-end modules" (not an official term) in GAE are still basically web services at heart. Everything in the module is still basically written as HTTP handlers. So, the main ways you control that module are via HTTP: using push queues to hit HTTP endpoints, using cron to trigger HTTP endpoints that read from pull queues/the datastore/Google Cloud Storage, and/or making HTTP requests from your "front-end module" directly to your "back-end module".
Note that Google App Engine historically provided the concept of "backends" and "backend instances" that you could use for much the same purpose as modules for longer-running background processes. However, the module system is more flexible, and it is now recommended.
yes there is. look at backend and frontend instances. your question is too broad to go into more detail. in general the backend type of instance is used for long running tasks but you could also do everyrhing in the frontend instance.
I am currently learning Google App Engine. I want to develop a cloud app that provides synchronization using Google Cloud Endpoints. Frankly, I am impressed with Picturesque App (https://github.com/GoogleCloudPlatform/appengine-picturesque-python) that was demonstrated during Google I/O 2013. This app shows the feature that I really need.
To try out the application, I cloned it from GitHub and ran it through Google App Engine Launcher then when I tested it, there was no synchronization happened there. All pictures were saved locally. I already created and configured "settings.py" file with my Client ID as well as a "custom-js/picturesque-config.js" however I could not see Client-Server interaction in the app. Everything seemed to work locally.
I also got a problem with the google authentication. There was an error written there "Error: origin_mismatch" with all the requests details. I have been trying to fix this problem for a week but still, it could not work as expected. Could anyone shed some light on this issue? Herewith, I list the information on the requests details.
from_login=1
scope=https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/plus.login
https://www.googleapis.com/auth/plus.moments.write
https://www.googleapis.com/auth/plus.me
https://www.googleapis.com/auth/plus.profile.agerange.read
https://www.googleapis.com/auth/plus.profile.language.read
https://www.googleapis.com/auth/plus.circles.members.read
redirect_uri=postmessage
state=519184294|0.3676346342
origin=http://localhost:22080
as=-5faa3d6126cb2118
display=page
request_visible_actions=http://schemas.google.com/AddActivity
hl=en-GB
cookie_policy_enforce=false
response_type=code token id_token gsession
access_type=online
cookie_policy=single_host_origin
proxy=oauth2relay412480175
include_granted_scopes=true
client_id=604391723960.apps.googleusercontent.com
authuser=0
Your help would be greatly appreciated.
Thank you
This is an OAuth problem and the synchronization can't work if you can't sign in.
As the error says, you have an "Origin Mismatch".
What are the "Redirect URIs" for your application ID in the APIs console? The URI you are using -- e.g. http://localhost:8080 -- must match exactly, port, HTTP scheme and trailing slash.
You should try to fix this error by checking out existing answers on StackOverflow: https://stackoverflow.com/search?q=error%3A+origin_mIsmatch
I'm trying to run some code on Appengine using dynamic backends (python), but I find Appengine dynamic backends documentation to be inadequate. Does anyone have any sample code regarding how this can be done?
I have already configured my backends.yaml like so
backends:
- name: fileupload-backend
options: dynamic
start: backend_handler.py
And I understand that dynamic backends run when Appengine sends a start request to /_ah/start, then run when they receive a request from the application and stops when they receive no further requests from the application. But how do I write code in my backends_handler.py in order to prompt appengine to do this?
You've slightly misunderstood the point of the start option. This is the script that is automatically invoked when AppEngine hits the /_ah/start - it's not responsible for calling it, it's responsible for responding to that call. Most of the time you won't need this: it's really for when your backend needs specific things to be set up on startup. It's perfectly OK in fact to not handle the /_ah/start call at all, and let it respond with a 404 - that's enough to trigger the backend to start up.
If you're confused about how to actually run code on the backend, your best bet is to configure a task queue to run on that backend with the target parameter, and then get your frontend code to trigger a task on that queue.
For a nice example on how to use Google App Engine Backends, you can take a look at Google App Engine Tutorial - Code Lab Exercise 8: Queues and Backends.
This tutorial presents an example on how to user Task Queues and Backends.
Hope this helps!
I am thinking about implementing resource throttling in my application in google app engine.
My idea is checking whether I am running out of resources (for example, bandwidth) and disabling part of the website, using the final part of the available daily traffic to inform the user that the site is running in a "resources saving" mode.
I read the GAE documentation, but I just found that if I run out of traffic, it directly returns HTTP 403.
Is there a way to make my python application aware of the used resources and to try not to be so rude with my users?
Unfortunately this is not possible, there is no API that you can use for this.
Looking at the App Engine roadmap there is no such feature coming along any time soon.
The only thing i can recommend is you sign up for billing and recieve the 50$ free quota, it's here till 31 october. You can enable billing and disable it and keep the free 50$!
Hope this helped.
Does anyone know, if I can fetch an internal AppEngine url from within my AppEngine app?
The official URL Fetch Python API doesn´t cover that.
http://code.google.com/intl/et-EE/appengine/docs/python/urlfetch/overview.html
I tried different possibilities, but as it seems nothing works. Does anyone did that before?
urllib2.urlopen('http://127.0.0.1:8080/start_something/')
or
urllib2.urlopen('/start_something/')
...
Thanks in advance.
This will not work at all with the development server. It is single-threaded, so trying to load one of your app's URL's while inside one of its request handlers will hang until the URLFetch times out.
It should work with no problems at all in production.
To get around the development server limitation, you should run two instances on different ports.