Google App Engine - Frequently getting logged out of the deployed .NET application - google-app-engine

Frequently getting logged out from the deployed application, session is not working/timing out too soon in the deployed .net 5 application in the App Engine flex.
Below are the warning logs which i'm getting, not sure are they related to session issue or not.
Logged warnings
Are there any session settings which needs to be done within GCP console which i'm unaware of?
I've found similar configuration for Java applications but nothing for .NET.
Reference:- https://developers.google.com/appengine/docs/java/config/appconfig?csw=1#Java_appengine_web_xml_Enabling_sessions

Apparently, I found the issue and fixed it as mentioned below
app.yml file is to be modified with custom env instead of the default which Google App Engine flex provides with 2 instances, like below -
Modified app.yml -
runtime: custom
env: flex
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
Here we are explicitly mentioning the instances and power required to run our app.
The default deployment uses multiple instances, and the sessions seem to be stored privately per instance. If you reload the page a few times, you will see your session exists sometimes and does not exist other times as you toggle between instances.
Hence by providing 1 instance we are restricting our session to be then and there hence resolving the above issue with it.

Related

Google App Engine Manual Scaling Prevents Restart

I have a python app engine that handles api results and it's stateful. However it seems that after a few hours of inactivity (no requests), the server shuts off, resetting all states, and when a new request is made, it's listening again.
But the states are reset. I want the server to actively remain unchanged 24/7 and not reset/restart as I want to maintain states.
I have configured as per documentation but it's still restarting, I am not sure what's wrong
Here is my app.yaml:
runtime: python37
entrypoint: python main.py
manual_scaling:
instances: 1
In App Engine the general recomendation is to create stateless applications as mentioned on the documentation
Your app should be "stateless" so that nothing is stored on the instance.
As an alternative for the application not to get restarted you can deploy it on Compute Engine, As that service is a Virtual Machine you can have total control of the states.

How to fix google-cloud app-engine flexible-environment quota issue

I have a deployed app engine service with a flexible environment which I'm trying to update, by running from the terminal:
gcloud app deploy
I am met with this error message:
ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: The following quotas were exceeded: BACKEND_SERVICES (quota: 5, used: 5 + needed: 1), IN_USE_ADDRESSES (quota: 8, used: 8 + needed: 1).
I have only one other service running with a flexible environment.
In the past, I fixed this problem by stopping, then deleting older versions of my service (or of the other one running on the flexible environment).
This problem was caused now because I deleted a version without stopping it first. I have a feeling these versions still occupy my "quota", though I can't see them anywhere (not in the web GUI, nor in the terminal).
Please help!
This issue is related to this thread wherein there are options that can be followed to stop the error.
It is possible that the backend load balancer or the VM instances of your App Engine Flex still exist even if you have removed the whole service. You can verify it through the following:
Load Balancer (Cloud Console -> Network Services -> Load balancing -> Backends) https://console.cloud.google.com/net-services/loadbalancing/backends/list
VM Instances (Cloud Console -> Compute Engine -> VM Instances)
https://console.cloud.google.com/compute/instances
If there is no existing backend, you can file a support ticket to verify if:
Your project quotas are still maxed out.
The service backends are still active only that they do not reflect in Cloud Console.

How to actually stop an AppEngine form creating instances

I have been trying to get an AppEngine project to simply stop running. After trying deleting versions, deleting instances, and even uploading straight up empty main.py and worker.py files the project is still using about 3 hours of instance hours per hour. I don't understand how this is physically possibly. Where are some places I can start looking, since where I've been looking before doesn't seem to have any relevance whatsoever.
One possible approach would be to disable (or even shutdown) your application. From Google App Engine FAQ:
How can I disable one of my existing applications?
Disabling your application stops all serving requests, but your data and state are retained. You are still be billed for applicable
charges, such as Compute Engine instances. To release all the
resources used within the project, shut down your project.
To disable your application:
In the GCP Console, go to the App Engine Settings page.
Click Disable application and follow the instructions.
Disabling your app takes effect immediately. Confirm that your application has been disabled by visiting the URL of your app, such as
http://[YOUR_PROJECT_ID].appspot.com/. Your application should
return an HTTP 404 Not Found error.
Note that shutting the project down will be automatically followed by deletion in 30 days, so don't do that if you still want to re-enable the project at some point.
You can set the max instances in app.yaml:
instance_class: B2
basic_scaling:
max_instances: 1
Not sure if you can set that to 0, but at least limit it to 1.
Also
1) Make sure you don't have some backend instance (which uses its own app.yaml) running.
2) make sure you don't have any cron jobs running, or tasks stuck in the taskqueue
3) Try:
health_check:
enable_health_check: False
4) Shut down your instances.

Google App Engine Flexible Environment creating too many VM instances

I followed the Quickstart for Node.js in the App Engine Flexible Environment found at
https://cloud.google.com/nodejs/getting-started/hello-world
I deployed the hello-world node.js app using gcloud preview app deploy.
However, this simple command generated dozens of VM instances that I can see on the Developers Console. These instances are named gae-default-timestamp-xywz.
I manually deleted the instances on the console, and minutes later new ones were back, only stopping to create new ones when my resources quota is reached.
Has anyone out there seen anything like this and know how to fix the issue? Thanks!
For the existing instances, you need to shut down first before deleting them. And to fix the new instance spinning, you can use max_num_instances: THE NUMBER_AS_YOU_DESIRE (ex. max_num_instances: 2 for auto scale) in your app.yaml file.

Why do I have backend in Google App Engine if I don't have backends.yaml at all

When I open the admin panel of Google App Engine I see that I have running backend. I didn't intend to have one and I don't have backends.yaml file in my config.
I doubt it is because in the app.yaml I have this line manual_scaling in order to be able to make longer operatiotns:
manual_scaling:
instances: 1
Probably I should consider using modules. But first I want to clear this issue.
Manual scaling only works with "B"-type instances, which used to be known as "backend instances":
https://developers.google.com/appengine/docs/python/modules/#Python_Instance_scaling_and_class

Resources