google-app-engine


Change backend instance class programmatically on Google App Engine


I am using backend instances for an Google App Engine project. (Frontend instances can't handle requests longer than 60 seconds — I need longer time.)
I chose B4 instance type because sometimes the load is high. However, on certain times (let's say 2am to 7am) the load is so low that having an B4 instance is overkill.
I want to make a cron job that changes the type of that instance to B2 on certain times and back to B4 on other times to save cost.
However, looking at the Modules API, I could not find a way to do so.
So how can I do so?
Edit after getting an answer by Ramiel
In the end I used the Admin API as follows:
# Construct the api client
cred = GoogleCredentials.get_application_default()
svc = discovery.build('appengine', 'v1', credentials=cred)
vapi = svc.apps().services().versions()
# get list of versions
o = vapi.list(appsId=app_identity.get_application_id(), servicesId=modules.get_current_module_name()).execute()
# PATCH all SERVING versions with the new instanceClass
for v in o['versions']:
if v['servingStatus'] == 'SERVING':
result = vapi.patch(
appsId=app_identity.get_application_id(),
servicesId=modules.get_current_module_name(),
versionsId=v['id'],
updateMask='instanceClass',
body={
'instanceClass': instanceClass
}
).execute()
Checkout admin-api endpoints
https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.services.versions/patch
If this does not work for some reason, you can also deploy multiple versions of app with various instance/scaling settings and programmatically switch them
with start_version from Modules API
btw, if you switch to manual scaling you don't have 60s limit
This might not be what you're looking for, but it's a possible way of achieving what you want.
Set up a system on container engine or something like that which would automatically pull the latest code from your repo, automatically adjust the instance type and automatically do a redeploy. You could make it deploy different instance types on different times. A new redeploy would be needed for every change in instance class, but these could be fully automated in theory so this would be possible.
Thought? Is this a possible solution for you?
Task Queue can run for 10 minutes, check out the document

Related Links

App Engine - How to Clear Cookie
How do I get the path to the Cloud SDK directory using the gcloud command?
Cannot reach Endpoint method with cURL
Find the total instance hours in my Google Apps Engine
Cron Jobs on Google App Engine
Golang GAE, aestest.NewContect not working on local machine. Could not find python interpreter
Downloading my existing project in google cloud using Gcloud SDK
Google app engine css not found/deployed
CI for ASP.Net using Jenkins on Google Cloud
Can the GAE Servlet code be accessest by anyone
Is there a way of checking if a Web Application or Website using the Google App Engine?
google endpoints on flex app engine
Deploy to Google App Engine via a GitHub Repo
Using App Engine Datastore over MySQL for a CRM System
Geospatial Query at Google App Engine Datastore
how to put in the top as a ad My website in google?

Categories

HOME
batch-file
asp.net-web-api
twitter-bootstrap-3
deep-learning
polymer
merge
redux-form
rdbms
flex
jwplayer
edge
static-site
nsbundle
alsa
parameters
big-o
nstableheaderview
qpython
xcodebuild
onedrive-api
libusb
azure-iot-hub
easyphp
google-content-api
google-picker
bourbon
selinux
joptionpane
gmock
xcode-ui-testing
gpio
jackson-modules
oculus
ceylon
alm
quickfixj
memory-address
catch-unit-test
erb
searchkit
openproject
graphhopper
android-augmented-reality
health-monitoring
branching-and-merging
print-css
facebook-social-plugins
dotnet-httpclient
wcftestclient
magic-draw
scalding
wpas
opengl-4
excel-dna
template-toolkit
cmp
universal-analytics
visual-studio-2008-sp1
simplepie
jquery-jscrollpane
gogs
avspeechsynthesizer
bizagi
r-package
pax-exam
jdk1.7
mirror
botan
cwrsync
uvc
fail2ban
cross-join
exceldatareader
functional-java
accesscontrolexception
sphinxql
ie8-compatibility-mode
flex++
epiceditor
font-awesome-4.0.0
resource-management
curb
extreme-programming
frameworkelementfactory
sentestingkit
faye
azman
koken
saxparseexception
winmain
multiplatform
mbeans
strsep
timthumb
metaweblog
updatesourcetrigger
maven-1
tabpanel
web-application-project
dsl-tools
technical-debt

Resources

Encrypt Message