Cron To Go Review — A Heroku Scheduler Alternative
We all at some point in our programming journey have come across Heroku- a cloud-native platform for developing applications in various languages. It offers us many inbuilt features in one platform such as Github, Docker Integrations, Command-Line, Web UI, and various other add-ons to choose from. Heroku is one of the most popular platforms for free hosting of websites and offers a free scheduling add-on of its own for running jobs on our apps at scheduled time intervals, much like Cron in a traditional server environment.
Some of the major problems with Heroku Scheduler
The scheduler has no guarantee that jobs will execute at their scheduled time, or at all, there may be a chance that a job will be skipped, and there may be a chance that a job will run twice.
One of the good alternatives to this is a custom clock process on Heroku and in this article, I am going to talk about Cron To Go Scheduler an add-on created by Crazy Ant Labs its features, setup, and integration with Nodejs code.
What are Crons?
Crons are the command-line utilities also known as cron jobs, they are the schedulers that are used by the developers to schedule jobs that are responsible to run on a fixed time, date, or periodically in some intervals. It typically automates system maintenance or administration. It is most suitable for scheduling repetitive tasks.
Before we talk about what exactly Cron To Go Scheduler is, let's figure out what Heroku Dynos are.
Dynos are isolated, virtualized Linux containers that are designed to execute code based on a user-specified command. They are the building blocks that power any Heroku app, from simple to sophisticated.
What is Cron To Go Scheduler?
Cron To Go Scheduler is an add-on created for Heroku users to run scheduled jobs based on one-off dynos using cron expressions. It enables the dynos to run only when it is needed and it combines the simplicity of using cron to schedule jobs with the scale and elasticity of the cloud.
Setting up the Environment
Setting up your Cron To Go Scheduler is quite easy and has a fully managed environment with flexible scheduling, let us see how to configure and setup the environment, there are two ways to add Cron To Go Scheduler to your application which is:
Adding Cron To Go Scheduler using Heroku UI
- Go to the Heroku Dashboard and select any one of the existing projects, if there is no existing project, create one
2. After selecting the project go to the installed add-ons section and click on Configure Add-ons
3. Now, click on Find more add-ons
4. Now, select Cron To Go Scheduler from the available add-ons from the Data Stores section
5. Next, click on install Cron To Go Scheduler on the rightmost top corner of the window
6. Now, select any add-on plan and select the application in the search bar with which the add-on has to be connected and click on Submit Order Form
7. Next, wait for a few seconds to get the add-on started, and now, you can add your jobs and manage them to get started! after deploying the add-on you will be directed to your dashboard which looks something like this
Adding Cron To Go Scheduler using Heroku CLI
- Login to your Heroku account using the command and enter the credentials such as email and the password on the terminal
$ heroku login -i
2. Now, use the command to add the Cron To Go Scheduler add-on to your Heroku dashboard
$ heroku addons:create crontogo -a APP_NAME
Once ready you can access the Cron To Go Scheduler Dashboard directly from Heroku
In your Cron To Go Scheduler dashboard, you can find all your information related to the jobs created, last run, webhooks, and other settings in the platform.
You can also access the dashboard using the command
$ heroku addons:open crontogo -a APP_NAME
and then, visit the dashboard using the web
How to Create Jobs?
Jobs in Cron To Go Scheduler can be created using the Cron To go dashboard or the APIs
You will have to provide the name of your job which you are creating as a Nickname and add the time interval when you want your job to be executed, enter the script in the Command which you want to run then select the Dyno Size according to your needs and usage in your application and Timeout and then create your job by clicking on the button click.
While you are selecting Dyno Size you might come across different types of dynos that are, free having a size of 512MB, hobby having a size of 512MB, standard-1x having a size of 512MB, standard-2x having a size of 1024MB, performance-m having a size of 2.5GB, performance-I having a size of 14GB, it depends on which plan are you currently working or having your application working upon!
How can one Monitor and check the Logs of the application?
Monitoring and checking the logs for your application can be easily done from within the UI (by clicking the menu button […] for the job and then choosing view job history or view job logs). You can also use the CLI:
$ heroku logs -t -a <APP_NAME> -d crontogo
then, you can use the dashboard to view the streamed dyno log from Heroku or you can also install logging add-ons.
Application Features
Cron To Go can run any command that can be run in your application. For Node.js, you can simply add a file to your app and execute it using the command
$ node <SCRIPT_NAME> <METHOD_NAME>
Removing the Add-on
The add-on can be removed using the following command
$ heroku addons:destroy crontogo
What are Webhooks?
Webhooks enable us to receive notifications whenever particular events occur with our jobs. You can subscribe to notifications regarding the following events:
- Job Execution Failed — occurs whenever a job execution fails to complete.
- Job Execution Started — occurs whenever a job execution is started.
- Job Execution Succeeded — occurs whenever a job execution completes successfully.
Webhook notifications are sent as HTTPS POST requests to a URL of your choosing.
for creating a webhook in Cron To Go Scheduler you can refer to the image above where you need to add the Nickname as a descriptive name for the webhook., Endpoint URL is the server endpoint to send all your webhook notifications to, Authorization Header is a header that will be included with all webhook notifications and selecting the topics for which the notifications have to be sent.
After the webhook has been created you will be getting a secret key that is displayed only once, so you are advised to copy this key and store it in a safe file. Each request is signed by Cron To Go in the X-Hub-Signature header.
After successfully creating a webhook, you may pause/resume, rotate secret, ping webhook, and view deliveries.
Receiving Webhooks
While we get a POST request to your server endpoint with the details of the event. You can verify this by matching the authorization header with the value you passed when subscribing to notifications and also by checking the HMAC SHA256 signature of the request body.
Why do we need this?
Cron To Go Scheduler comes up with various features which are very unique and reliable some of them are:
- One-Click Migration: It provides easy import of jobs from Heroku Scheduler, Advanced Scheduler, and Temporizes Scheduler for a smooth migration.
- Flexible Scheduling: It supports the Unix cron format so that you can define schedules with a 60 seconds precision allowing you to run your jobs run multiple times a day, on specific days and times of the week or of the month.
- No Code Platform: No code changes are required to add, edit or remove a scheduled job.
- Different Time-Zones Feature: You can schedule your jobs in different time zones.
- Notifications and Webhooks: You can receive notifications directly to your email or via webhooks.
Summary
Now, talking about the summary of this article we have discussed various features and functionalities of Cron To Go Scheduler from talking what it means to discuss about how to create jobs, to scheduling the jobs and managing them, and also how to destroy the jobs and also its features, this is one of the best product created by Crazy Ant Labs which helps you manage all your automated jobs at one place, helps in scaling up your platform easily according to the needs and allow you to monitor and get the quick and correct logs of your jobs at one place.
Conclusions
Cron To Go Scheduler is one of the best and most fully-managed job schedulers for your Heroku applications which is flexible, scalable, and easy to get started with I am really impressed with the product on its features of fully managed, scalability, notifications, and webhook features, security, flexible scheduling, monitoring, and logging features, etc features which are not present in other job scheduling add-ons.
Keep learning and keep growing and also keep exploring more! All the very best!
For more interesting and informative articles and tips follow me on Medium and Linkedin