Logo Knowledge
  • Product Documentation
  • Insight
  • Developer Center
  • Training
  • Submit a Request
  • Product Documentation
  • Insight
  • Developer Center
  • Training
  • Submit a Request
  1. Acquia Support Knowledge Base
  2. How-To
  3. Best Practices

Elysia Cron on Acquia Cloud

    See more
    • Updated
    • June 15, 2018 16:23

    Cron jobs are required for a number of tasks and general system maintenance, and custom or contributed modules can have their own hook_cron implementations to run maintenance. However, having a badly configured or overloaded configuration can saturate the cron processes and cause serious performance problems.

    Elysia Cron is an extension of the Drupal-standard cron. It allows for greater control over tasks than standard cron, and it offers several ways to add custom cron jobs to your site. Elysia Cron allows you to both run cron frequently on time-sensitive hooks (for example, a scheduler) and to postpone cron for hooks that may need to run infrequently (such as only once a week).

    When used correctly, Elysia Cron is a tool that can both lessen and distribute load and ensure that hooks only execute when necessary.

    Setting up Elysia Cron

    To set up Elysia Cron on Acquia Cloud:

    1. Install the Elysia Cron module on your site. For more information about installing modules, see Installing modules and themes for Drupal 7 or Drupal 8 on drupal.org.
    2. Enable the module on the Modules page (site path) .
    3. Configure Elysia Cron to run hooks frequently or infrequently, as desired. In the admin menu, go to Configuration > Cron (http://[site_URL]/admin/config/system/cron) and set the options accordingly.
    4. Sign in to Acquia, and then go to Scheduled Jobs.
    5. Set the time of execution to be equal to that of your most frequently executed hook, and use the following command (which uses Drush to invoke Elysia Cron):
      drush @[site].[env] -dv -l http://www.example.com elysia-cron run  &>> /var/log/sites/${AH_SITE_NAME}/logs/$(hostname -s)/drush-elysia-cron.log
      

      substituting your site's domain name for "www.example.com".

      The command above will redirect all of the output to a log file located in your website's logs directory. This prevents disk space issues caused by emails sent to the root user and ensures that you can see the troubleshooting information.

    Setting specific time intervals for your site

    To help prevent site overloads from cron, we reccomend that cron.php runs only once every six hours, or use Elysia Cron to set the specific system_cron call to be called only once every 6-12 hours, depending on site traffic. This way, you can also set Elysia Cron to an interval of 15 minutes to allow more granular calls. Setting the default timing to one hour then gives several, 15-minute time blocks to interleave calls and to have only specific actions happening at one time. Reasonable settings for cron.php or Elysia Cron tasks may not always match these specifications. Intervals on your site may be longer or shorter depending on your site's needs.

    As a specific example, the system_cron call that is invoked by cron.php in Drupal effectively clears all cache tables every time it runs. If your cron is being called more often than your page cache is reset, the page cache entries are truncated prematurely. This forces the server to rebuild its caches more often, which can lead to server resource depletion. This can be very problematic when a traffic surge coincides with system cron calls, because it can expose a site to very large amounts of cache warming in a short period of time. Elysia cron can help with this if you set its tasks to coincide with, rather than use, the system cron to clear caches.

    Understanding the Cron time string format is very important to ensure that you are setting up jobs appropriately and not crossing them.

    Adhering to best practices

    Here are some points to remember when you're using Elysia Cron:

    • Ensure that Elysia is running only as frequently as your most frequent hook.
    • Audit your cron usage and ask whether each hook needs to be run as frequently as it is.
    • Ensure that hooks and especially those that have significant database activity, are less frequent, and perhaps are longer running, isolated in their execution and not overlapping other hooks.

    Elysia Cron is not a magic bullet and still has the potential to cause issues on the server if cron is run every minute.

    One final note is that Elysia Cron provides the minimum, maximum, and average times for every cron hook and the number of times it has run. You can use this information as a simple profiling tool to create custom cron hooks that you can test before making changes in a production environment.

    Acquia Products

    • Acquia Cloud

    Topics

    • cron

    Drupal Projects

    • elysia_cron

    External Links

    • elysia_cron
    Avatar
    Dimitris Kaskarelis
    • June 15, 2018 16:23
    • Updated
    • Facebook
    • Twitter
    • LinkedIn
    • Google+

    Was this article helpful?
    0 out of 0 found this helpful
    Have more questions? Submit a request

    Return to top

    Related articles

    • Debugging cron
    • Adding flexibility to your server structure using symlinks
    • Setting up localhost cron jobs
    • Changes to supported libssh2 algorithms
    • Help my drush aliases don't work with Drush 9!

    Support

    Acquia Support Knowledge Base
    • Submit a Request
    • Contact Support
    • Acquia Support Guide
    • Product Documentation
    • System Status

    About Acquia

    • About Us
    • Leadership
    • Board of directors
    • Newsroom
    • Careers
    • Customers
    • Contact Us
    53 State Street, 10th Floor
    Boston, MA 02109
    United States
    Phone: 888-922-7842
    Map: Google Maps
    View other locations
    • Feeds
    • Legal
    • Security Issue?

    Copyright © 2018 Acquia Inc. All Rights Reserved. Drupal is a registered trademark of Dries Buytaert.