This question already has answers here:
Long running program in Google App Engine
(2 answers)
Closed 6 years ago.
I am trying to change the scaling of my google app engine task queue from automatic (requires response in 10 min) to manual (extends response to 24 hr). My app.yaml file contains
application: my-application
version: alpha-1
runtime: python27
api_version: 1
threadsafe: true
I altered it to
application: my-application
version: alpha-1
runtime: python27
api_version: 1
threadsafe: true
instance_class: B1
manual_scaling:
instances: 5
I cannot deploy this to test and am trying to test locally. Unfortunately the dev_appserver.py does not timeout after 10 minutes when I use the first app.yaml configuration (it should timeout). How should I test this? Or how can I scale properly?
The instance scaling can not be tested locally - the SDK doesn't have support for the actual GAE scaling logic, you need to test it on the actual GAE infrastructure.
There are also some task queue features which aren't supported by the devserver, see Using Push Queues in the Development Server.
In order to not affect your production environment you can create a staging/development environment, for example by creating a different project & app where to deploy the same app code (with just the app ID updated). Just as the 2nd suggestion in Naming environments, for example.
Related
I am trying to deploy a python app on google app engine.
I was able to preview the web successfully on cloud shell editor but when I deploy it, I obtain Error Response:[13] An internal error occurred.
This is my app.yaml content
runtime: python
env: flex
entrypoint: gunicorn -b:8078 main:app
runtime_config:
python_version: 3.7
manual_scaling:
instances: 2
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
It doesn't also show logs that could indicate what is wrong with the application.
Thank you
There have been multiple iterations since the original question was asked. OP has switched from standard to flex and python27 to python37.
I think I've previously come across someone who encountered the error because they had exceeded the 1000 file limit. Since you're using python37, I assume you have a virtual environment in your project folder which you first used in running the App on your local machine. You need to have a skip_files section in your app.yaml or a .git_ignore or .gcloudignore folder and include your virtual env in it so that gcloud doesn't try to deploy it
You can also check out these other links to see if they can help you resolve your issue
https://github.com/GoogleCloudPlatform/nodejs-getting-started/issues/172
https://groups.google.com/g/google-appengine/c/M4acI1YElVs
If none of the above, I'm not sure one can figure out the solution without looking at the code. If your code is public, you can provide a link to the github.
I try to deploy application on the GC AppEngine. There are no errors during deploy process but application doesn't work (Just show loading page).
The only one strange raw in logs
OpenBLAS WARNING - could not determine the L2 cache size on this system
By the way - it works well on my local machine.
This is python web app based on Dash framework
My app.yaml:
runtime: python37
service: service-name
instance_class: F2
entrypoint: gunicorn -b :$PORT main:app.server
Requirements.txt:
Flask==1.0.2
dash==0.34.0
dash-html-components==0.13.4
dash-core-components==0.41.0
dash-table==3.1.11
gunicorn==19.9.0
google-cloud-pubsub==0.37.2
requests==2.21.0
pandas==0.23.4
I just had your same problem with pandas and Dash and found your question (hoping it would give me some light). After being stuck for several hours, I found the answer, and came back to share :-)
If the only error that you're seeing is the OpenBLAS warning, most likely the app is working well. After debugging this problem for several hours, I found that as Dash and Pandas consume a lot of memory, the F2 instance is not able to handle the web app properly and fails due to lack of RAM memory. Please try changing in your YAML/JSON configuration file your instance to the highest possible automatic unit with more RAM memory, and then it will probably work:
instance_class: F4_HIGHMEM
EDIT: Google App Engine now supports more instance types. Check the docs of instance types: standard instances
In addition, please keep in mind that the first time you run this web app, it will take considerably more time to execute. If you check the logs you'll have several prompts like the one below. Just wait a little bit more
This request caused a new process to be started for your application,
and thus caused your application code to be loaded for the first time.
This request may thus take longer and use more CPU than a typical
request for your application.
I personally solved it by adding a timeout to gunicorn, as the default timeout is only 30 sec
entrypoint: gunicorn -b :$PORT main:app.server --timeout 120
I found this solution as I tried the following:
switched from a F1 to a F4_1G instance: still had the same warning
switched from App Engine Standard to App Engine Flexible environment (which I highly DO NOT recommend, as app engine flexible instances not properly shut down (deleted) can cost you a lot of money: please see here for reference Pricing of Google App Engine Flexible env, a $500 lesson), with 16gb of ram and 4 CPU -> eventually got a different warning "[CRITICAL] WORKER TIMEOUT" which pointed me to this post: Gunicorn worker timeout error , which is where I found this solution.
Now my app works well, even with a F1 instance 😊
Don't forget to change the number of workers !
there is a default number of workers in AppEngine instances, so your application is multiplied by this number on the same instance
https://cloud.google.com/appengine/docs/standard/python3/runtime
I experienced the same error log using a AWS Lambda function. My function was processing a decent number of records so I needed to increase two settings in my lambda function configuration:
Increase the size of Memory.
Increase the Timeout in seconds.
Hope that helps.
GAE will not update the deployed code through gcloud. For instance, I created this method:
main.py
#app.route('/test',methods=['GET'])
def test():
print 'print test'
return 'test'
app.yaml
runtime: python27
api_version: 1
threadsafe: true
runtime_config:
python_version: 2
instance_class: F2
handlers:
- url: /.*
script: main.app
libraries:
- name: flask
version: 0.12
deploy the app:
gcloud app deploy app.yaml queue.yaml --project $PROJECT
Then I get a 404 when visiting /test.
I tracked down the log error:
This request caused a new process to be started for your application,
and thus caused your application code to be loaded for the first time.
This request may thus take longer and use more CPU than a typical
request for your application.
I looked at this article, which noted that I shouldn't be getting the error every time I visit the URL. I do.
I added --verbosity=info to my deployment and everything looked great except:
INFO: Could not find any remote repositories associated with
[path-to-app]. Cloud diagnostic tools may not be able to display the
correct source code for this deployment.
The code appeared updated in the dedugger, which is strange. The latest version is 100% deployed in the App Engine Dashboard.
This is really confusing because on deployment, there isn't a repo, but the code appears in the debugger but the end point won't function because there aren't enough resources.
There seems to be a lot happening here and not sure what the issue is.
Update
Some posts recommend a warmup. I followed the guidelines here and still, no dice. I'm getting a 404 when visiting /test and /_ah/warmup.
This issue could be caused by multiple different reasons, there could be a lot of factors in play, in most cases the error 404 shows when the app.yaml failed to allocate the flask library as the ‘flask’ libraries by default not bundled in the libraries the Google App Engine includes. So it needs to be added manually. One of the way to figure out if the issue is a deployment issue is to go to this link (https://console.cloud.google.com/logs/viewer) and check if there is any logs recorded or not. If there is no log appearing in the viewer it could very well mean that the problem occurred even before it actually knocks the server.
Additionally, I would highly recommend you to go through the following link (https://codelabs.developers.google.com/codelabs/cloud-vision-app-engine/index.html?index=..%2F..%2Findex#0) to deploy flask on the Google Cloud App Engine environment.
Also, I would like to make a suggestion to try a workaround using the ‘webapp2’ library if possible. The link is the following (http://webapp2.readthedocs.io/en/latest/index.html)
I have also noticed there is an attempt to run the queue.yaml. It is important to configure the file accordingly as well.
To summarize, I would really appreciate if you could try all the different possibilities to deploy the flask library and observe the results. Thank you so much.
I'm deploying Python 2.7 app to Google App Engine.
The app works on local dev-server but when I try to deploy it the deployment complete successfully but any HTTP request to the app result in error 500, no matter what url I'm using.
In the App Engine logs I see the logging of the 500 response but no clue to what the problem is.
I've also try to deploy the last code that did worked and the result is the same so it doesn't looks like the code changes are the reason.
Any idea how to diagnose this problem?
You can see the code of the app.
The problem ends up being tiny mistake that I've changed the api_version from 1 to 2.
The app.yaml needs to start like this:
runtime: python27
api_version: 1
threadsafe: true
In my code it was like this which causes the error:
runtime: python27
api_version: 2
threadsafe: true
dear all
I'm trying to create a App Engine Module for hosting my api server developed with Google Cloud Endpoints. The endpoint I developed runs well in local dev environment but it responds notFound error after I deployed to remote and test it. I was guessing this might be caused by the fact that endpoints are run in a non-default module. Not sure though. Here is my module definition file (api-server.yaml):
application: myapp
module: api-server
version: dev
runtime: python27
instance_class: F2
api_version: 1
threadsafe: true
automatic_scaling:
max_idle_instances: 5
handlers:
- url: /_ah/spi/.*
script: api_dispatch.application
libraries:
- name: endpoints
version: 1.0
I plan to host endpoints with module cause my api server actually share a lot of code with my default module, which is a normal web app. Please let me know if it's possible. And sample code is very welcome.
Thanks a lot!
Yes, it's supported. I don't know why the problem happened before. But it starts working now.