开发者

How do I run system wide operations on a cluster of app-servers?

开发者 https://www.devze.com 2023-01-20 00:47 出处:网络
I am running my application on a group of unclustered tomcat servers.It serves restlet web-services.As per restful paradigm, each call is stateless.

I am running my application on a group of unclustered tomcat servers. It serves restlet web-services. As per restful paradigm, each call is stateless.

In this environment, I want the application to periodically review the database for status changes and take action. Since one of the actions is to fire off an email, I want to ensure that I don't check the status of a particular record more than once per review period.

I know that messaging would help with this situation, but I don't understand e开发者_高级运维xactly how. The periodic event can be generated by each instance of the application. Is there a way to debounce similar messages in a message queue? What tool works best for this problem?


You should be able to feed record 'ids' through a message queue. If your apps are listening to the queue, then each message will be picked up by one of the servers and that server can do the checking for that id. The question is the generation of the initial messages. You'll need a feeder process that will query for records to be reviewed and then put the messages on the queue.

Of course, if you're doing to that you could just POST to your restlets by id or multiple Ids and have them to the work that way. It's not async, but it doesn't really need to be async if you're just trying to split the load across nodes. If you have a load balancer in front of your nodes then you could just POST your review request to the load balancer and it will spread the requests amongst the servers.

If you can't use specific record ids... then pick some natural way to partition your data and push that partition key as if you were pushing ids. Depending on the dataset size you could push 'City/State' or 'First two letters of name' or 'region' or whatever will break your dataset into small manageable chunks.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号