Optimising Compute Engine Cost by Scheduling VMs
Google Cloud’s most widely used service is Compute Engine, which is an Infrastructure as a Service offering provided by Google Cloud Platform. It is a general-purpose, flexible, highly scalable virtual machine. There are many types and sizes of compute engines. Compute Engine offers a wide range of options from general purpose machines to resource-specific optimised […]
October 31, 2022
by Sneha Farkya
8 mins Read
Google Cloud’s most widely used service is Compute Engine, which is an Infrastructure as a Service offering provided by Google Cloud Platform. It is a general-purpose, flexible, highly scalable virtual machine. There are many types and sizes of compute engines.
Compute Engine offers a wide range of options from general purpose machines to resource-specific optimised machines such as memory-optimised, compute-optimised, and GPU-optimised, all at different pricing. Additionally, the user can also customise their own machine types to better fit their needs.
Why should you schedule Instances?
Instances are run in different environments, including production, testing, and others. Some environments don’t require instances to be on at all times. For example, you can only use a testing environment when you need to or development environment tied to the working hours.
By using scheduling, you can automate the start and stop of instances, so you do not have to worry about running an instance when it is not needed, or how much money you waste by leaving it running unnecessarily.
The following are some benefits:
- Automated start and stop of VM instances is possible. No additional manpower is required.
- It helps you in cost optimization.
- VM instances can be managed more efficiently if scheduled.
- Workloads can be scheduled on a recurring or one-time basis with the instance scheduler.
- It creates deployment and test environments.
VM instances are enabled using instance schedules by creating and attaching a resource policy that defines the start and stops behavior. Here are some pre-requistes that needs to be ensured before scheduleding
Required Permissions
Your project’s Compute Engine Service Agent must have the following permissions to use instance schedules:
- For VM instances to start, you need to have compute.instances.start permission.
- For VM instances to stop, you need to have compute.instances.stop permission.
The Compute Engine Service Agent should have an IAM role if they don’t have the above permissions. The IAM role should have required permissions, such as Compute Instance Admin (v1) (roles/compute.instanceAdmin.v1).
Listing instances
A project or organization must have to compute.resourcePolicies.list permission in order to view all the instance schedules. Follow the below steps to list all the instances:
- Open the VM instance page in GCP.
- At the top of the page, select Instance schedules. All scheduled instances are displayed here.
Scheduling instances
For creating an instance, you need to have compute.resourcePolicies.create permission on a particular project.
- Go to the VM Instances page in GCP.
- At the top of the page, click the Instance schedules tab.
- Click Create schedule.
- Give it a name.
- You may enter a Description.
- Select a region for this instance schedule in the drop-down menu.
- Define when VM instances attached to the instance schedule will start and stop.
- Choose the time zone for the Start time and Stop time, from the Time-zone dropdown.
- Select the date and time when you want this instance scheduled to begin in the Initiate date field. It takes effect immediately if omitted.
- Select the date and time when you want this instance scheduled to end in the End date field. In the absence of this clause, the schedule will remain in effect indefinitely.
- Click on Submit.
To configure Start time, Stop time, Frequency, and more complex schedule, use Cron expressions. A cron expression is a series of six-seven fields that describes the details of the schedule.
- At the top of the page, click the Use Cron expression
- Choose whether to start or stop Cron.
- Enter a cron expression that describes when VM instances will be started in the Start Cron expression field.
- Enter a cron expression that describes when to stop VM instances in the Stop Cronexpression field.
These fields are separated by white space and can contain values with the following special characters:
- “ * ” symbolizes “any”
- “ – ” symbolizes “range”
- “, ” symbolizes “list”
Deleting an instance schedule
When you no longer need a VM instance, delete it by removing its resource policies. Given below are the steps to be taken:
- You can delete instance schedules by selecting the checkboxes.
- At the top of the page, click delete.
- Select delete in the dialog box to confirm your action.
This way, you can create and schedule a Virtual Machine instance to automate your task. The resource policy is like a handbook describing when to start and stop your VM instance. Along with this, you can also mention the frequency, time zones, description, etc. The Compute Engine API, the Google Cloud console, or the Google Cloud CLI are all available for creating new instances or groups of managed instances. This article has delivered the way to schedule VM instances using Compute Engine.
Limitations of Scheduling Compute Engine VM Instances
While scheduling VMs on Google Cloud Compute Engine helps optimize costs, certain limitations can impact efficiency. Below are key challenges to consider.
- Daylight Saving Time (DST) Impact: Schedules may behave unpredictably during DST shifts, leading to delayed startups or shutdowns and misaligned operations. To prevent this, using UTC time zones is recommended.
- Time Zone Considerations: Managing multiple time zones complicates scheduling, potentially misaligning workloads with working hours across regions. Clear configurations can help avoid operational disruptions.
- Region Limitations: Scheduling features vary by region, leading to inconsistent behavior and limiting flexibility. Users must ensure that resource policies align with the available regional features.
- Scheduled Operation Delay: VM start/stop operations can experience delays due to system load, network issues, or dependencies, disrupting time-sensitive workloads.
- Start and Stop Behavior Issues: Scheduled VMs can fail to start due to quota limits or errors, while premature shutdowns may disrupt tasks. Testing sequences and monitoring operations reduce such risks.
- Manual Start and Stop Conflicts: Manual overrides can cause state inconsistencies and disrupt scheduled workflows. Keeping track of both manual and scheduled actions ensures smoother operations.
- Resource Policy Constraints: Resource policies may conflict with schedules, limiting flexibility. Aligning these policies with schedules ensures instances behave as expected.
How Economize Can Help You in Cloud Cost Optimization
Implementing scheduling strategies is just one piece of the puzzle in managing cloud costs effectively. Economize offers a comprehensive cloud cost optimization platform that takes cost management to the next level by providing real-time insights, automation tools, and smart recommendations across cloud environments. With Economize, users can:
- Identify idle and underutilized VMs: Automatically detect instances that are not in use and suggest optimal schedules.
- Automate cost-saving actions: Leverage built-in scheduling tools alongside auto-tagging features to manage resources efficiently.
- Track cost trends and anomalies: Receive alerts on unusual spikes in cloud spending to prevent budget overruns.
- Multi-cloud support: Manage and optimize costs not just on Google Cloud but across AWS and Azure as well.
By integrating Economize into your cloud workflow, businesses can streamline cloud cost management, align instance usage with operational needs, and ensure every resource contributes to business value.
Conclusion
Scheduling VM instances on Google Cloud Compute Engine is a practical way to automate workloads and reduce unnecessary expenses. It ensures resources are only active when needed, improving efficiency in development, testing, and production environments. However, challenges like time zone complexities, DST shifts, region limitations, and manual overrides must be managed carefully. With the right monitoring and automation in place, scheduling becomes a key tool for balancing cloud performance and cost savings.
Is Your Cloud Budget Overwhelming?
Struggling with high cloud bills? Don’t stress any longer. Economize offers a simple solution to cut your expenses by up to 30%. Sign up for a free demo today and experience firsthand how quick and easy it is to reduce your costs and lighten your financial load.
More Like this
Amazon ECS: Pricing & 5 Cost Optimization Strategies
February 23, 2024
AWS EBS Pricing and 5 Cost Optimization Strategies
March 07, 2024
Top 7 Benefits of Using Google DataFlow for Analytics
September 25, 2024