R
R
Rrooom2014-08-23 16:07:49
Python
Rrooom, 2014-08-23 16:07:49

How to lock a resource in an asynchronous application?

There is a service on tonado and postgres.
Tornado receives data, takes data from the database, processes it, and writes to the database. Let the data be some "quantity". Which is always limited. And it shouldn't go negative.
The problem is... the data is very sensitive. Already now, when I loaded the application, the "quantity" went into the red. I foresee even more problems when the service is launched in production - 16 instances.
How to make a locking mechanism? So that until one request completes its actions, others could not read? And at the same time not to slide down from the situation when 16 users put the service down?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
_
_ _, 2014-08-23
@AMar4enko

SELECT ... FOR UPDATE?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question