Ways to Mitigate Concurrency

The underlying problem is multiple processes working on the same resource, so the mitigation methods look at how to limit exposure. Let’s first look at general concepts and then look more specifically at databases, which usually are at the heart of concurrency issues.

Two simple generic methods, resource locks and atomic operations, are generally good enough to use in most situations. Locking deals directly with concurrency by preventing simultaneous process flows. Atomic operations move operations closer to the resources and enforce serialization at the resource level.

Locking the resources so no one else can run them makes sense if the workflow is not supposed to run concurrently. In the withdrawal example, ...

Get Secure Your Node.js Web Application now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.