简体   繁体   中英

How to start a web process in only one tomcat instance in AWS EC2 autoscaling group

I have a REST web application running in AWS ec2 cloud. I want to ensure that a web process is only started in only one of the tomcat instances in AWS autoscaling group. What is the best way to implement this? I am looking for something like a cloud-wise semaphore or lock that can be acquired and flagged appropriately by a tomcat instance so as to prevent the process from being started again by other tomcat instances. Thanks in advance.

Not sure what you're trying to accomplish, but there are probably better ways to do it.

I think I'd push details of your job into an SES queue, and have all of your instances poll the queue. When there's work to do, one of them can grab the item from SES, do the work, and delete the item when complete.

If you're trying to achieve cron-like functionality, look at scheduled tasks in Lambda - you can run java code, so you don't need to run a server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM