Search code examples
node.jsormthread-safetywaterline

Is Waterline ORM thread safe by design?


Is waterline ORM thread safe? Or should we implement a singleton data-layer above it in our app to achieve thread safety?


Solution

  • If you are using Node clusters, every cluster is an independent process, so every cluster has already its own memory that is not shared with other clusters.
    If you have some critical sections to lock ,you should lock them using a cross-process semaphore library like redis-mutex-semaphore or live-mutex (Not tested on windows).
    Note that many of distributed semaphore librairies relay on a third party like redis for redis-mutex-semaphore library.