<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Distributed-Systems on Adam Vu</title><link>https://vutg.me/tags/distributed-systems/</link><description>Recent content in Distributed-Systems on Adam Vu</description><generator>Hugo</generator><language>en</language><lastBuildDate>Mon, 27 Nov 2023 00:00:00 +0000</lastBuildDate><atom:link href="https://vutg.me/tags/distributed-systems/index.xml" rel="self" type="application/rss+xml"/><item><title>Redis TTL Distributed Lock for Ticket Reservation</title><link>https://vutg.me/posts/redis-ttl-distributed-lock-for-ticket-reservation/</link><pubDate>Mon, 27 Nov 2023 00:00:00 +0000</pubDate><guid>https://vutg.me/posts/redis-ttl-distributed-lock-for-ticket-reservation/</guid><description>&lt;p&gt;If you&amp;rsquo;ve ever booked concert tickets or a flight, you&amp;rsquo;ve seen that countdown timer: &lt;em&gt;&amp;ldquo;You have 10 minutes to complete your purchase.&amp;rdquo;&lt;/em&gt; That timer isn&amp;rsquo;t just UX theatre — it&amp;rsquo;s a distributed lock with a TTL. This post walks through why that pattern exists and how to implement it with Redis.&lt;/p&gt;
&lt;h2 id="the-problem-with-naive-ticket-booking"&gt;
 The problem with naive ticket booking
 &lt;a class="heading-link" href="#the-problem-with-naive-ticket-booking"&gt;
 &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;
 &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;
 &lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The simplest correct implementation of a booking system uses a database transaction:&lt;/p&gt;</description></item></channel></rss>