<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Anatolii</title>
    <description>The latest articles on DEV Community by Anatolii (@econ__11).</description>
    <link>https://dev.clauneck.workers.dev/econ__11</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3997488%2Fdd3aa5cd-efc2-40fd-b347-935f3a853b05.jpg</url>
      <title>DEV Community: Anatolii</title>
      <link>https://dev.clauneck.workers.dev/econ__11</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.clauneck.workers.dev/feed/econ__11"/>
    <language>en</language>
    <item>
      <title>Why I set `dynamic: false` on my Elasticsearch audit-log stream</title>
      <dc:creator>Anatolii</dc:creator>
      <pubDate>Wed, 24 Jun 2026 12:31:00 +0000</pubDate>
      <link>https://dev.clauneck.workers.dev/econ__11/why-i-set-dynamic-false-on-my-elasticsearch-audit-log-stream-206k</link>
      <guid>https://dev.clauneck.workers.dev/econ__11/why-i-set-dynamic-false-on-my-elasticsearch-audit-log-stream-206k</guid>
      <description>&lt;p&gt;Most Elasticsearch advice is about getting more out of it: better relevance, faster queries, smarter aggregations. This is about the opposite. It's a place where I deliberately told Elasticsearch to do less, and why that was the right call.&lt;/p&gt;

&lt;p&gt;👌 The short version: I built an audit-log pipeline, a record of what changed on our entities over time, and I set &lt;code&gt;dynamic: false&lt;/code&gt; on the mapping so Elasticsearch would stop trying to index every field it had never seen before. Run an append-only log of arbitrary change events through Elasticsearch with the default settings and the mapping grows without bound. A growing mapping doesn't announce itself. You find out it's a problem once it's already hurting you.&lt;/p&gt;




&lt;h2&gt;
  
  
  What we were building
&lt;/h2&gt;

&lt;p&gt;The job was an audit log: track what changed on records over time. An entity gets created, updated, deleted, and we write an event describing that change. Which entity, what fields, the old and new values, who did it and when. It's append-only by nature. You never update an audit event, you only add more of them. And you read it far less often than you write it, mostly when someone asks "what happened to this record, and when?"&lt;/p&gt;

&lt;p&gt;That shape matters, because it's the shape that makes Elasticsearch's friendliest default turn against you.&lt;/p&gt;

&lt;h2&gt;
  
  
  The default that will quietly hurt you
&lt;/h2&gt;

&lt;p&gt;By default, Elasticsearch uses &lt;em&gt;dynamic mapping&lt;/em&gt;. A document arrives with a field Elasticsearch hasn't seen, it guesses a type, and it adds that field to the index mapping automatically. For most use cases this is genuinely great. You throw documents at it, it figures out the schema, you move on.&lt;/p&gt;

&lt;p&gt;Now think about what that means for an audit log.&lt;/p&gt;

&lt;p&gt;An audit log's payload is, by design, the union of every field that has ever changed on every entity you track. Every entity type, every column, every nested attribute. Anything that can change is something that can show up in a change event. Run that through dynamic mapping and Elasticsearch faithfully adds a field to the mapping for each new leaf it sees. The mapping stops describing one document shape and slowly accretes every shape your application has ever produced.&lt;/p&gt;

&lt;p&gt;A normal index has a roughly stable set of fields. An audit log over a real application does not. It trends toward "every field in the system, ever." So the feature that's a convenience everywhere else is, for this one data shape, a slow leak that you only opt out of if you saw it coming.&lt;/p&gt;

&lt;h2&gt;
  
  
  What a mapping explosion actually costs
&lt;/h2&gt;

&lt;p&gt;"Mapping explosion" sounds dramatic, so I want to be concrete about the mechanism. The cost is real and it isn't obvious.&lt;/p&gt;

&lt;p&gt;The mapping is part of the cluster state, the metadata that lives in memory and is replicated across the cluster. It isn't free per field. As the field count climbs into the thousands, that metadata grows, cluster-state updates get heavier, and the cost is paid by the whole cluster, not just the one index. That's why Elasticsearch ships with a default limit of 1,000 fields per index (&lt;code&gt;index.mapping.total_fields.limit&lt;/code&gt;). The limit isn't arbitrary. It's a guardrail against exactly this.&lt;/p&gt;

&lt;p&gt;When you hit that limit, you don't get a gentle warning. Indexing fails and the document is rejected. For an audit log that's a nasty failure mode, because the whole point of the system is that it captures everything, and the way dynamic mapping breaks is by silently raising the field count until writes start getting rejected. You can "fix" it by raising the limit, but that's treating the symptom. You're buying time until a bigger number while making every cluster-state update heavier along the way.&lt;/p&gt;

&lt;p&gt;There's a second, subtler cost before you ever hit the limit. Every dynamically mapped field is a field Elasticsearch builds indexing structures for. You're paying, in memory and in indexing work, to make fields queryable that, for an audit log, almost nobody will ever query directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  The decision: &lt;code&gt;dynamic: false&lt;/code&gt; 🥳
&lt;/h2&gt;

&lt;p&gt;So I locked the mapping down. The setting that matters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mappings"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"dynamic"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"properties"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"@timestamp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;  &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"date"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"entity_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"keyword"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"entity_type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"keyword"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"trace_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"keyword"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"author"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"dynamic"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"properties"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;       &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"keyword"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"username"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"keyword"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"source"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;   &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"keyword"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
          &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt;     &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"text"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the same &lt;code&gt;dynamic: false&lt;/code&gt; on the nested &lt;code&gt;author&lt;/code&gt; object. The author of a change is a small, known set of fields, id, username, source, name, so I map those and lock that sub-object down too. Nothing unexpected creeps in there either.&lt;/p&gt;

&lt;p&gt;It's worth being precise about what &lt;code&gt;dynamic: false&lt;/code&gt; does, because there are three options and they aren't the same:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;dynamic: true&lt;/code&gt; (the default): unknown fields get auto-mapped and become searchable. This is the explosion path.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dynamic: false&lt;/code&gt;: unknown fields are stored in &lt;code&gt;_source&lt;/code&gt; and returned with the document, but they aren't added to the mapping and aren't indexed, so you can't search or aggregate on them. The document is accepted. The field just isn't queryable.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dynamic: strict&lt;/code&gt;: a document containing an unknown field is rejected outright.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I chose &lt;code&gt;false&lt;/code&gt;, not &lt;code&gt;strict&lt;/code&gt;, on purpose. &lt;code&gt;strict&lt;/code&gt; would have meant that every time the application started tracking changes on a new field, the audit pipeline would start rejecting events until someone updated the mapping. That couples the audit log's health to every schema change upstream. It's fragile, and it defeats the point of an audit log, which is to never drop a change event. &lt;code&gt;false&lt;/code&gt; keeps the full payload in &lt;code&gt;_source&lt;/code&gt;, so the complete record of what changed is still there and still retrievable. It just isn't turned into a searchable field. I explicitly map the handful of fields I actually query on, the entity identity, the timestamp, a trace id that ties an event back to the request that caused it, and who made the change, and everything else rides along in &lt;code&gt;_source&lt;/code&gt; without bloating the mapping.&lt;/p&gt;

&lt;p&gt;That's the whole trade in one sentence: I keep the data, I drop the ability to query arbitrary fields, and in exchange the mapping stays small and the cluster stays healthy.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trade I accepted
&lt;/h2&gt;

&lt;p&gt;I want to be honest about the cost, because &lt;code&gt;dynamic: false&lt;/code&gt; isn't free.&lt;/p&gt;

&lt;p&gt;What I gave up: I can't run an ad-hoc query like "find every audit event where some arbitrary nested field changed to value X," because that field was never indexed. If I genuinely needed that, I'd have to map the field explicitly, ahead of time.&lt;/p&gt;

&lt;p&gt;Why it was the right trade for this data: an audit log is overwhelmingly read by entity. The real query is "show me the change history for this record," and that's served by the fields I did map, the entity type and id and timestamp. The rare case where someone wants the full detail of a specific event is served by &lt;code&gt;_source&lt;/code&gt;, which still has everything. I'm not losing information. I'm losing a query pattern I don't actually use, in exchange for a system that doesn't degrade as the application grows.&lt;/p&gt;

&lt;p&gt;The general principle I took from it: dynamic mapping is a convenience that assumes a bounded set of fields. The moment your data's field set is unbounded by design, and an audit log is the textbook example, that convenience works against you, and you should opt out deliberately rather than discover the field limit in production.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this lives: data streams, not a plain index
&lt;/h2&gt;

&lt;p&gt;One more piece, because "set &lt;code&gt;dynamic: false&lt;/code&gt;" is only half the design. An audit log is append-only and time-ordered. You write a continuous stream of events and basically never modify what's already there. That's the case Elasticsearch data streams are built for.&lt;/p&gt;

&lt;p&gt;Instead of writing to a single ever-growing index, a data stream sits in front of a series of backing indices and rolls over to a new one as they grow, while you read and write through one stable name. You configure the whole thing, the &lt;code&gt;dynamic: false&lt;/code&gt; mapping included, once, in an index template, and every backing index the stream creates inherits it. So the mapping discipline isn't something you have to remember to reapply. It's in the template, and every new index the stream rolls into starts out locked down.&lt;/p&gt;

&lt;p&gt;That pairing is the actual design: a data stream for append-only, time-series writes, plus an index template that carries the &lt;code&gt;dynamic: false&lt;/code&gt; mapping so the field set stays controlled no matter how long the log runs or how many indices it rolls through.&lt;/p&gt;




&lt;h2&gt;
  
  
  The takeaway 📝
&lt;/h2&gt;

&lt;p&gt;If you're putting an append-only log into Elasticsearch, audit events, entity-change history, anything where the field set grows with your application, decide your mapping strategy before the field count forces the decision for you. The default will happily index every field your app has ever produced, and the way you find out is the day writes start failing.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dynamic: false&lt;/code&gt; plus a small set of explicitly mapped query fields, sitting on a data stream driven by an index template, is the configuration I'd reach for again without thinking twice. It's a small, boring decision, and boring is what you want here. It's the difference between an audit log that quietly runs for years and one that turns into a cluster-state problem you have to firefight later.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>database</category>
      <category>dataengineering</category>
    </item>
    <item>
      <title>From PHP to Go: what took me longest to rewire</title>
      <dc:creator>Anatolii</dc:creator>
      <pubDate>Mon, 22 Jun 2026 20:16:03 +0000</pubDate>
      <link>https://dev.clauneck.workers.dev/econ__11/from-php-to-go-what-took-me-longest-to-rewire-2nfn</link>
      <guid>https://dev.clauneck.workers.dev/econ__11/from-php-to-go-what-took-me-longest-to-rewire-2nfn</guid>
      <description>&lt;p&gt;I wrote PHP for about seven years before Go became my main language — Laravel for five of them, Yii2 and plain MVC before that. Then I led the rebuild of a Laravel monolith into Go microservices, and later joined a marketplace-product, to work on Go services in production. So I didn't come to Go from a tutorial. I came to it carrying a decade of PHP habits, and I had to ship real systems while unlearning them 🥲&lt;/p&gt;

&lt;p&gt;The syntax was the easy part. You can read Go in an afternoon. What took months to rewire were the &lt;strong&gt;&lt;em&gt;mental models&lt;/em&gt;&lt;/strong&gt; — the default assumptions PHP had built into me about how a program is shaped, how errors move, how a request lives and dies. Some of those assumptions are actively wrong in Go, and they don't announce themselves 😫. They show up as code that compiles, passes review on a tired day, and then behaves in a way you didn't predict 😳&lt;/p&gt;

&lt;p&gt;This is a list of the ones that took me longest. Each is tied to something I actually built, not a textbook example.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. There is no &lt;code&gt;try/catch&lt;/code&gt;, and that is a feature, not a missing one
&lt;/h2&gt;

&lt;p&gt;In PHP I threw exceptions and caught them somewhere up the stack — often far up the stack, in a global handler that turned anything unexpected into a 500. The mental model is: errors travel invisibly until someone decides to look. Most of my code didn't think about failure at all; failure was something that happened to the call stack, above me.&lt;/p&gt;

&lt;p&gt;Go inverts this. A function that can fail returns an &lt;code&gt;error&lt;/code&gt; as its last value, and you, the caller, deal with it right there 🥳:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;repo&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;FindUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Errorf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"find user %d: %w"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My first instinct was that this was noise. Coming from &lt;code&gt;try { ... } catch (\Throwable $e) {}&lt;/code&gt;, the &lt;code&gt;if err != nil&lt;/code&gt; after every call felt like ceremony 😅. It took me a while — and a few production incidents — to understand what it buys you: failure becomes part of the visible control flow. You can't not see that a call can fail, because the error is sitting in a variable in front of you. The decision "swallow this, retry this, or pass it up" is made at the exact place that has the most context to make it.&lt;/p&gt;

&lt;p&gt;The habit that took longest to kill was the urge to build a catch-all. In PHP I leaned on the global exception handler. In Go I had to learn to wrap errors with context as they go up (&lt;code&gt;%w&lt;/code&gt; and a short message at each layer) so that by the time an error reaches the top, the message is a breadcrumb trail — "find user 42: query timeout: ..." — instead of a stack trace I have to decode 🥳&lt;/p&gt;

&lt;p&gt;This paid off in a real incident. An order wouldn't create, and the wrapped error that came out the top read essentially like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;create order 8842: charge payment: gateway timeout after 5s
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That one line pointed straight at the cause — a downstream service we were calling to charge the payment was misbehaving and timing out. No log spelunking, no guessing which layer failed. The message had assembled itself from each layer adding a little context on the way up, and by the time it reached me it told me exactly where to look. In my PHP days that would have surfaced as a generic 500 and a stack trace I'd have to read backwards 🥲&lt;/p&gt;

&lt;p&gt;What I'd tell a PHP developer: stop looking for &lt;code&gt;try/catch&lt;/code&gt;. The &lt;code&gt;if err != nil&lt;/code&gt; &lt;em&gt;is&lt;/em&gt; your error handling, and writing it everywhere forces you to actually think about each failure instead of deferring all of them to one handler that prints "Something went wrong." 👍&lt;/p&gt;




&lt;h2&gt;
  
  
  2. The request is not the unit of life anymore
&lt;/h2&gt;

&lt;p&gt;This was the deepest shift, and the one I underestimated most.&lt;/p&gt;

&lt;p&gt;In PHP, the model is shared-nothing per request. A request comes in, the framework boots, you handle it, the process tears everything down, and the next request starts from a clean slate. Memory leaks barely matter — the worst case is one request. Global state is reset for you. You almost never think about two requests touching the same variable, because in the classic PHP model they physically can't; they're separate processes 🙂&lt;/p&gt;

&lt;p&gt;Go is the opposite. The process is long-lived. One Go binary stays up and handles thousands of requests concurrently, in the same memory, often literally at the same time across goroutines. The moment I internalized that, a whole category of bugs I'd never had to think about became something I had to actively watch for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A package-level variable is now shared across every concurrent request. In PHP that was a per-request convenience. In Go it's a data race waiting to happen.&lt;/li&gt;
&lt;li&gt;A map written to by two requests at once will crash the whole process — not the one request, the &lt;strong&gt;whole binary&lt;/strong&gt;. The PHP blast radius of "one bad request" doesn't exist; a panic from a concurrent map write can take down everything in flight 😢&lt;/li&gt;
&lt;li&gt;Resources you open have to be closed deliberately, because nothing is tearing the world down after each request to clean up after you.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of those are exotic. They're the baseline things you now have to keep in your head on every change, because the language and the runtime won't reset the world for you between requests the way PHP did. The point isn't a specific disaster — it's that a whole class of failure that was simply impossible in the per-request PHP model is now possible by default, and avoiding it is on you 🧐&lt;/p&gt;

&lt;p&gt;Rewiring this meant changing my default question. In PHP I asked "what does this request need?" In Go I had to ask "what happens when a thousand of these run at once, in the same memory?" That question is now automatic, but it took real production exposure to make it automatic.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Concurrency is in the language, so you own correctness
&lt;/h2&gt;

&lt;p&gt;PHP's concurrency story, for most of my career, was "use a queue and more workers." Parallelism lived outside the language — in the infrastructure, in separate processes, in something like a job queue. I rarely reasoned about two things touching the same data in the same memory, for the same reason as above: they usually couldn't.&lt;/p&gt;

&lt;p&gt;Go puts concurrency in my hands directly. &lt;code&gt;go someFunc()&lt;/code&gt; starts a goroutine 👍. Channels pass data between them 👍. It's genuinely powerful, and it's the reason Go fit the kind of services we were building 🥳. But the power comes with ownership: the language hands you concurrency and then holds you responsible for correctness. A goroutine that writes to a shared structure without coordination is a bug that may pass every test on your machine and only surface under real load 🥲.&lt;/p&gt;

&lt;p&gt;Two specific habits I had to build that PHP never required:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reach for the race detector early.&lt;/strong&gt; In my own projects I run tests with &lt;code&gt;-race&lt;/code&gt;, and it's caught real races a few times now — races I'd never have spotted by reading the code, because they only show up when goroutines happen to interleave the wrong way at run time 🙏. In PHP I never had a tool like that, because I never had the problem.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decide deliberately how goroutines share data&lt;/strong&gt; — pass copies, use a channel, or protect shared state with a mutex — instead of just sharing a variable because it's in scope. "It's in scope so I'll use it" is a perfectly safe PHP habit and a dangerous Go one ☝️&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The mental shift: in PHP, concurrency was an infrastructure concern I delegated. In Go, it's a &lt;em&gt;code&lt;/em&gt; concern I own line by line.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. &lt;code&gt;context.Context&lt;/code&gt; is the spine, not a parameter you tolerate
&lt;/h2&gt;

&lt;p&gt;When I first saw &lt;code&gt;ctx context.Context&lt;/code&gt; as the first argument of seemingly every function, I treated it the way I'd treated similar things in PHP frameworks — boilerplate to thread through and otherwise ignore. That was wrong, and it cost me before it clicked 😅.&lt;/p&gt;

&lt;p&gt;In PHP, the request was bounded for me. When the client disconnected or the request finished, the process ended; I never had to manually propagate "this work should stop now." In a long-lived Go service, nothing stops your work automatically. If a client gives up, or a request times out, the goroutines doing the work for that request will happily keep running — querying the database, calling other services — for no one. &lt;code&gt;context.Context&lt;/code&gt; is how cancellation and deadlines travel down through every call so that work can actually be stopped and resources released.&lt;/p&gt;

&lt;p&gt;Once I understood it as &lt;strong&gt;&lt;em&gt;the cancellation and deadline spine of the request&lt;/em&gt;&lt;/strong&gt;, passing &lt;code&gt;ctx&lt;/code&gt; everywhere stopped feeling like boilerplate and started feeling like the thing that keeps a long-lived service from leaking work 🙌. In a marketplace with a lot of concurrent traffic, "stop doing work nobody is waiting for" is not a nicety; it's how the service stays healthy under load.&lt;/p&gt;

&lt;p&gt;A concrete way I use it: when I call another service, I put a deadline on the context — lets say around 5 seconds. If that downstream call runs past the deadline, the context fires, I stop waiting, and I return a clean degraded response to the client — something like "we can't process this right now, please try again in a few minutes" 🤔 — instead of leaving the request hanging forever and tying up resources behind it. That's the whole point of the spine: the deadline travels down with the call, and when it expires everyone downstream can give up together. Under load, failing fast and politely is far better than hanging, and &lt;code&gt;context.Context&lt;/code&gt; is what makes that possible without threading a timeout flag through every function by hand 👌&lt;/p&gt;




&lt;h2&gt;
  
  
  5. Composition over inheritance — and Laravel had hidden how much I leaned on inheritance
&lt;/h2&gt;

&lt;p&gt;This one was subtle because I didn't realize how much of my PHP design instinct was inheritance-shaped until Go took the option away 😎&lt;/p&gt;

&lt;p&gt;In Laravel, so much is built on extending base classes — your controllers, your models, your form requests all inherit a large amount of behavior from the framework. The "right" way to add capability was often "extend the base class." That instinct is invisible while you have it; it just feels like how code is organized.&lt;/p&gt;

&lt;p&gt;Go has no class inheritance (in usual meaning). It has struct embedding and, more importantly, interfaces that are satisfied &lt;em&gt;implicitly&lt;/em&gt; — a type implements an interface just by having the right methods, with no &lt;code&gt;implements&lt;/code&gt; keyword and no declared relationship. Coming from PHP's explicit &lt;code&gt;class Foo extends Bar implements Baz&lt;/code&gt;, implicit interfaces felt almost too loose at first. Where's the contract? Who guarantees it? 🤯&lt;/p&gt;

&lt;p&gt;What rewired it for me was using this pattern consistently at the marketplace-project. There, I define interfaces at the consumer for repositories, for internal services, and for external services — a small interface declared &lt;em&gt;where it's used&lt;/em&gt;, and any type with the right methods satisfies it. The consumer declares only the handful of methods it actually needs; the provider doesn't have to know the interface exists. That's a very different shape from "everyone extends the framework's base class," and it produces code where dependencies are small and swapping an implementation is trivial — a real database behind a repository in production, a fake satisfying the same interface in a test. Writing tests stopped requiring a whole framework's worth of scaffolding and started being a matter of passing in a small fake that fits the interface 🥳&lt;/p&gt;

&lt;p&gt;Coming to that from years of Laravel's &lt;code&gt;extends&lt;/code&gt;-everything instinct is exactly why I can feel how different it is. A developer who only ever wrote Go might take implicit interfaces for granted; I had to consciously give up the inheritance reflex to get there.&lt;/p&gt;




&lt;h2&gt;
  
  
  6. Explicit beats clever, and the language enforces it
&lt;/h2&gt;

&lt;p&gt;PHP let me be clever. Dynamic typing, magic methods, arrays that were lists and maps and objects depending on my mood — a lot of expressiveness, and a lot of rope. I wrote some clever PHP I was proud of and later could not fully reconstruct why it worked 😅&lt;/p&gt;

&lt;p&gt;Go is deliberately boring in a way that annoyed me at first and that I now value. No magic methods. No implicit type juggling. The compiler refuses unused variables and unused imports. The formatting is not up for debate — &lt;code&gt;gofmt&lt;/code&gt; decides, and the entire community's code looks the same. Coming from PHP's freedom, this felt like the language not trusting me 🤔&lt;/p&gt;

&lt;p&gt;The reframe: Go optimizes for the code being &lt;em&gt;read&lt;/em&gt;, not the code being &lt;em&gt;written&lt;/em&gt;. On a team — and I was leading one through the rebuild, plus interviewing developers now — that tradeoff is obviously correct. Clever PHP is a liability the moment someone other than its author has to maintain it. Boring, explicit, uniformly-formatted Go is something a teammate can read at 2am during an incident and actually understand. The language took away cleverness, and what I got back - a code that my team could understand about the same way I do 😎&lt;/p&gt;

&lt;p&gt;That, more than any single feature, is the mental model I'd most want a PHP developer to adopt before they write a line of Go: you are not writing for the interpreter's flexibility anymore. You are writing for the next person who reads it, and the language is going to hold you to that whether you like it or not 🧐&lt;/p&gt;




&lt;h2&gt;
  
  
  What I'd actually tell someone making this move
&lt;/h2&gt;

&lt;p&gt;The syntax will take you a week. The mental models took me months, because the hard part isn't learning Go — it's &lt;em&gt;unlearning&lt;/em&gt; the PHP assumptions that are so deep you don't know they're assumptions.&lt;/p&gt;

&lt;p&gt;None of this is a complaint about PHP. Seven years of PHP is exactly what made the Laravel-to-Go migration something I could lead rather than just attend — I understood the system we were leaving as deeply as the one we were building. But the move only worked once I stopped writing Go in PHP's syntax and started actually thinking in Go.&lt;/p&gt;

</description>
      <category>go</category>
      <category>learning</category>
      <category>microservices</category>
      <category>php</category>
    </item>
  </channel>
</rss>
