<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Concurrency on Moonstreet</title>
    <link>https://www.moonstreet.nl/tags/concurrency/</link>
    <description>Recent content in Concurrency on Moonstreet</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en</language>
    <copyright>Copyright © 2008–2018, Steve Francia and the Hugo Authors; all rights reserved.</copyright>
    <lastBuildDate>Sat, 28 Nov 2026 00:00:00 +0100</lastBuildDate><atom:link href="https://www.moonstreet.nl/tags/concurrency/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Concurrency refresher: threads, event loops, and syscalls</title>
      <link>https://www.moonstreet.nl/post/concurrency-refresher/</link>
      <pubDate>Sat, 28 Nov 2026 00:00:00 +0100</pubDate>
      
      <guid>https://www.moonstreet.nl/post/concurrency-refresher/</guid>
      <description>
        
          
            &lt;h2 id=&#34;why-this-post&#34;&gt;Why this post&lt;/h2&gt;
&lt;p&gt;I keep mixing up concurrency and parallelism, forgetting what an event
loop actually does, and losing track of where blocking happens. This is
my reference. See also: &lt;a href=&#34;https://www.moonstreet.nl/post/containers-refresher/&#34;&gt;Containers refresher&lt;/a&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;single-threaded-vs-multi-threaded&#34;&gt;Single-threaded vs multi-threaded&lt;/h2&gt;
&lt;h3 id=&#34;single-threaded-one-worker&#34;&gt;Single-threaded: one worker&lt;/h3&gt;
&lt;p&gt;One thing at a time. Task 2 waits for Task 1 to finish.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;Task 1: ████████░░░░░░░░░░░░  (working)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;2&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;Task 2: ░░░░░░░░████████░░░░  (waiting, then working)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;3&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;Task 3: ░░░░░░░░░░░░░░░░████  (waiting, then working)
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;4&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;                ─────────────────────►
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;ln&#34;&gt;5&lt;/span&gt;&lt;span class=&#34;cl&#34;&gt;                          time
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;multi-threaded-multiple-workers&#34;&gt;Multi-threaded: multiple workers&lt;/h3&gt;
&lt;p&gt;All tasks run at the same time - if you have enough CPU cores.&lt;/p&gt;
          
          
        
      </description>
    </item>
    
    <item>
      <title>Django &#43; Daphne &#43; Celery: handling slow tasks without blocking</title>
      <link>https://www.moonstreet.nl/post/django-celery-daphne/</link>
      <pubDate>Sat, 28 Nov 2026 00:00:00 +0100</pubDate>
      
      <guid>https://www.moonstreet.nl/post/django-celery-daphne/</guid>
      <description>
        
          
            &lt;h2 id=&#34;the-problem&#34;&gt;The problem&lt;/h2&gt;
&lt;p&gt;You have a Django app served by Daphne. A user triggers a slow task -
fetching thousands of records from an external API and uploading them to
object storage. The task takes minutes.&lt;/p&gt;
&lt;p&gt;During those minutes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Health checks get no response.&lt;/li&gt;
&lt;li&gt;Other users get no response.&lt;/li&gt;
&lt;li&gt;Kubernetes decides the pod is dead and kills it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The fix is not more CPU or RAM. The fix is Celery.&lt;/p&gt;
&lt;p&gt;See also: &lt;a href=&#34;https://www.moonstreet.nl/post/concurrency-refresher/&#34;&gt;Concurrency refresher&lt;/a&gt; for the
theory behind this.&lt;/p&gt;
          
          
        
      </description>
    </item>
    
  </channel>
</rss>
