0

I updated AppEngine on my Mac (haven't done so in a while). dev_appserver used to start almost instantly (I have a very small website), but it now takes 30 seconds. After the first start, it is fast again if I turn it off then on. But if I switch to another project and back to the first one it is really slow.

I ran it with --log_level=debug but it doesn't print anything while it is hanging. Any idea what's going on? What was a joy to work with became a nightmare. Let me know if you need any additional info (I have a python webapp, mainly serving static files)

Thomas
  • 8,306
  • 8
  • 53
  • 92

1 Answers1

2

When dev_appserver is first run, a new instance is deployed, this takes a bit of time due to all the setup and configurations it requires. This time is known as cold-boot.

Now, when you "switch to another project and back to the first one", this process is repeated, thus another cold-boot.

Yet, 30 seconds seams a bit too much. If you have updated your application recently, you could check your imported librarys in case one of them is taken too long to load. You can also read this blog post on Best practices for App Engine startup time, which states:

Most of the time, a standard application importing a few modules should have a negligible impact on performance. However, when third-party libraries get big enough, we start to see them do weird things with import semantics, which can mess up your boot time significantly.

If you need to get better performance, you can try using warmup requests:

Use warmup requests to avoid request and response latency during the time when your app's code is being loaded to a newly created instance.

UPDATE: There seems to be an issue with dev_appserver which is affecting it's functionality on version 219.0.1. As mentioned on the Issue Tracker:117145272:

It turns out a recent change in dev_appserver (released with Cloud SDK 219) makes the start time slow, but only when dev_appserver is used with pydevd in debug mode

It's recommended to upgrade the SDK to version 220 and install grpcio with pip install grpcio

Also, as another workaround could be to downgrade the SDK version to 228 using this command:

gcloud components update --version 218.0.0

Keep in mind that downgrading is not recommended since it could open the door for security vulnerabilities. Use it with caution.

Nahuel Varela
  • 1,022
  • 7
  • 17
  • Thanks but how long does it take on your computer for a baseline? I do not import any libraries (I have almost the minimum code to have a handler call jinja templates) and do not use the datastore. Also it used to start in ~1 second in the previous version of GAE I had – Thomas Jan 07 '19 at 13:48
  • When you say previous version of GAE, you mean the GAE runtime? By the Running Locally documentation[1] it states that "The updated dev_appserver does not support development of Python 3 apps on Windows". Yet, in other platform it's still limited. Saying so, I had been running some tests on a simple hello_world example and it takes a longer time to run on Python 3 than on Python 2 because it has to set up the enviroment for the new runtime. [1] [https://cloud.google.com/appengine/docs/standard/python3/testing-and-deploying-your-app#running_the_local_development_server] – Nahuel Varela Jan 07 '19 at 15:54
  • I am using Python 2 on a mac. It takes 1 min 17 seconds to run a hello world :( What are your running times? (by "run" I mean be able to access the webpage on localhost) – Thomas Jan 07 '19 at 16:39
  • Check the answer, I have updated it with new information. – Nahuel Varela Jan 08 '19 at 17:00
  • Thanks, I ran both commands and now back to a ~1 second startup time, yeah! (I didn't try to run in between the 2 commands, so not sure which command was most useful) – Thomas Jan 11 '19 at 15:35