<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Rust on Luther Monson</title>
    <link>https://luth.io/categories/rust/</link>
    <description>Recent content in Rust on Luther Monson</description>
    <generator>Hugo</generator>
    <language>en</language>
    <lastBuildDate>Wed, 14 Oct 2026 23:20:00 -0700</lastBuildDate>
    <atom:link href="https://luth.io/categories/rust/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Composer Without PHP: Embedding vivacity in ePHPm</title>
      <link>https://luth.io/blog/2026/10/composer-without-php-vivacity/</link>
      <pubDate>Wed, 14 Oct 2026 23:20:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/10/composer-without-php-vivacity/</guid>
      <description>&lt;p&gt;The pitch for &lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; is one binary in place of php-fpm, nginx and Redis. There was&#xA;always a hole in it though. To deploy a PHP app you still need to run &lt;code&gt;composer install&lt;/code&gt;. That drags PHP and&#xA;&lt;code&gt;composer.phar&lt;/code&gt; back onto the box or into the container build, just for that one step. &lt;code&gt;ephpm composer install&lt;/code&gt; now&#xA;runs a pure-Rust, Composer-compatible installer called &lt;a href=&#34;https://github.com/Adelagric/vivacity&#34;&gt;vivacity&lt;/a&gt; inside the&#xA;ePHPm binary. One binary serves the app and installs its dependencies. On Windows that works with no PHP installed at&#xA;all. Getting it right took five upstream PRs and a fork. It also took a docs rewrite that took back claims we&amp;rsquo;d already&#xA;made. And I had to teach &lt;code&gt;ephpm&lt;/code&gt; to pretend to be &lt;code&gt;php&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Clustered SQLite in ePHPm, Part 3: CDC Over the Cluster Channel</title>
      <link>https://luth.io/blog/2026/09/clustered-sqlite-cdc-cluster-channel/</link>
      <pubDate>Tue, 15 Sep 2026 21:08:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/09/clustered-sqlite-cdc-cluster-channel/</guid>
      <description>&lt;p&gt;By the end of &lt;a href=&#34;https://luth.io/blog/2026/08/clustered-sqlite-adding-turso/&#34;&gt;Part 2&lt;/a&gt; ePHPm v0.7.0 ran exactly one SQLite engine in&#xA;process. That was Turso, for single-node and clustered mode alike. The sidecar was gone. What I skipped over is how a&#xA;replica actually gets the primary&amp;rsquo;s writes, and what happens when the primary dies with data on it. That&amp;rsquo;s this post.&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://luth.io/blog/2026/08/clustered-sqlite-sqld-sidecar/&#34;&gt;Part 1: Replication by sidecar with sqld&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;&lt;a href=&#34;https://luth.io/blog/2026/08/clustered-sqlite-adding-turso/&#34;&gt;Part 2: Adding Turso&lt;/a&gt;&lt;/li&gt;&#xA;&lt;li&gt;Part 3: CDC over the cluster channel (this post)&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h3 id=&#34;cdc-from-the-engine-itself&#34;&gt;CDC from the engine itself&lt;/h3&gt;&#xA;&lt;p&gt;Turso has change data capture built in. Turn it on for a connection and every committed change lands in a &lt;code&gt;turso_cdc&lt;/code&gt;&#xA;table. Each row has a monotonically increasing &lt;code&gt;change_id&lt;/code&gt;, the table, the rowid, and before/after images of the record.&#xA;The primary tails that table and ships transaction batches. Replicas apply them. That&amp;rsquo;s the whole design. It landed as&#xA;an experimental path in &lt;a href=&#34;https://github.com/ephpm/ephpm/pull/186&#34;&gt;#186&lt;/a&gt; at the end of July. The tailer and applier live&#xA;in litewire (&lt;a href=&#34;https://github.com/ephpm/litewire/pull/10&#34;&gt;litewire#10&lt;/a&gt;).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Calling Rust From PHP Without a Socket, Part 1: The Native Functions</title>
      <link>https://luth.io/blog/2026/09/calling-rust-from-php-without-a-socket-part-1/</link>
      <pubDate>Mon, 14 Sep 2026 20:40:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/09/calling-rust-from-php-without-a-socket-part-1/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; is a single Rust binary that embeds PHP. It carries its own KV store and its own&#xA;SQLite-backed database in the same process. For a long time PHP code could only reach that KV store the same way it&#xA;reaches Redis. It opened a TCP socket to the RESP listener ePHPm runs on localhost, encoded a command and waited for the&#xA;reply. That works, and every PHP Redis client in existence already speaks it. But it is a strange thing to do when the&#xA;hash map you&amp;rsquo;re talking to lives a few pointers away in the same address space.&lt;/p&gt;</description>
    </item>
    <item>
      <title>P99 From 280 ms to 58 ms by Making the Queue Fair</title>
      <link>https://luth.io/blog/2026/09/php-dispatch-fair-queue-p99/</link>
      <pubDate>Mon, 07 Sep 2026 19:45:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/09/php-dispatch-fair-queue-p99/</guid>
      <description>&lt;p&gt;A third-party Laravel runtime comparison put &lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt;&amp;rsquo;s worker mode at the top on&#xA;throughput. It was about 19% ahead of FrankenPHP on &lt;code&gt;/api/static&lt;/code&gt;. It was also at the bottom of the fast group on tail&#xA;latency, with a P99 of 157 ms against FrankenPHP&amp;rsquo;s 57 ms. Best throughput plus the fattest tail is a shape worth&#xA;chasing, because fast execution can&amp;rsquo;t produce it. Making requests faster lowers the mean &lt;em&gt;and&lt;/em&gt; the tail. Only waiting&#xA;can pull them apart. Specifically, unfair waiting.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Stop Running PHP on tokio&#39;s spawn_blocking - Own Your Thread Pool</title>
      <link>https://luth.io/blog/2026/09/own-your-php-thread-pool/</link>
      <pubDate>Fri, 04 Sep 2026 20:30:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/09/own-your-php-thread-pool/</guid>
      <description>&lt;p&gt;For most of its life, &lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; ran every PHP request on tokio&amp;rsquo;s &lt;code&gt;spawn_blocking&lt;/code&gt;&#xA;pool. It works. It passes tests and it serves benchmarks fine. It&amp;rsquo;s the first thing anybody reaches for when they need&#xA;to call blocking code from async Rust. It&amp;rsquo;s also quietly wrong for a language runtime. The problems only show up under&#xA;overload or after a crash. Over the last three weeks it got replaced with a pool of OS threads that ePHPm owns. That&#xA;pool shipped first behind a config flag, then as the default. As of v0.9.0 the &lt;code&gt;spawn_blocking&lt;/code&gt; engine is gone.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Clustered ACME in Production: Three Bugs That Took TLS Down</title>
      <link>https://luth.io/blog/2026/09/clustered-acme-three-bugs/</link>
      <pubDate>Wed, 02 Sep 2026 19:30:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/09/clustered-acme-three-bugs/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; gets its own certificates from Let&amp;rsquo;s Encrypt. In a cluster only one node should&#xA;be talking to the CA. The nodes elect an ACME leader over the shared KV store. The leader orders the cert, and everybody&#xA;else installs it from KV. That all had unit tests and had worked on single nodes for months. Then I tried to move&#xA;wildcard TLS termination for our preview environment off a separate proxy and onto the 3-node cluster itself. In about&#xA;two days it found three separate bugs that each took TLS down. None of them showed up in a unit test. All of them are&#xA;the kind of thing you only learn by putting the feature on real machines.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Middleware in PHP: Compiling It With elephc, Then Not Needing To</title>
      <link>https://luth.io/blog/2026/08/php-middleware-elephc/</link>
      <pubDate>Mon, 31 Aug 2026 20:50:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/08/php-middleware-elephc/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; middleware runs &lt;em&gt;before&lt;/em&gt; PHP. It&amp;rsquo;s a small versioned C ABI, loaded with&#xA;&lt;code&gt;dlopen&lt;/code&gt;, that gets to look at a request and reject it before PHP boots or the request body is read. That&amp;rsquo;s the&#xA;right shape for a gateway. It&amp;rsquo;s the wrong shape for most PHP shops, who want to write their middleware in PHP. This is&#xA;the story of compiling PHP into a native &lt;code&gt;.so&lt;/code&gt; to fit that ABI and finding exactly where it broke. Then I built the lane&#xA;that should have existed in the first place.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Security and Performance Hardening of a Rust Database Proxy</title>
      <link>https://luth.io/blog/2026/08/hardening-rust-database-proxy/</link>
      <pubDate>Thu, 27 Aug 2026 20:30:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/08/hardening-rust-database-proxy/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/ephpm/litewire&#34;&gt;litewire&lt;/a&gt; is the piece of ePHPm that lets PHP apps talk MySQL to a SQLite file. I&#xA;wrote about &lt;a href=&#34;https://luth.io/blog/2026/07/sqlite-production-database-protocol-translation/&#34;&gt;how it works&lt;/a&gt; and about &lt;a href=&#34;https://luth.io/blog/2026/08/faking-mysql-quirks-wordpress/&#34;&gt;the MySQL quirks&#xA;WordPress depends on&lt;/a&gt;. This one is the less visible half of August:&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;an audit pass on litewire&lt;/li&gt;&#xA;&lt;li&gt;a multi-tenant mode that turned a database proxy into a security boundary&lt;/li&gt;&#xA;&lt;li&gt;a performance regression I shipped and then had to go find&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;It&amp;rsquo;s written in Rust. Memory safety is supposed to be the part I don&amp;rsquo;t have to think about, and it mostly is. The&#xA;use-after-free in this story was in a dependency. The worst bug wasn&amp;rsquo;t a memory bug at all.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Rolling Your Own KV Store Instead of Embedding Redis</title>
      <link>https://luth.io/blog/2026/08/rolling-your-own-kv-store/</link>
      <pubDate>Mon, 17 Aug 2026 20:44:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/08/rolling-your-own-kv-store/</guid>
      <description>&lt;p&gt;Every PHP deployment I&amp;rsquo;ve run eventually grew a Redis. Sessions, the WordPress object cache, Laravel&amp;rsquo;s cache and locks,&#xA;rate limiting. &lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; is supposed to be one binary that replaces nginx + php-fpm +&#xA;Redis, so it needed a cache in the box. I didn&amp;rsquo;t want to write one. This post covers why I did anyway and how it&amp;rsquo;s&#xA;built. It also covers the bug that sat in its eviction code from March until last month. Then I compare it against a&#xA;stock Redis on the same machine with &lt;code&gt;redis-benchmark&lt;/code&gt; doing the talking.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Requests That End Wrong: A 200 That Was Really a Crash</title>
      <link>https://luth.io/blog/2026/08/requests-that-end-wrong/</link>
      <pubDate>Thu, 13 Aug 2026 21:14:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/08/requests-that-end-wrong/</guid>
      <description>&lt;p&gt;The scariest response a server can send isn&amp;rsquo;t a 500. It&amp;rsquo;s a 200 that should have been a 500. A crash is loud. The pod&#xA;restarts, an alert fires, somebody looks. A truncated page with a success status code is quiet. Your CDN caches it and&#xA;the health check calls the box healthy. A client parses half a document as if it were the whole thing.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; embeds PHP inside a Rust server. So we own the part of PHP that php-fpm&#xA;normally owns: starting a request, running the script and ending it. Over the last couple of months I&amp;rsquo;ve fixed three&#xA;bugs that all live in that start-and-end code. None of them were in the SAPI I/O callbacks like &lt;code&gt;ub_write&lt;/code&gt; and&#xA;&lt;code&gt;read_post&lt;/code&gt;, where you&amp;rsquo;d expect to find embed bugs. They were in the Zend request lifecycle and in TSRM teardown.&#xA;That&amp;rsquo;s code you never touch when you run PHP behind php-fpm.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Gossip-Based Clustering for PHP Apps</title>
      <link>https://luth.io/blog/2026/08/gossip-clustering-for-php/</link>
      <pubDate>Tue, 04 Aug 2026 20:52:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/08/gossip-clustering-for-php/</guid>
      <description>&lt;p&gt;Most PHP developers never touch clustering primitives. That&amp;rsquo;s by design. PHP is share-nothing. Each request starts&#xA;from zero, and anything shared lives somewhere else. Sessions go in Redis. Cache goes in Redis or Memcached. Locks go&#xA;in Redis. When you run two app servers, the &amp;ldquo;cluster&amp;rdquo; is really two stateless boxes pointed at the same Redis. That&#xA;works until Redis is the thing you&amp;rsquo;re trying not to run.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; has its own KV store in the same process as PHP. On one node that&amp;rsquo;s&#xA;straightforward. On three nodes behind a load balancer, a session written on node 1 has to be readable on node 3. That&#xA;means the nodes have to know about each other and agree on where data lives. This post is how that works as of&#xA;&lt;a href=&#34;https://github.com/ephpm/ephpm/releases/tag/v0.5.2&#34;&gt;v0.5.2&lt;/a&gt;, including the parts I&amp;rsquo;m not happy with yet.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Building a Custom SAPI - How PHP Actually Talks to the Outside World</title>
      <link>https://luth.io/blog/2026/07/building-a-custom-php-sapi/</link>
      <pubDate>Thu, 30 Jul 2026 20:18:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/07/building-a-custom-php-sapi/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;ve only ever run PHP behind nginx, you&amp;rsquo;ve probably never had to think about how &lt;code&gt;echo&lt;/code&gt; reaches a socket. When&#xA;you embed PHP like &lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; does, it&amp;rsquo;s the first thing you have to answer. The answer&#xA;is a SAPI. There is very little written about implementing one. Most of what I know came from reading &lt;code&gt;sapi/cli&lt;/code&gt;,&#xA;&lt;code&gt;sapi/cgi&lt;/code&gt; and &lt;code&gt;sapi/embed&lt;/code&gt; in php-src. Then I found out which parts I&amp;rsquo;d misread. This is the write-up I wanted back&#xA;in March.&lt;/p&gt;</description>
    </item>
    <item>
      <title>SQLite as a Production Database via Protocol Translation</title>
      <link>https://luth.io/blog/2026/07/sqlite-production-database-protocol-translation/</link>
      <pubDate>Sat, 25 Jul 2026 20:40:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/07/sqlite-production-database-protocol-translation/</guid>
      <description>&lt;p&gt;Most of the PHP sites I&amp;rsquo;d put on &lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; don&amp;rsquo;t need a MySQL server. A brochure&#xA;WordPress, an internal Laravel tool, a preview environment that lives for an afternoon. What they do need is something&#xA;that &lt;em&gt;looks&lt;/em&gt; like MySQL, because &lt;code&gt;mysqli&lt;/code&gt; and &lt;code&gt;pdo_mysql&lt;/code&gt; are the only database drivers their code has ever been&#xA;pointed at. I mentioned this in the &lt;a href=&#34;https://luth.io/blog/2026/06/ephpm-pragmatism/&#34;&gt;ePHPm pragmatism post&lt;/a&gt; as a one-paragraph&#xA;&amp;ldquo;because&amp;rdquo;. This is the longer version, now that WordPress 7.0 and Laravel 13 both install and run end to end on it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The Pragmatism of ePHPm - Every Decision Has a &#34;Because&#34; Behind It</title>
      <link>https://luth.io/blog/2026/06/ephpm-pragmatism/</link>
      <pubDate>Sun, 21 Jun 2026 19:05:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/06/ephpm-pragmatism/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt; tagged &lt;a href=&#34;https://github.com/ephpm/ephpm/releases/tag/v0.1.0&#34;&gt;v0.1.0&lt;/a&gt; this&#xA;week, three months after the first commit. Before the feature list grows any further I want to write down how&#xA;decisions get made on it. This is mostly for myself. The easiest way to ruin a project like this is to let it turn&#xA;into a checklist of things other projects have.&lt;/p&gt;&#xA;&lt;p&gt;The pitch is simple. One binary that runs a PHP app with fewer moving parts than nginx + php-fpm + Redis + MySQL. Every&#xA;feature has to trace back to that. If I can&amp;rsquo;t finish the sentence &amp;ldquo;this exists because&amp;hellip;&amp;rdquo; with a real problem from&#xA;running PHP in production, it doesn&amp;rsquo;t go in.&lt;/p&gt;</description>
    </item>
    <item>
      <title>PHP Signal Safety - The Init Ordering Bug Nobody Warns You About</title>
      <link>https://luth.io/blog/2026/04/php-signal-safety-init-ordering/</link>
      <pubDate>Sun, 12 Apr 2026 20:15:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/04/php-signal-safety-init-ordering/</guid>
      <description>&lt;p&gt;Last week I wrote about &lt;a href=&#34;https://luth.io/blog/2026/04/why-rust-for-php-embedding/&#34;&gt;why ePHPm embeds PHP from Rust&lt;/a&gt; and promised the&#xA;signal bug its own post. Here it is. It&amp;rsquo;s the kind of bug where the fix is about ten lines and the explanation is the&#xA;whole post. Nothing in PHP&amp;rsquo;s embed documentation (there&amp;rsquo;s barely any) tells you that initializing PHP has&#xA;process-wide side effects. Those side effects assume PHP is the only thing in the process.&lt;/p&gt;&#xA;&lt;h3 id=&#34;the-setup&#34;&gt;The setup&lt;/h3&gt;&#xA;&lt;p&gt;The first working version of &lt;code&gt;ephpm serve&lt;/code&gt; looked like every async Rust program. It was &lt;code&gt;#[tokio::main]&lt;/code&gt;-style. Build&#xA;the runtime, then inside it load config, initialize PHP and start the HTTP server. PHP requests run on&#xA;&lt;code&gt;spawn_blocking&lt;/code&gt; threads. Simplified:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Why Rust for PHP Embedding (Not Go)</title>
      <link>https://luth.io/blog/2026/04/why-rust-for-php-embedding/</link>
      <pubDate>Sun, 05 Apr 2026 19:40:00 -0700</pubDate>
      <guid>https://luth.io/blog/2026/04/why-rust-for-php-embedding/</guid>
      <description>&lt;p&gt;Go is my primary language and has been for a long time. When I started building &lt;a href=&#34;https://github.com/ephpm/ephpm&#34;&gt;ePHPm&lt;/a&gt;&#xA;a few weeks ago the obvious move was to write it in Go. ePHPm is a PHP application server. It&amp;rsquo;s one binary that embeds&#xA;the real PHP interpreter (&lt;code&gt;libphp&lt;/code&gt;, the Zend engine) and puts an HTTP server, TLS, a KV cache and a database proxy&#xA;around it. A PHP app doesn&amp;rsquo;t need nginx + php-fpm + Redis to run. &lt;a href=&#34;https://frankenphp.dev/&#34;&gt;FrankenPHP&lt;/a&gt; already proved&#xA;the &amp;ldquo;PHP inside a Go web server&amp;rdquo; idea works, and it works well. I wrote it in Rust anyway. This post covers the&#xA;reasoning, and the part of the design that Rust made easier and the part it didn&amp;rsquo;t. It also has some numbers I should&#xA;have measured before I wrote the design doc instead of after.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
