Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pattern to avoid message counter in a singleton on multi instances applications

I would like to know which pattern is recommended to work with counter representing the number of message processed, with an application that should be stateless.

For example, in an architecture where an application is deployed on several servers, a database is used to store the persistent information (session, etc...). However, such information are not exposed to concurrent updates like a message counter would be. In a mono-instance application we could use singleton, but this is not the case here.

What would be your suggestion to implement a such counter ? Is using a counter a bad design ?

like image 372
Anthony Corrado Avatar asked Nov 09 '22 10:11

Anthony Corrado


1 Answers

I may not be directly answering to your question, but I can give you a reference of a counter service available, which is multi threaded , multi noded, scalable and at the same time considers availability scenarios. Check the jgroups counter service http://jgroups.org/manual/index.html#CounterService.

This can guide you to a set of problems in the scenario of a distributed counter and also act as a live working reference.

like image 161
arunvg Avatar answered Nov 14 '22 22:11

arunvg