Does stopping google cloud instance stop all charges? - google-cloud-platform

Ive read: https://cloud.google.com/compute/docs/instances/stopping-or-deleting-an-instance. In it they explain that:
You can stop an instance temporarily so you can come back to it at a
later time. A stopped instance does not incur charges, but all of the
resources that are attached to the instance will still be charged.
Alternatively, if you are done using an instance, delete the instance
and its resources to stop incurring charges.
However, i don't know how things are allocated in google cloud so im not sure what this means.
Say I stop my instance, I guess i am still using their storage, but im not using any CPU right? Does that mean that i will only pay for storage but not for the CPU and GPU hours?
Also how does google stop my instance? I know that if you suspend an instance in something like "Virtualbox" you can start it and start from when you left off. Is that what google does? Can I stop the instance halfway through running something and have it continue where it left off when i start the instance again?

When you stop your instance, you will not pay for CPU or GPU while the instance is stopped as the instance is not using them but you will be charged for resources attached as stated in the link you posted:
Your instances are not charged for per-second usage charges in TERMINATED state but any resources attached to the virtual machine will be charged until they are deleted, such as static IPs and persistent disks.
Google stops your instance by shutting it down, so you will lose data that is not in a persistent disk already.
From their docs:
When you shut down or delete an instance, Compute Engine sends the ACPI Power Off signal to the instance and waits a short period of time for your instance to shut down cleanly. If your instance is still running after this grace period, Compute Engine forcefully terminates it even if your shutdown script is still running.
There is a gcloud command that is in alpha that can suspend your VM: gcloud alpha compute instances suspend, you can read more in the docs here. It will only work on instances not using GPU or CSEK or preemptible VMs.

Compute Engine documentation says:
A stopped instance does not incur charges, but all of the resources
that are attached to the instance continue to incur charges. For
example, you are charged for persistent disks and external IP
addresses according to the price sheet, even if an instance is
stopped. To stop being charged for attached resources, you can
reconfigure a stopped instance to not use those resources, and then
delete the resources.

Related

GCP VM instance schedule randomly not starting VM

We've started using GCP Instance schedule for one of our VMs which needs to be up for 3 hours every night. For some reason, about once per week the VM is not up - services can't access it.
Checking from Logs Explorer, there are no errors or warnings, but on those days when it is not working, there are a few events which are not published/logged. These are the GCE Agent Started and OSConfig Agent Started events which happen on days where everything is OK (09-11, 09-12, 09-14) but are missing on days when the instance is not up (09-13).
The VM is Windows Server 2012 R2.
There is no retry policy implemented in the GCP instance schedule feature.
We know there are other ways to schedule VMs but we'd prefer to use the instance schedule feature if possible and if it is stable.
Is there somewhere else we should look for understanding why the VM is not starting properly?
This is the image from logs:
Instance schedules do not provide capacity guarantees, so if the resources required for a scheduled VM instance are not available at the scheduled time, your VM instance might not start when scheduled. Although you can reserve VM instances before starting them to provide capacity guarantees, reservations cannot be automatically scheduled.(Assuming that randomly VM instances are showing up this behaviour every week, not a particular VM every week.)
If it's with the same VM everytime then high memory utilization can also cause VM not being responsive. Manual reboot would fix this since it would close whatever is consuming the memory and re-open processes or services that may have been killed due to being OOM.
Please consider monitoring the VM memory usage by installing a monitoring agent, and increase the memory request based on the utilization.

Difference between STOP instance and SUSPEND instance in Google Cloud Platform

I was created an instance in Google Cloud Platform. I use this instance 2 to 4 days in a week. So, I want to close my instance for rest of the days to save my billing charges. So, what is best option for me. Stop the instance or Suspend the instance? What is the difference between them?
Please have a look at the documentation Suspending and resuming an instance:
Suspending an instance differs from stopping an instance in the following ways:
Suspended instances preserve the guest OS memory, device state, and application state.
Google charges for the storage necessary to save instance memory.
You can only suspend an instance for up to 60 days. After 60 days, the instance is automatically moved to the TERMINATED state.
and at the article Stopping and starting an instance:
Instances that are in a TERMINATED state are not charged for
per-second usage and do not count toward your regional CPU quota, so
you can choose to stop instances that you are not using, saving you
from being charged for instances that aren't active. After you are
ready, you can come back and start the same instances again, with the
same instance properties, metadata, and resources.
Your instances are not charged for per-second usage while in the
TERMINATED state but any resources attached to the virtual machine,
such as static IPs and persistent disks, are charged until they are
deleted.
As a result, it's better to stop your VM instance, to avoid extra changes for keeping instance's memory.
In addition, please have a look at the article Save money by stopping and starting Compute Engine instances on schedule.

Google Cloud VM Instance Stuck on resizing suggested by Console

I had a vm instance running on Google Cloud, it's suggested me that "you should resize instance to 2CPU and 16GB RAM from 4CPU and 16GB RAM".
I pressed to Apply to set new config. Instance has stopped and stucked in resize process since an hour, neigher shows resized in gcloud instance list nor starting up.
Even try for taking snapshot of that vm's disk shows error that "it's being used in some operations"
Tried to force stop via gcloud, but no luck. In notification pop-up shows, resizing vm only.
Pls help me here.
The main reason for this issue is GCP resource availability which depends on users requests and therefore is dynamic. As result, issues like this could happen when you use cloud resources on-demand without reservation.
Let's have a look at the cause of this issue:
when you stop an instance it releases some resources like vCPU and memory;
when you start an instance it requests resources like vCPU and memory back;
when you resize your VM it's the same.
In case if there's not enough resources available in the zone you'll get an error message:
The zone 'projects/xyz-project-272905/zones/asia-south1-a' does not have enough resources available to fulfill the request. Try a different zone, or try again later..
more details you can find in the documentation:
If you receive a resource error (such as ZONE_RESOURCE_POOL_EXHAUSTED
or ZONE_RESOURCE_POOL_EXHAUSTED_WITH_DETAILS) when requesting new
resources, it means that the zone cannot currently accommodate your
request. This error is due to Compute Engine resource obtainability,
and is not due to your Compute Engine quota.
There are a few ways to solve your issue:
Move your instance to another zone by following instructions.
Wait for a while and try to resize your VM instance again.
Reserve resources for your VM by following documentation to avoid such issue in future (extra payment will be required):
Create reservations for Virtual Machine (VM) instances in a specific
zone, using custom or predefined machine types, with or without
additional GPUs or local SSDs, to ensure resources are available for
your workloads when you need them. After you create a reservation, you
begin paying for the reserved resources immediately, and they remain
available for your project to use indefinitely, until the reservation
is deleted.

Google Cloud Platform Preemptive Instances: What happens to the disk?

I am asking about the GCP Preemptive Instances. I have read that when an instance is terminated on a preemptive instance, an ACPI Soft Power Off occurs.
I am wondering if the hypervisor pauses the instance so that I can continue on my tasks. Or, the VM is shut off and not paused.
I have used preemptive instances in the past, but I cannot seem to remember if the VM was shut down or paused.
When your instance is turned off (or terminated) as stated in the documentation you can still access your data which are stored on a persistent disk.
Preemption process is described in the documentation and it states:
Preempted instances still appear in your project, but you are not charged for the instance hours while it remains in a TERMINATED state. You can access and recover data from any persistent disks that are attached to the instance, but those disks still incur storage charges until you delete them. As with normal instances, persistent disks that are marked for auto-delete are deleted when you delete the preemptible instance.
You can start your instance later and access your data - and if a proper resources are not available then you can attach the disk to other VM's and still access your data.
In short you will retain the disk data and when new vm comes up then it will automatically attach to it

Does Google Cloud charge for Compute Engine instances during the startup or shutdown periods?

I'm referring to the periods when your startup and shutdown scripts are run (or not run if you don't have any).
Yes, google will charge you during the time the instance runs startup/shutdown scripts.
Any time the instance is running, you will be charged. The only time one is not charged is when the instance has the 'TERMINATED' status. If the instance disk is kept even though is terminated, the disk continues to generate charges as well.