Idempotence and Microservices

We often hear about exactly-once message delivery semantics in distributed computing. Even many vendors claim that their message brokers support exactly once semantic but the reality is that it’s impossible to guarantee exactly once message delivery in a distributed system. The exactly-once message delivery guarantee is completely based on the message producer receiving a ACK from the message consumer acknowledging that the message was received. But then the ACK itself is unreliable because it will also travel over the network. It’s quite possible that the ACK could be lost due to a network issue or consumer crash after the message was processed.  

So how can you achieve exactly-once message semantics? The answer to it is idempotence! You will have to make your consumer operation idempotent and set your producer to at-least-once message delivery semantic. With this setup your producer will keep resending the message until a ACK is received from the consumer and your consumer can consume potential duplicate messages without causing any inconsistencies.

From a distributed architecture like Microservices, idempotence should be a key property for every stateful operation. It should not be an afterthought.

Govind Kanshi

Product @ Cosmos DB

8 年

+1 Most of the cloud based Queues(Azure Queue, AWS SQS etc) today support this model. It is responsibility of the client to do idempotent operation and ensure ack reaches within visibility timeout period. Keep writing friend. Waiting for that book :)

要查看或添加评论,请登录

Ravi Tella的更多文章

  • Container Platforms in Azure

    Container Platforms in Azure

    One of the fundamental building blocks for microservice architecture style is the platform. Today, container platforms…

  • Azure Container Services Episode Summary

    Azure Container Services Episode Summary

    Thanks for attending. Following is a summary of the topics we discussed in the second episode: Microservice…

  • Microservice Architecture Episode Summary

    Microservice Architecture Episode Summary

    Thanks for attending. Following is a summary of the topics we discussed in the first episode: Microservice architecture…

    1 条评论

社区洞察

其他会员也浏览了