0

I am planning on building an application using Node JS that stores and retrieves its data from a postgresql database. My concern is that as the application scales will I run into query contention on the database? If I have perhaps a dozen or more Node JS instances talking to the database at once updating different tables and fields eventually something somewhere will collide. How can I prevent this from happening or what is the best way to mitigate it ?

1 Answer 1

1

...at once updating different tables and fields eventually something somewhere will collide. How can I prevent this from happening

For that PostgreSQL supports database transactions and locks.

Sign up to request clarification or add additional context in comments.

3 Comments

Worth warning about deadlocks here though. For the uninitiated, a deadlock occurs when a process gains a lock on table A, and does some heavy duty processing there. Meanwhile, another process has a lock on table B. The first process then needs access to table B, so it starts waiting. The second process then moves on to needing table A. Neither process can proceed until the other finishes. Postgres detects this, and kills both processes. Rolling back transactions in both if they are in transactions.
@Scoots No spoilers! ;)
amazing answers ! Thanks !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.