<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Singleflight on Nalar</title>
    <link>https://nalar.dev/tags/singleflight/</link>
    <description>Recent content in Singleflight on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 07 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/singleflight/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Suppress Duplicate Concurrent Work in Go with singleflight</title>
      <link>https://nalar.dev/suppress-duplicate-concurrent-work-in-go-with-singleflight/</link>
      <pubDate>Mon, 07 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/suppress-duplicate-concurrent-work-in-go-with-singleflight/</guid>
      <description>&lt;p&gt;A service can become overloaded even when each individual request is reasonable. Imagine a popular product whose cached record expires. Fifty requests arrive almost together, all observe the same cache miss, and all start the same database query.&lt;/p&gt;&#xA;&lt;p&gt;The problem is not ordinary parallelism. Those requests are doing &lt;strong&gt;duplicate work for the same result at the same time&lt;/strong&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;golang.org/x/sync/singleflight&lt;/code&gt; provides a small mechanism for suppressing that duplication inside one Go process. For a given key, one caller performs the work while concurrent callers for the same key wait and receive the same result. Calls using different keys can still perform their own work.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
