network programming - Synchronising across networked python apps -
i hoping isn't vague question...
i writing python app have multiple instances of allow load balancing , redundancy take place.
each instance need able read , write backend database, raises issue of 2 'gateways' trying update same item.
can recommend approach (not looking code solution) this?
thank in advance ;)
you have 2 ways avoid loosing consistency on data set:
- either use lock mechanisms between python processes,
- or use transactions when accessing database.
lock mechanisms must based on inter-process communications. depending on underlying operating system, may have access shared memory (think test-and-set primitive, use shared memory such goal), semaphores , others tools. see python ipc, instance: https://docs.python.org/2/library/ipc.html
transactions depend on database. instance, traditional sql database, can configure behaviours according needs: auto-commit, optimistic concurrency, etc...
Comments
Post a Comment