Difference between STOP instance and SUSPEND instance in Google Cloud Platform - 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.

Related

Are EC2 instances charged when starting/stopping?

I am trying to host an application on AWS. I am comparing hosting it on Lambda and on EC2, and was thinking about "sides costs".
Indeed with lambda I am charged for cold starts, and I was wondering if when starting/stopping an EC2 instance you're charged for this time, since my instance will take something between 1 or 2 minutes to start and stop.
Since I plan to start and shut down quite a lot of instances frequently it would represent a non negligible cost for me if I am charged for this period.
You pay when the instance is in RUNNING state. From docs:
If your instance is billed by the second, then you're billed for a minimum of 60 seconds each time a new instance is started—that is, when the instance enters the running state.
This is independent of your application on the instance.

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.

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

What is the latency from hibernated state to a request can be accepted on AWS?

AWS supports hibernation of instances to EBS storage. From the hibernated state, they can be resumed and continue execution.
How useful hibernation is compared to starting a new instance is crucially linked to startup time of a fresh instance vs how long it takes for a hibernated instance to continue running, specifically how long it takes to be able to accept and process network requests.
How long does this take?
Time taken for hibernated instance to resume depends on the size of the RAM. If you are using instances with low to medium memory, your instances should resume pretty quickly.
However, that should not be the only consideration because Hibernation allows you to resume the instance (with the applications) from the saved state. If your instance on a fresh start requires bootstrapping time, in that case, Hibernation will be much more beneficial for you.
Based on the results mentioned in AWS Blog of "How Backbase How Backbase Leveraged EC2 Hibernation to Reduce Compute Spending by 30%", Backbase is able to resume instances within 30 seconds.

Does stopping google cloud instance stop all charges?

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.