AppEngine Task Queue Object Replication on EC2 / Elastic Beanstalk

I’m thinking about switching from AppEngine to EC2 / Elastic Beanstalk, because I need my servers located in the EU [AppEngine does not offer an AFAIK server location option]. I launched the Elastic Beanstalk sample application, which is as good as possible; however, one of the features of AppEngine that I will describe is standalone / cron task queues, as I periodically get a lot of data from other sites. I am wondering what I need to configure on Elastic Beanstalk / EC2 in order to replicate this task queue object, are there any other recommendations, how much work will be required, etc.

Thank!

+5
source share
2 answers

A potential problem with cron services in Beanstalk is that this scheduled command can be called by more than one service if the application runs on more than one instance. Coordination between Tomcat executable instances is required to ensure that only one job is running and that if one of them dies, the cron service will not be interrupted.

How do I implement this:

  • The "config file" cron package is set using WAR. This file should contain frequencies and URLs (since each actual cron is just a call to a specific URL, as AE does)
  • Use one database table to maintain coordination. This requires at least two columns.

tomcat cron, WAR , . , "" , , , "".

  • query(SELECT last_execution_time FROM crontable WHERE command = ?)
  • if(NOW() - last_execution_time < reasonable window) skip;
  • query(UPDATE crontable SET last_execution_time = NOW() WHERE command = ? AND last_execution_time = ?)
  • if(number of rows updated == 0) skip;
  • run task()

, last_execution_time WHERE, , - , SELECT UPDATE, , , .

+1

, , , TyphoonAE AppScale. , App Engine , EC2.

0

All Articles