This is a very similar thread, I’d suggest reading it:
Basically, since you’re going to be running multiple servers of your application and MongoDB doesn’t have transactions, it’s hard to guarantee a lock, but it can be done with some clever programming.