KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
We are hosting our website in AWS. We currently have 3 EC2 instances in one cluster, using the AWS load balancer. The servers have linux, apache, java, mysql, and tomcat 6.0. We are making a decision on how to set up a task to run every hour. The obvious place to do this is in the Java code, but there is one problem. The problem is that since we have 3 instances in the cluster (all are identical), the task will run 3 times on the hour, instead of once an hour, once per instance. I have a few ideas to overcome this but was hoping that there is a better, possibly an industry standard, on how to manage this. One idea is to store in the DB that it has already run. The task will see that it has already ran today or not. I see bugs there though. The other idea was to use cron installed on one of the instances in the native OS, outside of the code in Tomcat. This would use wget to call a webpage which calls a java method. Since that would only call one of the instances, it should only run once. Both ways seem like hacks and prone to bugs. Is there a real way to do this?
Tags (comma-separated)
Save Edits
Cancel