How To Atomically Update A Counter Shared Between Docker Instances
Problem
There are some multiple API endpoints (REST services for example) that increased some counter every time API is called. The counter value must be shared between endpoints. They are often dockerized and different containers can be run on different hosts.
Solution
To solve given problem using for example database is overhead. Everything needed is just some distributed lightweight key-value storage with shared lock support. Here are some candidates:
- etcd
- consul, especially consul-lock
- redis
Leave a Comment
Your email address will not be published. Required fields are marked *