[{"data":1,"prerenderedAt":177},["ShallowReactive",2],{"term-e\u002Fexactly-once-semantics":3,"related-e\u002Fexactly-once-semantics":163},{"id":4,"title":5,"acronym":6,"body":7,"category":144,"description":145,"difficulty":146,"extension":147,"letter":148,"meta":149,"navigation":150,"path":151,"related":152,"seo":157,"sitemap":158,"stem":161,"subcategory":6,"__hash__":162},"terms\u002Fterms\u002Fe\u002Fexactly-once-semantics.md","Exactly-Once Semantics",null,{"type":8,"value":9,"toc":138},"minimark",[10,15,19,23,26,30,127,131,134],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 - The Vibe Check",[16,17,18],"p",{},"In a distributed system, messages can get lost, or worse, delivered twice. Exactly-once semantics is the promise that no matter how many retries or crashes happen along the way, each event still ends up processed exactly once, not zero times, not five times. It's one of the hardest promises in distributed computing to actually keep, and most systems that claim it are really faking it with idempotency tricks underneath.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Exactly-once semantics guarantees that a message or event is processed and its effects applied precisely one time, even in the presence of retries, failures, or duplicate delivery. True exactly-once delivery is generally considered impossible across an unreliable network, so systems like Kafka achieve effectively-once processing by combining at-least-once delivery with idempotent producers or transactional commits.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-javascript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","\u002F\u002F Kafka producer config for effectively-once semantics\nconst producer = kafka.producer({\n  idempotent: true,\n  transactionalId: 'orders-producer-1'\n});\n","javascript","",[38,39,40,49,80,97,115],"code",{"__ignoreMap":36},[41,42,45],"span",{"class":43,"line":44},"line",1,[41,46,48],{"class":47},"sHwdD","\u002F\u002F Kafka producer config for effectively-once semantics\n",[41,50,52,56,60,64,67,70,74,77],{"class":43,"line":51},2,[41,53,55],{"class":54},"spNyl","const",[41,57,59],{"class":58},"sTEyZ"," producer ",[41,61,63],{"class":62},"sMK4o","=",[41,65,66],{"class":58}," kafka",[41,68,69],{"class":62},".",[41,71,73],{"class":72},"s2Zo4","producer",[41,75,76],{"class":58},"(",[41,78,79],{"class":62},"{\n",[41,81,83,87,90,94],{"class":43,"line":82},3,[41,84,86],{"class":85},"swJcz","  idempotent",[41,88,89],{"class":62},":",[41,91,93],{"class":92},"sfNiH"," true",[41,95,96],{"class":62},",\n",[41,98,100,103,105,108,112],{"class":43,"line":99},4,[41,101,102],{"class":85},"  transactionalId",[41,104,89],{"class":62},[41,106,107],{"class":62}," '",[41,109,111],{"class":110},"sfazB","orders-producer-1",[41,113,114],{"class":62},"'\n",[41,116,118,121,124],{"class":43,"line":117},5,[41,119,120],{"class":62},"}",[41,122,123],{"class":58},")",[41,125,126],{"class":62},";\n",[11,128,130],{"id":129},"when-youll-hear-this","When You'll Hear This",[16,132,133],{},"\"Kafka's transactional producer gives us exactly-once semantics end to end.\" \u002F \"We faked exactly-once with an idempotency key instead of fighting the framework.\"",[135,136,137],"style",{},"html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":51,"depth":51,"links":139},[140,141,142,143],{"id":13,"depth":51,"text":14},{"id":21,"depth":51,"text":22},{"id":28,"depth":51,"text":29},{"id":129,"depth":51,"text":130},"backend","In a distributed system, messages can get lost, or worse, delivered twice.","advanced","md","e",{},true,"\u002Fterms\u002Fe\u002Fexactly-once-semantics",[153,154,155,156],"At-Least-Once Delivery","Idempotency","Apache Kafka","Idempotency Key",{"title":5,"description":145},{"changefreq":159,"priority":160},"weekly",0.7,"terms\u002Fe\u002Fexactly-once-semantics","9r1sBgTQLEtZ-0Vk3t8B3QSOEpDCSjm93ipm1wS4jXI",[164,168,171,174],{"title":155,"path":165,"acronym":6,"category":144,"difficulty":166,"description":167},"\u002Fterms\u002Fa\u002Fapache-kafka","intermediate","Kafka is like the world's most reliable postal service, except instead of delivering letters, it delivers millions of messages per second and never loses o",{"title":153,"path":169,"acronym":6,"category":144,"difficulty":146,"description":170},"\u002Fterms\u002Fa\u002Fat-least-once-delivery","At-least-once delivery guarantees every message gets delivered... but maybe more than once. If the acknowledgment gets lost, the message gets sent again.",{"title":154,"path":172,"acronym":6,"category":144,"difficulty":166,"description":173},"\u002Fterms\u002Fi\u002Fidempotency","Idempotency means doing the same thing twice gives you the same result as doing it once.",{"title":156,"path":175,"acronym":6,"category":144,"difficulty":166,"description":176},"\u002Fterms\u002Fi\u002Fidempotency-key","An idempotency key is a unique ID you attach to a request so the server knows if it's a duplicate.",1792528083315]