Google Cloud Platform Blog
Reliable task scheduling on Google Compute Engine
Thursday, June 11, 2015
Many systems require regularly scheduled tasks, but getting them to run reliably in a distributed environment can be surprisingly hard.
Imagine trying to run the standard UNIX cron service in a fleet of virtual machines. Individual machines come and go due to autoscaling and network partitioning. A critical task might never run because the instance it was scheduled on became unavailable. Or a task meant to run only once might be duplicated by many servers as your autoscaler brings them online.
Using Google
App Engine’s Cron service
for scheduling and
Google Cloud Pub/Sub
for messaging, you can build a distributed and fault-tolerant scheduler for your virtual machines. We’ll teach you how in our
Reliable Task Scheduling for Google Compute Engine
a
rticle, which includes
code for a sample implementation
on GitHub.
In this design pattern, a lightweight App Engine application schedules events in the Cron service. When the Cron service calls this application’s event handlers, the App Engine application uses Cloud Pub/Sub to relay the events to a utility running on each Compute Engine instance.
When the subscribing utility receives a message, it runs a script corresponding to the Cloud Pub/Sub topic. The scripts run locally on the instance just as if they were run by Cron. In fact,
you can reuse existing Cron scripts
with this design pattern.
Using Cloud Pub/Sub for distributed messaging means that you can schedule an event to only run on one of many servers, or to run the task on several servers concurrently. The topic and subscriber model (shown in the diagram below) gives you fine-grained control over which instances receive a given task.
Figure 1 - Using App Engine Cron from Compute Engine
For a detailed explanation of this design pattern, check out our
Reliable Task Scheduling for Google Compute Engine
a
rticle, which includes
a sample implementation
on GitHub. Feel free to make pull requests or open issues directly on the open source sample, or ping me at @ptone on twitter if you find this useful.
- Posted by Preston Holmes, Solutions Architect
No comments :
Post a Comment
Don't Miss Next '17
Use promo code NEXT1720 to save $300 off general admission
REGISTER NOW
Free Trial
GCP Blogs
Big Data & Machine Learning
Kubernetes
GCP Japan Blog
Labels
Announcements
56
Big Data & Machine Learning
91
Compute
156
Containers & Kubernetes
36
CRE
7
Customers
90
Developer Tools & Insights
80
Events
34
Infrastructure
24
Management Tools
39
Networking
18
Open Source
105
Partners
63
Pricing
24
Security & Identity
23
Solutions
16
Stackdriver
19
Storage & Databases
111
Weekly Roundups
16
Archive
2017
Feb
Jan
2016
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2015
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2014
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2013
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2012
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2011
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2010
Dec
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2009
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Mar
Feb
Jan
2008
Dec
Nov
Oct
Sep
Aug
Jul
Jun
May
Apr
Feed
Subscribe by email
Technical questions? Check us out on
Stack Overflow
.
Subscribe to
our monthly newsletter
.
Google
on
Follow @googlecloud
Follow
Follow
No comments :
Post a Comment