Google App Engine Flexible Environment at 0 instances










2















Over the past week I've been seeing the number of instances on my GAE Flexible Environment fall to 0, with no new instance spinning up. My understanding of the Flexible environment is that this shouldn't be possible... (https://cloud.google.com/appengine/docs/the-appengine-environments)



I was wondering if anyone else has been seeing these issues, or if they've solved the problem on their end before. My one hypothesis is that this might be an issue with my health monitoring endpoints, but haven't seen anything that jumps out as a problem when I review the code.



This hasn't been a problem for me until last week, and now it seems like I have to redeploy my environment (with no changes) every couple of days just to "reset" the instances. It's worth noting that I have two services under this same App Engine project, both running flexible versions. But I only seem to have this issue with one of the services (what I call the worker service).



Screenshot from App Engine UI:



Screenshot from App Engine UI



Screenshot from Logs UI that shows the SIGTERM being sent:



Screenshot from Logs UI that shows the SIGTERM being sent



PS - Could this have anything to do with the recent Google Compute issues that have been coming up... https://news.ycombinator.com/item?id=18436187



Edit: Adding the yaml file for "worker" service. Note that I'm using Honcho to add an endpoint to monitor health of the worker service via Flask. I added those code examples as well.



yaml File



service: worker
runtime: python
threadsafe: yes
env: flex
entrypoint: honcho start -f /app/procfile worker monitor

runtime_config:
python_version: 3

resources:
cpu: 1
memory_gb: 4
disk_size_gb: 10

automatic_scaling:
min_num_instances: 1
max_num_instances: 20
cool_down_period_sec: 120
cpu_utilization:
target_utilization: 0.7


Procfile for Honcho



default: gunicorn -b :$PORT main:app
worker: python tasks.py
monitor: python monitor.py /tmp/psq.pid


monitor.py



import os
import sys

from flask import Flask


# The app checks this file for the PID of the process to monitor.
PID_FILE = None


# Create app to handle health checks and monitor the queue worker. This will
# run alongside the worker, see procfile.
monitor_app = Flask(__name__)


@monitor_app.route('/_ah/health')
def health():
"""
The health check reads the PID file created by tasks.py main and checks the proc
filesystem to see if the worker is running.
"""
if not os.path.exists(PID_FILE):
return 'Worker pid not found', 503

with open(PID_FILE, 'r') as pidfile:
pid = pidfile.read()

if not os.path.exists('/proc/'.format(pid)):
return 'Worker not running', 503

return 'healthy', 200


@monitor_app.route('/')
def index():
return health()


if __name__ == '__main__':
PID_FILE = sys.argv[1]
monitor_app.run('0.0.0.0', 8080)









share|improve this question
























  • Can you show the app.yaml scaling configuration for that service? What do you see if you're trying to access the service?

    – Dan Cornilescu
    Nov 14 '18 at 12:15











  • @DanCornilescu, just added more details. When I try to access the service with 0 instances, I see something along the lines of "The service is down, please try again in 30 seconds". This seems like a default page that GAE shows if a service is down... once I redeploy I get the 'healthy' result based on my Flask endpoint.

    – vrk7bp
    Nov 14 '18 at 23:34











  • Yep, sounds like a problem with the GAE instance management, there really should have been at least one instance running as you have auto scaling with min_num_instances: 1. True, during unexpected outages or during the periodic (weekly I believe) instance restarts I'm not certain if the requirement is still met, but even if it's not - it should only be for a brief, transitory moment, there should be no extended periods with no instances running.

    – Dan Cornilescu
    Nov 15 '18 at 3:34











  • Thanks @DanCornilescu... do you have any suggestions on the best way to reach out to the Google Cloud folks about this?

    – vrk7bp
    Nov 19 '18 at 16:23











  • Check the open issue list at issuetracker.google.com/… and maybe open a new one if nothing appears to be matching, mentioning this SO post.

    – Dan Cornilescu
    Nov 19 '18 at 18:02















2















Over the past week I've been seeing the number of instances on my GAE Flexible Environment fall to 0, with no new instance spinning up. My understanding of the Flexible environment is that this shouldn't be possible... (https://cloud.google.com/appengine/docs/the-appengine-environments)



I was wondering if anyone else has been seeing these issues, or if they've solved the problem on their end before. My one hypothesis is that this might be an issue with my health monitoring endpoints, but haven't seen anything that jumps out as a problem when I review the code.



This hasn't been a problem for me until last week, and now it seems like I have to redeploy my environment (with no changes) every couple of days just to "reset" the instances. It's worth noting that I have two services under this same App Engine project, both running flexible versions. But I only seem to have this issue with one of the services (what I call the worker service).



Screenshot from App Engine UI:



Screenshot from App Engine UI



Screenshot from Logs UI that shows the SIGTERM being sent:



Screenshot from Logs UI that shows the SIGTERM being sent



PS - Could this have anything to do with the recent Google Compute issues that have been coming up... https://news.ycombinator.com/item?id=18436187



Edit: Adding the yaml file for "worker" service. Note that I'm using Honcho to add an endpoint to monitor health of the worker service via Flask. I added those code examples as well.



yaml File



service: worker
runtime: python
threadsafe: yes
env: flex
entrypoint: honcho start -f /app/procfile worker monitor

runtime_config:
python_version: 3

resources:
cpu: 1
memory_gb: 4
disk_size_gb: 10

automatic_scaling:
min_num_instances: 1
max_num_instances: 20
cool_down_period_sec: 120
cpu_utilization:
target_utilization: 0.7


Procfile for Honcho



default: gunicorn -b :$PORT main:app
worker: python tasks.py
monitor: python monitor.py /tmp/psq.pid


monitor.py



import os
import sys

from flask import Flask


# The app checks this file for the PID of the process to monitor.
PID_FILE = None


# Create app to handle health checks and monitor the queue worker. This will
# run alongside the worker, see procfile.
monitor_app = Flask(__name__)


@monitor_app.route('/_ah/health')
def health():
"""
The health check reads the PID file created by tasks.py main and checks the proc
filesystem to see if the worker is running.
"""
if not os.path.exists(PID_FILE):
return 'Worker pid not found', 503

with open(PID_FILE, 'r') as pidfile:
pid = pidfile.read()

if not os.path.exists('/proc/'.format(pid)):
return 'Worker not running', 503

return 'healthy', 200


@monitor_app.route('/')
def index():
return health()


if __name__ == '__main__':
PID_FILE = sys.argv[1]
monitor_app.run('0.0.0.0', 8080)









share|improve this question
























  • Can you show the app.yaml scaling configuration for that service? What do you see if you're trying to access the service?

    – Dan Cornilescu
    Nov 14 '18 at 12:15











  • @DanCornilescu, just added more details. When I try to access the service with 0 instances, I see something along the lines of "The service is down, please try again in 30 seconds". This seems like a default page that GAE shows if a service is down... once I redeploy I get the 'healthy' result based on my Flask endpoint.

    – vrk7bp
    Nov 14 '18 at 23:34











  • Yep, sounds like a problem with the GAE instance management, there really should have been at least one instance running as you have auto scaling with min_num_instances: 1. True, during unexpected outages or during the periodic (weekly I believe) instance restarts I'm not certain if the requirement is still met, but even if it's not - it should only be for a brief, transitory moment, there should be no extended periods with no instances running.

    – Dan Cornilescu
    Nov 15 '18 at 3:34











  • Thanks @DanCornilescu... do you have any suggestions on the best way to reach out to the Google Cloud folks about this?

    – vrk7bp
    Nov 19 '18 at 16:23











  • Check the open issue list at issuetracker.google.com/… and maybe open a new one if nothing appears to be matching, mentioning this SO post.

    – Dan Cornilescu
    Nov 19 '18 at 18:02













2












2








2








Over the past week I've been seeing the number of instances on my GAE Flexible Environment fall to 0, with no new instance spinning up. My understanding of the Flexible environment is that this shouldn't be possible... (https://cloud.google.com/appengine/docs/the-appengine-environments)



I was wondering if anyone else has been seeing these issues, or if they've solved the problem on their end before. My one hypothesis is that this might be an issue with my health monitoring endpoints, but haven't seen anything that jumps out as a problem when I review the code.



This hasn't been a problem for me until last week, and now it seems like I have to redeploy my environment (with no changes) every couple of days just to "reset" the instances. It's worth noting that I have two services under this same App Engine project, both running flexible versions. But I only seem to have this issue with one of the services (what I call the worker service).



Screenshot from App Engine UI:



Screenshot from App Engine UI



Screenshot from Logs UI that shows the SIGTERM being sent:



Screenshot from Logs UI that shows the SIGTERM being sent



PS - Could this have anything to do with the recent Google Compute issues that have been coming up... https://news.ycombinator.com/item?id=18436187



Edit: Adding the yaml file for "worker" service. Note that I'm using Honcho to add an endpoint to monitor health of the worker service via Flask. I added those code examples as well.



yaml File



service: worker
runtime: python
threadsafe: yes
env: flex
entrypoint: honcho start -f /app/procfile worker monitor

runtime_config:
python_version: 3

resources:
cpu: 1
memory_gb: 4
disk_size_gb: 10

automatic_scaling:
min_num_instances: 1
max_num_instances: 20
cool_down_period_sec: 120
cpu_utilization:
target_utilization: 0.7


Procfile for Honcho



default: gunicorn -b :$PORT main:app
worker: python tasks.py
monitor: python monitor.py /tmp/psq.pid


monitor.py



import os
import sys

from flask import Flask


# The app checks this file for the PID of the process to monitor.
PID_FILE = None


# Create app to handle health checks and monitor the queue worker. This will
# run alongside the worker, see procfile.
monitor_app = Flask(__name__)


@monitor_app.route('/_ah/health')
def health():
"""
The health check reads the PID file created by tasks.py main and checks the proc
filesystem to see if the worker is running.
"""
if not os.path.exists(PID_FILE):
return 'Worker pid not found', 503

with open(PID_FILE, 'r') as pidfile:
pid = pidfile.read()

if not os.path.exists('/proc/'.format(pid)):
return 'Worker not running', 503

return 'healthy', 200


@monitor_app.route('/')
def index():
return health()


if __name__ == '__main__':
PID_FILE = sys.argv[1]
monitor_app.run('0.0.0.0', 8080)









share|improve this question
















Over the past week I've been seeing the number of instances on my GAE Flexible Environment fall to 0, with no new instance spinning up. My understanding of the Flexible environment is that this shouldn't be possible... (https://cloud.google.com/appengine/docs/the-appengine-environments)



I was wondering if anyone else has been seeing these issues, or if they've solved the problem on their end before. My one hypothesis is that this might be an issue with my health monitoring endpoints, but haven't seen anything that jumps out as a problem when I review the code.



This hasn't been a problem for me until last week, and now it seems like I have to redeploy my environment (with no changes) every couple of days just to "reset" the instances. It's worth noting that I have two services under this same App Engine project, both running flexible versions. But I only seem to have this issue with one of the services (what I call the worker service).



Screenshot from App Engine UI:



Screenshot from App Engine UI



Screenshot from Logs UI that shows the SIGTERM being sent:



Screenshot from Logs UI that shows the SIGTERM being sent



PS - Could this have anything to do with the recent Google Compute issues that have been coming up... https://news.ycombinator.com/item?id=18436187



Edit: Adding the yaml file for "worker" service. Note that I'm using Honcho to add an endpoint to monitor health of the worker service via Flask. I added those code examples as well.



yaml File



service: worker
runtime: python
threadsafe: yes
env: flex
entrypoint: honcho start -f /app/procfile worker monitor

runtime_config:
python_version: 3

resources:
cpu: 1
memory_gb: 4
disk_size_gb: 10

automatic_scaling:
min_num_instances: 1
max_num_instances: 20
cool_down_period_sec: 120
cpu_utilization:
target_utilization: 0.7


Procfile for Honcho



default: gunicorn -b :$PORT main:app
worker: python tasks.py
monitor: python monitor.py /tmp/psq.pid


monitor.py



import os
import sys

from flask import Flask


# The app checks this file for the PID of the process to monitor.
PID_FILE = None


# Create app to handle health checks and monitor the queue worker. This will
# run alongside the worker, see procfile.
monitor_app = Flask(__name__)


@monitor_app.route('/_ah/health')
def health():
"""
The health check reads the PID file created by tasks.py main and checks the proc
filesystem to see if the worker is running.
"""
if not os.path.exists(PID_FILE):
return 'Worker pid not found', 503

with open(PID_FILE, 'r') as pidfile:
pid = pidfile.read()

if not os.path.exists('/proc/'.format(pid)):
return 'Worker not running', 503

return 'healthy', 200


@monitor_app.route('/')
def index():
return health()


if __name__ == '__main__':
PID_FILE = sys.argv[1]
monitor_app.run('0.0.0.0', 8080)






google-app-engine app-engine-flexible






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 14 '18 at 23:31







vrk7bp

















asked Nov 14 '18 at 0:10









vrk7bpvrk7bp

205




205












  • Can you show the app.yaml scaling configuration for that service? What do you see if you're trying to access the service?

    – Dan Cornilescu
    Nov 14 '18 at 12:15











  • @DanCornilescu, just added more details. When I try to access the service with 0 instances, I see something along the lines of "The service is down, please try again in 30 seconds". This seems like a default page that GAE shows if a service is down... once I redeploy I get the 'healthy' result based on my Flask endpoint.

    – vrk7bp
    Nov 14 '18 at 23:34











  • Yep, sounds like a problem with the GAE instance management, there really should have been at least one instance running as you have auto scaling with min_num_instances: 1. True, during unexpected outages or during the periodic (weekly I believe) instance restarts I'm not certain if the requirement is still met, but even if it's not - it should only be for a brief, transitory moment, there should be no extended periods with no instances running.

    – Dan Cornilescu
    Nov 15 '18 at 3:34











  • Thanks @DanCornilescu... do you have any suggestions on the best way to reach out to the Google Cloud folks about this?

    – vrk7bp
    Nov 19 '18 at 16:23











  • Check the open issue list at issuetracker.google.com/… and maybe open a new one if nothing appears to be matching, mentioning this SO post.

    – Dan Cornilescu
    Nov 19 '18 at 18:02

















  • Can you show the app.yaml scaling configuration for that service? What do you see if you're trying to access the service?

    – Dan Cornilescu
    Nov 14 '18 at 12:15











  • @DanCornilescu, just added more details. When I try to access the service with 0 instances, I see something along the lines of "The service is down, please try again in 30 seconds". This seems like a default page that GAE shows if a service is down... once I redeploy I get the 'healthy' result based on my Flask endpoint.

    – vrk7bp
    Nov 14 '18 at 23:34











  • Yep, sounds like a problem with the GAE instance management, there really should have been at least one instance running as you have auto scaling with min_num_instances: 1. True, during unexpected outages or during the periodic (weekly I believe) instance restarts I'm not certain if the requirement is still met, but even if it's not - it should only be for a brief, transitory moment, there should be no extended periods with no instances running.

    – Dan Cornilescu
    Nov 15 '18 at 3:34











  • Thanks @DanCornilescu... do you have any suggestions on the best way to reach out to the Google Cloud folks about this?

    – vrk7bp
    Nov 19 '18 at 16:23











  • Check the open issue list at issuetracker.google.com/… and maybe open a new one if nothing appears to be matching, mentioning this SO post.

    – Dan Cornilescu
    Nov 19 '18 at 18:02
















Can you show the app.yaml scaling configuration for that service? What do you see if you're trying to access the service?

– Dan Cornilescu
Nov 14 '18 at 12:15





Can you show the app.yaml scaling configuration for that service? What do you see if you're trying to access the service?

– Dan Cornilescu
Nov 14 '18 at 12:15













@DanCornilescu, just added more details. When I try to access the service with 0 instances, I see something along the lines of "The service is down, please try again in 30 seconds". This seems like a default page that GAE shows if a service is down... once I redeploy I get the 'healthy' result based on my Flask endpoint.

– vrk7bp
Nov 14 '18 at 23:34





@DanCornilescu, just added more details. When I try to access the service with 0 instances, I see something along the lines of "The service is down, please try again in 30 seconds". This seems like a default page that GAE shows if a service is down... once I redeploy I get the 'healthy' result based on my Flask endpoint.

– vrk7bp
Nov 14 '18 at 23:34













Yep, sounds like a problem with the GAE instance management, there really should have been at least one instance running as you have auto scaling with min_num_instances: 1. True, during unexpected outages or during the periodic (weekly I believe) instance restarts I'm not certain if the requirement is still met, but even if it's not - it should only be for a brief, transitory moment, there should be no extended periods with no instances running.

– Dan Cornilescu
Nov 15 '18 at 3:34





Yep, sounds like a problem with the GAE instance management, there really should have been at least one instance running as you have auto scaling with min_num_instances: 1. True, during unexpected outages or during the periodic (weekly I believe) instance restarts I'm not certain if the requirement is still met, but even if it's not - it should only be for a brief, transitory moment, there should be no extended periods with no instances running.

– Dan Cornilescu
Nov 15 '18 at 3:34













Thanks @DanCornilescu... do you have any suggestions on the best way to reach out to the Google Cloud folks about this?

– vrk7bp
Nov 19 '18 at 16:23





Thanks @DanCornilescu... do you have any suggestions on the best way to reach out to the Google Cloud folks about this?

– vrk7bp
Nov 19 '18 at 16:23













Check the open issue list at issuetracker.google.com/… and maybe open a new one if nothing appears to be matching, mentioning this SO post.

– Dan Cornilescu
Nov 19 '18 at 18:02





Check the open issue list at issuetracker.google.com/… and maybe open a new one if nothing appears to be matching, mentioning this SO post.

– Dan Cornilescu
Nov 19 '18 at 18:02












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291313%2fgoogle-app-engine-flexible-environment-at-0-instances%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291313%2fgoogle-app-engine-flexible-environment-at-0-instances%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Barbados

How to read a connectionString WITH PROVIDER in .NET Core?

Node.js Script on GitHub Pages or Amazon S3