Safe, Sequential And Scalable Counters In Mnesia

前端 未结 4 1479
旧时难觅i
旧时难觅i 2021-02-11 04:44

I am writing an application in Erlang/OTP and want to use sequential counters on a version recording system.

I first implemented them with

mnesia:dirty_update_count         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-11 05:34

    Perhaps the simplest answer is what you are looking for, simply by getting a write lock (for replicated syncing) and making a transactional function that gets the current value of the counter, increments it and saves it back to the DB. Certainly you will get increased overhead as the system scales, but I would recommend writing a server that does this for you and run that on a subset of the nodes, so the lock contention is not directly linked with the cluster size.

提交回复
热议问题