Help me understand this data sharing concept related to micro-services, I am trying to learn the best practices. Suppose I have a Lambda function (micro-service) ‘A’ that is designed specifically to perform CRUD operations on a DynamoDB table (NoSQL). I have use cases that trigger this function to update specific items in the table. I have another micro-service B that will need to read and write to the same database table. If I were to have this micro-service B directly perform CRUD on the DynamoDB table, that would be a bad idea since now A and B are both configured to operate separately on the table so ACID guarantee is lost. (correct?) To prevent this, would this be the best solution? : Get rid of micro-service B altogether. Whatever event would have triggered B, have it trigger A instead to perform the corresponding database CRUD operations. Would this maintain ACID guarantee? P. S., Posted on stack overflow, no luck :( Edit: going with optimistic locking with versioning
Can you use a message queue? They can operate independently but the message queue can make sure you maintain ACID
Sorry I’m a bit unfamiliar with this approach, do you mean SQS?
Yes, but why can’t you just wrap all functionality in one service, service A. What is the purpose of service b?
Elon told tweeps to get rid of micro services and you should follow suit. What an abomination.
He's can be a great business person but...a software architect, he is not.
Well, does it matter that two conflicting transactions are happening from different services? Even with same service, say service A, two lambda instances could run in parallel. One possible solution is optimistic locking or versioning which DDB supports. Other is kinesis. Get a design review with some senior engineer 😃
Thanks, that’s what I feared, parallel lambda instances may perform the same operation. In my use case, it’s physically impossible for the same transaction to occur on an item but SDM disagreed with the approach of both services sharing the same database. Appreciate the suggestions, I’ll look into them.
Can you explain why ACID guarantee would be lost ? I don't understand.
Exactly. ACID gurantee is provided by the database/database manager not the web server accesing it.
I took it as meaning two conflicting writes will overwrite the same primary or hash key on the table
Both of those microservices should be consolidated into a single monolith
That’s what I’m thinking too , but if consolidated to a monolithic lambda function, would parallel instances create the same problem?
Whose to say one service combined is still not a microservice.
solved problem, use optimistic locking and you’re good
I think this is probably the easiest, quickest path forward, and right.
Optimistic locking with version number. This is the way. Multiple instances of same service or two different services can use this approach
Thanks everyone who replied, looks like optimistic locking with versioning should do the trick
Dude get some rest