<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[RSS Feed of sewon.dev]]></title><description><![CDATA[프로젝트를 만들고 운영하면서 배운 개발, 제품, 디버깅 기록을 남깁니다.]]></description><link>https://sewon.dev</link><generator>GatsbyJS</generator><lastBuildDate>Thu, 03 Sep 2026 00:04:21 GMT</lastBuildDate><item><title><![CDATA[벡터 검색을 앞두고 SQLite에서 PostgreSQL + pgvector로 옮긴 이유]]></title><description><![CDATA[일기 서비스에 “비슷한 기록 보여주기”를 넣으려 했다. 같은 단어가 있는 글이 아니라 문맥과 감정이 닮은 과거 일기를 찾는 기능이다. 텍스트를 임베딩으로 바꾸고, 벡터를 저장한 뒤 가까운 기록을 찾는 흐름이 필요했다. 처음에는 SQLite…]]></description><link>https://sewon.dev/sqlite-to-postgresql-pgvector-migration/</link><guid isPermaLink="false">https://sewon.dev/sqlite-to-postgresql-pgvector-migration/</guid><pubDate>Wed, 15 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/d456347091040dff00aa8c803763b7d4/769fc/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 55.88235294117647%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACHklEQVR42lWRW0tUURTHz8fpJRJ6CHwrKKEwoq8SRE+CBJX11EUhH0qxCE26GUmkiIwIReWkzuk0zmQ641zO2fvc9nWdfYsZDXLxX0+L/7r8ltcOWQexLua7zbwTsSgW+y3SRSzEvItFiGU74tpY51wvj4cnoKACGJeyUFQA4ZJySZlgXGpjjLXWOWuPnMZY/U/GWk9hrJJEZ1kRxzZNXVH83xuUaiboIEEJo60M80IcmwwSJGghCxAip7CPRDOGgxgKbZxzSutcAAUlAPajrBQkn+vky2+6vpOHGXhWSYVqmiLnzEolHfnARt92bi/JegS9Pa2zpKtQ3blic4+Ovk9uLkS3FuORhXT1F/FUewuXxtnmGwesHsKiz5d+kk9ViYnqQVJAy/NobcKh4NtOMrZE737EY4vhnWWxGuSeVaDjPcsTA8IUBWmzpMl5pvuY+pw4UknDOVPt8PvL5HFJTJbkgxX+dZd5h6f3YWrc4OW1vLQS+huK06NKHNntMvPLeXQAnZBVovZG1GimqVLac0oZzjRjBgBCjP1Wt56RUFhjDs1GuLChcMMoYddNY5b8mM3K74qgZYlnWy0RBHnFzyo+3a7Q7S0a+LpWNVnmnIuTdOr5yycz80/nXk3Nzd97Nn19evza5MMbE4++V3zPEmIRMhj3FfeFDUJG9F5aq/8ZGLx0avDiwNDwwIXh0+cvnxm6Mnju6omTZ2devP4L18ZJ4QPSMgoAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;별도 벡터 DB와 PostgreSQL pgvector의 데이터 경계 비교&apos; title=&apos;&apos; src=&apos;/static/d456347091040dff00aa8c803763b7d4/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/d456347091040dff00aa8c803763b7d4/e7570/situation-diagram.png 170w,
/static/d456347091040dff00aa8c803763b7d4/f46e7/situation-diagram.png 340w,
/static/d456347091040dff00aa8c803763b7d4/ca1dc/situation-diagram.png 680w,
/static/d456347091040dff00aa8c803763b7d4/02d09/situation-diagram.png 1020w,
/static/d456347091040dff00aa8c803763b7d4/9d567/situation-diagram.png 1360w,
/static/d456347091040dff00aa8c803763b7d4/769fc/situation-diagram.png 4512w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;별도 벡터 DB와 PostgreSQL pgvector의 데이터 경계 비교&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;일기 서비스에 “비슷한 기록 보여주기”를 넣으려 했다. 같은 단어가 있는 글이 아니라 문맥과 감정이 닮은 과거 일기를 찾는 기능이다. 텍스트를 임베딩으로 바꾸고, 벡터를 저장한 뒤 가까운 기록을 찾는 흐름이 필요했다.&lt;/p&gt;
&lt;p&gt;처음에는 SQLite는 그대로 두고 벡터 데이터베이스만 따로 붙이는 방법을 검토했다. 그런데 원문은 한 저장소, 임베딩은 다른 저장소에 두면 삭제·백업·복구·재시도가 모두 두 시스템에 걸친 일이 된다. 기능 하나를 넣으면서 운영할 곳을 하나 더 만드는 셈이었다.&lt;/p&gt;
&lt;p&gt;그래서 PostgreSQL과 pgvector로 옮겼다. 전용 벡터 DB가 맞는 상황도 분명 있다. 다만 지금 서비스에서는 &lt;strong&gt;원문과 임베딩을 PostgreSQL 하나에서 같이 관리하는 편이 훨씬 덜 복잡했다.&lt;/strong&gt; 이 글에는 그 판단과 실제 컷오버 과정을 남겼다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;유사 일기 검색에는 벡터 컬럼과 근접 검색이 필요했고, &lt;code class=&quot;language-text&quot;&gt;pgvector&lt;/code&gt;가 그 기능을 PostgreSQL 안에 추가해준다.&lt;/li&gt;
&lt;li&gt;원문과 임베딩의 삭제·권한·백업 경계를 하나로 유지하기 위해 PostgreSQL + pgvector를 선택했다.&lt;/li&gt;
&lt;li&gt;API는 공용 프록시 네트워크와 서비스 내부 네트워크에, PostgreSQL은 내부 네트워크에만 연결했다.&lt;/li&gt;
&lt;li&gt;컷오버는 “API 중지 → SQLite 최종 snapshot → 빈 PostgreSQL 이관 → 검증 → API 재기동”의 짧은 쓰기 중단 구간으로 만들었다.&lt;/li&gt;
&lt;li&gt;PostgreSQL이 새 쓰기를 받기 전과 후에는 되돌리는 방법이 달라진다. 이 경계를 미리 정해둬야 새 데이터를 잃지 않는다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;결정의-기준-검색-엔진보다-데이터-생명주기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%B0%EC%A0%95%EC%9D%98-%EA%B8%B0%EC%A4%80-%EA%B2%80%EC%83%89-%EC%97%94%EC%A7%84%EB%B3%B4%EB%8B%A4-%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%83%9D%EB%AA%85%EC%A3%BC%EA%B8%B0&quot; aria-label=&quot;결정의 기준 검색 엔진보다 데이터 생명주기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;결정의 기준: 검색 엔진보다 데이터 생명주기&lt;/h2&gt;
&lt;p&gt;유사 기록 검색은 다음 흐름이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;일기 작성 → 임베딩 생성 → 벡터 저장 → 비슷한 과거 기록 검색&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;일기 서비스라서 더 까다로운 조건도 있다. 검색 후보는 늘 현재 사용자의 기록으로 제한해야 한다. 일기를 지우면 임베딩도 함께 지워져야 하고, 백업을 복구했을 때 둘은 같은 시점으로 돌아와야 한다.&lt;/p&gt;
&lt;p&gt;SQLite와 별도 벡터 DB를 함께 쓰면 이 규칙이 나뉜다. 한쪽 저장이 실패했을 때 어떻게 다시 맞출지, 두 백업의 시점이 어긋나면 어떻게 할지, 삭제가 한쪽에만 반영되면 어떻게 찾을지까지 일일이 정해야 한다. 대규모 검색 서비스라면 그 비용을 감수할 이유가 생긴다. 하지만 내가 풀 문제는 “한 사용자의 과거 기록에서 비슷한 것을 찾기”였다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;선택지&lt;/th&gt;
&lt;th&gt;장점&lt;/th&gt;
&lt;th&gt;운영에서 늘어나는 일&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;SQLite + 별도 벡터 DB&lt;/td&gt;
&lt;td&gt;기존 DB를 유지할 수 있다&lt;/td&gt;
&lt;td&gt;원문·임베딩·삭제·백업의 source of truth가 둘이 된다&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PostgreSQL + pgvector&lt;/td&gt;
&lt;td&gt;관계형 조건과 벡터 검색을 같은 DB에서 다룬다&lt;/td&gt;
&lt;td&gt;한 번의 DB 이관이 필요하다&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;전용 벡터 DB&lt;/td&gt;
&lt;td&gt;대규모 ANN과 복잡한 검색에 유리할 수 있다&lt;/td&gt;
&lt;td&gt;별도 클러스터, 권한, 동기화, 백업, 관측이 필요하다&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;pgvector는 PostgreSQL에 벡터 타입과 거리 연산, HNSW 같은 인덱스를 더하는 확장이다. 처음에는 정확도 검색으로 시작하고, 데이터량과 지연 시간을 본 뒤 근사 최근접 이웃 인덱스를 붙이면 된다. &lt;a href=&quot;https://github.com/pgvector/pgvector&quot;&gt;pgvector 공식 문서&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;결국 비교한 것은 제품 기능표가 아니라 운영비였다. 지금은 &lt;strong&gt;데이터를 두 곳에 나누는 비용보다 DB를 한 번 옮기는 비용이 작았다.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;네트워크-이름도-인프라-계약이다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%84%A4%ED%8A%B8%EC%9B%8C%ED%81%AC-%EC%9D%B4%EB%A6%84%EB%8F%84-%EC%9D%B8%ED%94%84%EB%9D%BC-%EA%B3%84%EC%95%BD%EC%9D%B4%EB%8B%A4&quot; aria-label=&quot;네트워크 이름도 인프라 계약이다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;네트워크 이름도 인프라 계약이다&lt;/h2&gt;
&lt;p&gt;홈서버에는 이미 공용 reverse proxy 네트워크가 있었다. API는 이 네트워크에 있어야 외부 HTTP 요청을 받을 수 있지만, PostgreSQL이 여기에 있을 이유는 없다.&lt;/p&gt;
&lt;p&gt;처음에는 튜토리얼에서 흔히 쓰는 &lt;code class=&quot;language-text&quot;&gt;app-net&lt;/code&gt; 같은 이름을 그대로 쓸 뻔했다. 하지만 운영 서버는 서비스마다 &lt;code class=&quot;language-text&quot;&gt;&amp;lt;서비스&gt;-&amp;lt;역할&gt;&lt;/code&gt; 형태의 명시적 이름을 쓰고 있었다. 예제 이름을 하드코딩하면 컨테이너가 어떤 경계를 공유하는지 나중에 한눈에 보이지 않는다.&lt;/p&gt;
&lt;p&gt;그래서 API는 &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;과 &lt;code class=&quot;language-text&quot;&gt;dear-crush-internal&lt;/code&gt;에 연결하고, PostgreSQL은 &lt;code class=&quot;language-text&quot;&gt;dear-crush-internal&lt;/code&gt;에만 연결했다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/30d1de603a36714b4864e97997e57ce5/769fc/network-boundary.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 59.411764705882355%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACKElEQVR42lVSW08TQRTu//HNxKQan9Toi4mC9P+YEF0IhUTQ6gtPRhMjPmkaEQygiLZI10tKS9vtbi/bdi9daOe+nYvutpD05MuXM5PznZnzzSQsG/gB8QJitUHDBv1T2vNwswON5rDdg46PLRvYDjobMqWUVFORgJiOARAZQkIoGwAMIBnGDBEBiACICWVSSjGNxHQvJeWELyBicKG4kCMheQwR1yXiiihzzvhPg+omPaxi3aQ1lxuuqLm87gnLDetOaLqh6UWbVZdbHpdSJVgzHxQ2lF+1PZY77q9selrWm//gZv/Ck25Y6gq9Qd8V0IZO3hyRnTKpurLsyJMuj67NzIN+/pV0SwMsGy77YeCDGtmv4HInbPV502PfS/7y3mjpM1rcGb09Qp0gbAaiexqffGEgC3l/QAFiQ0ghYqeAxsuw3oNP9kh601/cgu9/A0Y4RhITHs2sJiMru08Pa0PdgkcG0E1UqMNfFiq2Sd7AS5/OlrYH2sfB+tfebquVbZt/OgMlI/HEYTsIix1RccSJI8s9ec6iaI92Smi7hLePcc6kLy09bWztduyJeByUS8AVFAryKaCRYlKFUoVK+T4yTPe41rJbgRy/sxBCKfXlW+7ho5WF5Yy2ktHWnmtrGW01E/Fa5vHyUy39bH5htVKrq5DxRnP8ByIx59H0L9ZfX7py59rNueTtB8mZVPL+XPJeKkpmUslbs1dvzF6+fndvP3dR/9+wf6N+d33aK4PmAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;API는 proxy-net과 서비스 내부 네트워크에 연결하고 PostgreSQL은 내부 네트워크에만 두는 구조&apos; title=&apos;&apos; src=&apos;/static/30d1de603a36714b4864e97997e57ce5/ca1dc/network-boundary.png&apos; srcset=&apos;/static/30d1de603a36714b4864e97997e57ce5/e7570/network-boundary.png 170w,
/static/30d1de603a36714b4864e97997e57ce5/f46e7/network-boundary.png 340w,
/static/30d1de603a36714b4864e97997e57ce5/ca1dc/network-boundary.png 680w,
/static/30d1de603a36714b4864e97997e57ce5/02d09/network-boundary.png 1020w,
/static/30d1de603a36714b4864e97997e57ce5/9d567/network-boundary.png 1360w,
/static/30d1de603a36714b4864e97997e57ce5/769fc/network-boundary.png 4512w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;API는 proxy-net과 서비스 내부 네트워크에 연결하고 PostgreSQL은 내부 네트워크에만 두는 구조&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;PostgreSQL에는 host port를 열지 않았다. DB를 프록시 네트워크에서 빼고 내부 네트워크에만 두면 웹에서 직접 닿을 수 없는 계층이라는 점도 바로 드러난다.&lt;/p&gt;
&lt;p&gt;이 구성은 Compose 파일에만 남기지 않았다. 다음 조건을 배포 계약 테스트로 고정했다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;PostgreSQL은 &lt;code class=&quot;language-text&quot;&gt;pgvector&lt;/code&gt; 이미지를 사용한다.&lt;/li&gt;
&lt;li&gt;API는 PostgreSQL health check가 통과한 뒤 시작한다.&lt;/li&gt;
&lt;li&gt;API는 두 네트워크에, PostgreSQL은 서비스 내부 네트워크에만 속한다.&lt;/li&gt;
&lt;li&gt;PostgreSQL은 host port를 publish하지 않는다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Compose는 설정 파일이지만, 잘못 바뀌면 배포에서 바로 터진다. 그래서 이 조건도 테스트로 봤다.&lt;/p&gt;
&lt;h2 id=&quot;예상보다-까다로웠던-것은-PostgreSQL-자체보다-SQLite-전제였다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%98%88%EC%83%81%EB%B3%B4%EB%8B%A4-%EA%B9%8C%EB%8B%A4%EB%A1%9C%EC%9B%A0%EB%8D%98-%EA%B2%83%EC%9D%80-PostgreSQL-%EC%9E%90%EC%B2%B4%EB%B3%B4%EB%8B%A4-SQLite-%EC%A0%84%EC%A0%9C%EC%98%80%EB%8B%A4&quot; aria-label=&quot;예상보다 까다로웠던 것은 PostgreSQL 자체보다 SQLite 전제였다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;예상보다 까다로웠던 것은 PostgreSQL 자체보다 SQLite 전제였다&lt;/h2&gt;
&lt;p&gt;DB만 바꾸면 SQL만 손보면 될 거라고 생각하기 쉽다. 실제로는 코드와 테스트 곳곳에 “현재 DB는 SQLite”라는 전제가 숨어 있었다.&lt;/p&gt;
&lt;p&gt;가장 먼저 발목을 잡은 건 Alembic head를 문자열로 박아둔 테스트였다. pgvector용 revision을 추가하자 실제 체인은 맞는데도 예전 head를 기대하던 테스트가 깨졌다. 이관 전에 테스트의 기대값부터 마이그레이션 체인과 맞춰야 했다.&lt;/p&gt;
&lt;p&gt;또 하나는 보호 장치였다. 이관 테스트가 운영 PostgreSQL을 잘못 초기화하지 않도록 테스트 대상은 &lt;code class=&quot;language-text&quot;&gt;_test&lt;/code&gt; suffix가 붙은 DB만 허용했다. 번거롭더라도 이관 코드에서는 “운영 데이터를 실수로 건드리지 않는다”가 먼저다.&lt;/p&gt;
&lt;p&gt;백업 도구의 역할도 분리했다. &lt;code class=&quot;language-text&quot;&gt;pg_dump&lt;/code&gt;는 SQLite 파일을 PostgreSQL로 바꾸는 도구가 아니다. SQLite는 &lt;a href=&quot;https://www.sqlite.org/backup.html&quot;&gt;Backup API&lt;/a&gt;로 일관된 snapshot을 만들고, PostgreSQL로 전환한 뒤에야 &lt;code class=&quot;language-text&quot;&gt;pg_dump&lt;/code&gt;로 새 운영 DB를 백업한다. 이 구분을 놓치면 WAL이 남은 SQLite 파일을 단순 복사하거나 엉뚱한 시점의 백업을 믿게 된다.&lt;/p&gt;
&lt;h2 id=&quot;컷오버-이관-스크립트보다-전환-순서가-중요했다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%BB%B7%EC%98%A4%EB%B2%84-%EC%9D%B4%EA%B4%80-%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%B3%B4%EB%8B%A4-%EC%A0%84%ED%99%98-%EC%88%9C%EC%84%9C%EA%B0%80-%EC%A4%91%EC%9A%94%ED%96%88%EB%8B%A4&quot; aria-label=&quot;컷오버 이관 스크립트보다 전환 순서가 중요했다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;컷오버: 이관 스크립트보다 전환 순서가 중요했다&lt;/h2&gt;
&lt;p&gt;컷오버(cutover)는 실제 쓰기를 받는 기준 DB를 바꾸는 작업이다. 여기서는 SQLite에서 PostgreSQL로 운영 source of truth를 넘기는 순간을 뜻한다.&lt;/p&gt;
&lt;p&gt;무중단을 목표로 두 DB를 동기화하는 방법도 있다. 대신 이 서비스에서는 짧은 쓰기 중단을 허용하고, 절차를 단순하게 만들었다. 중간 상태가 적을수록 검증도 쉬웠다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/a8126bb350cd6c12d3b3a374477df993/769fc/cutover-timeline.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 62.94117647058823%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAAsTAAALEwEAmpwYAAACNklEQVR42o2RW0/UQBTH+5188K3BZ+Ti27KfxhjDdhGTLai7riHywIu+QAwREgSzAQwPLChEQEAo3Xa3V3qZazszrWnFW2KMJ7+cmeTM/5z5z0g9Cw5cpBlg4CDHJ30HDhx8ZQLNALaHvYBoBrgOqRAiy7L8z5BiiBGmAJIYEoRpGCNEkhiSCCCACEQ0hjgGGGLKywa/I+X/HX+ZnAueZeJHlZeLyEVawkSWpTxLec54MSphIuFZym4sSO6HOXS4lAQOdI/9qzWKfKTt+1tta2su+fxm78yrvfUml+35Lf/jRTj9DjxacabXIiNgpedPi8nXDo4C5B3F/XUc9YF24HdfObuv6dnGoRa2O/7zjr/YDb6YoL0dtzru/A6yo1JM05SkKeW82BAAkyQkOCYwz7OSX4YZ44jSNE1yIfLv16acWTg6DsyD0Oj6+r6ruQQwUZovxZgle4G2Yh0uGfsXyBMxID2dhWEhvsTewnX3yfnGzMX646PVdn97OToiPP35vDaNXxo7zctO29hcvT7JEM4Yy3jRXUo5s0l8Dp0TaJ1CW0NemGDOxQ0iE5giy7J0zTk/JVc9ZJrYdvDASuNY+vfPFgkApvdEfyAMk+k67xnCNHlPF64rPZyaVRqtSbVZU5tFbjRrakuZaSlqS1Gbymyr1nimKA2l3qgXqPWpxlRdfXC//n5jU7p9597Q8IQ8OiGPVQqGK/JIRR6vyHdLxibk8bJaHKjKI1V5vDo0Ur0ljz59sfANJDObsppO7MwAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;SQLite에서 PostgreSQL로 운영 기준 DB를 넘기는 컷오버와 롤백 창&apos; title=&apos;&apos; src=&apos;/static/a8126bb350cd6c12d3b3a374477df993/ca1dc/cutover-timeline.png&apos; srcset=&apos;/static/a8126bb350cd6c12d3b3a374477df993/e7570/cutover-timeline.png 170w,
/static/a8126bb350cd6c12d3b3a374477df993/f46e7/cutover-timeline.png 340w,
/static/a8126bb350cd6c12d3b3a374477df993/ca1dc/cutover-timeline.png 680w,
/static/a8126bb350cd6c12d3b3a374477df993/02d09/cutover-timeline.png 1020w,
/static/a8126bb350cd6c12d3b3a374477df993/9d567/cutover-timeline.png 1360w,
/static/a8126bb350cd6c12d3b3a374477df993/769fc/cutover-timeline.png 4512w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;SQLite에서 PostgreSQL로 운영 기준 DB를 넘기는 컷오버와 롤백 창&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;실행 명령은 서비스별 경로와 비밀값을 제거하면 아래 정도로 단순하다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;# 1. SQLite에 새 쓰기가 들어오지 않게 한다.&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose stop api

&lt;span class=&quot;token comment&quot;&gt;# 2. SQLite Backup API를 사용한 최종 snapshot을 만든다.&lt;/span&gt;
./backup-sqlite.sh

&lt;span class=&quot;token comment&quot;&gt;# 3. PostgreSQL을 준비하고 일회성 이관 컨테이너를 실행한다.&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose up &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--wait&lt;/span&gt; postgres
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; docker-compose.yml &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; docker-compose.cutover.yml run &lt;span class=&quot;token parameter variable&quot;&gt;--rm&lt;/span&gt; api

&lt;span class=&quot;token comment&quot;&gt;# 4. 검증 후 정상 API로 전환한다.&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt; docker-compose.yml up &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; api&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;docker-compose.cutover.yml&lt;/code&gt;은 API 이미지를 새로 만들려는 파일이 아니다. 같은 이미지를 이관 명령으로 한 번만 실행하는 override다. 이관이 끝나면 빼고 정상 API 모드로 다시 띄운다. 덕분에 빈 PostgreSQL을 바라보는 API가 먼저 떠서 쓰기를 받는 중간 상태를 막을 수 있다.&lt;/p&gt;
&lt;p&gt;이관 컨테이너는 다음 조건을 통과할 때만 성공하도록 만들었다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;원본은 읽기 전용 SQLite snapshot이고 대상 PostgreSQL은 비어 있다.&lt;/li&gt;
&lt;li&gt;Alembic revision과 &lt;code class=&quot;language-text&quot;&gt;vector&lt;/code&gt; extension이 준비되어 있다.&lt;/li&gt;
&lt;li&gt;외래 키 순서에 맞춰 데이터를 복사하고, 실패하면 PostgreSQL transaction을 rollback한다.&lt;/li&gt;
&lt;li&gt;모든 테이블의 row count와 핵심 데이터 값을 source와 비교한다.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;컨테이너가 exit code 0으로 끝났다고 이관이 끝난 건 아니다. 스키마와 데이터는 물론이고, API와 네트워크 경계까지 따로 확인했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;스키마: Alembic revision, vector extension
데이터: 테이블별 row count, 시간값·원문 등 핵심 값 표본
애플리케이션: 로그인, 작성, 조회, 삭제
운영: DB의 내부 네트워크 격리, API health check&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;롤백-창은-새-쓰기-전에-끝난다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%A1%A4%EB%B0%B1-%EC%B0%BD%EC%9D%80-%EC%83%88-%EC%93%B0%EA%B8%B0-%EC%A0%84%EC%97%90-%EB%81%9D%EB%82%9C%EB%8B%A4&quot; aria-label=&quot;롤백 창은 새 쓰기 전에 끝난다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;롤백 창은 새 쓰기 전에 끝난다&lt;/h2&gt;
&lt;p&gt;이관에서 제일 위험한 생각은 “문제가 생기면 SQLite로 돌아가면 된다”는 말이다. 그 말이 맞는 건 PostgreSQL이 새 데이터를 받기 전까지다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;시점&lt;/th&gt;
&lt;th&gt;대응&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PostgreSQL 검증 전&lt;/td&gt;
&lt;td&gt;API를 멈춘 채 이관을 다시 실행한다&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PostgreSQL API를 열기 전&lt;/td&gt;
&lt;td&gt;이전 Compose 설정과 SQLite snapshot으로 되돌릴 수 있다&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PostgreSQL이 새 쓰기를 받은 후&lt;/td&gt;
&lt;td&gt;SQLite로 단순 복귀하면 새 데이터가 사라진다. PostgreSQL backup/restore를 기준으로 복구해야 한다&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;그래서 API 전환 직후 PostgreSQL 첫 백업을 만들고 복원 목록까지 확인했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;pg_dump &lt;span class=&quot;token parameter variable&quot;&gt;--format&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;custom --no-owner --no-privileges &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--username&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$POSTGRES_USER&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--dbname&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$POSTGRES_DB&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; ./backups/post-cutover.dump

pg_restore &lt;span class=&quot;token parameter variable&quot;&gt;--list&lt;/span&gt; ./backups/post-cutover.dump &lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; /dev/null&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 시점부터는 기존 SQLite 백업 cron도 PostgreSQL용으로 바꿔야 한다. DB만 바꾸고 백업 대상을 그대로 두면 복구 계획은 무용지물이 된다.&lt;/p&gt;
&lt;h2 id=&quot;마치며&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%A7%88%EC%B9%98%EB%A9%B0&quot; aria-label=&quot;마치며 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;마치며&lt;/h2&gt;
&lt;p&gt;다 끝나고 보니 DB 엔진만 바뀐 게 아니었다. 어느 DB를 기준 데이터로 볼지 정한 작업이었다.&lt;/p&gt;
&lt;p&gt;PostgreSQL + pgvector를 선택하니 원문, 임베딩, 권한, 삭제, 백업을 한 DB 경계 안에서 관리할 수 있었다. 컷오버 때도 새 source of truth가 바뀌는 시점과 되돌릴 수 있는 범위를 분명히 정할 수 있었다.&lt;/p&gt;
&lt;p&gt;다음에도 비슷한 이관을 한다면, 성능 수치보다 먼저 적을 건 롤백 창이다. &lt;strong&gt;실패했을 때 원본을 잃지 않고 어디까지 되돌릴 수 있는지.&lt;/strong&gt; 그 답이 있어야 새 DB를 열 수 있다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/pgvector/pgvector&quot;&gt;pgvector 공식 문서&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.sqlite.org/backup.html&quot;&gt;SQLite Backup API&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://hub.docker.com/_/postgres&quot;&gt;PostgreSQL Docker Official Image&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Localization 502를 Top-Down으로 좁힌 기록]]></title><description><![CDATA[Place2Page에서 localization을 생성하다가 버튼이 오래 돌고 실패하는 문제가 있었다. 처음에는 번역 모델이 실패했거나 backend에서 예외가 난 것처럼 보였다. 그런데 에러 파일을 열어보니 앱이 만든 JSON…]]></description><link>https://sewon.dev/place2page-localization-502-long-request-debugging/</link><guid isPermaLink="false">https://sewon.dev/place2page-localization-502-long-request-debugging/</guid><pubDate>Tue, 07 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/b2c265d5741b6aceb300fa968d4f8481/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAABd0lEQVR42oWQaWscMQyG9///uXwoDbSbkjniOTy+xuNLko+wk7Jkm0DFi5Bf8UjCl1KrMmAO3E+pHQ5/K7SF/UDrTh1oLOodiGr7FBfK9WWw/eT7yXXM/Rn9uPhh8q/Md8yNS+inMzN/7a2P1Fq7D7i01kJMfJNC6oRQ0APAKuTCBSBlCASJC8U3GRPUh8UnLI17WwRblbE+SW6tnzczrcq6GLXgK582wxa5yp1yeYBra1QqlYpUiHKtNZfqAUwMudRSK1KmXKgUOLv/bgYrkl7+2mfbY1L+OF93+/HiO6y1mhlb+caFnBeupRmm+TqMYlObuIlzeRzuK3+DkciH6HzwIRzOmeg6zX9tk3LWh2ii2zHERqFRaV/O/hyl1S27H+Prz6nn6BSF33J66q5P3cvzMlAr/4WPt6BYMhs5kQ4WDQuaBT3D/g1MOSMRUUYkzDkQxIwxYyDIlNNZfKh889tIIUFMEGJKCVLCGOGm0/mow5lLeYDfAYm7tja1qp0cAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;긴 localization 요청을 proxy boundary 전에 작게 나누는 흐름&apos; title=&apos;&apos; src=&apos;/static/b2c265d5741b6aceb300fa968d4f8481/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/b2c265d5741b6aceb300fa968d4f8481/e7570/situation-diagram.png 170w,
/static/b2c265d5741b6aceb300fa968d4f8481/f46e7/situation-diagram.png 340w,
/static/b2c265d5741b6aceb300fa968d4f8481/ca1dc/situation-diagram.png 680w,
/static/b2c265d5741b6aceb300fa968d4f8481/02d09/situation-diagram.png 1020w,
/static/b2c265d5741b6aceb300fa968d4f8481/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;긴 localization 요청을 proxy boundary 전에 작게 나누는 흐름&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Place2Page에서 localization을 생성하다가 버튼이 오래 돌고 실패하는 문제가 있었다. 처음에는 번역 모델이 실패했거나 backend에서 예외가 난 것처럼 보였다. 그런데 에러 파일을 열어보니 앱이 만든 JSON 에러가 아니었다.&lt;/p&gt;
&lt;p&gt;Cloudflare가 내려준 &lt;code class=&quot;language-text&quot;&gt;502: Bad gateway&lt;/code&gt; HTML 페이지였다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;txt&quot;&gt;&lt;pre class=&quot;language-txt&quot;&gt;&lt;code class=&quot;language-txt&quot;&gt;example.page | 502: Bad gateway
Browser Working
Cloudflare Working
Host Error&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;가볍게 풀어 쓰면 이렇다. 브라우저에서 Cloudflare까지는 도달했고, Cloudflare 자체도 요청을 처리하고 있었다. 하지만 Cloudflare가 origin 서버에서 정상적인 응답을 받지 못했다. 그래서 이 문제는 &quot;번역 결과가 이상하다&quot;보다 &quot;긴 localization 요청이 proxy와 origin 사이 경계에서 끝까지 버티지 못했다&quot;에 가까웠다.&lt;/p&gt;
&lt;p&gt;이 글은 &lt;code class=&quot;language-text&quot;&gt;Computer Networking: A Top-Down Approach&lt;/code&gt;에서 말하는 top-down 관점처럼, application layer에서 시작해 아래 경계로 내려가며 가능성을 지운 기록이다. 다만 모든 네트워크 계층을 다 검사했다는 뜻은 아니다. 실제로는 관리 화면의 응답 형식, HTTP/proxy 경계, origin reachability, 그리고 localization workload 크기를 확인했다. link나 physical layer까지 내려갈 증거는 없어서 거기서는 멈췄다.&lt;/p&gt;
&lt;p&gt;이번 이슈에 빌려올 네트워크 개념은 네 가지다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;HTTP는 client-server application protocol이고 request/response가 끝나야 화면이 성공 또는 실패를 판단한다.&lt;/li&gt;
&lt;li&gt;end-to-end delay는 link의 전송 시간만이 아니라 end system의 처리 시간과 대기 시간도 포함한다.&lt;/li&gt;
&lt;li&gt;TCP의 reliable data transfer는 byte stream 전달을 안정적으로 해줄 뿐, origin application이 제한 시간 안에 response를 완성한다는 보장은 아니다.&lt;/li&gt;
&lt;li&gt;proxy는 browser와 origin 사이에 별도 대기 경계를 만들고, 이 경계에는 timeout 정책이 있다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;증상: localization 생성 중 Cloudflare &lt;code class=&quot;language-text&quot;&gt;502: Bad gateway&lt;/code&gt; HTML이 반환됐다.&lt;/li&gt;
&lt;li&gt;판단: 앱 JSON 에러가 아니라 Cloudflare HTML이어서 handler 내부 예외보다 proxy와 origin 사이 경계를 먼저 봤다.&lt;/li&gt;
&lt;li&gt;핵심 단서: 대상 HTML이 약 &lt;code class=&quot;language-text&quot;&gt;533,358&lt;/code&gt;자였고, 번역 segment가 &lt;code class=&quot;language-text&quot;&gt;166&lt;/code&gt;개였다.&lt;/li&gt;
&lt;li&gt;구조적 문제: 여러 locale을 한 번의 HTTP 요청에서 한꺼번에 생성하고 있었다.&lt;/li&gt;
&lt;li&gt;조치: 관리 화면에서는 locale별로 더 작은 request/response transaction을 보내도록 바꿨다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;요청-흐름을-sequence로-보면&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%B2%AD-%ED%9D%90%EB%A6%84%EC%9D%84-sequence%EB%A1%9C-%EB%B3%B4%EB%A9%B4&quot; aria-label=&quot;요청 흐름을 sequence로 보면 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요청 흐름을 sequence로 보면&lt;/h2&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c7a31a9ead1f79546602476513104db4/769fc/request-shape-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 64.11764705882354%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAAsTAAALEwEAmpwYAAACgUlEQVR42lVRXUsUURieP9VdUdJFNyVRkOjV1o3Qna0EuVlelG2ki0ZKl+lFECIaYlCUQSQ6rqlp6fqxq7ub7s7OmdmZM+f7zDknxr7s5eG5eXmfD17r4Ed05ODKETp0UM3Fh3XUAKTmYAeQmkuKFVgHRCkl4ziOE9Zamz9jISYQ4RFhmHFEOaaccBFRjghDmCFMCeGEcnoMQphSyhijtFZaWxIAGUEZQeF50vdlEAjgCddVjBljRCzdKESc1WDTjcKAYBDBOmwyKRNnSjhjcaKKCE1AKSYcR+p4HSsVYowpgxhHmNTCZtl3CaO/wltxUCWlzwq5MWnAxrIIC5jQma9wIh8cNrkx5m9HKsUHUJgF3xoIV30JImnh4vzR3FNaXuNewT2YYe4n0HD6Z5170/WNCjXGoNKCvzKJvTIUcjWorqL9d4XmnUnnxXzTMlpreeyghEABg5A2ac0RxaKgRBmj0facvzgG67uBELa3vxjuvC/4mSlnfCGwzInRxijKOeSVHbq9AglSJ1cRpx/d7bfge8nzdh0CIvH/sZRGMIbNWh7a8z6oq+PO/x7rCXyAPal+i1pKSsW5ljImRHqeEkJLEVMZY6mV0trEsQIY7ob1TXiUb5TW/WopbAASxUpZem9P2rZYWpK2Le0lmc+LRVss5+MvS8oDOgmsF3jlNS9M860JvDHNtqbp1rI8TJzfvJrK3e8ffZwbeTQ4mk04QTY33Jct7xYjTB4+efYgN5IZGErnBm8NDnTnBnsHhvuyw+MvJ62h52PXOrtu3L6b6upJdWdS6Z5UOnM9nWnvTK9vbgPgn7nQdvpi29lL7S1XO1paO1qudJxr7Th1/vLNrt6f9w2lA5IpNCEAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;여러 locale을 한 요청에 넣어 502로 이어진 흐름과 locale별 작은 요청으로 나눈 뒤의 대비&apos; title=&apos;&apos; src=&apos;/static/c7a31a9ead1f79546602476513104db4/ca1dc/request-shape-diagram.png&apos; srcset=&apos;/static/c7a31a9ead1f79546602476513104db4/e7570/request-shape-diagram.png 170w,
/static/c7a31a9ead1f79546602476513104db4/f46e7/request-shape-diagram.png 340w,
/static/c7a31a9ead1f79546602476513104db4/ca1dc/request-shape-diagram.png 680w,
/static/c7a31a9ead1f79546602476513104db4/02d09/request-shape-diagram.png 1020w,
/static/c7a31a9ead1f79546602476513104db4/9d567/request-shape-diagram.png 1360w,
/static/c7a31a9ead1f79546602476513104db4/769fc/request-shape-diagram.png 4512w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;여러 locale을 한 요청에 넣어 502로 이어진 흐름과 locale별 작은 요청으로 나눈 뒤의 대비&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;Application-layer-먼저-앱-응답을-봤다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Application-layer-%EB%A8%BC%EC%A0%80-%EC%95%B1-%EC%9D%91%EB%8B%B5%EC%9D%84-%EB%B4%A4%EB%8B%A4&quot; aria-label=&quot;Application layer 먼저 앱 응답을 봤다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Application layer: 먼저 앱 응답을 봤다&lt;/h2&gt;
&lt;p&gt;Top-down 접근에서는 먼저 사용자가 실제로 만지는 application과 application protocol을 본다. 이번 경우에는 관리 화면, localization 생성 버튼, HTTP response body가 출발점이었다.&lt;/p&gt;
&lt;p&gt;관리 화면은 전형적인 client-server 구조다. 브라우저가 localization 생성 request를 보내고, backend가 response를 돌려줘야 화면이 성공 또는 실패를 판단한다. 이 모델에서는 서버 안에서 번역 작업이 계속 진행 중이어도 HTTP response가 제한 시간 안에 돌아오지 않으면 화면에서는 실패다.&lt;/p&gt;
&lt;p&gt;문제가 발생한 화면은 root page를 기준으로 여러 locale을 한 번에 생성하는 상태였다. 버튼은 하나였고, 그 버튼은 missing locale 전체를 생성하는 흐름이었다. 한 번 클릭하면 여러 locale 전체가 생성 대상이 됐다.&lt;/p&gt;
&lt;p&gt;여기서 바로 번역 로직을 고치지 않았다. 먼저 에러가 어느 층에서 났는지 확인했다. 첨부된 에러 파일은 Cloudflare HTML이었고, 앱 backend가 내려준 JSON response가 아니었다.&lt;/p&gt;
&lt;p&gt;이건 application layer에서 중요한 분기다. backend가 만든 JSON 에러라면 API validation, provider exception, 저장 로직을 먼저 봤을 것이다. 하지만 body가 HTML이고 문구가 &lt;code class=&quot;language-text&quot;&gt;Browser Working&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Cloudflare Working&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Host Error&lt;/code&gt;였기 때문에 handler 내부 예외보다 HTTP proxy와 origin 사이 경계에 가까웠다.&lt;/p&gt;
&lt;h2 id=&quot;HTTPproxy-boundary-그-다음-아래로-내려갔다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#HTTPproxy-boundary-%EA%B7%B8-%EB%8B%A4%EC%9D%8C-%EC%95%84%EB%9E%98%EB%A1%9C-%EB%82%B4%EB%A0%A4%EA%B0%94%EB%8B%A4&quot; aria-label=&quot;HTTPproxy boundary 그 다음 아래로 내려갔다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;HTTP/proxy boundary: 그 다음 아래로 내려갔다&lt;/h2&gt;
&lt;p&gt;다음으로 확인한 것은 &quot;서비스 전체가 죽었는가&quot;였다. 대표적인 health check와 관리 화면은 정상적으로 응답했다. 전체 서비스 장애라기보다는 특정 localization 생성 요청만 길어졌거나, 그 요청을 처리하는 동안 proxy 또는 origin 경계에서 실패했을 가능성이 더 컸다.&lt;/p&gt;
&lt;p&gt;Cloudflare proxy는 교과서의 five-layer model에서 독립된 계층은 아니다. 하지만 browser-to-Cloudflare와 Cloudflare-to-origin 사이에 연결 경계를 하나 더 만든다. 그래서 이 문제에서는 &quot;transport layer를 패킷 단위로 분석했다&quot;기보다, HTTP proxy가 origin 응답을 기다리는 경계를 확인했다고 쓰는 편이 더 정확하다.&lt;/p&gt;
&lt;p&gt;여기서 TCP와 HTTP timeout을 구분해야 한다. TCP는 손실되거나 순서가 바뀐 segment를 복구하는 reliable transport를 제공한다. 하지만 Cloudflare가 origin HTTP response를 얼마나 오래 기다릴지는 별개의 application/proxy 정책이다. TCP 연결이 가능하다는 사실만으로 긴 localization 작업이 브라우저 요청 안에서 끝난다는 뜻은 아니다.&lt;/p&gt;
&lt;p&gt;network layer 아래를 깊게 파지는 않았다. DNS 전체 장애, 물리 연결 단절, host reachability 문제가 있었다면 health check와 관리 화면도 같이 흔들렸을 가능성이 컸다. 실제 증거는 &quot;모든 요청이 안 된다&quot;가 아니라 &quot;특정 긴 관리 요청이 실패한다&quot;에 가까웠다.&lt;/p&gt;
&lt;h2 id=&quot;갑자기-발생한-이유&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B0%91%EC%9E%90%EA%B8%B0-%EB%B0%9C%EC%83%9D%ED%95%9C-%EC%9D%B4%EC%9C%A0&quot; aria-label=&quot;갑자기 발생한 이유 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;갑자기 발생한 이유&lt;/h2&gt;
&lt;p&gt;이 이슈가 갑자기 드러난 데에는 모델 교체가 영향을 준 것으로 봤다. 최근 생성 모델을 바꾼 뒤 landing HTML이 이전보다 훨씬 커지는 경향이 생겼다. localization은 최종 HTML을 다시 segment로 나누고 locale별로 번역한다. 그래서 page 생성 품질이나 표현력이 좋아지는 변화가, localization 단계에서는 곧 번역해야 할 입력 크기 증가로 이어졌다.&lt;/p&gt;
&lt;p&gt;당시 확인한 workload 크기는 이랬다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;txt&quot;&gt;&lt;pre class=&quot;language-txt&quot;&gt;&lt;code class=&quot;language-txt&quot;&gt;rendered_html_length: 533358
segment_count: 166
existing_localizations: 0
target_locales: multiple locales
translation_batch_size: 25&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;166&lt;/code&gt;개 segment를 batch size &lt;code class=&quot;language-text&quot;&gt;25&lt;/code&gt;로 나누면 한 locale에 7개 batch가 필요하다. 대상 locale이 여러 개이면 버튼 한 번이 여러 번의 번역 provider 호출을 포함하는 하나의 HTTP 요청이 된다. 품질 보정이나 retry가 붙으면 더 길어진다.&lt;/p&gt;
&lt;p&gt;이때 병목은 네트워크 throughput이 아니었다. &lt;code class=&quot;language-text&quot;&gt;533,358&lt;/code&gt;자 HTML은 크긴 하지만, 현대 웹에서 전송량만으로 설명하기 어려운 크기다. 더 큰 문제는 request 하나가 여러 번의 외부 provider round trip과 origin-side processing delay를 직렬로 기다린다는 점이었다.&lt;/p&gt;
&lt;p&gt;전공책에서 delay를 processing delay, queuing delay, transmission delay, propagation delay로 나눠 보는 이유가 여기에 있다. 이번에는 physical link의 propagation delay나 packet transmission delay가 핵심이 아니었다. origin application이 segment를 나누고, provider 호출을 기다리고, 결과를 합치는 processing/waiting time이 HTTP response 시간을 밀어 올렸다. provider가 느리거나 backend worker가 바쁘면 queuing delay처럼 누적되는 대기도 생길 수 있다.&lt;/p&gt;
&lt;p&gt;Cloudflare 공식 connection limits 문서에는 proxied traffic에서 origin 응답을 기다리는 &lt;code class=&quot;language-text&quot;&gt;Proxy Read Timeout&lt;/code&gt;이 120초로 정리되어 있다. Cloudflare의 502/504 문서도 502를 origin 또는 Cloudflare edge 쪽에서 발생할 수 있는 gateway 계열 실패로 설명한다. 실제 화면은 &lt;code class=&quot;language-text&quot;&gt;524&lt;/code&gt;가 아니라 &lt;code class=&quot;language-text&quot;&gt;502&lt;/code&gt;였기 때문에 &quot;Cloudflare read timeout이 정확히 발생했다&quot;고 단정하지는 않았다. 다만 이 구조가 public proxy 앞에서 긴 동기 작업을 한 요청에 몰아넣는 취약한 구조라는 점은 충분히 확인됐다.&lt;/p&gt;
&lt;h2 id=&quot;실제-top-down-흐름&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%A4%EC%A0%9C-top-down-%ED%9D%90%EB%A6%84&quot; aria-label=&quot;실제 top down 흐름 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;실제 top-down 흐름&lt;/h2&gt;
&lt;p&gt;이번 디버깅은 에러 메시지 하나만 보고 결론을 낸 것이 아니다. 전공책식 계층 모델을 현장에 대입하면, 실제로 한 일은 이 순서에 가깝다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Application layer: 관리 화면 상태와 error body를 봤다. 앱 JSON이 아니라 Cloudflare HTML 502였다.&lt;/li&gt;
&lt;li&gt;Application protocol / HTTP boundary: &lt;code class=&quot;language-text&quot;&gt;Browser Working&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Cloudflare Working&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Host Error&lt;/code&gt; 문구로 browser-to-Cloudflare보다는 Cloudflare-to-origin 쪽을 의심했다.&lt;/li&gt;
&lt;li&gt;Origin reachability: 대표 health check와 관리 화면이 정상인지 확인했다. 전체 origin 장애보다는 특정 요청 문제가 더 그럴듯했다.&lt;/li&gt;
&lt;li&gt;HTTP proxy / origin connection boundary: Cloudflare가 origin 응답을 기다리는 시간 제한을 확인했다. 긴 동기 요청이 위험한 구조라는 기준을 세웠다.&lt;/li&gt;
&lt;li&gt;Application workload: 실제 HTML 길이, segment 수, batch size, target locale 수를 계산했다.&lt;/li&gt;
&lt;li&gt;Delay source: 전송량보다 provider round trip과 origin processing/waiting time이 더 큰 병목이라고 판단했다.&lt;/li&gt;
&lt;li&gt;Request shape: missing locale 전체를 하나의 payload에 넣는 흐름을 확인했다.&lt;/li&gt;
&lt;li&gt;Transport vs application guarantee: TCP가 reliable하더라도 HTTP proxy timeout 안에 response가 완성된다는 보장은 없다고 정리했다.&lt;/li&gt;
&lt;li&gt;Fix boundary: network 설정을 늘리는 대신 browser-facing 요청을 locale별로 나눴다.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;중요한 지점은 로그가 없다고 해서 추측으로 건너뛰지 않은 것이다. 해당 실패 요청의 origin log line을 직접 확보하지는 못했다. 그래서 &quot;이 로그가 timeout을 증명했다&quot;고 쓰지 않았다. 대신 현재 데이터와 설정으로 그 요청이 얼마나 무거웠는지 다시 계산했다.&lt;/p&gt;
&lt;h2 id=&quot;고친-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B3%A0%EC%B9%9C-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;고친 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;고친 방식&lt;/h2&gt;
&lt;p&gt;문제는 관리 화면의 request shape이었다. 여러 locale을 한 번에 생성할 수 있는 backend 기능 자체가 항상 나쁜 것은 아니다. 별도 batch 작업에서는 한 번에 여러 locale을 넘기는 흐름이 편할 수 있다.&lt;/p&gt;
&lt;p&gt;하지만 브라우저에서 Cloudflare와 reverse proxy를 지나 backend까지 가는 요청은 짧고 예측 가능해야 한다. 그래서 관리 화면에서는 여러 locale을 한 요청에 넣지 않고, locale별로 순차 처리하도록 바꿨다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;txt&quot;&gt;&lt;pre class=&quot;language-txt&quot;&gt;&lt;code class=&quot;language-txt&quot;&gt;request 1 -&gt; locale A
request 2 -&gt; locale B
request 3 -&gt; locale C&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;네트워크 개념으로 말하면, 하나의 큰 request/response transaction을 여러 개의 작은 transaction으로 나눈 것이다. 전체 작업량이 갑자기 줄어든 것은 아니다. 대신 한 HTTP response가 proxy timeout 경계에 걸릴 확률을 줄였다. link bandwidth를 늘린 것이 아니라, application protocol 위에서 작업 단위를 다시 잡은 fix다.&lt;/p&gt;
&lt;p&gt;같이 고친 부분도 있다. proxy가 HTML 에러 페이지를 내려줄 때 그 HTML을 화면에 그대로 노출하지 않고, HTTP 상태 문구로 정리해서 보여주도록 했다. 이건 root cause fix는 아니지만 다음 디버깅 품질을 올린다. 거대한 Cloudflare HTML을 그대로 보여주면 에러의 핵심을 놓치기 쉽다.&lt;/p&gt;
&lt;h2 id=&quot;검증&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%80%EC%A6%9D&quot; aria-label=&quot;검증 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;검증&lt;/h2&gt;
&lt;p&gt;검증은 두 가지를 중심으로 했다.&lt;/p&gt;
&lt;p&gt;첫째, 여러 locale을 한 번에 담은 요청이 아니라 locale별 요청으로 나뉘는지 확인했다. 둘째, proxy가 HTML error body를 반환했을 때 화면이 raw HTML을 그대로 노출하지 않는지 확인했다.&lt;/p&gt;
&lt;p&gt;그 뒤 lint, typecheck, frontend test, build/deploy pipeline을 통과시켰고, 배포 후 대표 health check와 관리 화면 접근도 다시 확인했다. 여기까지가 &quot;코드상으로는 고쳤다&quot;가 아니라 &quot;배포 후 다시 접근 가능한 상태까지 확인했다&quot;는 범위다.&lt;/p&gt;
&lt;h2 id=&quot;이번에-배운-것&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9D%B4%EB%B2%88%EC%97%90-%EB%B0%B0%EC%9A%B4-%EA%B2%83&quot; aria-label=&quot;이번에 배운 것 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;이번에 배운 것&lt;/h2&gt;
&lt;p&gt;첫 번째, 에러 body의 형식을 먼저 봐야 한다. &lt;code class=&quot;language-text&quot;&gt;502&lt;/code&gt;라는 status만 보면 backend 예외처럼 보일 수 있다. 하지만 body가 Cloudflare HTML이면 문제는 app handler 안쪽이 아니라 proxy와 origin 사이의 경계일 수 있다.&lt;/p&gt;
&lt;p&gt;두 번째, 모델 교체는 생성 품질만 바꾸지 않는다. 생성된 HTML의 크기, segment 수, 후속 localization 작업량까지 같이 바꿀 수 있다.&lt;/p&gt;
&lt;p&gt;세 번째, 긴 작업을 browser request 하나에 오래 붙잡아두면 edge timeout, reverse proxy timeout, upstream timeout 중 하나와 싸우게 된다. localization처럼 provider 호출이 여러 번 필요한 작업은 작은 단위로 쪼개거나, 더 나아가 background job과 polling으로 빼는 쪽이 맞다.&lt;/p&gt;
&lt;p&gt;네 번째, TCP의 reliable transport와 application의 timely response는 다른 문제다. packet이 안정적으로 전달될 수 있어도, origin이 응답을 만들기 전에 proxy가 포기하면 화면에서는 실패를 본다.&lt;/p&gt;
&lt;p&gt;다섯 번째, 로그가 사라졌을 때도 볼 수 있는 증거가 있다. 이번에는 live data의 HTML 길이, segment count, target locale 수, batch size가 그 역할을 했다. 이 값들이 없었다면 &quot;느렸을 것 같다&quot;에서 멈췄을 것이다.&lt;/p&gt;
&lt;h2 id=&quot;남은-과제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%82%A8%EC%9D%80-%EA%B3%BC%EC%A0%9C&quot; aria-label=&quot;남은 과제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;남은 과제&lt;/h2&gt;
&lt;p&gt;이번 fix는 관리 화면 요청을 locale별로 나눠서 proxy boundary를 덜 밟게 만든 조치다. 하지만 localization 생성 자체가 무거운 작업이라는 사실은 그대로다. 한 locale의 page가 더 커지고 provider 응답이 느려지면 단일 locale 요청도 다시 길어질 수 있다.&lt;/p&gt;
&lt;p&gt;장기적으로는 localization 생성도 background job으로 옮기고, 관리 화면은 job status를 polling하거나 stream으로 받는 구조가 더 안정적이다. 그때는 request가 &quot;번역을 끝낼 때까지 기다리는 일&quot;이 아니라 &quot;작업을 등록하고 진행 상태를 보는 일&quot;이 된다.&lt;/p&gt;
&lt;p&gt;네트워크 관점에서도 이쪽이 더 자연스럽다. 짧은 HTTP request는 job을 만들고 바로 response를 돌려준다. 긴 처리 시간은 browser와 proxy가 붙잡고 있는 TCP/HTTP transaction 밖으로 빠진다. 그 뒤 화면은 별도의 짧은 request나 stream으로 상태만 받는다.&lt;/p&gt;
&lt;p&gt;이번 변경은 그 전 단계다. 다시 같은 작업을 실행했을 때 여러 locale 전체를 한 HTTP 요청에 밀어 넣지 않도록 경계를 줄였다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/fundamentals/reference/connection-limits/&quot;&gt;Cloudflare Docs: Connection limits&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-502-504/&quot;&gt;Cloudflare Docs: Error 502 or 504&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;James F. Kurose, Keith W. Ross, &lt;em&gt;Computer Networking: A Top-Down Approach&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[DB가 느린 게 아니라 HTML blob을 너무 많이 읽고 있었다]]></title><description><![CDATA[Place2Page 공개 랜딩 몇 개가 갑자기 느려졌다. 로그만 보면 데이터베이스가 전반적으로 무거워진 것처럼 보였다. 같은 시각에  하나가 24-27초씩 걸렸고 slow query warning은 0.8-2.…]]></description><link>https://sewon.dev/place2page-public-page-html-blob-slow-query/</link><guid isPermaLink="false">https://sewon.dev/place2page-public-page-html-blob-slow-query/</guid><pubDate>Tue, 07 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Place2Page 공개 랜딩 몇 개가 갑자기 느려졌다. 로그만 보면 데이터베이스가 전반적으로 무거워진 것처럼 보였다. 같은 시각에 &lt;code class=&quot;language-text&quot;&gt;GET /&lt;/code&gt; 하나가 24-27초씩 걸렸고 slow query warning은 0.8-2.1초 단위로 여러 번 찍혔다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/0a742705ac2828d6baf11a2dc9934441/1e677/query-projection-flow.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACEklEQVR42m2RO2hTURjHKy4ODg5WqQgutakuTmo7OYmrFh1bulZcnXzQoZFASlATl2K7WESlUOySgMHUUFq0RtO03mrITXKNSZObJjf3cV73vORmyUM/zvlzOPD7+H//b4BzYZikaRLTcQ2TmDYBgDqOazkugNSy3ZZNGRNSSu/21gAXonQACr/t8gEolkFZR0rB+pY1d1R7VzW1CtBKFraApK4kRGAsOe/AUnBeScFcAqsJUU0LF6ymnWBMn49WFrdA08GioZs7meLGVnU7hX8oEkKPE56PAcEo/P5Wi4e1eBimV3BDX95o+GN2INp8vu5outUqaIbyq7qnVPf27f2fPbAUgh7mua6wmkIbRSFEbNdc2rRefQYrKRsQJlsGVXOsWGDFAlVVgVCX7XYSXErW1s5A3rcQ/6bUHZiU8sP69v3ZyGxw8VFg4XFgIRR56Q++SG5+kVJaLkpaatLIfWpkk07+DzLaXUUHfjIfOX56dOTStXMXxs+OXD1zfuzoieEHcyEpZVovhkofw/nE02z8WTn5taX1w3PByJGTw0MXxwd9l0/5rgz5xo4Njj70e3AdWWu1TLSuROvKWi2Th4f98Ot376/fnLwzfW9icmZiaub29N0bt6aW36xKKXnXVv8/M+eCMsYY7xzOXUoxdjFxESEQE08JoYz1w8SlNoAQIogwQMh7QIwwIcSDu5X1wn8B/RJu+Wed8LkAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;공개 페이지 요청에서 projection이 tuple width와 data movement를 줄이는 흐름&apos; title=&apos;&apos; src=&apos;/static/0a742705ac2828d6baf11a2dc9934441/ca1dc/query-projection-flow.png&apos; srcset=&apos;/static/0a742705ac2828d6baf11a2dc9934441/e7570/query-projection-flow.png 170w,
/static/0a742705ac2828d6baf11a2dc9934441/f46e7/query-projection-flow.png 340w,
/static/0a742705ac2828d6baf11a2dc9934441/ca1dc/query-projection-flow.png 680w,
/static/0a742705ac2828d6baf11a2dc9934441/02d09/query-projection-flow.png 1020w,
/static/0a742705ac2828d6baf11a2dc9934441/1e677/query-projection-flow.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;공개 페이지 요청에서 projection이 tuple width와 data movement를 줄이는 흐름&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;처음에는 인덱스부터 봤다. 그런데 로그를 다시 보니 row를 찾는 과정만으로는 설명이 부족했다. locale 목록만 필요한 코드가 어떤 column까지 읽는지, 그 row에 붙은 HTML payload가 얼마나 큰지, 그걸 매 요청마다 어디까지 옮기는지가 더 중요했다.&lt;/p&gt;
&lt;p&gt;결론부터 쓰면 DB가 갑자기 망가진 게 아니었다. 공개 페이지 렌더링 경로가 필요 없는 HTML blob을 너무 많이 읽고 있었다. 여기에 한 페이지의 HTML 안에 큰 inline media payload까지 들어가면서 작은 메타데이터 조회가 매 요청마다 MB 단위 payload 전송으로 바뀌었다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: public page &lt;code class=&quot;language-text&quot;&gt;GET /&lt;/code&gt;가 24-27초까지 늘고, 같은 시간대에 0.8-2.1초 slow DB query warning이 연속으로 찍혔다.&lt;/li&gt;
&lt;li&gt;원인: locale switcher에 필요한 것은 locale 목록뿐인데 ORM이 큰 HTML column까지 포함한 full row를 읽고 있었다.&lt;/li&gt;
&lt;li&gt;증폭 요인: 특정 페이지 HTML 안에 큰 inline media payload가 있었고, 같은 payload가 localized row에도 복사되어 있었다.&lt;/li&gt;
&lt;li&gt;해결: 조회를 필요한 locale column으로 줄여 projection을 되살리고, 반복 조회 경로에는 보조 인덱스를 추가했다. inline media data source는 HTML normalizer에서 제거했다.&lt;/li&gt;
&lt;li&gt;결과: root 응답 body는 1,936,992 bytes에서 75,784 bytes로 96.09% 줄었고, warm TTFB median은 1.012초에서 0.123초로 약 8.23배 개선됐다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;처음-보인-증상&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C-%EB%B3%B4%EC%9D%B8-%EC%A6%9D%EC%83%81&quot; aria-label=&quot;처음 보인 증상 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음 보인 증상&lt;/h2&gt;
&lt;p&gt;로그의 신호는 이렇게 보였다. 요청 식별자는 글에서 제거했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;API request completed: GET / - Status: 200 - Duration: 24850.14ms
Slow database query: 1390.34ms
Slow database query: 1437.01ms
Slow database query: 1277.03ms
...
API request completed: GET / - Status: 200 - Duration: 25093.56ms
Slow database query: 1615.34ms
...
API request completed: GET / - Status: 200 - Duration: 27724.10ms
Slow database query: 2113.47ms&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;여기서 조심해야 할 점이 있었다. &quot;25초짜리 단일 쿼리&quot;가 보인 게 아니었다. 한 요청 안에서 여러 DB query가 느리게 관측됐고, 같은 초에 public request 여러 개가 겹쳤다. 그래서 첫 질문을 바꿨다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;어떤 쿼리 하나가 index를 못 타나?
-&gt; public render path가 요청마다 무엇을 얼마나 읽고 있나?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;전공서식으로 말하면 selection predicate만 볼 일이 아니었다. access path, projection, tuple width를 같이 봐야 했다.&lt;/p&gt;
&lt;h2 id=&quot;전공서-기준으로-문제를-다시-쓰기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A0%84%EA%B3%B5%EC%84%9C-%EA%B8%B0%EC%A4%80%EC%9C%BC%EB%A1%9C-%EB%AC%B8%EC%A0%9C%EB%A5%BC-%EB%8B%A4%EC%8B%9C-%EC%93%B0%EA%B8%B0&quot; aria-label=&quot;전공서 기준으로 문제를 다시 쓰기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;전공서 기준으로 문제를 다시 쓰기&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;Database System Concepts&lt;/code&gt; 6판은 11장에서 indexing, 12장에서 query processing과 query cost, 13장에서 query optimization을 다룬다. 이번 문제를 그 순서로 다시 쓰면 꽤 단순해진다.&lt;/p&gt;
&lt;p&gt;첫째, 인덱스는 &quot;어떤 row를 찾을지&quot;를 도와준다. 하지만 찾은 row에서 어떤 attribute를 가져올지는 다른 문제다.&lt;/p&gt;
&lt;p&gt;둘째, SQL의 &lt;code class=&quot;language-text&quot;&gt;select *&lt;/code&gt;는 결과 relation의 모든 attribute를 고른다. 책에서는 이걸 SQL 기본 문법으로 설명하지만, 운영에서는 비용 모델이 된다. row 안에 큰 &lt;code class=&quot;language-text&quot;&gt;TEXT&lt;/code&gt; column이 있으면 &lt;code class=&quot;language-text&quot;&gt;select *&lt;/code&gt;는 &quot;필요한 값 하나&quot;가 아니라 &quot;큰 payload 전체&quot;를 가져오겠다는 뜻이다.&lt;/p&gt;
&lt;p&gt;셋째, relational algebra에서 projection은 단순한 문법 장식이 아니다. 이번 케이스에서는 &lt;code class=&quot;language-text&quot;&gt;locale&lt;/code&gt;만 projecting 해야 했다. 그래야 DB에서 API process로 넘어오는 tuple 폭이 작아지고, public render request 하나가 localization HTML 전체를 끌고 오지 않는다.&lt;/p&gt;
&lt;p&gt;그래서 디버깅 기준을 이렇게 잡았다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Selection: 현재 페이지에 맞는 localization row를 찾는다.
Projection: switcher에 필요한 locale column만 읽는다.
Cost: row count보다 row width와 transfer size를 먼저 확인한다.
Index: selection predicate와 order by에 맞춰 보조한다.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;public-render-path에서-본-실제-쿼리&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#public-render-path%EC%97%90%EC%84%9C-%EB%B3%B8-%EC%8B%A4%EC%A0%9C-%EC%BF%BC%EB%A6%AC&quot; aria-label=&quot;public render path에서 본 실제 쿼리 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;public render path에서 본 실제 쿼리&lt;/h2&gt;
&lt;p&gt;문제가 난 경로는 공개 페이지 렌더링이었다. 단순화하면 흐름은 이랬다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;GET /{page}
-&gt; 공개 page 조회
-&gt; localization locale 목록 조회
-&gt; locale별 switcher/hreflang 구성
-&gt; stored HTML normalizing
-&gt; HTML response&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;여기서 locale 목록 조회는 실제 HTML이 필요 없다. 루트 페이지에서 필요한 값은 &quot;이 페이지에 어떤 locale이 있는가&quot; 정도다.&lt;/p&gt;
&lt;p&gt;그런데 코드상 helper는 &lt;code class=&quot;language-text&quot;&gt;LandingLocalization&lt;/code&gt; entity 전체를 조회한 뒤 Python에서 &lt;code class=&quot;language-text&quot;&gt;.locale&lt;/code&gt;만 읽고 있었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;필요한 값: locale
실제로 읽은 값: localization full row
문제 column: stored HTML&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;ORM 코드에서 흔한 실수다. Python에서는 &lt;code class=&quot;language-text&quot;&gt;.locale&lt;/code&gt; 하나만 읽는다. 하지만 SQLAlchemy가 entity 전체를 load하면 DB와 application은 full row 비용을 낸다. row 안에 큰 &lt;code class=&quot;language-text&quot;&gt;TEXT&lt;/code&gt; column이 있으면 &lt;code class=&quot;language-text&quot;&gt;SELECT *&lt;/code&gt;의 의미가 완전히 달라진다.&lt;/p&gt;
&lt;h2 id=&quot;DB에서-확인한-숫자&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#DB%EC%97%90%EC%84%9C-%ED%99%95%EC%9D%B8%ED%95%9C-%EC%88%AB%EC%9E%90&quot; aria-label=&quot;DB에서 확인한 숫자 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;DB에서 확인한 숫자&lt;/h2&gt;
&lt;p&gt;DB에서 본 테이블 크기는 row 수만 보고 예상한 것과 달랐다. row는 많지 않았다. 문제는 tuple 폭이었다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;항목&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;값&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;localization row 수&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;39 rows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;localization table 총 크기&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;18 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;stored HTML 합계&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;12 MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;rendered_html&lt;/code&gt; 평균&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;328,346 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;rendered_html&lt;/code&gt; 최대&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1,934,756 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;특히 대표 페이지는 더 극단적이었다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;항목&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;수정 전&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;root page HTML&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1,931,827 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;현재 locale row 수&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3 rows&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;현재 locale HTML 합계&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;5,799,877 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;즉 root page 하나를 렌더링할 때 locale switcher를 만들려고 localized HTML 5.8MB를 추가로 읽을 수 있는 구조였다. 화면에는 언어 목록 몇 글자만 필요했는데 DB에서는 MB 단위 HTML blob을 읽고 있었다.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;EXPLAIN&lt;/code&gt;도 방향을 확인해줬다. 캐시가 따뜻한 상태에서는 실행 시간 자체가 아주 길지 않았지만, query shape가 문제였다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sql&quot;&gt;&lt;pre class=&quot;language-sql&quot;&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;-- 기존 의도와 다른 형태&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;select&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; localization_rows
&lt;span class=&quot;token keyword&quot;&gt;where&lt;/span&gt; page_scope &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;token comment&quot;&gt;-- 필요한 형태&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;select&lt;/span&gt; locale
&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; landing_localizations
&lt;span class=&quot;token keyword&quot;&gt;where&lt;/span&gt; page_scope &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 차이는 row 수가 적을 때는 잘 안 보인다. 하지만 &lt;code class=&quot;language-text&quot;&gt;rendered_html&lt;/code&gt;이 2MB 가까이 커지고 같은 요청이 동시에 몰리면 API process, DB connection, network transfer, response normalizing 비용이 함께 커진다.&lt;/p&gt;
&lt;h2 id=&quot;왜-인덱스만으로-끝낼-수-없었나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EC%9D%B8%EB%8D%B1%EC%8A%A4%EB%A7%8C%EC%9C%BC%EB%A1%9C-%EB%81%9D%EB%82%BC-%EC%88%98-%EC%97%86%EC%97%88%EB%82%98&quot; aria-label=&quot;왜 인덱스만으로 끝낼 수 없었나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 인덱스만으로 끝낼 수 없었나&lt;/h2&gt;
&lt;p&gt;인덱스는 필요했다. 같은 페이지와 locale 기준으로 조회하는 경로가 반복되기 때문이다. 그래도 이것만으로는 부족했다.&lt;/p&gt;
&lt;p&gt;전공서에서 query cost를 다룰 때도 access path만 보지 않는다. disk I/O, block transfer, intermediate result, 선택한 plan 전체가 비용을 만든다. 이 사건에서는 &quot;찾는 row 수&quot;보다 &quot;찾은 뒤 가져오는 column 크기&quot;가 더 컸다. 인덱스가 row 세 개를 빠르게 찾아줘도, 그 row 세 개에 5.8MB HTML이 붙어 있으면 public request는 여전히 무겁다.&lt;/p&gt;
&lt;p&gt;그래서 수정 순서는 이렇게 잡았다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;1. projection 수정: locale 목록 조회는 locale column만 읽는다.
2. index 추가: 반복되는 selection predicate를 보조한다.
3. payload 정리: stored HTML 안의 inline media를 없앤다.
4. guardrail 추가: normalizer가 같은 payload를 다시 저장하지 못하게 막는다.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;더-큰-증폭-요인-inline-video&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8D%94-%ED%81%B0-%EC%A6%9D%ED%8F%AD-%EC%9A%94%EC%9D%B8-inline-video&quot; aria-label=&quot;더 큰 증폭 요인 inline video permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;더 큰 증폭 요인: inline video&lt;/h2&gt;
&lt;p&gt;왜 HTML이 2MB 가까이 됐는지도 따로 봤다. 원인은 하나의 attribute였다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;source&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;data:video/webm;base64,...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;video/webm&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 &lt;code class=&quot;language-text&quot;&gt;data:video&lt;/code&gt; payload 하나가 거의 1.9MB였다. 페이지 HTML 안에는 fallback image도 이미 있었기 때문에 public page에서 반드시 inline video를 들고 있을 이유가 없었다.&lt;/p&gt;
&lt;p&gt;문제는 이 payload가 원본 페이지에만 있는 것이 아니었다. localization row에도 HTML이 저장되기 때문에 같은 inline video가 locale별 row에 반복 저장됐다. 그래서 root HTML 1.9MB, localized HTML 1.9MB, 또 다른 locale 1.9MB 식으로 커졌다.&lt;/p&gt;
&lt;h2 id=&quot;한-번의-운영-데이터-정리&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%9C-%EB%B2%88%EC%9D%98-%EC%9A%B4%EC%98%81-%EB%8D%B0%EC%9D%B4%ED%84%B0-%EC%A0%95%EB%A6%AC&quot; aria-label=&quot;한 번의 운영 데이터 정리 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;한 번의 운영 데이터 정리&lt;/h2&gt;
&lt;p&gt;먼저 이미 생성된 HTML을 정리했다. inline video를 제거하고, &lt;code class=&quot;language-text&quot;&gt;&amp;lt;video&gt;&lt;/code&gt; 내부 fallback &lt;code class=&quot;language-text&quot;&gt;&amp;lt;img&gt;&lt;/code&gt;가 있으면 그 이미지를 남기는 방식이었다.&lt;/p&gt;
&lt;p&gt;대표 페이지 기준 변화는 이랬다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;대상&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;수정 전&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;수정 후&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;감소&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;root page HTML&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1,931,827 bytes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;70,619 bytes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;96.34% 감소, 27.36배 축소&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3개 locale HTML 합계&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;5,799,877 bytes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;216,231 bytes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;96.27% 감소, 26.82배 축소&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;public root response body&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1,936,992 bytes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;75,784 bytes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;96.09% 감소, 25.56배 축소&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;public &lt;code class=&quot;language-text&quot;&gt;/ko/&lt;/code&gt; response body&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1,938,888 bytes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;77,674 bytes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;95.99% 감소, 24.96배 축소&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;이 정리는 코드 수정 전에도 즉시 효과가 있었다. root와 locale page가 더 이상 2MB 가까운 HTML을 내려주지 않았기 때문이다.&lt;/p&gt;
&lt;h2 id=&quot;코드상-재발-방지&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%BD%94%EB%93%9C%EC%83%81-%EC%9E%AC%EB%B0%9C-%EB%B0%A9%EC%A7%80&quot; aria-label=&quot;코드상 재발 방지 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;코드상 재발 방지&lt;/h2&gt;
&lt;p&gt;이미 생성된 데이터를 정리하는 것만으로는 부족했다. 다음 HTML import나 localization 생성에서 같은 문제가 다시 들어올 수 있기 때문이다. 코드는 네 군데를 고쳤다.&lt;/p&gt;
&lt;p&gt;첫째, locale 목록 조회를 full row query에서 scalar query로 바꿨다. 이게 이번 수정의 중심이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sql&quot;&gt;&lt;pre class=&quot;language-sql&quot;&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;select&lt;/span&gt; localization&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;locale
&lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; localization
&lt;span class=&quot;token keyword&quot;&gt;where&lt;/span&gt; page_scope &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; :page_scope
&lt;span class=&quot;token keyword&quot;&gt;order&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;by&lt;/span&gt; locale&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;둘째, 이 조회 패턴에 맞춰 인덱스를 추가했다. projection으로 tuple 폭을 줄이고, index로 lookup 경로를 안정시킨 셈이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sql&quot;&gt;&lt;pre class=&quot;language-sql&quot;&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;create&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;index&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;on&lt;/span&gt; localization &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;page_scope&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; locale&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;셋째, localization status 조회도 큰 HTML column을 불필요하게 로드하지 않도록 필요한 metadata만 읽게 했다. status 화면에 필요한 것은 locale, 상태, timestamp, metadata이지 전체 HTML이 아니다.&lt;/p&gt;
&lt;p&gt;넷째, HTML normalizer에서 inline &lt;code class=&quot;language-text&quot;&gt;data:video&lt;/code&gt; source를 제거하도록 했다. &lt;code class=&quot;language-text&quot;&gt;&amp;lt;video&gt;&lt;/code&gt; 안에 fallback &lt;code class=&quot;language-text&quot;&gt;&amp;lt;img&gt;&lt;/code&gt;가 있으면 video wrapper를 image로 치환하고, fallback이 없으면 video data source만 제거한다. public response normalizer와 stored HTML normalizer 양쪽에 같은 규칙을 적용했다.&lt;/p&gt;
&lt;h2 id=&quot;응답-시간-개선&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9D%91%EB%8B%B5-%EC%8B%9C%EA%B0%84-%EA%B0%9C%EC%84%A0&quot; aria-label=&quot;응답 시간 개선 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;응답 시간 개선&lt;/h2&gt;
&lt;p&gt;정리 전후 &lt;code class=&quot;language-text&quot;&gt;curl&lt;/code&gt;로 같은 public URL을 여러 번 확인했다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;측정&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;수정 전&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;수정 후&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;root response size&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1,936,992 bytes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;75,784 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;root warm TTFB median&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1.012s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.123s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;root warm TTFB 개선&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;-&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;87.85% 감소, 8.23배 개선&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;root total time range&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1.328-1.650s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.099-0.140s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;/ko/&lt;/code&gt; response size&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1,938,888 bytes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;77,674 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;/ko/&lt;/code&gt; warm TTFB range&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;약 1.00-1.10s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.124-0.154s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;/ko/&lt;/code&gt; total time range&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;최대 2.46s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.131-0.161s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;배포 직후 첫 요청은 container warmup 영향으로 5.5초가 한 번 나왔다. 그 다음 warm request들은 root가 0.09-0.14초, &lt;code class=&quot;language-text&quot;&gt;/ko/&lt;/code&gt;가 0.13-0.16초 범위로 안정됐다.&lt;/p&gt;
&lt;h2 id=&quot;검증&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%80%EC%A6%9D&quot; aria-label=&quot;검증 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;검증&lt;/h2&gt;
&lt;p&gt;검증은 세 단계로 나눴다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;로컬 테스트&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;git diff --check
lint
targeted tests for indexing, HTML normalization, and public rendering&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;마이그레이션 상태&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;schema migration head matched the deployed database
the expected localization lookup index existed&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt;배포 후 smoke&lt;/li&gt;
&lt;/ol&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;GET /      -&gt; 200, 75,784 bytes, warm total 0.099-0.140s
GET /ko/   -&gt; 200, 77,674 bytes, warm total 0.131-0.161s
slow query warnings for the checked path no longer appeared&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;CI/CD에서도 API static check, typing, tests, image build, deploy job이 통과했다.&lt;/p&gt;
&lt;h2 id=&quot;이번에-배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9D%B4%EB%B2%88%EC%97%90-%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;이번에 배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;이번에 배운 점&lt;/h2&gt;
&lt;p&gt;row 수는 테이블 무게를 말해주지 않는다. 작은 테이블도 row 안에 2MB &lt;code class=&quot;language-text&quot;&gt;TEXT&lt;/code&gt;가 있으면 public request path에서 충분히 위험하다. 전공서의 cost model을 운영 코드에 대입하면 이 말은 더 단순해진다. relation cardinality만 보지 말고 tuple width와 transfer size를 같이 봐야 한다.&lt;/p&gt;
&lt;p&gt;ORM entity 조회는 생각보다 비싸다. Python에서는 &lt;code class=&quot;language-text&quot;&gt;.locale&lt;/code&gt; 하나만 읽더라도 SQL이 full row를 가져오면 DB와 application은 full row 비용을 낸다. public render path에서는 &quot;필요한 column만 select한다&quot;가 성능 최적화라기보다 안전 규칙에 가깝다.&lt;/p&gt;
&lt;p&gt;stored HTML 기반 제품에서는 HTML 크기 budget이 필요하다. 특히 &lt;code class=&quot;language-text&quot;&gt;data:image&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;data:video&lt;/code&gt;, base64 font, 거대한 inline script 같은 값은 한 번 들어오면 원본 HTML, localized HTML, revision HTML로 복제되기 쉽다.&lt;/p&gt;
&lt;p&gt;마지막으로 slow query warning은 &quot;DB가 느리다&quot;는 결론이 아니라 &quot;이 요청이 DB와 주고받는 일이 느리다&quot;는 신호로 봐야 한다. 이번 문제는 index 하나만의 문제가 아니었다. query shape, stored blob, HTML import, localization lifecycle이 겹친 결과였다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-막을-것&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%EB%A7%89%EC%9D%84-%EA%B2%83&quot; aria-label=&quot;다음에는 이렇게 막을 것 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 막을 것&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;public render path에서 full HTML column을 읽는 query를 테스트로 잡는다.&lt;/li&gt;
&lt;li&gt;HTML import/generation 단계에서 inline media budget을 둔다.&lt;/li&gt;
&lt;li&gt;localization status와 locale switcher는 HTML blob 없이 metadata만 읽게 한다.&lt;/li&gt;
&lt;li&gt;landing HTML과 localization HTML의 byte size를 운영 지표로 남긴다.&lt;/li&gt;
&lt;li&gt;slow query 로그는 SQL text, row width, request group, response size를 함께 볼 수 있게 개선한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Abraham Silberschatz, Henry F. Korth, S. Sudarshan, &lt;em&gt;Database System Concepts&lt;/em&gt;, 6th edition
&lt;ul&gt;
&lt;li&gt;Chapter 11: Indexing and Hashing&lt;/li&gt;
&lt;li&gt;Chapter 12: Query Processing, Measures of Query Cost, Selection Operation&lt;/li&gt;
&lt;li&gt;Chapter 13: Query Optimization&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[운영 트래픽을 제품 지표에서 빼는 analytics wrapper]]></title><description><![CDATA[제품 지표를 보기 시작하면 가장 먼저 부딪히는 문제가 있다. 숫자는 찍히는데, 그 숫자가 고객 행동인지 테스트 행동인지 헷갈린다.  Place2Page의 분석 환경을 정리하면서 GA4, Mixpanel, Search Console…]]></description><link>https://sewon.dev/place2page-analytics-wrapper-admin-suppression/</link><guid isPermaLink="false">https://sewon.dev/place2page-analytics-wrapper-admin-suppression/</guid><pubDate>Tue, 30 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;제품 지표를 보기 시작하면 가장 먼저 부딪히는 문제가 있다. 숫자는 찍히는데, 그 숫자가 고객 행동인지 테스트 행동인지 헷갈린다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/69278cfa40472a900114f5d8ac6deeaf/1e677/analytics-suppression-flow.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACGElEQVR42m1Su24TQRT1F9DQWEJKFYkGJBpS0CE6CBISCAml4yEaPoCeColHQZPGHVYKUAQWDW7My8karx2HEDuOwY/1ZtfeeO2d2ee87qBdY+NIHF2NZnTvuTrnaFIA4LjURtQL+ART5FKEqYOJ4yYnptiLL57HXY/Jk0gJgK7mtDu2aTq/OhPN8DXD1Qzc7qPeEdYM3De9ruHX9fGBOUYixCwCmJFBcNC+evu5oJ4DvQjzTgKQ8XPiWRt2OaN/W9e+vB3vhowmLZkCznBt83g7Myxm8M5mZB+Tcc8bVhyjgkw1HO0xZFlW782gsjGoZAflD6OfhLO/ZCklDz2IMISIRz4IGfYUq5M73Hv3u/7ePfpInUGiAeZi/nmWIJheRc1PqFlg+g7DKDB+RPaWP1ICW4nsErF113O2UbcwaBSsg6qrMyFmZMFc9XU//1LLv3DLWRH6IATQEFhcgkVSysGou258fn6Yf9bKZ0dqwMg0jpQE4I4BThcmHY7M2AXnlCbFOGGcMe5T0nDNRjDc982WZ4mZhdTcCEgpEj1Pnr66vHrnxtrD67fvr966d/Xm3SvX1uqNlpwNLHiehwEw7T149PjU0vkz5y6lz66kly+ml1dOL10oqbVElICFxGIyYzyMSERoRChjrNlqF8tVpVorVXcVtaaota3v1fEETcc4F/8nE0KjiHAR/xQhJEwRawJK2XT7IvkPddmFgSPf7gYAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;route와 auth state를 shared helper에서 판단한 뒤 GA4와 Mixpanel 호출을 막는 흐름&apos; title=&apos;&apos; src=&apos;/static/69278cfa40472a900114f5d8ac6deeaf/ca1dc/analytics-suppression-flow.png&apos; srcset=&apos;/static/69278cfa40472a900114f5d8ac6deeaf/e7570/analytics-suppression-flow.png 170w,
/static/69278cfa40472a900114f5d8ac6deeaf/f46e7/analytics-suppression-flow.png 340w,
/static/69278cfa40472a900114f5d8ac6deeaf/ca1dc/analytics-suppression-flow.png 680w,
/static/69278cfa40472a900114f5d8ac6deeaf/02d09/analytics-suppression-flow.png 1020w,
/static/69278cfa40472a900114f5d8ac6deeaf/1e677/analytics-suppression-flow.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;route와 auth state를 shared helper에서 판단한 뒤 GA4와 Mixpanel 호출을 막는 흐름&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Place2Page의 분석 환경을 정리하면서 GA4, Mixpanel, Search Console도 같이 정리했다. 이때 제품 분석에 넣을 트래픽과 제외할 트래픽을 먼저 나눠야 했다. 특히 초기 제품에서는 트래픽 모수가 작아서, 테스트나 운영 확인 몇 번만으로도 전환율과 funnel 숫자가 쉽게 흔들린다.&lt;/p&gt;
&lt;p&gt;처음에는 Mixpanel 쪽만 생각했다. 관리 화면에서 Mixpanel event를 안 보내면 된다고 봤다. 그런데 다시 보니 문제는 특정 SDK 하나가 아니었다. GA4도 있고, Mixpanel도 있고, 로그인 상태에 따라 user identity도 붙는다. 한쪽만 막으면 나중에 숫자를 볼 때 다시 의심하게 된다.&lt;/p&gt;
&lt;p&gt;그래서 이번 작업의 기준은 단순하게 잡았다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;제품 지표에서 제외해야 하는 조건은 한 곳에서 판단한다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;왜-wrapper에서-막아야-했나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-wrapper%EC%97%90%EC%84%9C-%EB%A7%89%EC%95%84%EC%95%BC-%ED%96%88%EB%82%98&quot; aria-label=&quot;왜 wrapper에서 막아야 했나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 wrapper에서 막아야 했나&lt;/h2&gt;
&lt;p&gt;분석 도구를 붙일 때는 보통 이벤트 이름과 property schema를 먼저 본다. 어떤 CTA를 눌렀는지, 어떤 단계에서 이탈했는지, 어떤 URL을 제출했는지 같은 것들이다.&lt;/p&gt;
&lt;p&gt;하지만 테스트성 트래픽을 빼는 문제는 schema보다 앞에 있다. 애초에 보내지 말아야 하는 이벤트면, 이벤트 이름을 잘 정리해도 소용이 없다.&lt;/p&gt;
&lt;p&gt;이번에 제외해야 했던 것은 두 가지였다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;제품 분석 대상이 아닌 관리성 화면&lt;/li&gt;
&lt;li&gt;제품 사용자가 아닌 운영·테스트 주체&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;경로 기준은 비교적 쉽다. 현재 화면이 제품 사용 흐름이 아니라 관리성 흐름이면 GA4와 Mixpanel 모두 보내지 않으면 된다.&lt;/p&gt;
&lt;p&gt;사용자 기준은 조금 더 조심해야 했다. 브라우저가 처음 로드될 때는 아직 로그인 상태가 정해지지 않았을 수 있다. 즉, &quot;이 사용자를 제품 지표에 포함해도 되는가?&quot;라는 질문은 auth state가 resolve된 뒤에야 확정된다.&lt;/p&gt;
&lt;p&gt;그래서 route suppression과 user suppression을 같은 helper에 두되, user suppression은 auth state가 바뀔 때 갱신하게 했다.&lt;/p&gt;
&lt;h2 id=&quot;GA4는-이벤트만-막으면-부족했다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#GA4%EB%8A%94-%EC%9D%B4%EB%B2%A4%ED%8A%B8%EB%A7%8C-%EB%A7%89%EC%9C%BC%EB%A9%B4-%EB%B6%80%EC%A1%B1%ED%96%88%EB%8B%A4&quot; aria-label=&quot;GA4는 이벤트만 막으면 부족했다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;GA4는 이벤트만 막으면 부족했다&lt;/h2&gt;
&lt;p&gt;처음에는 기존 &lt;code class=&quot;language-text&quot;&gt;trackEvent&lt;/code&gt; wrapper에서 return early 하면 충분하다고 생각하기 쉽다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;shouldSuppressAnalytics&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;하지만 GA4는 wrapper로 보내는 이벤트만 문제가 아니다. gtag script가 이미 페이지에 들어가면 자동으로 page/session 수집이 일어날 수 있다.&lt;/p&gt;
&lt;p&gt;그래서 GA4는 두 겹으로 막았다.&lt;/p&gt;
&lt;p&gt;첫 번째는 script 자체를 렌더링하지 않는 것. 관리성 화면에서는 &lt;code class=&quot;language-text&quot;&gt;GoogleAnalytics&lt;/code&gt; client component가 gtag script를 넣지 않는다.&lt;/p&gt;
&lt;p&gt;두 번째는 이미 브라우저에 GA가 준비된 뒤 auth state가 바뀌는 경우다. 제품 분석에서 제외할 사용자로 확인되면 &lt;code class=&quot;language-text&quot;&gt;window[&quot;ga-disable-${measurementId}&quot;]&lt;/code&gt;를 켠다. 이러면 wrapper event뿐 아니라 해당 measurement id로 나가는 GA 수집도 끊을 수 있다.&lt;/p&gt;
&lt;p&gt;이 구조가 마음에 드는 이유는 책임이 분명해서다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;route suppression은 script render 단계에서 막는다.&lt;/li&gt;
&lt;li&gt;event suppression은 wrapper 단계에서 막는다.&lt;/li&gt;
&lt;li&gt;identity suppression은 auth state가 resolve된 뒤 disable flag로 막는다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Mixpanel은-더-앞에서-막았다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Mixpanel%EC%9D%80-%EB%8D%94-%EC%95%9E%EC%97%90%EC%84%9C-%EB%A7%89%EC%95%98%EB%8B%A4&quot; aria-label=&quot;Mixpanel은 더 앞에서 막았다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Mixpanel은 더 앞에서 막았다&lt;/h2&gt;
&lt;p&gt;Mixpanel은 event를 안 보내는 것만으로 끝내지 않았다. 제품 분석 대상이 아닌 화면에서는 SDK init 자체를 하지 않고, session replay도 시작하지 않는다.&lt;/p&gt;
&lt;p&gt;이유는 간단하다. 운영 확인용 흐름은 제품 분석 대상이 아니다. 그러면 &lt;code class=&quot;language-text&quot;&gt;track()&lt;/code&gt;만 막을 게 아니라 &lt;code class=&quot;language-text&quot;&gt;init&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;identify&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;reset&lt;/code&gt;, replay start/stop까지 같은 기준으로 no-op 되는 편이 낫다.&lt;/p&gt;
&lt;p&gt;이렇게 해두면 나중에 다른 화면에서 Mixpanel 함수를 호출하더라도, suppressed route나 suppressed user에서는 같은 정책이 적용된다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;route/auth/action
  -&gt; shared suppression helper
  -&gt; GA4 wrapper or Mixpanel wrapper
  -&gt; provider call or no-op&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;핵심은 GA4와 Mixpanel이 서로 다른 조건문을 갖지 않게 만드는 것이다. 분석 도구는 보통 시간이 지나면서 조금씩 붙는다. 이때 &quot;GA는 막았는데 Mixpanel은 열려 있다&quot;거나, 반대로 &quot;Mixpanel은 막았는데 GA realtime에 보인다&quot; 같은 상태가 되면 지표를 믿기 어렵다.&lt;/p&gt;
&lt;h2 id=&quot;auth-state와-연결한-부분&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#auth-state%EC%99%80-%EC%97%B0%EA%B2%B0%ED%95%9C-%EB%B6%80%EB%B6%84&quot; aria-label=&quot;auth state와 연결한 부분 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;auth state와 연결한 부분&lt;/h2&gt;
&lt;p&gt;사용자 기준 suppression은 auth state에 연결했다.&lt;/p&gt;
&lt;p&gt;로그인 상태가 바뀌면 현재 사용자를 shared suppression helper에 전달한다. suppressed user로 판단되면 GA user id를 세팅하지 않고, Mixpanel identify도 호출하지 않는다.&lt;/p&gt;
&lt;p&gt;여기서 일부러 보안 기능처럼 다루지는 않았다. 이건 접근 제어가 아니라 분석 수집 정책이다. 실제 권한 판단은 여전히 backend와 token verification 쪽 책임이다.&lt;/p&gt;
&lt;p&gt;다만 분석 지표 관점에서는 효과가 크다. 테스트나 운영 확인 과정에서 생긴 행동이 제품 funnel에 섞이지 않는다.&lt;/p&gt;
&lt;h2 id=&quot;검증한-것&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%80%EC%A6%9D%ED%95%9C-%EA%B2%83&quot; aria-label=&quot;검증한 것 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;검증한 것&lt;/h2&gt;
&lt;p&gt;이번 변경은 테스트를 먼저 넓혔다. 단순히 &quot;브라우저에서 안 보이는 것 같다&quot;로 끝내면 나중에 다시 깨지기 쉽다.&lt;/p&gt;
&lt;p&gt;확인한 것은 다음과 같다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;관리성 화면에서는 GA4 script가 렌더링되지 않는다.&lt;/li&gt;
&lt;li&gt;관리성 화면에서는 GA4 page visit과 event wrapper가 no-op 된다.&lt;/li&gt;
&lt;li&gt;제외 대상 사용자로 auth state가 resolve되면 GA disable flag가 켜진다.&lt;/li&gt;
&lt;li&gt;Mixpanel init, identify, track, reset, session replay가 suppressed state에서 no-op 된다.&lt;/li&gt;
&lt;li&gt;사용자 식별 기준은 대소문자 차이로 흔들리지 않는다.&lt;/li&gt;
&lt;li&gt;일반 public route와 anonymous traffic은 계속 수집된다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;로컬에서는 web test, lint, typecheck를 모두 돌렸다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/web &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;test&lt;/span&gt;
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/web &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; run lint
&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/web &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;npm&lt;/span&gt; run typecheck&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;남은-주의점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%82%A8%EC%9D%80-%EC%A3%BC%EC%9D%98%EC%A0%90&quot; aria-label=&quot;남은 주의점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;남은 주의점&lt;/h2&gt;
&lt;p&gt;사용자 기준 suppression은 auth state가 resolve된 뒤에 확정된다. 그래서 제외 대상 사용자가 public page를 열었는데 아직 auth state를 모르는 아주 초기 순간에는 anonymous event가 먼저 찍힐 수 있다.&lt;/p&gt;
&lt;p&gt;지금 단계에서는 괜찮다고 봤다. 당장 제거하려는 것은 관리성 화면의 트래픽과 로그인된 테스트성 행동이다. 만약 나중에 제외 대상 사용자의 public page 접근까지 더 강하게 막아야 한다면, analytics provider를 로드하기 전에 서버가 내려준 분석 제외 flag를 확인하는 구조가 필요하다.&lt;/p&gt;
&lt;p&gt;이번 작업에서 얻은 기준은 이렇다.&lt;/p&gt;
&lt;p&gt;분석 코드는 이벤트를 잘 보내는 코드이기도 하지만, 보내지 말아야 할 것을 정확히 안 보내는 코드이기도 하다. 특히 초기 제품에서는 이 두 번째 기준이 지표 신뢰도를 더 크게 좌우한다.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[소개팅 앱의 추천 점수를 궁합 점수 하나로 두지 않은 이유]]></title><description><![CDATA[…]]></description><link>https://sewon.dev/dating-app-reciprocal-matching-objective/</link><guid isPermaLink="false">https://sewon.dev/dating-app-reciprocal-matching-objective/</guid><pubDate>Wed, 24 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;이번 구현에서 가장 먼저 분리한 것은 &lt;strong&gt;사용자에게 보여주는 궁합 점수&lt;/strong&gt;와 &lt;strong&gt;실제 추천 순서를 정하는 내부 랭킹 점수&lt;/strong&gt;였다.&lt;/p&gt;
&lt;p&gt;소개팅 앱의 라운지에서는 궁합 점수가 높다고 무조건 먼저 보여주면 안 된다. 사용자가 그 사람을 마음에 들어 할 가능성도 중요하지만, 상대가 다시 반응할 가능성도 함께 봐야 하기 때문이다.&lt;/p&gt;
&lt;p&gt;예를 들어 거리가 멀면 추천 순서는 낮출 수 있다. 하지만 그 이유로 사용자에게 &quot;궁합이 낮다&quot;고 보여주면 설명이 이상해진다. 거리는 노출 순서를 조정하는 신호이지, 두 사람의 궁합을 설명하는 신호는 아니다.&lt;/p&gt;
&lt;p&gt;그래서 &lt;code class=&quot;language-text&quot;&gt;match_rate&lt;/code&gt;는 사용자에게 보여주는 설명용 점수로 두고, &lt;code class=&quot;language-text&quot;&gt;/discover/profiles&lt;/code&gt; 내부 정렬에는 별도의 &lt;code class=&quot;language-text&quot;&gt;RankScore&lt;/code&gt;를 사용했다. ML 모델을 바로 붙이기보다, 같은 입력이면 항상 같은 결과를 내는 MVP ranker와 200명 synthetic evaluation loop를 먼저 만들었다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/eb30b7b6782303c5240601ff1d91163c/0031c/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACSElEQVR42nWSz0tVQRTHb20ron2bqGgTtXATUgsJfBSGlFGUYkH0F7QIWrQxNV20iBa1DwxLEAQlTC1NeqTmfff98vl++Ozquz/m/nj33Xtn7ty5MxP3pZZQhy/DOcN85sw5ZwRgBSqAugltJ9ANuK35PxVPBXBL9WvAr+m+YQec8X+IcwGHBCLsQxQL4TAkOEAkxISEGAc4QJRS/h8T9jzWvMz0olUZi7GC5hq6QYRcZmrU1CNDDU2VWDq1dEpC9gemTXhh3Xs2jQcnQd+EOjBpDM5gSQ70DbaWYnkRryYdackrpllBpA2LCpwx6gHa0KKI8sCZF2sDs+T5FOifUIc/2kOzOC0jfYOUc1xacZJf1W8LtfVMWMowx6JCpGbMxdfG4puwsshwUIdRViFralTQorwW5ZXQNsBm2izneEEieRHnRVzKsqLE48wM2rD6HW0kI0clyKeuxbEbuhWor3Lq86DOI+TWSa3q69uwmvOUTajJUNnyESLC/v4xSgi2ZLU8Vc2N+SAX18J534uXrTduJrp727q6L9/pab/bezHR9ehJv7DTZc7YjhMbQQbx5L2djp6HB06eOdrScvj0uUPHzx45cf7gsVMX2q7vz/zXB9idXxwMDL9qbe/quP3gauf9K9fuJTp7LyVuPX46JPDdwyD0Prulea8875W/NEpzdmGuXvwEchPllUklPQ3yC43KTKNYgiCea5P6Dcf4VmCP1sUxRxpzpA+2OKItjyhL77Tlt3LyvfFj3M+Ou5nRRirl13aeyNgvzWxr0yIyi9IAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;소개팅 앱 추천 시스템에서 표시용 사주 궁합 점수와 내부 랭킹 점수를 분리한 구조&apos; title=&apos;&apos; src=&apos;/static/eb30b7b6782303c5240601ff1d91163c/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/eb30b7b6782303c5240601ff1d91163c/e7570/situation-diagram.png 170w,
/static/eb30b7b6782303c5240601ff1d91163c/f46e7/situation-diagram.png 340w,
/static/eb30b7b6782303c5240601ff1d91163c/ca1dc/situation-diagram.png 680w,
/static/eb30b7b6782303c5240601ff1d91163c/02d09/situation-diagram.png 1020w,
/static/eb30b7b6782303c5240601ff1d91163c/9d567/situation-diagram.png 1360w,
/static/eb30b7b6782303c5240601ff1d91163c/0031c/situation-diagram.png 4136w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;소개팅 앱 추천 시스템에서 표시용 사주 궁합 점수와 내부 랭킹 점수를 분리한 구조&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: 소개팅 앱 추천을 단순 궁합 점수 정렬로 만들면 실제 대화 가능성, 상호 관심, 노출 쏠림을 설명하기 어렵다.&lt;/li&gt;
&lt;li&gt;판단: 사용자에게 보이는 &lt;code class=&quot;language-text&quot;&gt;match_rate&lt;/code&gt;는 관계 설명용으로 유지하고, &lt;code class=&quot;language-text&quot;&gt;/discover/profiles&lt;/code&gt; 내부 정렬에는 별도의 &lt;code class=&quot;language-text&quot;&gt;RankScore&lt;/code&gt;를 둔다.&lt;/li&gt;
&lt;li&gt;구현: 궁합, 관심사, 거리, 나이 proxy, 프로필 완성도, freshness를 섞은 MVP ranker를 만들고, 남자 100명/여자 100명 synthetic profile로 기존 ranker와 비교했다.&lt;/li&gt;
&lt;li&gt;결과: MVP ranker는 대화 시작 가능성은 조금 높였지만, 서로 좋아할 가능성과 노출 분산은 나빠졌다.&lt;/li&gt;
&lt;li&gt;배운 점: synthetic 평가는 실제 성과를 증명하는 도구가 아니라, 새 ranker가 어떤 지표를 개선하고 어떤 지표를 망치는지 미리 보는 도구다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;이번에 작업한 제품은 사주 기반 궁합, 라운지 스와이프, 대화 신청, 채팅을 가진 소개팅 앱이다. 기존에는 MBTI, 출생연도 기준 띠, 관심사, 거리로 궁합 점수를 계산하고, 그 점수를 라운지 카드에서 보여줬다.&lt;/p&gt;
&lt;p&gt;처음에는 궁합 점수가 추천 정렬에도 자연스럽게 쓰일 수 있어 보였다. 예를 들어 &lt;code class=&quot;language-text&quot;&gt;궁합 95점&lt;/code&gt;인 후보를 &lt;code class=&quot;language-text&quot;&gt;궁합 70점&lt;/code&gt;인 후보보다 먼저 보여주는 것은 직관적이다. 하지만 제품 흐름을 놓고 보면 이 판단은 너무 단순했다.&lt;/p&gt;
&lt;p&gt;라운지 추천은 &quot;높은 점수를 보여주는 것&quot;에서 끝나지 않는다. 더 중요한 목표는 &quot;좋은 대화가 시작될 가능성을 높이는 것&quot;이다. 이 둘은 비슷해 보이지만 다르다.&lt;/p&gt;
&lt;h2 id=&quot;궁합-점수와-추천-랭킹은-목적이-다르다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B6%81%ED%95%A9-%EC%A0%90%EC%88%98%EC%99%80-%EC%B6%94%EC%B2%9C-%EB%9E%AD%ED%82%B9%EC%9D%80-%EB%AA%A9%EC%A0%81%EC%9D%B4-%EB%8B%A4%EB%A5%B4%EB%8B%A4&quot; aria-label=&quot;궁합 점수와 추천 랭킹은 목적이 다르다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;궁합 점수와 추천 랭킹은 목적이 다르다&lt;/h2&gt;
&lt;p&gt;사용자가 보는 궁합 점수는 설명용이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;이 사람과 왜 잘 맞는다고 말하는가?
어떤 성향, 관심사, 거리 조건이 점수에 반영됐는가?
사용자가 이 점수를 보고 납득할 수 있는가?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;반면 추천 랭킹은 노출 순서를 정하는 운영용 점수다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;이 후보를 지금 보여주면 사용자가 반응할 가능성이 높은가?
상대도 응답할 가능성이 있는가?
차단, 신고, 즉시 pass 가능성은 낮은가?
특정 후보에게 노출이 과도하게 몰리지 않는가?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그래서 &lt;code class=&quot;language-text&quot;&gt;match_rate&lt;/code&gt;를 내부 랭킹 점수처럼 쓰지 않기로 했다. 사용자에게 보이는 &lt;code class=&quot;language-text&quot;&gt;match_rate&lt;/code&gt;는 계속 표시용 궁합 점수로 유지하고, 내부 정렬에는 별도 &lt;code class=&quot;language-text&quot;&gt;RankScore&lt;/code&gt;를 둔다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;response.match_rate = DisplayCompatibility
internal.rank_score = DiscoveryRank&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;특히 거리 때문에 이 분리가 필요했다. 거리가 멀다는 이유로 추천 순서를 낮추는 것은 자연스럽다. 하지만 그 이유로 사용자에게 &quot;궁합이 낮다&quot;고 말하면 설명이 틀어진다. 거리는 노출 순서에서 감점할 수 있지만, 궁합 설명 자체를 망가뜨리면 안 된다.&lt;/p&gt;
&lt;p&gt;아래 sequence diagram은 실제 라운지 요청에서 이 분리가 어떻게 쓰이는지 보여준다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/9dfac69311f9349f7cb6332104716c5a/c852c/discover-ranking-sequence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 34.705882352941174%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAIAAACHqfpvAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA/UlEQVR42mWQSXbDMAxDff9jtlYbKbHsSKQGjn120m76HxfcACSwMAnUYaaq8jxGWBGQ3b2hfAWshUOoeet7pnjrZu7uiPz5URF5IWKoQEQAwMyPey6l1FrhpLk7k6qayDl+YWpM4m6Lqav6H3nbW2sxxntKKSYzG2OKqKnbW3suehktpqa/lu6+54OIxhgppdt3PI4j56P3Pvpk4n9i894GIiC23lvespna1QFUnHOqqJmPMRFRRFiEiGjy6/Ir1YmINiQ9taeYpvY+yhMBGkKH2hCx91ZKjfFh5ouIjv7+p1YKKwDQ1TaHFUqhsJZta3ue9zT8ytfOtgsi/QBTf5bNf39hvAAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;라운지 추천 요청에서 표시용 궁합 점수와 내부 RankScore를 분리해 응답하는 sequence diagram&apos; title=&apos;&apos; src=&apos;/static/9dfac69311f9349f7cb6332104716c5a/ca1dc/discover-ranking-sequence.png&apos; srcset=&apos;/static/9dfac69311f9349f7cb6332104716c5a/e7570/discover-ranking-sequence.png 170w,
/static/9dfac69311f9349f7cb6332104716c5a/f46e7/discover-ranking-sequence.png 340w,
/static/9dfac69311f9349f7cb6332104716c5a/ca1dc/discover-ranking-sequence.png 680w,
/static/9dfac69311f9349f7cb6332104716c5a/c852c/discover-ranking-sequence.png 784w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;라운지 추천 요청에서 표시용 궁합 점수와 내부 RankScore를 분리해 응답하는 sequence diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;소개팅-추천은-reciprocal-문제다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%86%8C%EA%B0%9C%ED%8C%85-%EC%B6%94%EC%B2%9C%EC%9D%80-reciprocal-%EB%AC%B8%EC%A0%9C%EB%8B%A4&quot; aria-label=&quot;소개팅 추천은 reciprocal 문제다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;소개팅 추천은 reciprocal 문제다&lt;/h2&gt;
&lt;p&gt;일반 상품 추천은 대체로 &lt;code class=&quot;language-text&quot;&gt;P(user likes item)&lt;/code&gt;을 높이는 문제로 시작할 수 있다. 하지만 소개팅 추천에서는 &lt;code class=&quot;language-text&quot;&gt;item&lt;/code&gt;도 사람이다. 내가 상대를 좋아해도 상대가 응답하지 않으면 제품의 핵심 흐름인 대화가 시작되지 않는다.&lt;/p&gt;
&lt;p&gt;그래서 장기 objective는 이런 형태가 더 맞다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;maximize ExpectedSuccessfulConversation

ExpectedSuccessfulConversation =
  P(A likes B)
* P(B likes A)
* P(first_reply_or_chat_continues)
* QualityWeight
- RiskPenalty&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 관점에서는 총 궁합 점수의 합을 최대화하는 것만으로는 부족하다. 남자 100명, 여자 100명이 있고 모든 사람을 1:1로 묶는 batch matching 문제라면 stable matching이나 maximum weight bipartite matching을 생각할 수 있다. 하지만 라운지 피드는 최종 짝을 바로 정하는 기능이 아니다. 사용자가 여러 후보를 보고, pass/like/대화 신청을 하고, 상대가 다시 응답하는 반복 추천 문제다.&lt;/p&gt;
&lt;p&gt;그래서 기본 구현은 batch matching이 아니라 feed ranking으로 잡았다.&lt;/p&gt;
&lt;h2 id=&quot;MVP에서는-ML보다-평가-가능한-proxy를-먼저-둔다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#MVP%EC%97%90%EC%84%9C%EB%8A%94-ML%EB%B3%B4%EB%8B%A4-%ED%8F%89%EA%B0%80-%EA%B0%80%EB%8A%A5%ED%95%9C-proxy%EB%A5%BC-%EB%A8%BC%EC%A0%80-%EB%91%94%EB%8B%A4&quot; aria-label=&quot;MVP에서는 ML보다 평가 가능한 proxy를 먼저 둔다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;MVP에서는 ML보다 평가 가능한 proxy를 먼저 둔다&lt;/h2&gt;
&lt;p&gt;운영 이벤트가 충분히 쌓이면 &lt;code class=&quot;language-text&quot;&gt;P(mutual_like)&lt;/code&gt;나 &lt;code class=&quot;language-text&quot;&gt;P(first_reply)&lt;/code&gt;를 학습할 수 있다. 문제는 초기에는 데이터가 없다는 점이다. 이 단계에서 복잡한 모델을 먼저 붙이면 그럴듯한 모델 이름만 생기고, 실제로 무엇이 좋아졌는지 설명하기 어렵다.&lt;/p&gt;
&lt;p&gt;여기서 ranker는 후보를 어떤 순서로 보여줄지 정하는 코드다. 처음부터 ML 모델을 학습시키지는 않았다. 대신 지금 DB에 있는 값으로 계산할 수 있는 proxy, 그러니까 &quot;실제 행동을 직접 본 것은 아니지만 그 행동과 관련이 있을 것 같은 대리 신호&quot;로 시작했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;RankScore =
  0.35 * Compatibility
+ 0.20 * SharedInterest
+ 0.15 * DistanceFit
+ 0.10 * AgePreferenceFit
+ 0.10 * ProfileCompletenessAndActivity
+ 0.10 * ExplorationFreshness
- RiskPenalty&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;각 항목의 역할은 다르다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;항목&lt;/th&gt;
&lt;th&gt;의도&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;Compatibility&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;제품의 차별점인 궁합 설명을 랭킹에도 반영한다.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;SharedInterest&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;실제 대화 주제가 생길 가능성을 proxy로 본다.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;DistanceFit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;가까운 후보를 노출상 유리하게 둔다.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;AgePreferenceFit&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;명시 선호 schema가 생기기 전까지 나이대 적합성을 약하게 반영한다.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;ProfileCompletenessAndActivity&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;사진, 소개글, 관심사, 온보딩 완료 여부를 반영한다.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;ExplorationFreshness&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;신규 후보가 최소한의 탐색 기회를 갖게 한다.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;RiskPenalty&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;이미 본 후보, 차단/신고 후보 같은 부정 신호를 제외하거나 감점한다.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;여기서 중요한 점은 이 값들이 &quot;최종 정답&quot;이 아니라는 점이다. 지금 단계의 목표는 완벽한 추천 모델이 아니다. 교체 가능한 점수 함수와 평가 루프를 만드는 것이다.&lt;/p&gt;
&lt;h2 id=&quot;200명-synthetic-profile과-event를-만든-이유&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#200%EB%AA%85-synthetic-profile%EA%B3%BC-event%EB%A5%BC-%EB%A7%8C%EB%93%A0-%EC%9D%B4%EC%9C%A0&quot; aria-label=&quot;200명 synthetic profile과 event를 만든 이유 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;200명 synthetic profile과 event를 만든 이유&lt;/h2&gt;
&lt;p&gt;처음에는 &quot;남자 100명, 여자 100명 더미를 넣자&quot;가 요구사항처럼 보였다. 그런데 추천 시스템을 평가하려면 프로필만으로는 부족하다. 추천은 노출 이후 행동으로 평가된다.&lt;/p&gt;
&lt;p&gt;여기서 synthetic은 실제 유저 데이터가 아니라 평가를 위해 코드로 만든 가짜 데이터라는 뜻이다. synthetic profile은 가짜 사용자 프로필이고, synthetic event는 그 가짜 사용자가 봤다, 좋아요를 눌렀다, 답장을 했다 같은 행동 로그를 확률 규칙으로 만든 것이다.&lt;/p&gt;
&lt;p&gt;이 방식은 실제 성과를 보장하지 않는다. 대신 같은 조건에서 두 ranker를 비교할 수 있게 해준다. 실제 유저가 없는 초기 단계에서는 &quot;완벽한 수치&quot;보다 &quot;무엇이 좋아지고 무엇이 나빠지는지 볼 수 있는 반복 실험&quot;이 더 중요했다.&lt;/p&gt;
&lt;p&gt;그래서 synthetic profile과 synthetic event를 나눴다.&lt;/p&gt;
&lt;p&gt;프로필은 이렇게 만들었다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;남성 100명, 여성 100명&lt;/li&gt;
&lt;li&gt;22세부터 38세까지의 생년월일&lt;/li&gt;
&lt;li&gt;MBTI 16종 분산&lt;/li&gt;
&lt;li&gt;거리 bucket&lt;/li&gt;
&lt;li&gt;관심사 3-6개&lt;/li&gt;
&lt;li&gt;사진 수, 소개글, 온보딩 완료 여부 차이&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;그리고 이벤트는 DB schema를 늘리지 않고 메모리에서 생성했다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;impression&lt;/li&gt;
&lt;li&gt;like&lt;/li&gt;
&lt;li&gt;chat request&lt;/li&gt;
&lt;li&gt;first reply&lt;/li&gt;
&lt;li&gt;block/report proxy&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이렇게 하면 production DB를 건드리지 않으면서도 현재 ranker와 새 ranker를 같은 조건에서 비교할 수 있다.&lt;/p&gt;
&lt;h2 id=&quot;평가-결과가-한-방향으로-좋지는-않았다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%8F%89%EA%B0%80-%EA%B2%B0%EA%B3%BC%EA%B0%80-%ED%95%9C-%EB%B0%A9%ED%96%A5%EC%9C%BC%EB%A1%9C-%EC%A2%8B%EC%A7%80%EB%8A%94-%EC%95%8A%EC%95%98%EB%8B%A4&quot; aria-label=&quot;평가 결과가 한 방향으로 좋지는 않았다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;평가 결과가 한 방향으로 좋지는 않았다&lt;/h2&gt;
&lt;p&gt;평가 명령은 단순하게 만들었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api
uv run python scripts/evaluate_matching.py&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;결과는 한 방향으로만 좋지는 않았다.&lt;/p&gt;
&lt;p&gt;표는 이렇게 읽으면 된다. &lt;code class=&quot;language-text&quot;&gt;like_rate&lt;/code&gt;는 사용자가 좋아요를 누를 가능성, &lt;code class=&quot;language-text&quot;&gt;mutual_like_rate&lt;/code&gt;는 양쪽이 서로 좋아할 가능성, &lt;code class=&quot;language-text&quot;&gt;first_reply_rate&lt;/code&gt;는 대화가 실제로 시작될 가능성에 가깝다. &lt;code class=&quot;language-text&quot;&gt;unique_exposed_users&lt;/code&gt;는 노출된 후보의 다양성이고, &lt;code class=&quot;language-text&quot;&gt;exposure_gini&lt;/code&gt;는 노출 쏠림이다. gini는 높을수록 일부 후보에게 노출이 몰렸다고 보면 된다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;metric&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;legacy&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;mvp&lt;/th&gt;
&lt;th&gt;변화&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;like_rate&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.7030&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.7035&lt;/td&gt;
&lt;td&gt;거의 동일&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;mutual_like_rate&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.4424&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.3227&lt;/td&gt;
&lt;td&gt;나빠짐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;first_reply_rate&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.5345&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.5588&lt;/td&gt;
&lt;td&gt;좋아짐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;block_report_rate&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.0570&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.0520&lt;/td&gt;
&lt;td&gt;좋아짐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;unique_exposed_users&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;181&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;170&lt;/td&gt;
&lt;td&gt;나빠짐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;exposure_gini&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.2758&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.4341&lt;/td&gt;
&lt;td&gt;나빠짐&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;즉, MVP ranker는 &lt;strong&gt;대화가 시작될 가능성&lt;/strong&gt;은 조금 높였지만, &lt;strong&gt;서로 좋아할 가능성&lt;/strong&gt;과 &lt;strong&gt;노출 분산&lt;/strong&gt;은 망쳤다.&lt;/p&gt;
&lt;p&gt;이 결과는 실패라기보다 쓸 만한 신호였다. like rate 하나만 봤다면 &quot;비슷하거나 조금 좋아졌다&quot;고 말했을 수 있다. 하지만 mutual-like와 노출 집중도를 같이 보니 다음에 무엇을 봐야 하는지가 드러났다.&lt;/p&gt;
&lt;p&gt;아마 MVP ranker가 프로필 완성도, 활동성, first reply 가능성에 더 무게를 주면서 &quot;서로 취향이 맞는 후보&quot;보다 &quot;응답 가능성이 높은 후보&quot;를 더 위로 올린 것으로 보인다. 그래서 대화 시작 가능성은 올라갔지만, 양방향 선호와 노출 다양성은 떨어졌다.&lt;/p&gt;
&lt;p&gt;물론 이 평가는 실제 유저 행동이 아니라 synthetic event 기반이다. 그래서 절대적인 수치보다 중요한 것은 &quot;새 ranker가 어떤 지표를 개선하고 어떤 지표를 악화시키는지 비교할 수 있게 됐다&quot;는 점이다.&lt;/p&gt;
&lt;p&gt;다음 튜닝은 weight를 더 만지는 것보다 exposure cap이나 diversity slot이 먼저다.&lt;/p&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;이번 작업에서 가장 크게 바뀐 생각은 &quot;좋은 매칭 알고리즘&quot;을 하나의 산식으로 정의하려고 하면 안 된다는 점이다.&lt;/p&gt;
&lt;p&gt;초기 단계에서 더 중요한 것은 다음 세 가지였다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;사용자에게 설명하는 점수와 내부 운영 점수를 분리한다.&lt;/li&gt;
&lt;li&gt;상호 관심, 대화 시작, 부정 경험, 노출 집중도를 같이 본다.&lt;/li&gt;
&lt;li&gt;production에 연결하기 전에 synthetic 평가라도 재현 가능한 비교 루프를 둔다.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;결국 추천 시스템은 &quot;누가 가장 잘 맞는가&quot;만의 문제가 아니다. &quot;누구에게 어떤 순서로 기회를 줄 것인가&quot;의 문제다. 사람과 사람을 연결하는 제품에서는 한쪽 만족만 최적화해도 전체 경험이 쉽게 무너진다.&lt;/p&gt;
&lt;p&gt;지금의 MVP ranker는 최종 답이 아니다. 다만 다음 질문을 더 정확하게 만들었다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;exposure cap을 얼마나 둘 것인가?&lt;/li&gt;
&lt;li&gt;diversity slot을 top N 안에서 어떻게 섞을 것인가?&lt;/li&gt;
&lt;li&gt;실제 impression, like, pass, reply 이벤트를 저장하면 synthetic proxy와 얼마나 달라지는가?&lt;/li&gt;
&lt;li&gt;궁합 점수는 어디까지 추천에 반영하고, 어디부터는 설명용으로만 둘 것인가?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 질문들이 생겼다는 점만으로도 이번 구현은 의미가 있었다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-할-것&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%95%A0-%EA%B2%83&quot; aria-label=&quot;다음에는 이렇게 할 것 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 할 것&lt;/h2&gt;
&lt;p&gt;다음 단계는 새 모델을 붙이는 것이 아니라 운영 이벤트를 남기는 것이다.&lt;/p&gt;
&lt;p&gt;실제 impression, like, pass, chat request, first reply 이벤트를 저장하고, score bucket별 전환율과 exposure concentration을 함께 볼 예정이다. 신규 유저에게 줄 exploration slot과 특정 후보에게 노출이 몰리는 것을 막는 exposure cap도 작은 비율로 실험할 수 있다.&lt;/p&gt;
&lt;p&gt;그 다음에야 learned ranker를 검토할 수 있다. 데이터가 충분하지 않은 상태에서 모델부터 붙이는 것보다, 작지만 검증 가능한 ranker를 두고 지표를 쌓는 편이 낫다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/1501.06247&quot;&gt;Reciprocal Recommendation System for Online Dating&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://web.cs.ucla.edu/~yzsun/papers/snam2016.pdf&quot;&gt;Design of Reciprocal Recommendation Systems for Online Dating&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://proceedings.neurips.cc/paper_files/paper/2018/file/97af07a14cacba681feacf3012730892-Paper.pdf&quot;&gt;Online Reciprocal Recommendation with Theoretical Performance Guarantees&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://ojs.aaai.org/index.php/AAAI/article/view/17807&quot;&gt;A Reciprocal Embedding Framework For Modelling Mutual Preferences&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://sites.math.washington.edu/~billey/classes/562.winter.2018/articles/Gale.Shapley.pdf&quot;&gt;College Admissions and the Stability of Marriage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://proceedings.neurips.cc/paper/2021/hash/48259990138bc03361556fb3f94c5d45-Abstract.html&quot;&gt;Two-sided fairness in rankings via Lorenz dominance&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Validation Error를 장애로 만들지 않기]]></title><description><![CDATA[Sentry에는 저장 화면에서 발생한 unresolved issue가 남아 있었다. 저장 중 가 global unhandled rejection으로 잡힌 케이스였다. 처음에는 단순히 "저장 API가 실패했다"처럼 보였다. 하지만 문제의 핵심은 API…]]></description><link>https://sewon.dev/place2page-editor-save-failure-boundary/</link><guid isPermaLink="false">https://sewon.dev/place2page-editor-save-failure-boundary/</guid><pubDate>Sun, 14 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/56271d9d7784e3e6615e7baf0811e998/acfb4/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 53.529411764705884%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACHUlEQVR42kWN3U/aUBjG+//fLDPL1MQNTCZmN+5Ck20XczrAOmiVCgJtobSnhX730J4vsO05C7hlT3558uZNfnkk18fLkPgRDWK6ConpFAsPuT7xIzJzilVMVzEFPglTannIsHMvpEIIvoNLyRpnOUkgzvEmhThKUQZJCnfPOMP5muKcFTlDBYMpQcX2ZctfVcGFVAGnWnolACVwStetlh4Pgzrw6ziuq3pIlje52UHWzdps57N2sSefd7A1IYGEe73NcLjRtBdt8DIaVbouPI/bdr2wGWXnsfpm+fMo6h74v45S+V3YeR93jxO5iZQv2ZOUTqaLnuprw/h5XBgmnEyxYQjXrR2HMXYJRydO+3h6/dFuN9zup7jf9O5amXqOB1dwJLHZ3Ozej2+749sOMU1imqVtcwBqB1DKrvDkg3/3Vvt28PT9QPt6AjpnUG3ljy00uITPO3km/57LPbunWPf9Qjc4AP9lNG4E8uH0eod+fTj5cZY9fMZaCz1ewWeJO05t27W962q/yW1nj00JvShGDaSc5mozV04Ltbnu7w6kNpBykT1Jte/zIOBhyKNIxKGIQhGHPFiVUViV5RAtZbxQmKswoDDQp0AmjoztLl7oJJTEPlVVrRELII0gDSH1U2ytMidYL0AaxQTCbZaxNGMUbwXn4l/+ypsNM0GkGMnjLFWNRLPgg5kM5tmDmbyi6nFfTywvqevqVeFC/AGokUbVluqIOAAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Editor save failure boundary diagram&apos; title=&apos;&apos; src=&apos;/static/56271d9d7784e3e6615e7baf0811e998/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/56271d9d7784e3e6615e7baf0811e998/e7570/situation-diagram.png 170w,
/static/56271d9d7784e3e6615e7baf0811e998/f46e7/situation-diagram.png 340w,
/static/56271d9d7784e3e6615e7baf0811e998/ca1dc/situation-diagram.png 680w,
/static/56271d9d7784e3e6615e7baf0811e998/02d09/situation-diagram.png 1020w,
/static/56271d9d7784e3e6615e7baf0811e998/9d567/situation-diagram.png 1360w,
/static/56271d9d7784e3e6615e7baf0811e998/acfb4/situation-diagram.png 4368w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Editor save failure boundary diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Sentry에는 저장 화면에서 발생한 unresolved issue가 남아 있었다. 저장 중 &lt;code class=&quot;language-text&quot;&gt;ApiError: Request validation failed.&lt;/code&gt;가 global unhandled rejection으로 잡힌 케이스였다.&lt;/p&gt;
&lt;p&gt;처음에는 단순히 &quot;저장 API가 실패했다&quot;처럼 보였다. 하지만 문제의 핵심은 API validation 자체가 아니었다. 사용자가 복구할 수 있는 저장 실패가 UI에서 toast로 처리된 뒤에도 다시 throw되면서, 운영 관측 시스템에는 전역 장애처럼 올라가고 있었다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: editor 저장 중 validation error가 Sentry unhandled rejection으로 기록됐다.&lt;/li&gt;
&lt;li&gt;분류: 시스템 장애라기보다 user-recoverable failure가 잘못된 failure boundary를 넘은 문제였다.&lt;/li&gt;
&lt;li&gt;수정: auth error만 다시 던지고 일반 저장 실패는 toast에서 끝나도록 경계를 정리했다.&lt;/li&gt;
&lt;li&gt;검증: validation failure는 재던지지 않고 auth failure는 기존 auth boundary로 넘기는 테스트를 추가했다.&lt;/li&gt;
&lt;li&gt;배운 점: Sentry issue 수보다 먼저 봐야 할 것은 어떤 실패를 운영 장애로 올릴지다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;문제가 된 흐름은 editor의 초안 저장이었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;user clicks save
  -&gt; build editor payload
  -&gt; POST editor save endpoint
  -&gt; API returns validation failure
  -&gt; UI shows failure toast
  -&gt; error is thrown again
  -&gt; Sentry records unhandled rejection&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 경로에서는 저장 실패 toast가 이미 사용자에게 노출되고 있었다. 사용자는 &quot;저장에 실패했다&quot;는 피드백을 받는다. 그런데 코드가 그 뒤에 같은 error를 다시 throw하면서 브라우저 전역의 unhandled rejection으로 승격됐다.&lt;/p&gt;
&lt;p&gt;서비스를 운영할 때는 이 차이를 구분해야 한다. 같은 error도 어디서 멈추느냐에 따라 의미가 달라진다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;실패 유형&lt;/th&gt;
&lt;th&gt;적절한 처리 위치&lt;/th&gt;
&lt;th&gt;Sentry issue로 볼 성격&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;인증 만료&lt;/td&gt;
&lt;td&gt;auth boundary&lt;/td&gt;
&lt;td&gt;필요&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;저장 validation 실패&lt;/td&gt;
&lt;td&gt;editor UI boundary&lt;/td&gt;
&lt;td&gt;보통 불필요&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;서버 장애 / 네트워크 장애&lt;/td&gt;
&lt;td&gt;request boundary + Sentry&lt;/td&gt;
&lt;td&gt;필요&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;Request validation failed.&lt;/code&gt;는 사용자가 다시 시도하거나 payload를 고쳐야 하는 종류의 실패에 가깝다. 이걸 전역 unhandled rejection으로 올리면 실제 장애와 사용자가 복구할 수 있는 실패가 같은 레벨로 섞인다.&lt;/p&gt;
&lt;h2 id=&quot;failure-boundary로-보기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#failure-boundary%EB%A1%9C-%EB%B3%B4%EA%B8%B0&quot; aria-label=&quot;failure boundary로 보기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;failure boundary로 보기&lt;/h2&gt;
&lt;p&gt;소프트웨어 공학에서 error handling은 단순히 &lt;code class=&quot;language-text&quot;&gt;try/catch&lt;/code&gt;를 붙이는 일이 아니다. 실패가 어느 경계에서 멈춰야 하는지를 정하는 일에 가깝다.&lt;/p&gt;
&lt;p&gt;이번에는 세 가지 경계가 있었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;API boundary:
  요청 payload를 검증하고 실패를 명시적으로 반환한다.

Editor UI boundary:
  저장 실패를 사용자에게 보여주고, draft를 dirty 상태로 유지한다.

Global error boundary:
  코드가 예상하지 못한 crash나 시스템성 장애를 잡는다.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;기존 구현은 editor UI boundary에서 실패를 처리한 뒤에도 global boundary로 다시 넘겼다. 그래서 관측 도구에는 &quot;사용자에게 안내된 저장 실패&quot;가 &quot;처리되지 않은 예외&quot;처럼 기록됐다.&lt;/p&gt;
&lt;p&gt;에러를 숨기자는 말은 아니다. 오히려 에러의 성격에 맞는 관측 위치를 정해야 한다. auth error처럼 세션 상태를 바꿔야 하는 실패는 기존 auth boundary로 넘겨야 한다. 일반 validation failure는 editor boundary에서 멈춰야 한다.&lt;/p&gt;
&lt;h2 id=&quot;바꾼-것&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%94%EA%BE%BC-%EA%B2%83&quot; aria-label=&quot;바꾼 것 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;바꾼 것&lt;/h2&gt;
&lt;p&gt;수정 범위는 작게 잡았다. 저장 실패를 무조건 삼키지 않고, 재던질 error의 기준만 분리했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;shouldRethrowEditorSaveFailure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  error&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;unknown&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token function-variable function&quot;&gt;handleAuthError&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;error&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;unknown&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;boolean&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;boolean&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;handleAuthError&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그리고 editor page의 저장 흐름에서는 이 기준을 사용했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; res &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; api&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;saveEditorDraft&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setProject&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;res&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;toast&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; title&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Draft saved&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;catch&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;error&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;unknown&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;shouldRethrowEditorSaveFailure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handleAuthError&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; error
  &lt;span class=&quot;token function&quot;&gt;toast&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    title&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Failed to save draft&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    description&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; error &lt;span class=&quot;token keyword&quot;&gt;instanceof&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;Error&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;?&lt;/span&gt; error&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;message &lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Unable to save this edit.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    variant&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;destructive&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;finally&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token function&quot;&gt;setSaving&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;핵심은 이 줄이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;shouldRethrowEditorSaveFailure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;error&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; handleAuthError&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;throw&lt;/span&gt; error&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;auth error는 기존처럼 상위 auth 처리 흐름으로 넘긴다. 일반 validation failure는 toast로 사용자에게 알리고, editor의 dirty state를 유지한 채 저장 버튼을 다시 누를 수 있게 둔다.&lt;/p&gt;
&lt;h2 id=&quot;증거와-검증&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A6%9D%EA%B1%B0%EC%99%80-%EA%B2%80%EC%A6%9D&quot; aria-label=&quot;증거와 검증 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;증거와 검증&lt;/h2&gt;
&lt;p&gt;관측 도구에서 확인한 증거는 다음과 같았다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;항목&lt;/th&gt;
&lt;th&gt;내용&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;error&lt;/td&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;ApiError: Request validation failed.&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;성격&lt;/td&gt;
&lt;td&gt;editor 저장 중 unhandled promise rejection&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;수정 후에는 두 가지 동작을 테스트로 고정했다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;케이스&lt;/th&gt;
&lt;th&gt;기대 동작&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;validation failure&lt;/td&gt;
&lt;td&gt;toast 처리 후 재throw하지 않는다&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;auth failure&lt;/td&gt;
&lt;td&gt;auth boundary가 처리할 수 있도록 재throw한다&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;검증은 editor save error handling 테스트와 observability 관련 테스트를 함께 돌렸다. 여기서 확인한 것은 &quot;모든 저장 실패가 사라졌다&quot;가 아니다. 확인한 내용은 &lt;strong&gt;복구 가능한 저장 실패가 더 이상 global unhandled rejection으로 승격되지 않는다&lt;/strong&gt;는 점이다.&lt;/p&gt;
&lt;h2 id=&quot;왜-이게-운영-품질인가&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EC%9D%B4%EA%B2%8C-%EC%9A%B4%EC%98%81-%ED%92%88%EC%A7%88%EC%9D%B8%EA%B0%80&quot; aria-label=&quot;왜 이게 운영 품질인가 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 이게 운영 품질인가&lt;/h2&gt;
&lt;p&gt;Issue count를 줄이는 것 자체는 목표가 될 수 없다. 잘못 줄이면 실제 장애를 숨기는 일이 된다.&lt;/p&gt;
&lt;p&gt;이번 작업의 목표는 issue count 감소가 아니라 signal quality 개선이었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;before:
  user-recoverable validation failure
    -&gt; toast
    -&gt; rethrow
    -&gt; global unhandled rejection
    -&gt; Sentry issue

after:
  user-recoverable validation failure
    -&gt; toast
    -&gt; keep editor state
    -&gt; no global incident&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;운영 중에 봐야 하는 issue는 &quot;사용자가 이미 안내받고 다시 시도할 수 있는 실패&quot;가 아니라 &quot;제품이 예상하지 못한 방식으로 깨졌거나 사용자가 복구할 수 없는 실패&quot;여야 한다.&lt;/p&gt;
&lt;p&gt;이 기준이 없으면 alert fatigue가 생긴다. 모든 실패가 같은 레벨로 쌓이면 진짜 장애를 봐야 할 때 노이즈에 묻힌다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-본다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%EB%B3%B8%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 본다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 본다&lt;/h2&gt;
&lt;p&gt;에러가 Sentry에 올라왔다고 바로 &quot;버그를 고친다&quot;로 들어가지 않는다. 먼저 이렇게 묻는다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;이 실패는 사용자가 복구할 수 있는가.&lt;/li&gt;
&lt;li&gt;이미 UI boundary에서 안내되고 있는가.&lt;/li&gt;
&lt;li&gt;auth, validation, network, server error 중 어디에 속하는가.&lt;/li&gt;
&lt;li&gt;global error boundary까지 올라가야 하는 실패인가.&lt;/li&gt;
&lt;li&gt;관측 도구에 남겨야 한다면 어떤 tag나 message가 있어야 나중에 분류 가능한가.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이번 이슈는 저장 API의 validation이 실패한 사건이기도 했다. 더 정확히는 failure boundary가 잘못 그어진 사건이었다.&lt;/p&gt;
&lt;p&gt;운영 시스템에서는 에러를 많이 모으는 것보다 올바른 레벨의 에러를 모으는 쪽이 더 중요하다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.sentry.io/platforms/javascript/configuration/filtering/&quot;&gt;Sentry JavaScript: Filtering Events&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event&quot;&gt;MDN: unhandledrejection event&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[How Projection Made the Project List DB Query 47x Faster]]></title><description><![CDATA[Place2Page's project dashboard is one of the default paths users hit after signing in. That screen calls  to render the project list. While…]]></description><link>https://sewon.dev/en/place2page-project-list-projection-optimization/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-project-list-projection-optimization/</guid><pubDate>Mon, 08 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/74f30834599ef91faf410f7d2dd0ff04/1d30e/thumbnail.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 53.529411764705884%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACdUlEQVR42iWR22vTYBjG86+IoN5Ixy7cbpyyQ7uKbMum7K5VFPFaBBEFr4TdyA4OoVLXdRsiQ7zbxTZ03cFtaZvads5tdm2aZDk2aQ5fDk3a5pPUlx8PDw/8rl7ktKLRnMnwZqmqEzQwTFeUrJNzlaDBBWeWKSDIFs0ZgmwzglWhAS/ZEMK253nQQyTNlnRbMWxZtzWzoQBLNRr+qNqyaiqqZRmOrlhAs3XVB6i2Yzu+CyHSromewHuS2GJZl2Ecjm3yfEsUmqIADVNqGjigjhpcwWLzxkVOo3Ia9UujiyZ7ZgmIk89bB5iTL1oY5h4V7XTa2N0FOzvu8W8oygegOkVtxrj9OTo1zaQ+iHszbGqO20nq+LKSReIzscu9A1f7htB7j9xi0dzeVrZ3la2UjWGwJu/L54ER9Nrg8KXe2/dfv4hJh3Pl7/OVrRizt6oXEHzjx/Ts+9n5+c/xJVitgp/7zPoms75ppNNQqh8qxJPl6aeL7x5/nHqzsbICcgsilqhhi3LGl5vnJcixkGU9inSOj51CwcxkLBy38KxXJtImtewUvzonq+6fL/ZRQkovdPgkYQvCIeKe/XVOT1ulklcuQ6ICySokSUhTXqUM+VrGomMqltTwhJZN6viSkUsCPKFk4ko6KWcQT9Ogppocr1RplbxQSfo/CkmBWp2q17J8OScQPjyRE/1yZgilRq3aqCOwcw+fvbzSP9wdRrvCY4HB0UBwtKt/NHDzbvfQSE8I7QmiNwbGesJo7wB6/Vb429o6hLDVbiOw8+7nr972hSfDEw9CaDQ0FgmhkU5Gg+PR4HjEB40EJyLDE9G+O5NrG1sdufUPcsv72PXbNBkAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Thumbnail comparing SELECT star with a projected query&apos; title=&apos;&apos; src=&apos;/static/74f30834599ef91faf410f7d2dd0ff04/ca1dc/thumbnail.png&apos; srcset=&apos;/static/74f30834599ef91faf410f7d2dd0ff04/e7570/thumbnail.png 170w,
/static/74f30834599ef91faf410f7d2dd0ff04/f46e7/thumbnail.png 340w,
/static/74f30834599ef91faf410f7d2dd0ff04/ca1dc/thumbnail.png 680w,
/static/74f30834599ef91faf410f7d2dd0ff04/02d09/thumbnail.png 1020w,
/static/74f30834599ef91faf410f7d2dd0ff04/9d567/thumbnail.png 1360w,
/static/74f30834599ef91faf410f7d2dd0ff04/1d30e/thumbnail.png 4048w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Thumbnail comparing SELECT star with a projected query&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Place2Page&apos;s project dashboard is one of the default paths users hit after signing in. That screen calls &lt;code class=&quot;language-text&quot;&gt;/v1/projects&lt;/code&gt; to render the project list.&lt;/p&gt;
&lt;p&gt;While reviewing Sentry, I noticed a small but useful signal. In the most recent 24 hours, DB span p95 was still in single-digit milliseconds, so this was not an outage. But over a 30-day window, old &lt;code class=&quot;language-text&quot;&gt;/v1/projects&lt;/code&gt; queries kept showing up with a shape that loaded the full &lt;code class=&quot;language-text&quot;&gt;projects&lt;/code&gt; row.&lt;/p&gt;
&lt;p&gt;The issue was not the number of rows alone. The endpoint only needed small fields such as project name, status, slug, and updated time. But the ORM was materializing the full &lt;code class=&quot;language-text&quot;&gt;Project&lt;/code&gt; model, including large JSON columns such as &lt;code class=&quot;language-text&quot;&gt;place_data_json&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;review_signal_payload_json&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;The-Numbers-First&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Numbers-First&quot; aria-label=&quot;The Numbers First permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Numbers First&lt;/h2&gt;
&lt;p&gt;From production Sentry DB spans:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Baseline&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Old full-row query&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;New projected query&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;p95&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;144.8~214.5ms&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.09ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Large JSON columns&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;included&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;excluded&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Optimization&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;full-row load&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;required-column projection&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;This is not full API response latency. It is DB query duration inside &lt;code class=&quot;language-text&quot;&gt;/v1/projects&lt;/code&gt;. At the time, Sentry transaction names did not cleanly separate &lt;code class=&quot;language-text&quot;&gt;GET /v1/projects&lt;/code&gt; from &lt;code class=&quot;language-text&quot;&gt;POST /v1/projects&lt;/code&gt;, so full request latency could be mixed with generation requests. For this post, I only use the DB query shape and DB span duration as production evidence.&lt;/p&gt;
&lt;p&gt;I also ran a local synthetic benchmark with the same schema and intentionally wide rows. The absolute numbers are not meant to reproduce production PostgreSQL throughput exactly, but they isolate the difference between full-row fetch and projected fetch under the same conditions.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Before&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;After&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;median elapsed&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;605.9ms&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;97.1ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;median peak allocation&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;163.7MB&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;11.8MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;result rows&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;2,000&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;2,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;avoided wide payload&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;80.1MB&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0MB fetched&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Sentry confirmed that the production query shape changed. The local benchmark showed how expensive that shape becomes as row width grows.&lt;/p&gt;
&lt;h2 id=&quot;Why-Projection-Came-Before-Indexing&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-Projection-Came-Before-Indexing&quot; aria-label=&quot;Why Projection Came Before Indexing permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why Projection Came Before Indexing&lt;/h2&gt;
&lt;p&gt;Once you get comfortable with an ORM, loading a full tuple from the database and mapping it into a DTO can start to feel like the natural programming pattern.&lt;/p&gt;
&lt;p&gt;That makes it easier to stop noticing the actual SQL being executed, including whether the query is reading columns the response never uses.&lt;/p&gt;
&lt;p&gt;From a database cost-model perspective, unnecessary columns increase tuple width. Even when row count stays the same, wider tuples mean more I/O, larger memory allocations, and more serialization work.&lt;/p&gt;
&lt;p&gt;So this was not primarily a cardinality problem. The number of rows could stay identical while each row remained too wide. If the DB driver and ORM have already moved a wide tuple into the application, a small response DTO does not undo that cost.&lt;/p&gt;
&lt;p&gt;In database textbooks, projection is introduced as the relational-algebra operation that keeps only the attributes required by the result. In an API server, that logical idea has a physical consequence.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;logical projection:
  keep only the attributes required by the result.

physical consequence:
  shrink the data width that the DB reads, the driver transfers,
  the ORM materializes, and the serializer processes.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The core question was therefore not &quot;how do I find these rows faster?&quot; It was &quot;what should I stop reading after finding them?&quot;&lt;/p&gt;
&lt;h2 id=&quot;What-Changed&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-Changed&quot; aria-label=&quot;What Changed permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What Changed&lt;/h2&gt;
&lt;p&gt;The old route used &lt;code class=&quot;language-text&quot;&gt;session.query(Project)&lt;/code&gt;, which loaded the full model. Even if the response schema was small, the ORM had already materialized the full row.&lt;/p&gt;
&lt;p&gt;The fix used SQLAlchemy&apos;s &lt;code class=&quot;language-text&quot;&gt;load_only()&lt;/code&gt; to restrict the columns eagerly loaded by the list endpoint.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;q &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; session&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;query&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Project&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;options&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;load_only&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;_PROJECT_LIST_LOAD_COLUMNS&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;not&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;is_admin&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    q &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; q&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Project&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;owner_user_id &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
projects &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; q&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;order_by&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Project&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;updated_at&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;desc&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I also had to avoid accidental lazy loads. A property such as &lt;code class=&quot;language-text&quot;&gt;Project.place_provider&lt;/code&gt; can read &lt;code class=&quot;language-text&quot;&gt;place_data_json&lt;/code&gt; internally. If the list route touches that property, &lt;code class=&quot;language-text&quot;&gt;load_only()&lt;/code&gt; can collapse into one deferred-column load per row.&lt;/p&gt;
&lt;p&gt;For the list path, I switched provider inference to use the URL only, without reading the large JSON payload. The detail page still keeps the full project context.&lt;/p&gt;
&lt;h2 id=&quot;Why-I-Deferred-the-Index&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-I-Deferred-the-Index&quot; aria-label=&quot;Why I Deferred the Index permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why I Deferred the Index&lt;/h2&gt;
&lt;p&gt;The next candidate was a composite index. The non-admin query generally follows this pattern:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sql&quot;&gt;&lt;pre class=&quot;language-sql&quot;&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;WHERE&lt;/span&gt; owner_user_id &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ?
&lt;span class=&quot;token keyword&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;BY&lt;/span&gt; updated_at &lt;span class=&quot;token keyword&quot;&gt;DESC&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For that shape, &lt;code class=&quot;language-text&quot;&gt;(owner_user_id, updated_at DESC)&lt;/code&gt; is a natural composite index. It can help filtering and ordering at the same time by reducing scan range and sort cost.&lt;/p&gt;
&lt;p&gt;I did not add it in this pass. Projection alone moved the recent production DB span p95 down to 3.09ms, and the matching ordered SELECT did not appear in the most recent 24-hour sample. An index could still improve reads, but it would also add write amplification and migration-management cost.&lt;/p&gt;
&lt;p&gt;At the current data size, adding the index felt like overkill. If project volume grows and &lt;code class=&quot;language-text&quot;&gt;/v1/projects&lt;/code&gt; becomes a top DB span again, then adding &lt;code class=&quot;language-text&quot;&gt;(owner_user_id, updated_at DESC)&lt;/code&gt; would be the next step.&lt;/p&gt;
&lt;h2 id=&quot;Product-Impact&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Product-Impact&quot; aria-label=&quot;Product Impact permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Product Impact&lt;/h2&gt;
&lt;p&gt;This optimization was less about making one isolated request faster and more about reducing unnecessary payload and memory allocation on a repeated default path.&lt;/p&gt;
&lt;p&gt;The project dashboard is loaded whenever users enter the product. If that path repeatedly reads large JSON payloads and materializes them into Python objects, the cost shows up not only as latency but also as worker memory pressure, GC pressure, and serialization overhead.&lt;/p&gt;
&lt;p&gt;The important part was not that I used &lt;code class=&quot;language-text&quot;&gt;load_only()&lt;/code&gt;. The important part was identifying the production query shape in Sentry, connecting it to row width through the database cost model, and reducing the actual data read by the endpoint.&lt;/p&gt;
&lt;p&gt;Performance work is less about knowing a faster trick and more about choosing which cost to reduce first. In this case, projection came before indexing.&lt;/p&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Abraham Silberschatz, Henry F. Korth, S. Sudarshan, &lt;em&gt;Database System Concepts&lt;/em&gt;, 7th edition, Chapter 15 Query Processing&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.sqlalchemy.org/en/20/orm/queryguide/columns.html&quot;&gt;SQLAlchemy ORM Querying Guide: Column Loading Options&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Sentry trace search: &lt;code class=&quot;language-text&quot;&gt;environment:production span.op:db&lt;/code&gt; on &lt;code class=&quot;language-text&quot;&gt;place2page-server&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[프로젝트 목록 DB 조회를 47배 빠르게 만든 projection]]></title><description><![CDATA[Place2Page의 프로젝트 대시보드는 로그인한 사용자가 자주 지나가는 기본 경로다. 이 화면은 를 호출해서 프로젝트 목록을 가져온다. Sentry에서 이 경로를 보다가 이상한 신호를 봤다. 최근 24시간 기준으로는 DB span p9…]]></description><link>https://sewon.dev/place2page-project-list-projection-optimization/</link><guid isPermaLink="false">https://sewon.dev/place2page-project-list-projection-optimization/</guid><pubDate>Mon, 08 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/74f30834599ef91faf410f7d2dd0ff04/1d30e/thumbnail.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 53.529411764705884%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACdUlEQVR42iWR22vTYBjG86+IoN5Ixy7cbpyyQ7uKbMum7K5VFPFaBBEFr4TdyA4OoVLXdRsiQ7zbxTZ03cFtaZvads5tdm2aZDk2aQ5fDk3a5pPUlx8PDw/8rl7ktKLRnMnwZqmqEzQwTFeUrJNzlaDBBWeWKSDIFs0ZgmwzglWhAS/ZEMK253nQQyTNlnRbMWxZtzWzoQBLNRr+qNqyaiqqZRmOrlhAs3XVB6i2Yzu+CyHSromewHuS2GJZl2Ecjm3yfEsUmqIADVNqGjigjhpcwWLzxkVOo3Ia9UujiyZ7ZgmIk89bB5iTL1oY5h4V7XTa2N0FOzvu8W8oygegOkVtxrj9OTo1zaQ+iHszbGqO20nq+LKSReIzscu9A1f7htB7j9xi0dzeVrZ3la2UjWGwJu/L54ER9Nrg8KXe2/dfv4hJh3Pl7/OVrRizt6oXEHzjx/Ts+9n5+c/xJVitgp/7zPoms75ppNNQqh8qxJPl6aeL7x5/nHqzsbICcgsilqhhi3LGl5vnJcixkGU9inSOj51CwcxkLBy38KxXJtImtewUvzonq+6fL/ZRQkovdPgkYQvCIeKe/XVOT1ulklcuQ6ICySokSUhTXqUM+VrGomMqltTwhJZN6viSkUsCPKFk4ko6KWcQT9Ogppocr1RplbxQSfo/CkmBWp2q17J8OScQPjyRE/1yZgilRq3aqCOwcw+fvbzSP9wdRrvCY4HB0UBwtKt/NHDzbvfQSE8I7QmiNwbGesJo7wB6/Vb429o6hLDVbiOw8+7nr972hSfDEw9CaDQ0FgmhkU5Gg+PR4HjEB40EJyLDE9G+O5NrG1sdufUPcsv72PXbNBkAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;SELECT star와 projection query의 비용 차이를 정리한 thumbnail&apos; title=&apos;&apos; src=&apos;/static/74f30834599ef91faf410f7d2dd0ff04/ca1dc/thumbnail.png&apos; srcset=&apos;/static/74f30834599ef91faf410f7d2dd0ff04/e7570/thumbnail.png 170w,
/static/74f30834599ef91faf410f7d2dd0ff04/f46e7/thumbnail.png 340w,
/static/74f30834599ef91faf410f7d2dd0ff04/ca1dc/thumbnail.png 680w,
/static/74f30834599ef91faf410f7d2dd0ff04/02d09/thumbnail.png 1020w,
/static/74f30834599ef91faf410f7d2dd0ff04/9d567/thumbnail.png 1360w,
/static/74f30834599ef91faf410f7d2dd0ff04/1d30e/thumbnail.png 4048w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;SELECT star와 projection query의 비용 차이를 정리한 thumbnail&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Place2Page의 프로젝트 대시보드는 로그인한 사용자가 자주 지나가는 기본 경로다. 이 화면은 &lt;code class=&quot;language-text&quot;&gt;/v1/projects&lt;/code&gt;를 호출해서 프로젝트 목록을 가져온다.&lt;/p&gt;
&lt;p&gt;Sentry에서 이 경로를 보다가 이상한 신호를 봤다. 최근 24시간 기준으로는 DB span p95가 한 자릿수 ms였고 장애라고 부를 정도는 아니었다. 하지만 기간을 30일로 넓히자 과거 &lt;code class=&quot;language-text&quot;&gt;/v1/projects&lt;/code&gt; 조회에서 &lt;code class=&quot;language-text&quot;&gt;projects&lt;/code&gt; row 전체를 읽는 쿼리가 반복적으로 보였다.&lt;/p&gt;
&lt;p&gt;문제는 응답에 필요한 데이터보다 DB에서 읽는 데이터가 훨씬 컸다는 점이었다. 목록 화면에는 프로젝트 이름, 상태, slug, 업데이트 시각 같은 작은 필드만 필요했다. 그런데 ORM은 &lt;code class=&quot;language-text&quot;&gt;Project&lt;/code&gt; 모델 전체를 materialize하고 있었고, 그 안에는 &lt;code class=&quot;language-text&quot;&gt;place_data_json&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;review_signal_payload_json&lt;/code&gt; 같은 큰 JSON 컬럼까지 포함되어 있었다.&lt;/p&gt;
&lt;h2 id=&quot;먼저-본-숫자&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%A8%BC%EC%A0%80-%EB%B3%B8-%EC%88%AB%EC%9E%90&quot; aria-label=&quot;먼저 본 숫자 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;먼저 본 숫자&lt;/h2&gt;
&lt;p&gt;운영 Sentry에서 확인한 DB span 기준 수치는 이랬다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;기준&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;이전 full-row 조회&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;이후 projection 조회&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;p95&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;144.8~214.5ms&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.09ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;개선폭&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;약 47배&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;-&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;큰 JSON 컬럼&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;포함&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;제외&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;최적화 방식&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;row 전체 로드&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;필요한 컬럼만 projection&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;이 수치는 전체 API 응답 시간이 아니라 &lt;code class=&quot;language-text&quot;&gt;/v1/projects&lt;/code&gt; 안에서 실행된 DB query duration 기준이다. 당시 Sentry transaction 이름이 &lt;code class=&quot;language-text&quot;&gt;GET /v1/projects&lt;/code&gt;와 &lt;code class=&quot;language-text&quot;&gt;POST /v1/projects&lt;/code&gt;를 충분히 분리하지 못했기 때문에 전체 request latency는 생성 요청과 섞일 수 있었다. 그래서 이 글에서는 전체 API latency가 아니라 &lt;strong&gt;문제였던 DB query shape과 DB span&lt;/strong&gt;만 근거로 삼는다.&lt;/p&gt;
&lt;p&gt;로컬에서는 같은 schema에 wide row를 크게 만든 synthetic benchmark도 돌렸다. 절대값은 운영 PostgreSQL 성능을 그대로 재현한 값이 아니지만, 같은 조건에서 full-row fetch와 projection query의 차이를 비교하기에는 충분했다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;항목&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;변경 전&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;변경 후&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;median elapsed&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;605.9ms&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;97.1ms&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;median peak allocation&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;163.7MB&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;11.8MB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;result rows&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;2,000&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;2,000&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;avoided wide payload&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;80.1MB&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0MB fetched&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;운영에서는 실제 query shape이 바뀌었는지 확인했다. 로컬에서는 그 shape이 커졌을 때 어떤 비용 차이를 만드는지 확인했다.&lt;/p&gt;
&lt;h2 id=&quot;왜-인덱스가-아니라-projection이-먼저였나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EC%9D%B8%EB%8D%B1%EC%8A%A4%EA%B0%80-%EC%95%84%EB%8B%88%EB%9D%BC-projection%EC%9D%B4-%EB%A8%BC%EC%A0%80%EC%98%80%EB%82%98&quot; aria-label=&quot;왜 인덱스가 아니라 projection이 먼저였나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 인덱스가 아니라 projection이 먼저였나&lt;/h2&gt;
&lt;p&gt;ORM 사용에 익숙해지다 보면 DB에서 tuple 전체를 가져온 뒤 DTO로 매핑하는 방식이 정석처럼 느껴진다.&lt;/p&gt;
&lt;p&gt;그러다 보면 실제로 어떤 SQL이 실행되는지, 불필요한 컬럼까지 조회하고 있지는 않은지에 점점 둔감해진다.&lt;/p&gt;
&lt;p&gt;데이터베이스 비용 모델 관점에서 보면, 불필요한 컬럼은 tuple width를 키우고, 같은 row count에서도 더 많은 I/O, 더 큰 memory allocation, 더 많은 serialization 비용으로 이어진다.&lt;/p&gt;
&lt;p&gt;이 문제는 cardinality, 즉 row 수만의 문제가 아니었다. 목록에 필요한 row 수는 같아도 각 row가 너무 넓었다. 응답 DTO가 작아도, DB driver와 ORM이 이미 큰 tuple을 애플리케이션으로 옮긴 뒤라면 늦다.&lt;/p&gt;
&lt;p&gt;전공서에서 projection은 결과에 필요한 attribute만 남기는 relational algebra 연산으로 등장한다. API 서버에서는 이 개념이 더 물리적으로 다가온다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;logical projection:
  결과에 필요한 attribute만 남긴다.

physical consequence:
  DB가 읽고, driver가 전달하고, ORM이 materialize하고,
  serializer가 처리해야 하는 data width를 줄인다.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그래서 이번 최적화의 핵심은 &quot;어떤 row를 더 빨리 찾을까&quot;가 아니라 &quot;찾은 row에서 무엇을 읽지 않을까&quot;였다.&lt;/p&gt;
&lt;h2 id=&quot;바꾼-것&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%94%EA%BE%BC-%EA%B2%83&quot; aria-label=&quot;바꾼 것 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;바꾼 것&lt;/h2&gt;
&lt;p&gt;기존 route는 &lt;code class=&quot;language-text&quot;&gt;session.query(Project)&lt;/code&gt;로 &lt;code class=&quot;language-text&quot;&gt;Project&lt;/code&gt; 모델 전체를 읽었다. 목록 응답 schema가 작아도 ORM 입장에서는 이미 전체 row를 materialize한 뒤였다.&lt;/p&gt;
&lt;p&gt;수정 후에는 SQLAlchemy의 &lt;code class=&quot;language-text&quot;&gt;load_only()&lt;/code&gt;로 목록에 필요한 컬럼만 즉시 로드하도록 제한했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;q &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; session&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;query&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Project&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;options&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;load_only&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;_PROJECT_LIST_LOAD_COLUMNS&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;not&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;is_admin&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    q &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; q&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;filter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Project&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;owner_user_id &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
projects &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; q&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;order_by&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;Project&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;updated_at&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;desc&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;all&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;또 신경 쓴 부분은 lazy load였다. &lt;code class=&quot;language-text&quot;&gt;Project.place_provider&lt;/code&gt; 같은 property가 내부에서 &lt;code class=&quot;language-text&quot;&gt;place_data_json&lt;/code&gt;을 읽으면 &lt;code class=&quot;language-text&quot;&gt;load_only()&lt;/code&gt;를 걸어도 row마다 deferred column을 다시 가져올 수 있다. 그러면 projection 최적화가 N번의 lazy load로 무너진다.&lt;/p&gt;
&lt;p&gt;그래서 목록 경로에서는 큰 JSON payload를 보지 않고 URL 기반으로 provider를 추론하도록 했다. 상세 화면에서는 기존처럼 전체 project context를 유지한다.&lt;/p&gt;
&lt;h2 id=&quot;인덱스는-왜-미뤘나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9D%B8%EB%8D%B1%EC%8A%A4%EB%8A%94-%EC%99%9C-%EB%AF%B8%EB%A4%98%EB%82%98&quot; aria-label=&quot;인덱스는 왜 미뤘나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;인덱스는 왜 미뤘나&lt;/h2&gt;
&lt;p&gt;다음으로는 복합 인덱스를 검토했다. 비관리자 쿼리는 보통 다음 패턴이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sql&quot;&gt;&lt;pre class=&quot;language-sql&quot;&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;WHERE&lt;/span&gt; owner_user_id &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; ?
&lt;span class=&quot;token keyword&quot;&gt;ORDER&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;BY&lt;/span&gt; updated_at &lt;span class=&quot;token keyword&quot;&gt;DESC&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 패턴에는 &lt;code class=&quot;language-text&quot;&gt;(owner_user_id, updated_at DESC)&lt;/code&gt; 복합 인덱스가 자연스럽다. 필터링과 정렬을 동시에 도와 scan 범위와 sort 비용을 줄일 수 있다.&lt;/p&gt;
&lt;p&gt;하지만 이번에는 추가하지 않았다. projection만으로 최근 운영 DB span p95가 3.09ms 수준까지 내려왔고, 해당 정렬 SELECT가 최근 24시간에는 샘플로 잡히지 않을 정도로 신호가 약해졌다. 인덱스는 read path를 빠르게 만들 수 있지만 write amplification과 migration 관리 비용도 만든다.&lt;/p&gt;
&lt;p&gt;현재 데이터 규모에서는 복합 인덱스까지 넣는 것이 오버킬에 가깝다고 판단했다. 프로젝트 수가 훨씬 늘고 &lt;code class=&quot;language-text&quot;&gt;/v1/projects&lt;/code&gt;가 다시 상위 DB span으로 올라오면 그때 &lt;code class=&quot;language-text&quot;&gt;(owner_user_id, updated_at DESC)&lt;/code&gt; 인덱스를 추가하는 편이 더 맞다.&lt;/p&gt;
&lt;h2 id=&quot;제품-관점의-의미&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A0%9C%ED%92%88-%EA%B4%80%EC%A0%90%EC%9D%98-%EC%9D%98%EB%AF%B8&quot; aria-label=&quot;제품 관점의 의미 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;제품 관점의 의미&lt;/h2&gt;
&lt;p&gt;이 최적화는 단일 요청 하나를 빠르게 만든 작업이라기보다 반복 호출되는 기본 경로에서 불필요한 payload와 memory allocation을 줄인 작업이다.&lt;/p&gt;
&lt;p&gt;프로젝트 대시보드는 사용자가 서비스를 열 때마다 지나가는 화면이다. 이런 경로에서 큰 JSON payload를 매번 읽고 Python object로 만들면 latency뿐 아니라 worker memory, GC pressure, serialization 비용까지 같이 커진다.&lt;/p&gt;
&lt;p&gt;이번 작업의 핵심은 &lt;code class=&quot;language-text&quot;&gt;load_only()&lt;/code&gt;를 넣었다는 사실이 아니다. Sentry로 운영 query shape을 확인했고, DB 비용 모델 관점에서 row width가 병목이라는 점을 잡았다. 그런 다음 projection으로 실제로 읽는 데이터를 줄였다.&lt;/p&gt;
&lt;p&gt;성능 최적화는 &quot;더 빠른 방법을 아는 것&quot;보다 &quot;지금 어떤 비용을 줄여야 하는지 고르는 것&quot;에 가깝다. 이번에는 인덱스가 아니라 projection이 먼저였다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Abraham Silberschatz, Henry F. Korth, S. Sudarshan, &lt;em&gt;Database System Concepts&lt;/em&gt;, 7th edition, Chapter 15 Query Processing&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.sqlalchemy.org/en/20/orm/queryguide/columns.html&quot;&gt;SQLAlchemy ORM Querying Guide: Column Loading Options&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Sentry trace search: &lt;code class=&quot;language-text&quot;&gt;environment:production span.op:db&lt;/code&gt; on &lt;code class=&quot;language-text&quot;&gt;place2page-server&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Not Mixing Up OAuth and Service Accounts in Google Analytics MCP Setup]]></title><description><![CDATA[Attaching Google Analytics MCP took longer than I expected. Installing the MCP server itself was not the hard part. The real confusion came…]]></description><link>https://sewon.dev/en/google-analytics-mcp-oauth-setup-debugging/</link><guid isPermaLink="false">https://sewon.dev/en/google-analytics-mcp-oauth-setup-debugging/</guid><pubDate>Sun, 07 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/91cbbd7317ea63e266fae6348c3184cf/3812c/thumbnail.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 61.1764705882353%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACXElEQVR42nVSXUsUYRSe39Nd0g/opgsNoojSvYgQopvsL9hFGNgHCUnaZigSmYVFEKW0boa5m+VK2ebsujuzOu7X7O7svDPv18z7MW/tmlEXPRwOB55zeA7nOZph+dtFd6+KSmWYM0FhzyvbWDdBrUUrDWKW4W4FFnZ926HlOmq2ad4EmDDVQaRBRNoAe5C4ADkuojgMUIhdRF0v8HAIA4Qo46LTq1QUdfIfaH/VSkjxzTHWW7nP7cImsjZdc93J1/y6YoxBi7vb3MtzkGOuzv2CwBVNwFagLwbGxwh6dUu/Z767XVq+YybijdQMyDxwP6VgSSGI9hOu8RyYL4GxAEsvuJtkTlqTxaSVHLdXJ5T1tRXgx40vM+X0zN7abG39iZN5Gm5t0IoSkrQ3WpX3DStZLSWAvUr9FIebGq9+d9KP/Myc8pu+kiMrzy7fHx2aHrsyPTY0dffq3PiH5o5SqpBdGp8cmXg4Gp+6ORkfnZi8YWQXtSiSElQFclSksBKX4reOnD51bDDWczHWM3D+6IXYKzOjlFpJzJ2Inekb7O/tP9s3cO5478nkm9l/DxbJHWxnYTWP6zq08njfYFVfYqWUpLXQ2QkaOgMmhxaHu4LYWteALg7NUEp5mKeKbCkL0oVwrRgu6+iH0Twk/2NVR6HLl2w88rp+/YU5PJ+/Np8bXth/u+V1VX77fRAaIhxi5iPmQQYRg0QwLjnnHsQOwAgThEnTRZiGUkgaioAJGcmDHbQgFIQKTAUmnAai0SYepCqKaMA8FCrVeRAHECGkEKLl4raHIcJCyl/DPwFDDnaqBBZLRAAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;A flowchart for choosing the right Google Analytics MCP credential path&apos; title=&apos;&apos; src=&apos;/static/91cbbd7317ea63e266fae6348c3184cf/ca1dc/thumbnail.png&apos; srcset=&apos;/static/91cbbd7317ea63e266fae6348c3184cf/e7570/thumbnail.png 170w,
/static/91cbbd7317ea63e266fae6348c3184cf/f46e7/thumbnail.png 340w,
/static/91cbbd7317ea63e266fae6348c3184cf/ca1dc/thumbnail.png 680w,
/static/91cbbd7317ea63e266fae6348c3184cf/02d09/thumbnail.png 1020w,
/static/91cbbd7317ea63e266fae6348c3184cf/9d567/thumbnail.png 1360w,
/static/91cbbd7317ea63e266fae6348c3184cf/3812c/thumbnail.png 4060w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;A flowchart for choosing the right Google Analytics MCP credential path&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Attaching Google Analytics MCP took longer than I expected. Installing the MCP server itself was not the hard part. The real confusion came after that: which credential should I use, why did the browser block the OAuth app, why did adding a service account to GA4 fail, and which setup actually fits the goal of seeing every GA property my own account can access?&lt;/p&gt;
&lt;p&gt;In an earlier note, &lt;a href=&quot;/en/place2page-growth-os-ga-cache-self-healing/&quot;&gt;Why I Replaced Growth OS GA Fetch Cron Jobs with a Self-Healing Cache&lt;/a&gt;, I broke Google access into three gates:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;can this identity mint a token?&lt;/li&gt;
&lt;li&gt;does it have permission to read the GA4 property?&lt;/li&gt;
&lt;li&gt;does the runtime actually receive the credential?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The MCP setup turned out to be the same kind of problem. The difference was that this was a local development tool, not a production server, and OAuth was a better fit than a service account.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: The Google Analytics MCP server started correctly, but reading real GA account lists surfaced a rotating mix of scope, OAuth consent, and service-account access problems.&lt;/li&gt;
&lt;li&gt;Decision: I had to stop treating this as one generic &quot;Google auth&quot; problem and separate OAuth ADC from service-account access.&lt;/li&gt;
&lt;li&gt;Result: Because the goal was to inspect all GA properties accessible to my own account, OAuth ADC was the right final setup.&lt;/li&gt;
&lt;li&gt;Lesson: Service accounts fit server-side automation. OAuth fits local tools that should reuse the access already granted to a human Google account.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;At-First-It-Looked-Like-an-MCP-Installation-Issue&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#At-First-It-Looked-Like-an-MCP-Installation-Issue&quot; aria-label=&quot;At First It Looked Like an MCP Installation Issue permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;At First It Looked Like an MCP Installation Issue&lt;/h2&gt;
&lt;p&gt;The original goal was simple: attach Google Analytics MCP to Codex and query the GA properties my account can access.&lt;/p&gt;
&lt;p&gt;The official-looking config shape was roughly this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;toml&quot;&gt;&lt;pre class=&quot;language-toml&quot;&gt;&lt;code class=&quot;language-toml&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;mcp_servers.analytics-mcp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pipx&quot;&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;run&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;analytics-mcp&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;mcp_servers.analytics-mcp.env&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;GOOGLE_APPLICATION_CREDENTIALS&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/path/to/credentials.json&quot;&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;GOOGLE_PROJECT_ID&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;your-google-cloud-project-id&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;pipx run analytics-mcp&lt;/code&gt; started fine. The MCP protocol responded. The tools were there:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;get_account_summaries
get_property_details
run_report
run_realtime_report
run_funnel_report
run_conversions_report&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;At that point it looked finished. Then &lt;code class=&quot;language-text&quot;&gt;get_account_summaries&lt;/code&gt; failed with:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;ACCESS_TOKEN_SCOPE_INSUFFICIENT&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That error was the first important fork. It did not mean the credential file was missing. It meant some ADC credential existed already, but it had not been issued with the scope needed to read Google Analytics.&lt;/p&gt;
&lt;h2 id=&quot;Having-ADC-Was-Not-Enough&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Having-ADC-Was-Not-Enough&quot; aria-label=&quot;Having ADC Was Not Enough permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Having ADC Was Not Enough&lt;/h2&gt;
&lt;p&gt;My local machine already had an &lt;code class=&quot;language-text&quot;&gt;application_default_credentials.json&lt;/code&gt;, so my first reaction was, &quot;I am already signed into Google, why is this failing?&quot;&lt;/p&gt;
&lt;p&gt;But ADC is not just &quot;a file exists.&quot; The result depends on which OAuth client issued it and which scopes were requested.&lt;/p&gt;
&lt;p&gt;Google Analytics MCP expects the Analytics read-only scope, so ADC has to be issued with that scope explicitly:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gcloud auth application-default login &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--scopes&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  --client-id-file&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;/path/to/oauth-client.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If I tried that without &lt;code class=&quot;language-text&quot;&gt;--client-id-file&lt;/code&gt;, using the default Cloud SDK OAuth client, the browser could block the request for a sensitive scope. In my case it surfaced as:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;This app is blocked&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/e307d6baf81448bbc82b7a70edf09aaa/a4b35/image.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 43.529411764705884%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAsUlEQVR42q2RQQuDMAyF/f+nncYu+0OD3Qc7VXQItlrbrqLYvJFi52SHgTPwSpqmHy9tBg4i0DRhj8h46e831OfjUiX6E3i9oD4dEJzdB/jse1jvYboOxhhordG2LcZx3AZUUuJRlsjzHFVVoSgKCCHgnItNIYS3iGiVpz3NU0UgX5RSQimFpmmiO3bJbpOSa2ttFOefZ8MwLEDvPbp53CSuLX9EP/PVyHvGFzC9y1bgCyGww7Iwsb9GAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;A blocked screen shown when the default Cloud SDK OAuth client requests Analytics scope&apos; title=&apos;&apos; src=&apos;/static/e307d6baf81448bbc82b7a70edf09aaa/ca1dc/image.png&apos; srcset=&apos;/static/e307d6baf81448bbc82b7a70edf09aaa/e7570/image.png 170w,
/static/e307d6baf81448bbc82b7a70edf09aaa/f46e7/image.png 340w,
/static/e307d6baf81448bbc82b7a70edf09aaa/ca1dc/image.png 680w,
/static/e307d6baf81448bbc82b7a70edf09aaa/02d09/image.png 1020w,
/static/e307d6baf81448bbc82b7a70edf09aaa/9d567/image.png 1360w,
/static/e307d6baf81448bbc82b7a70edf09aaa/a4b35/image.png 1442w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;A blocked screen shown when the default Cloud SDK OAuth client requests Analytics scope&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;That led to the next change: create a dedicated Desktop OAuth client and pass its JSON to &lt;code class=&quot;language-text&quot;&gt;--client-id-file&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The Desktop OAuth client is created in &lt;a href=&quot;https://console.cloud.google.com/auth/clients&quot;&gt;Google Auth Platform&apos;s Clients screen&lt;/a&gt;. The important detail is to choose &lt;strong&gt;Desktop app&lt;/strong&gt;, not a web application.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/14edef565579a06287e11d75d248963b/4b469/image-2.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 112.94117647058823%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAXCAYAAAALHW+jAAAACXBIWXMAABYlAAAWJQFJUiTwAAAELklEQVR42q2V229URRyANwu7JGIUetl7l7O7Z/dc93J2t3tp6W63ty21hRhqKaVe4cUnFLGaCGhQEftg9MkXbaGFgkSfhPjIs9JyaSsx/gEa/wFKW9rPnNMStLVPMsk3c2Yy+c78fmfmjI2nXGwrKyvMzf/K9MxtZmfnmLl9h+mZO9y9N8e92XluTc/wy61pft6AOT4//xv37//O7Nx9/vjzrzXhwsICR145itHYTEe1l2JLO5l8ieZyF43FVmQ9jaQZKHoaTTNQNQPZ7MezlCq9dFRfJJOr8OVXX68JHzx4wGvH3iSRLpLMNJHINFmtmsgSk1S0hIEghJEFEU1JocpJNFEhJITxBwTCUY1ddQE+OP3RY+ECA4PDJNM5ZC1JTNFR9BSRqILX68Xr9eGuqyfkchP2NyB4fAguN/W1tdTU1OLx+HE4n+HdkffXhA8fLnLk2FsYzT0kClWUTDt6rhtRMRAjIrKiWmhaHFWS8brduFxuXG6Phc/nx7HdwcjIyJpwcXGRoaNvk6scpKV6GCVbRS/0IippIqJIxsijKQmCewSEUPgJgtlGiMZkdu2u49TpM+shLyzQf2iITK4JI1tAUuKoCYNITMXn8yGKOtFYmoAg0hCSLIIhmWBYweML4nK5sNu3cfLkySdfeXD4deJGHt1cTaqReLpATE3gdnvweH34AkECwRCBBmGdkNX3+huskJ3OHYyMvPc4hw/p7N5PrSdIMKIQEMxVyLg8QRyOHdZkp9OJ07EZh8PJzp3PYrPZOH78+JpweXmZ6zd+4vKVa1y99gNXvvveai9NXWVsbIyxsXHGx00urPPP5wvWnNHRUW7evLkmNKuZ23cZG5/g8tRVi8lLU1ycmGRi8rLFhYuTm7g4cYlvvh3nx+s3WF1dfXL0zOrUmbPYbHZqauvx+4N4vX48Hh8ul5lDc5/twG53YN9msh27fbsVrhlqY2MOM22PpZbw3PlRa09JkkIkIhIORxDFqEU4LBKNxpAlGVEUkSQJRVGtuXuECL19+zHTZhZTagk/Of8F3oBAPl8kl8uTTKbIZhutt5tt0siSSOeJp3IoatySmtvK4w/Tva+P5eWlDcJzo+yu85HJt5DKFNATaVQ9haon0eIp1Hja+kmYROU4kahMTFYJBAV6XvgP4ceffka928/g0Mv0DwzR0dVDqbWDcqWT0jpliw7KbV20tldp6+im2NzKwf5DmKdtwwo/57nnayi3ddJcaqPQVCJfbCGRym5JKp0jKmn09PSyvLS0Wbi7pp7Ozn2Uy+2Uyu3kCntJZwtbks01WWnp7TvA0kbhqQ/P4tzmoLOwl65ShWLcICbpVuLFLYjJOv6GEJVK+2bhxOQU3dVu3hga5tXDRxjuH6Df5KWtGTg0SN/+A5w48Q6PHj36t9DqACurq9bg6v+5pJ72rfc3CIxD7ylSlDcAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;The Google Auth Platform screen for creating an OAuth client and selecting the Desktop app type&apos; title=&apos;&apos; src=&apos;/static/14edef565579a06287e11d75d248963b/ca1dc/image-2.png&apos; srcset=&apos;/static/14edef565579a06287e11d75d248963b/e7570/image-2.png 170w,
/static/14edef565579a06287e11d75d248963b/f46e7/image-2.png 340w,
/static/14edef565579a06287e11d75d248963b/ca1dc/image-2.png 680w,
/static/14edef565579a06287e11d75d248963b/02d09/image-2.png 1020w,
/static/14edef565579a06287e11d75d248963b/4b469/image-2.png 1046w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;The Google Auth Platform screen for creating an OAuth client and selecting the Desktop app type&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;The-OAuth-Consent-Screen-Also-Looked-Like-Failure-at-First&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-OAuth-Consent-Screen-Also-Looked-Like-Failure-at-First&quot; aria-label=&quot;The OAuth Consent Screen Also Looked Like Failure at First permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The OAuth Consent Screen Also Looked Like Failure at First&lt;/h2&gt;
&lt;p&gt;After creating a Desktop OAuth client and trying again, I saw a different message:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Google hasn&apos;t verified this app&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;At first glance that looks like another failure. It is not necessarily blocked. If the app is your own and the current Google account is registered as a test user on the OAuth consent app, you can continue through &lt;code class=&quot;language-text&quot;&gt;Advanced&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/8e62138bf60e0e748028f08646ebd867/a6a70/image-1.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 151.76470588235296%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAACXBIWXMAAAsTAAALEwEAmpwYAAACaklEQVR42rVVyY7TQBTM58IvcEWCCxcQBy7wByMEI6ERBy5ISNwQyyDIJHEUEsdLHO92u+0uVJ1ppweNGDMJliq9xK639ase4cjPiD/1j3PITbjbUepwwuX9e4hen+z4uu4wQtW2kJsAMkmglOrRdZ2GWQ8mFE2DieNgfDGB4ziYzWZYLBYYj8d6bTDcQ6XQ1DUaISClRNM02rOqqpAkCdI01WOWZf2ac4M4jlHXtZVDK0w7vDzP4boufN/X8DwPQRBgvV7rkWQ0TrK2bfeEXCRZhm2aIooije12qz2hdXplRu4ZcE2DJO+sQo6UEEBRQJXlwUdGEzZBgGi5ROG6UFX115eNPSEVHr4qcfdFiTvPSzw5233XKYacpih9HyIIACkHedEphcm6wdd5jS9zAcdrdgbNwT5u6zEOg3942m4Pu7lGfXKOUBBcCfmYhPXP78g+vL8k7g4nTE5P4D97fBwP2Wpsn6quUJal7mEhhG69oij03O7VQR6uPQ8Xkwmm0ynm8zmWy2WvNlQe7rO92KYE5xQSA1veNKFRGYIe0VPT16a3wzDUAmFEgnvsZ45XxEGffMs6QWIjTfzICIQRBqZFWiTqz5DpFV9izpg7ekhwbmD+q27od01ovLJdv1YcLsdKKLz7JvH2s8SbTxJO0PZHWRMyjE0YosjzQWqTFB2enhV4dFrgwcscH8dirzbXfcj8MA2mUHbBbopid+slCWQca7QsgrtCEkXI8ry/O4xK35jDlnLvrrBxVwh/LbBZrVBRG9P0Vj0+UixGmqJNE5C8jWN0vKOF0EUwh3bo/fwfBNYu4S3F1ib8DWk/LZ1MT9XaAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;The unverified OAuth warning with the Advanced and continue links&apos; title=&apos;&apos; src=&apos;/static/8e62138bf60e0e748028f08646ebd867/ca1dc/image-1.png&apos; srcset=&apos;/static/8e62138bf60e0e748028f08646ebd867/e7570/image-1.png 170w,
/static/8e62138bf60e0e748028f08646ebd867/f46e7/image-1.png 340w,
/static/8e62138bf60e0e748028f08646ebd867/ca1dc/image-1.png 680w,
/static/8e62138bf60e0e748028f08646ebd867/a6a70/image-1.png 730w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;The unverified OAuth warning with the Advanced and continue links&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;By contrast, this message is a real block:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Access blocked: app has not completed the Google verification process&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That usually means the currently logged-in Google account is not listed as a test user, or the OAuth consent app configuration is not accessible to that account yet.&lt;/p&gt;
&lt;p&gt;The three OAuth checks that ended up mattering were:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Is the OAuth client a &lt;code class=&quot;language-text&quot;&gt;Desktop app&lt;/code&gt; client?&lt;/li&gt;
&lt;li&gt;Is the current Google account listed as a test user on the OAuth consent app?&lt;/li&gt;
&lt;li&gt;Was ADC reissued with the &lt;code class=&quot;language-text&quot;&gt;analytics.readonly&lt;/code&gt; scope?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If those three line up, MCP can use the same account-level access you already have in GA.&lt;/p&gt;
&lt;h2 id=&quot;The-Service-Account-Path-Was-a-Different-Problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Service-Account-Path-Was-a-Different-Problem&quot; aria-label=&quot;The Service Account Path Was a Different Problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Service-Account Path Was a Different Problem&lt;/h2&gt;
&lt;p&gt;I also tried a service-account path in the middle of this. For production servers and scheduled jobs, that approach is often cleaner. No person needs to approve a browser flow every time, and the runtime just consumes a key file.&lt;/p&gt;
&lt;p&gt;But the purpose here was different. I wanted MCP to show &lt;strong&gt;all&lt;/strong&gt; GA properties my own Google account can access. A service account does not inherit my personal account&apos;s rights. It is a separate identity.&lt;/p&gt;
&lt;p&gt;If you do want the service-account route, the shape looks like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;PROJECT_ID&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;your-google-cloud-project-id&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;SA_NAME&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;analytics-mcp&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;KEY_PATH&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token environment constant&quot;&gt;$HOME&lt;/span&gt;/Downloads/analytics-mcp-service-account.json&quot;&lt;/span&gt;

gcloud config &lt;span class=&quot;token builtin class-name&quot;&gt;set&lt;/span&gt; project &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$PROJECT_ID&lt;/span&gt;&quot;&lt;/span&gt;

gcloud services &lt;span class=&quot;token builtin class-name&quot;&gt;enable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  analyticsadmin.googleapis.com &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  analyticsdata.googleapis.com &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--project&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$PROJECT_ID&lt;/span&gt;&quot;&lt;/span&gt;

gcloud iam service-accounts create &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$SA_NAME&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--project&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$PROJECT_ID&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  --display-name&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Google Analytics MCP&quot;&lt;/span&gt;

&lt;span class=&quot;token assign-left variable&quot;&gt;SA_EMAIL&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$SA_NAME&lt;/span&gt;@&lt;span class=&quot;token variable&quot;&gt;$PROJECT_ID&lt;/span&gt;.iam.gserviceaccount.com&quot;&lt;/span&gt;

gcloud iam service-accounts keys create &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$KEY_PATH&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  --iam-account&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$SA_EMAIL&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--project&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$PROJECT_ID&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then that service-account email also needs GA4 access, such as Viewer or Analyst.&lt;/p&gt;
&lt;p&gt;That introduced another trap. The GA4 UI&apos;s &lt;code class=&quot;language-text&quot;&gt;Add users&lt;/code&gt; flow sometimes expects a normal Google account email. When I tried a service-account address there, I could get an error like:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;This email does not match a Google account.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That does not mean the service-account key is wrong. It means the GA4 UI path and the service-account identity do not line up cleanly for that operation. In that case, the GA Admin API may be required:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;GA4_PROPERTY_ID&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;your-ga4-property-id&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;SA_EMAIL&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;analytics-mcp@your-google-cloud-project-id.iam.gserviceaccount.com&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;ACCESS_TOKEN&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;gcloud auth print-access-token&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-sS&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-X&lt;/span&gt; POST &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&quot;https://analyticsadmin.googleapis.com/v1alpha/properties/&lt;span class=&quot;token variable&quot;&gt;${GA4_PROPERTY_ID}&lt;/span&gt;/accessBindings&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Authorization: Bearer &lt;span class=&quot;token variable&quot;&gt;${ACCESS_TOKEN}&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Content-Type: application/json&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;{
    &lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;user&lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;: &lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;${SA_EMAIL}&lt;/span&gt;&lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;,
    &lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;roles&lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;: [&lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;predefinedRoles/viewer&lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;]
  }&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That path requires an administrator-level identity plus the &lt;code class=&quot;language-text&quot;&gt;analytics.manage.users&lt;/code&gt; scope.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Now-Choose-Between-OAuth-and-Service-Accounts&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Now-Choose-Between-OAuth-and-Service-Accounts&quot; aria-label=&quot;How I Now Choose Between OAuth and Service Accounts permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Now Choose Between OAuth and Service Accounts&lt;/h2&gt;
&lt;p&gt;The biggest lesson here was that neither method is &quot;better&quot; in the abstract. They solve different problems.&lt;/p&gt;
&lt;p&gt;OAuth uses a human account. If I want MCP to see the same accounts and properties I can see in the GA UI, OAuth is the right fit. But then OAuth consent, test-user setup, scope selection, and ADC refresh all matter.&lt;/p&gt;
&lt;p&gt;A service account uses an operations identity. If I am building a server cache, cron job, or back-office metric collector that should run without a human approving a browser dialog, the service-account model fits better. But then access has to be granted explicitly to that identity on each GA property or account.&lt;/p&gt;
&lt;p&gt;The decision rule I ended up with is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;exploring all GA properties I can personally access from local MCP: OAuth ADC&lt;/li&gt;
&lt;li&gt;server-side repeated metric collection for one product: service account&lt;/li&gt;
&lt;li&gt;shared numbers for several people: server cache plus service account&lt;/li&gt;
&lt;li&gt;one person asking questions with their own access rights: OAuth&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Without that separation, everything blurs into &quot;Google credentials&quot; and debugging gets longer than it should.&lt;/p&gt;
&lt;h2 id=&quot;The-Final-Setup-Flow-That-Worked&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Final-Setup-Flow-That-Worked&quot; aria-label=&quot;The Final Setup Flow That Worked permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Final Setup Flow That Worked&lt;/h2&gt;
&lt;p&gt;For my case, the final solution was OAuth ADC.&lt;/p&gt;
&lt;p&gt;First, enable the Analytics APIs on the Google Cloud project:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gcloud services &lt;span class=&quot;token builtin class-name&quot;&gt;enable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  analyticsadmin.googleapis.com &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  analyticsdata.googleapis.com &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--project&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;your-google-cloud-project-id&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Next, create a Desktop OAuth client in Google Auth Platform. If the OAuth consent app is still in testing, make sure the Google account you will use is listed as a test user.&lt;/p&gt;
&lt;p&gt;Then reissue ADC using the downloaded OAuth client JSON:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gcloud auth application-default login &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--scopes&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  --client-id-file&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;/path/to/oauth-client.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;On success, this file is updated:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;~/.config/gcloud/application_default_credentials.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then point MCP at that ADC file:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;toml&quot;&gt;&lt;pre class=&quot;language-toml&quot;&gt;&lt;code class=&quot;language-toml&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;mcp_servers.analytics-mcp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pipx&quot;&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;run&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;analytics-mcp&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;mcp_servers.analytics-mcp.env&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;GOOGLE_APPLICATION_CREDENTIALS&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/Users/you/.config/gcloud/application_default_credentials.json&quot;&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;GOOGLE_PROJECT_ID&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;your-google-cloud-project-id&quot;&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;GOOGLE_CLOUD_PROJECT&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;your-google-cloud-project-id&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The last check is the only one that matters:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;get_account_summaries&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If account and property lists show up, the setup is working. If the result is an empty array, the most likely causes are that the wrong Google account completed the OAuth flow or that the account has no GA access. If the failure is still scope-related, ADC needs to be reissued with the correct scope.&lt;/p&gt;
&lt;h2 id=&quot;Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Next-Time&quot; aria-label=&quot;Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Next Time&lt;/h2&gt;
&lt;p&gt;When wiring up the Google Analytics API, I will not start with &quot;do we have a credential?&quot; I will start with &quot;which identity should this flow use?&quot;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;my own Google account?&lt;/li&gt;
&lt;li&gt;a server-side service account?&lt;/li&gt;
&lt;li&gt;one specific property?&lt;/li&gt;
&lt;li&gt;all GA accounts and properties I can access?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Then I will check the access chain in order:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;can the identity mint a token?&lt;/li&gt;
&lt;li&gt;does the token include the required scope?&lt;/li&gt;
&lt;li&gt;does that identity actually have access to the GA account or property?&lt;/li&gt;
&lt;li&gt;is the MCP runtime or server runtime pointing at the same credential I think it is?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This setup took time not because MCP installation was hard, but because I initially treated OAuth and service accounts as one generic Google-auth topic. Once I split them, the problem got much smaller.&lt;/p&gt;
&lt;p&gt;For production automation, service accounts still fit best. For a local MCP tool that should reflect the GA permissions already attached to my personal Google account, OAuth is the right default.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[서버 앱에 Google Analytics MCP를 붙이며 OAuth와 서비스 계정 구분하기]]></title><description><![CDATA[서버 애플리케이션에 Google Analytics MCP를 붙이려다 생각보다 오래 헤맸다. MCP 서버 설치 자체는 어렵지 않았다. 문제는 그 다음이었다. 서버 런타임이 어떤 credential을 봐야 하는지, 왜 브라우저에서 OAuth…]]></description><link>https://sewon.dev/google-analytics-mcp-oauth-setup-debugging/</link><guid isPermaLink="false">https://sewon.dev/google-analytics-mcp-oauth-setup-debugging/</guid><pubDate>Sun, 07 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/91cbbd7317ea63e266fae6348c3184cf/3812c/thumbnail.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 61.1764705882353%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACXElEQVR42nVSXUsUYRSe39Nd0g/opgsNoojSvYgQopvsL9hFGNgHCUnaZigSmYVFEKW0boa5m+VK2ebsujuzOu7X7O7svDPv18z7MW/tmlEXPRwOB55zeA7nOZph+dtFd6+KSmWYM0FhzyvbWDdBrUUrDWKW4W4FFnZ926HlOmq2ad4EmDDVQaRBRNoAe5C4ADkuojgMUIhdRF0v8HAIA4Qo46LTq1QUdfIfaH/VSkjxzTHWW7nP7cImsjZdc93J1/y6YoxBi7vb3MtzkGOuzv2CwBVNwFagLwbGxwh6dUu/Z767XVq+YybijdQMyDxwP6VgSSGI9hOu8RyYL4GxAEsvuJtkTlqTxaSVHLdXJ5T1tRXgx40vM+X0zN7abG39iZN5Gm5t0IoSkrQ3WpX3DStZLSWAvUr9FIebGq9+d9KP/Myc8pu+kiMrzy7fHx2aHrsyPTY0dffq3PiH5o5SqpBdGp8cmXg4Gp+6ORkfnZi8YWQXtSiSElQFclSksBKX4reOnD51bDDWczHWM3D+6IXYKzOjlFpJzJ2Inekb7O/tP9s3cO5478nkm9l/DxbJHWxnYTWP6zq08njfYFVfYqWUpLXQ2QkaOgMmhxaHu4LYWteALg7NUEp5mKeKbCkL0oVwrRgu6+iH0Twk/2NVR6HLl2w88rp+/YU5PJ+/Np8bXth/u+V1VX77fRAaIhxi5iPmQQYRg0QwLjnnHsQOwAgThEnTRZiGUkgaioAJGcmDHbQgFIQKTAUmnAai0SYepCqKaMA8FCrVeRAHECGkEKLl4raHIcJCyl/DPwFDDnaqBBZLRAAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Google Analytics MCP 인증 방식 선택 흐름&apos; title=&apos;&apos; src=&apos;/static/91cbbd7317ea63e266fae6348c3184cf/ca1dc/thumbnail.png&apos; srcset=&apos;/static/91cbbd7317ea63e266fae6348c3184cf/e7570/thumbnail.png 170w,
/static/91cbbd7317ea63e266fae6348c3184cf/f46e7/thumbnail.png 340w,
/static/91cbbd7317ea63e266fae6348c3184cf/ca1dc/thumbnail.png 680w,
/static/91cbbd7317ea63e266fae6348c3184cf/02d09/thumbnail.png 1020w,
/static/91cbbd7317ea63e266fae6348c3184cf/9d567/thumbnail.png 1360w,
/static/91cbbd7317ea63e266fae6348c3184cf/3812c/thumbnail.png 4060w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Google Analytics MCP 인증 방식 선택 흐름&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;서버 애플리케이션에 Google Analytics MCP를 붙이려다 생각보다 오래 헤맸다. MCP 서버 설치 자체는 어렵지 않았다. 문제는 그 다음이었다. 서버 런타임이 어떤 credential을 봐야 하는지, 왜 브라우저에서 OAuth 앱이 막히는지, service account를 GA4 사용자로 넣으면 왜 안 되는지 계속 섞였다. 최종적으로 &quot;내가 볼 수 있는 모든 GA property&quot;를 서버 앱에서 MCP로 조회하려면 어떤 방식이 맞는지도 분명하지 않았다.&lt;/p&gt;
&lt;p&gt;이전에 &lt;a href=&quot;/place2page-growth-os-ga-cache-self-healing/&quot;&gt;Growth OS의 GA fetch를 cron에서 self-healing cache로 바꾼 이유&lt;/a&gt;를 쓰면서 Google 권한을 세 문으로 나눠야 한다고 정리했다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;token을 만들 수 있는가.&lt;/li&gt;
&lt;li&gt;GA4 property를 읽을 권한이 있는가.&lt;/li&gt;
&lt;li&gt;런타임이 credential을 실제로 전달받는가.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이번 MCP 세팅도 결국 같은 문제였다. 다만 단순한 GA 수집 배치가 아니라 서버 앱에 MCP를 붙여 내가 접근 가능한 GA 계정과 property를 탐색하는 흐름이었다. 그래서 고정된 property를 반복 수집하는 service account보다, 내 Google 계정의 권한을 가진 OAuth ADC가 더 맞았다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: 서버 앱에서 Google Analytics MCP 서버는 뜨는데 실제 GA 계정 목록을 읽는 단계에서 scope 부족, OAuth consent, service account 권한 문제가 번갈아 나왔다.&lt;/li&gt;
&lt;li&gt;판단: &quot;Google 인증&quot; 하나로 보지 않고 OAuth ADC와 service account를 분리해서 봐야 했다.&lt;/li&gt;
&lt;li&gt;해결: 서버 앱이라도 목적이 개인 계정이 접근 가능한 GA 전체를 탐색하는 것이었으므로 OAuth ADC 방식으로 끝냈다.&lt;/li&gt;
&lt;li&gt;배운 점: service account는 고정된 운영 자동화에 좋고, OAuth는 사람 계정의 기존 GA 접근권한을 서버 앱의 MCP 런타임에서 그대로 쓰고 싶을 때 맞다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;처음에는-MCP-설치-문제처럼-보였다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C%EC%97%90%EB%8A%94-MCP-%EC%84%A4%EC%B9%98-%EB%AC%B8%EC%A0%9C%EC%B2%98%EB%9F%BC-%EB%B3%B4%EC%98%80%EB%8B%A4&quot; aria-label=&quot;처음에는 MCP 설치 문제처럼 보였다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음에는 MCP 설치 문제처럼 보였다&lt;/h2&gt;
&lt;p&gt;처음 목표는 단순했다. 서버 애플리케이션에 Google Analytics MCP를 붙이고, 내가 접근 가능한 GA property들을 질문으로 조회하고 싶었다.&lt;/p&gt;
&lt;p&gt;공식 설정은 대략 이런 형태다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;toml&quot;&gt;&lt;pre class=&quot;language-toml&quot;&gt;&lt;code class=&quot;language-toml&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;mcp_servers.analytics-mcp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pipx&quot;&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;run&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;analytics-mcp&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;mcp_servers.analytics-mcp.env&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;GOOGLE_APPLICATION_CREDENTIALS&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/path/to/credentials.json&quot;&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;GOOGLE_PROJECT_ID&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;your-google-cloud-project-id&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;pipx run analytics-mcp&lt;/code&gt;는 바로 실행됐다. MCP protocol도 정상적으로 응답했고, tool 목록도 나왔다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;get_account_summaries
get_property_details
run_report
run_realtime_report
run_funnel_report
run_conversions_report&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;여기까지만 보면 세팅이 끝난 것처럼 보인다. 하지만 실제로 &lt;code class=&quot;language-text&quot;&gt;get_account_summaries&lt;/code&gt;를 호출하자 막혔다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;ACCESS_TOKEN_SCOPE_INSUFFICIENT&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 에러가 중요한 갈림길이었다. credential 파일이 없다는 뜻이 아니었다. 기존 ADC가 있기는 했지만 Google Analytics를 읽을 scope로 발급된 credential이 아니었다.&lt;/p&gt;
&lt;h2 id=&quot;ADC가-있다고-충분한-것은-아니었다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#ADC%EA%B0%80-%EC%9E%88%EB%8B%A4%EA%B3%A0-%EC%B6%A9%EB%B6%84%ED%95%9C-%EA%B2%83%EC%9D%80-%EC%95%84%EB%8B%88%EC%97%88%EB%8B%A4&quot; aria-label=&quot;ADC가 있다고 충분한 것은 아니었다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;ADC가 있다고 충분한 것은 아니었다&lt;/h2&gt;
&lt;p&gt;작업 환경에는 이미 &lt;code class=&quot;language-text&quot;&gt;application_default_credentials.json&lt;/code&gt;이 있었다. 그래서 처음에는 &quot;이미 Google 로그인이 되어 있는데 왜 안 되지?&quot;라고 생각했다.&lt;/p&gt;
&lt;p&gt;하지만 ADC는 파일 존재 여부만 보면 안 된다. 어떤 OAuth client로 발급됐는지, 어떤 scope를 요청했는지에 따라 API 호출 결과가 달라진다.&lt;/p&gt;
&lt;p&gt;Google Analytics MCP는 내부에서 Analytics read-only scope를 요구한다. 그러면 ADC도 이 scope를 포함해서 다시 발급해야 한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gcloud auth application-default login &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--scopes&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  --client-id-file&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;/path/to/oauth-client.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;여기서 &lt;code class=&quot;language-text&quot;&gt;--client-id-file&lt;/code&gt;을 뺀 채 기본 Cloud SDK OAuth client로 진행하면 민감 scope 요청에서 차단될 수 있다. 실제 브라우저에는 이런 화면이 나왔다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;This app is blocked&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/e307d6baf81448bbc82b7a70edf09aaa/a4b35/image.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 43.529411764705884%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAsUlEQVR42q2RQQuDMAyF/f+nncYu+0OD3Qc7VXQItlrbrqLYvJFi52SHgTPwSpqmHy9tBg4i0DRhj8h46e831OfjUiX6E3i9oD4dEJzdB/jse1jvYboOxhhordG2LcZx3AZUUuJRlsjzHFVVoSgKCCHgnItNIYS3iGiVpz3NU0UgX5RSQimFpmmiO3bJbpOSa2ttFOefZ8MwLEDvPbp53CSuLX9EP/PVyHvGFzC9y1bgCyGww7Iwsb9GAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;기본 Cloud SDK OAuth client로 Analytics scope를 요청했을 때 차단된 화면&apos; title=&apos;&apos; src=&apos;/static/e307d6baf81448bbc82b7a70edf09aaa/ca1dc/image.png&apos; srcset=&apos;/static/e307d6baf81448bbc82b7a70edf09aaa/e7570/image.png 170w,
/static/e307d6baf81448bbc82b7a70edf09aaa/f46e7/image.png 340w,
/static/e307d6baf81448bbc82b7a70edf09aaa/ca1dc/image.png 680w,
/static/e307d6baf81448bbc82b7a70edf09aaa/02d09/image.png 1020w,
/static/e307d6baf81448bbc82b7a70edf09aaa/9d567/image.png 1360w,
/static/e307d6baf81448bbc82b7a70edf09aaa/a4b35/image.png 1442w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;기본 Cloud SDK OAuth client로 Analytics scope를 요청했을 때 차단된 화면&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;그래서 Desktop OAuth client를 직접 만들고, 그 JSON을 &lt;code class=&quot;language-text&quot;&gt;--client-id-file&lt;/code&gt;로 넘겼다.&lt;/p&gt;
&lt;p&gt;Desktop OAuth client는 &lt;a href=&quot;https://console.cloud.google.com/auth/clients&quot;&gt;Google Auth Platform의 Clients 화면&lt;/a&gt;에서 만든다. 이때 application type은 웹 애플리케이션이 아니라 데스크톱 앱을 골라야 한다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/14edef565579a06287e11d75d248963b/4b469/image-2.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 112.94117647058823%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAXCAYAAAALHW+jAAAACXBIWXMAABYlAAAWJQFJUiTwAAAELklEQVR42q2V229URRyANwu7JGIUetl7l7O7Z/dc93J2t3tp6W63ty21hRhqKaVe4cUnFLGaCGhQEftg9MkXbaGFgkSfhPjIs9JyaSsx/gEa/wFKW9rPnNMStLVPMsk3c2Yy+c78fmfmjI2nXGwrKyvMzf/K9MxtZmfnmLl9h+mZO9y9N8e92XluTc/wy61pft6AOT4//xv37//O7Nx9/vjzrzXhwsICR145itHYTEe1l2JLO5l8ieZyF43FVmQ9jaQZKHoaTTNQNQPZ7MezlCq9dFRfJJOr8OVXX68JHzx4wGvH3iSRLpLMNJHINFmtmsgSk1S0hIEghJEFEU1JocpJNFEhJITxBwTCUY1ddQE+OP3RY+ECA4PDJNM5ZC1JTNFR9BSRqILX68Xr9eGuqyfkchP2NyB4fAguN/W1tdTU1OLx+HE4n+HdkffXhA8fLnLk2FsYzT0kClWUTDt6rhtRMRAjIrKiWmhaHFWS8brduFxuXG6Phc/nx7HdwcjIyJpwcXGRoaNvk6scpKV6GCVbRS/0IippIqJIxsijKQmCewSEUPgJgtlGiMZkdu2u49TpM+shLyzQf2iITK4JI1tAUuKoCYNITMXn8yGKOtFYmoAg0hCSLIIhmWBYweML4nK5sNu3cfLkySdfeXD4deJGHt1cTaqReLpATE3gdnvweH34AkECwRCBBmGdkNX3+huskJ3OHYyMvPc4hw/p7N5PrSdIMKIQEMxVyLg8QRyOHdZkp9OJ07EZh8PJzp3PYrPZOH78+JpweXmZ6zd+4vKVa1y99gNXvvveai9NXWVsbIyxsXHGx00urPPP5wvWnNHRUW7evLkmNKuZ23cZG5/g8tRVi8lLU1ycmGRi8rLFhYuTm7g4cYlvvh3nx+s3WF1dfXL0zOrUmbPYbHZqauvx+4N4vX48Hh8ul5lDc5/twG53YN9msh27fbsVrhlqY2MOM22PpZbw3PlRa09JkkIkIhIORxDFqEU4LBKNxpAlGVEUkSQJRVGtuXuECL19+zHTZhZTagk/Of8F3oBAPl8kl8uTTKbIZhutt5tt0siSSOeJp3IoatySmtvK4w/Tva+P5eWlDcJzo+yu85HJt5DKFNATaVQ9haon0eIp1Hja+kmYROU4kahMTFYJBAV6XvgP4ceffka928/g0Mv0DwzR0dVDqbWDcqWT0jpliw7KbV20tldp6+im2NzKwf5DmKdtwwo/57nnayi3ddJcaqPQVCJfbCGRym5JKp0jKmn09PSyvLS0Wbi7pp7Ozn2Uy+2Uyu3kCntJZwtbks01WWnp7TvA0kbhqQ/P4tzmoLOwl65ShWLcICbpVuLFLYjJOv6GEJVK+2bhxOQU3dVu3hga5tXDRxjuH6Df5KWtGTg0SN/+A5w48Q6PHj36t9DqACurq9bg6v+5pJ72rfc3CIxD7ylSlDcAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Google Auth Platform에서 OAuth client를 만들고 Desktop app 타입을 선택하는 화면&apos; title=&apos;&apos; src=&apos;/static/14edef565579a06287e11d75d248963b/ca1dc/image-2.png&apos; srcset=&apos;/static/14edef565579a06287e11d75d248963b/e7570/image-2.png 170w,
/static/14edef565579a06287e11d75d248963b/f46e7/image-2.png 340w,
/static/14edef565579a06287e11d75d248963b/ca1dc/image-2.png 680w,
/static/14edef565579a06287e11d75d248963b/02d09/image-2.png 1020w,
/static/14edef565579a06287e11d75d248963b/4b469/image-2.png 1046w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Google Auth Platform에서 OAuth client를 만들고 Desktop app 타입을 선택하는 화면&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;OAuth-consent-화면도-실패처럼-보였다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#OAuth-consent-%ED%99%94%EB%A9%B4%EB%8F%84-%EC%8B%A4%ED%8C%A8%EC%B2%98%EB%9F%BC-%EB%B3%B4%EC%98%80%EB%8B%A4&quot; aria-label=&quot;OAuth consent 화면도 실패처럼 보였다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;OAuth consent 화면도 실패처럼 보였다&lt;/h2&gt;
&lt;p&gt;Desktop OAuth client를 만들고 다시 시도했는데, 이번에는 다른 화면이 나왔다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Google hasn&apos;t verified this app&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;처음 보면 실패처럼 보이지만 이 화면은 막힌 것이 아니다. OAuth consent app이 테스트 또는 미검증 상태일 때 나오는 경고다. 내가 만든 앱이고 테스트 사용자로 등록된 계정이라면 &lt;code class=&quot;language-text&quot;&gt;Advanced&lt;/code&gt;를 눌러 계속 진행할 수 있다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/8e62138bf60e0e748028f08646ebd867/a6a70/image-1.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 151.76470588235296%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAACXBIWXMAAAsTAAALEwEAmpwYAAACaklEQVR42rVVyY7TQBTM58IvcEWCCxcQBy7wByMEI6ERBy5ISNwQyyDIJHEUEsdLHO92u+0uVJ1ppweNGDMJliq9xK639ase4cjPiD/1j3PITbjbUepwwuX9e4hen+z4uu4wQtW2kJsAMkmglOrRdZ2GWQ8mFE2DieNgfDGB4ziYzWZYLBYYj8d6bTDcQ6XQ1DUaISClRNM02rOqqpAkCdI01WOWZf2ac4M4jlHXtZVDK0w7vDzP4boufN/X8DwPQRBgvV7rkWQ0TrK2bfeEXCRZhm2aIooije12qz2hdXplRu4ZcE2DJO+sQo6UEEBRQJXlwUdGEzZBgGi5ROG6UFX115eNPSEVHr4qcfdFiTvPSzw5233XKYacpih9HyIIACkHedEphcm6wdd5jS9zAcdrdgbNwT5u6zEOg3942m4Pu7lGfXKOUBBcCfmYhPXP78g+vL8k7g4nTE5P4D97fBwP2Wpsn6quUJal7mEhhG69oij03O7VQR6uPQ8Xkwmm0ynm8zmWy2WvNlQe7rO92KYE5xQSA1veNKFRGYIe0VPT16a3wzDUAmFEgnvsZ45XxEGffMs6QWIjTfzICIQRBqZFWiTqz5DpFV9izpg7ekhwbmD+q27od01ovLJdv1YcLsdKKLz7JvH2s8SbTxJO0PZHWRMyjE0YosjzQWqTFB2enhV4dFrgwcscH8dirzbXfcj8MA2mUHbBbopid+slCWQca7QsgrtCEkXI8ry/O4xK35jDlnLvrrBxVwh/LbBZrVBRG9P0Vj0+UixGmqJNE5C8jWN0vKOF0EUwh3bo/fwfBNYu4S3F1ib8DWk/LZ1MT9XaAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;미검증 OAuth 앱 경고에서 Advanced와 계속 진행 링크를 선택하는 화면&apos; title=&apos;&apos; src=&apos;/static/8e62138bf60e0e748028f08646ebd867/ca1dc/image-1.png&apos; srcset=&apos;/static/8e62138bf60e0e748028f08646ebd867/e7570/image-1.png 170w,
/static/8e62138bf60e0e748028f08646ebd867/f46e7/image-1.png 340w,
/static/8e62138bf60e0e748028f08646ebd867/ca1dc/image-1.png 680w,
/static/8e62138bf60e0e748028f08646ebd867/a6a70/image-1.png 730w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;미검증 OAuth 앱 경고에서 Advanced와 계속 진행 링크를 선택하는 화면&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;반대로 이런 화면은 실제로 막힌 것이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Access blocked: app has not completed the Google verification process&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 경우에는 현재 로그인한 Google 계정이 OAuth consent app의 test user가 아니거나 앱 설정이 아직 접근 가능한 상태가 아니다.&lt;/p&gt;
&lt;p&gt;정리하면 OAuth에서 확인할 것은 세 가지였다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;OAuth client가 &lt;code class=&quot;language-text&quot;&gt;Desktop app&lt;/code&gt; 타입인가.&lt;/li&gt;
&lt;li&gt;OAuth consent app에 현재 로그인 계정이 test user로 들어가 있는가.&lt;/li&gt;
&lt;li&gt;ADC를 &lt;code class=&quot;language-text&quot;&gt;analytics.readonly&lt;/code&gt; scope로 다시 발급했는가.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;이 세 가지가 맞아야 서버 앱의 MCP 런타임에서 내 Google 계정이 볼 수 있는 GA 계정 목록을 읽을 수 있다.&lt;/p&gt;
&lt;h2 id=&quot;service-account는-다른-문제였다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#service-account%EB%8A%94-%EB%8B%A4%EB%A5%B8-%EB%AC%B8%EC%A0%9C%EC%98%80%EB%8B%A4&quot; aria-label=&quot;service account는 다른 문제였다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;service account는 다른 문제였다&lt;/h2&gt;
&lt;p&gt;중간에 service account 방식도 시도했다. 운영 서버나 배치 작업이라면 이 방식이 더 자연스럽다. 사람이 브라우저에서 승인하지 않아도 되고 key 파일을 런타임에 전달하면 token을 만들 수 있다.&lt;/p&gt;
&lt;p&gt;하지만 목적이 달랐다. 나는 서버 앱에 붙인 MCP에서 &quot;내 Google 계정이 볼 수 있는 모든 GA property&quot;를 보고 싶었다. service account는 내 Google 계정의 권한을 상속받지 않는다. 완전히 별도의 identity다.&lt;/p&gt;
&lt;p&gt;그래도 service account 방식을 쓰려면 흐름은 이렇게 된다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;PROJECT_ID&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;your-google-cloud-project-id&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;SA_NAME&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;analytics-mcp&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;KEY_PATH&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token environment constant&quot;&gt;$HOME&lt;/span&gt;/Downloads/analytics-mcp-service-account.json&quot;&lt;/span&gt;

gcloud config &lt;span class=&quot;token builtin class-name&quot;&gt;set&lt;/span&gt; project &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$PROJECT_ID&lt;/span&gt;&quot;&lt;/span&gt;

gcloud services &lt;span class=&quot;token builtin class-name&quot;&gt;enable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  analyticsadmin.googleapis.com &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  analyticsdata.googleapis.com &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--project&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$PROJECT_ID&lt;/span&gt;&quot;&lt;/span&gt;

gcloud iam service-accounts create &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$SA_NAME&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--project&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$PROJECT_ID&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  --display-name&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Google Analytics MCP&quot;&lt;/span&gt;

&lt;span class=&quot;token assign-left variable&quot;&gt;SA_EMAIL&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$SA_NAME&lt;/span&gt;@&lt;span class=&quot;token variable&quot;&gt;$PROJECT_ID&lt;/span&gt;.iam.gserviceaccount.com&quot;&lt;/span&gt;

gcloud iam service-accounts keys create &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$KEY_PATH&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  --iam-account&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$SA_EMAIL&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--project&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;$PROJECT_ID&lt;/span&gt;&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그 다음에는 GA4 쪽에서 이 service account 이메일에 Viewer 또는 Analyst 권한을 줘야 한다.&lt;/p&gt;
&lt;p&gt;여기서도 함정이 있었다. GA4 UI의 &lt;code class=&quot;language-text&quot;&gt;Add users&lt;/code&gt; 화면은 일반 Google 계정 이메일만 받는 경우가 있다. service account 이메일을 넣으면 이런 에러가 날 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;이메일이 Google 계정과 일치하지 않습니다.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이건 service account key가 틀렸다는 뜻이 아니다. GA4 UI의 사용자 추가 흐름과 service account identity가 맞지 않는 경우다. 이때는 GA Admin API의 access binding을 써야 할 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token assign-left variable&quot;&gt;GA4_PROPERTY_ID&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;your-ga4-property-id&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;SA_EMAIL&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;analytics-mcp@your-google-cloud-project-id.iam.gserviceaccount.com&quot;&lt;/span&gt;
&lt;span class=&quot;token assign-left variable&quot;&gt;ACCESS_TOKEN&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;gcloud auth print-access-token&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-sS&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-X&lt;/span&gt; POST &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token string&quot;&gt;&quot;https://analyticsadmin.googleapis.com/v1alpha/properties/&lt;span class=&quot;token variable&quot;&gt;${GA4_PROPERTY_ID}&lt;/span&gt;/accessBindings&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Authorization: Bearer &lt;span class=&quot;token variable&quot;&gt;${ACCESS_TOKEN}&lt;/span&gt;&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Content-Type: application/json&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;{
    &lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;user&lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;: &lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;${SA_EMAIL}&lt;/span&gt;&lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;,
    &lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;roles&lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;: [&lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;predefinedRoles/viewer&lt;span class=&quot;token entity&quot; title=&quot;\&amp;quot;&quot;&gt;\&quot;&lt;/span&gt;]
  }&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;다만 이 방식은 access binding을 만드는 사용자에게 GA property의 Administrator 권한과 &lt;code class=&quot;language-text&quot;&gt;analytics.manage.users&lt;/code&gt; scope가 필요하다.&lt;/p&gt;
&lt;h2 id=&quot;OAuth와-service-account의-선택-기준&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#OAuth%EC%99%80-service-account%EC%9D%98-%EC%84%A0%ED%83%9D-%EA%B8%B0%EC%A4%80&quot; aria-label=&quot;OAuth와 service account의 선택 기준 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;OAuth와 service account의 선택 기준&lt;/h2&gt;
&lt;p&gt;이번에 가장 크게 배운 것은 둘 중 하나가 더 좋은 방식은 아니라는 점이다. 목적이 다르다.&lt;/p&gt;
&lt;p&gt;OAuth는 사람 계정의 권한을 쓴다. 내가 GA UI에서 볼 수 있는 account와 property를 서버 앱의 MCP에서도 보고 싶다면 OAuth가 맞다. 대신 OAuth consent, test user, scope, ADC 갱신을 제대로 통과해야 한다.&lt;/p&gt;
&lt;p&gt;service account는 운영 자동화 identity를 쓴다. 서버 캐시, 배치, cron, 특정 property의 서버 지표 수집처럼 사람이 매번 승인하면 안 되는 작업에는 이 방식이 맞다. 대신 GA account 또는 property마다 service account에 명시적으로 권한을 줘야 한다.&lt;/p&gt;
&lt;p&gt;그래서 선택 기준은 이렇게 잡는 편이 낫다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;서버 앱의 MCP에서 내가 접근 가능한 GA 전체를 탐색한다: OAuth ADC&lt;/li&gt;
&lt;li&gt;특정 제품의 운영 지표를 서버가 반복해서 가져온다: service account&lt;/li&gt;
&lt;li&gt;여러 사람이 같은 숫자를 봐야 한다: 서버 캐시와 service account&lt;/li&gt;
&lt;li&gt;한 사람이 자기 권한으로 질문한다: OAuth&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 기준 없이 &quot;Google credential&quot;이라고만 부르면 디버깅이 길어진다.&lt;/p&gt;
&lt;h2 id=&quot;최종-setup-흐름&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B5%9C%EC%A2%85-setup-%ED%9D%90%EB%A6%84&quot; aria-label=&quot;최종 setup 흐름 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;최종 setup 흐름&lt;/h2&gt;
&lt;p&gt;내 경우 최종적으로는 OAuth ADC 방식으로 끝냈다.&lt;/p&gt;
&lt;p&gt;먼저 Cloud project에서 Analytics API를 켠다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gcloud services &lt;span class=&quot;token builtin class-name&quot;&gt;enable&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  analyticsadmin.googleapis.com &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  analyticsdata.googleapis.com &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--project&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;your-google-cloud-project-id&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그다음 Google Auth Platform에서 Desktop OAuth client를 만든다. OAuth consent app이 테스트 상태라면 현재 로그인할 Google 계정을 test user에 추가한다.&lt;/p&gt;
&lt;p&gt;다운로드한 OAuth client JSON으로 ADC를 다시 발급한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;gcloud auth application-default login &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;--scopes&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;https://www.googleapis.com/auth/analytics.readonly,https://www.googleapis.com/auth/cloud-platform &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  --client-id-file&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;/path/to/oauth-client.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;성공하면 아래 파일이 갱신된다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;~/.config/gcloud/application_default_credentials.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;서버 앱에서 실행되는 MCP 설정은 이 ADC 파일을 보게 한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;toml&quot;&gt;&lt;pre class=&quot;language-toml&quot;&gt;&lt;code class=&quot;language-toml&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;mcp_servers.analytics-mcp&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;command&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pipx&quot;&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;args&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;run&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;analytics-mcp&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token table class-name&quot;&gt;mcp_servers.analytics-mcp.env&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;GOOGLE_APPLICATION_CREDENTIALS&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;/Users/you/.config/gcloud/application_default_credentials.json&quot;&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;GOOGLE_PROJECT_ID&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;your-google-cloud-project-id&quot;&lt;/span&gt;
&lt;span class=&quot;token key property&quot;&gt;GOOGLE_CLOUD_PROJECT&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;your-google-cloud-project-id&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;마지막으로 서버 앱의 MCP tool이 실제 GA 계정 목록을 읽는지 확인한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;get_account_summaries&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;여기서 계정과 property 목록이 나오면 끝이다. 빈 배열이면 해당 Google 계정이 볼 수 있는 GA 계정이 없거나 다른 계정으로 OAuth를 완료했을 가능성이 높다. scope 부족이면 ADC를 다시 발급해야 한다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;Google Analytics API를 붙일 때는 &quot;credential이 있나?&quot;로 시작하지 않는다. 먼저 어떤 identity로 접근할지 정한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;내 Google 계정으로 볼 것인가.&lt;/li&gt;
&lt;li&gt;서버용 service account로 볼 것인가.&lt;/li&gt;
&lt;li&gt;특정 property만 필요한가.&lt;/li&gt;
&lt;li&gt;내가 접근 가능한 전체 GA 계정이 필요한가.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;그 다음에 확인 순서를 나눈다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;identity가 token을 만들 수 있는가.&lt;/li&gt;
&lt;li&gt;token에 필요한 scope가 있는가.&lt;/li&gt;
&lt;li&gt;그 identity가 GA account 또는 property 권한을 갖고 있는가.&lt;/li&gt;
&lt;li&gt;MCP나 서버 런타임이 같은 credential 파일을 보고 있는가.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;이번 MCP 세팅에서 오래 걸린 이유는 설치가 어려워서가 아니었다. OAuth와 service account를 같은 &quot;Google 인증&quot;으로 묶어 봤기 때문이다. 둘을 나누자 문제가 단순해졌다.&lt;/p&gt;
&lt;p&gt;고정된 운영 자동화에는 service account가 맞고, 개인 계정의 GA 접근권한을 그대로 쓰는 서버 앱 MCP에는 OAuth가 맞다. 이 기준을 먼저 정하면 Google 인증 디버깅은 훨씬 짧아진다.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Why I Replaced Growth OS GA Fetch Cron Jobs with a Self-Healing Cache]]></title><description><![CDATA[Our marketer had started building a back-office view that pulled Growth-related information into one place. I ended up finishing the…]]></description><link>https://sewon.dev/en/place2page-growth-os-ga-cache-self-healing/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-growth-os-ga-cache-self-healing/</guid><pubDate>Thu, 04 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c3809b538d62deb2d32e41b7f06c8b7d/00f4c/growth-os-ga-swr-sequence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 52.94117647058824%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAABQElEQVR42nWS2XLDMAhF8/8fmtiJY9lmlVjUUZZO2k4ZHhikAxeJ076Ru0f4vul1lt67e86TMHnvvawynSkiM/rljAjWe4ejXc5kFicAFBFmUtGybsxMhGXdw6P3njH8ae7Z3xaP+BTvVGa25hHj7jTNpRREAIDW7BP4D37WTjNblvtyWxDxOACRPk5/qPiAIxkbAsKBhOIP2e5JKGOE7NYy4uXW/nRWtdGI+NiHWmEpZVvXDQCsmVt8d/4N994J5Th2RJjnW9U6eFEirrWGh7C2t1nzPzPbK64az7xKXZZCxCq13HdhUVURrfo/bC3cxssT0u26rOtaSrnOt4j8IVuliUitisgE9TU8e1UzcwI9NhauVVu5g1tkpHtWfcCEam6ZUQpfzvt7w4h5CNs3vV15bFj260xE488R2jyNDfsCcAmDLEdj5boAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;A stale-while-revalidate flow for Growth OS GA caching&apos; title=&apos;&apos; src=&apos;/static/c3809b538d62deb2d32e41b7f06c8b7d/ca1dc/growth-os-ga-swr-sequence.png&apos; srcset=&apos;/static/c3809b538d62deb2d32e41b7f06c8b7d/e7570/growth-os-ga-swr-sequence.png 170w,
/static/c3809b538d62deb2d32e41b7f06c8b7d/f46e7/growth-os-ga-swr-sequence.png 340w,
/static/c3809b538d62deb2d32e41b7f06c8b7d/ca1dc/growth-os-ga-swr-sequence.png 680w,
/static/c3809b538d62deb2d32e41b7f06c8b7d/02d09/growth-os-ga-swr-sequence.png 1020w,
/static/c3809b538d62deb2d32e41b7f06c8b7d/9d567/growth-os-ga-swr-sequence.png 1360w,
/static/c3809b538d62deb2d32e41b7f06c8b7d/00f4c/growth-os-ga-swr-sequence.png 1568w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;A stale-while-revalidate flow for Growth OS GA caching&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Our marketer had started building a back-office view that pulled Growth-related information into one place. I ended up finishing the unresolved engineering parts. The unfamiliar part was not querying a database. It was combining Google Analytics, Mixpanel, and Google Search Console with product and planning context. That path was much less like a normal app-server query than I expected.&lt;/p&gt;
&lt;p&gt;The plan lived in Notion. The actual customer state lived in the database. Traffic lived in GA. Search performance lived in Search Console. Product events lived in Mixpanel. Answering a simple question like &quot;what should we look at this week?&quot; still meant opening several tabs.&lt;/p&gt;
&lt;p&gt;Growth OS was meant to change that. Notion would hold planning and actions. Growth OS would show results and metrics. But once GA and Search Console entered the picture, it became clear that &quot;connect an external analytics API&quot; is not just one successful request. Credentials can break. Permissions can disappear. Refresh jobs can fail quietly. The screen should not collapse along with that failure.&lt;/p&gt;
&lt;p&gt;This work was about making the Growth screen less fragile in the face of external analytics failures.&lt;/p&gt;
&lt;h2 id=&quot;Where-I-Was-Initially-Confused&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Where-I-Was-Initially-Confused&quot; aria-label=&quot;Where I Was Initially Confused permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Where I Was Initially Confused&lt;/h2&gt;
&lt;p&gt;At first it looked like a cadence problem:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Should the server prefetch on a schedule?&lt;/li&gt;
&lt;li&gt;Should it fetch on every user view?&lt;/li&gt;
&lt;li&gt;Should it show stored values first and refresh in the background?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;But after a second look, cadence was not the real issue. Whether data was pulled on a schedule or on demand, both strategies still depended on the same brittle Google fetch path. If authentication or authorization broke once, neither strategy was actually stable.&lt;/p&gt;
&lt;p&gt;A scheduled job also had an operational downside: if it failed while nobody was watching, it was hard to tell whether the numbers were old, refresh was broken, or there really was no activity.&lt;/p&gt;
&lt;p&gt;Fetching live on every request had the opposite problem. It tied the dashboard to Google API latency and quotas. Growth OS is meant to be scanned quickly. I did not want every page load to wait on analytics APIs.&lt;/p&gt;
&lt;p&gt;So I changed the structure. The screen always reads a stored value first. If the data is missing or stale, the server refreshes in the background. If refresh fails, the previous snapshot remains visible.&lt;/p&gt;
&lt;h2 id=&quot;The-Structure-I-Switched-To&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Structure-I-Switched-To&quot; aria-label=&quot;The Structure I Switched To permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Structure I Switched To&lt;/h2&gt;
&lt;p&gt;For preset date ranges, GA and Search Console data now use a stale-while-revalidate model on the server.&lt;/p&gt;
&lt;p&gt;When someone opens Growth OS, the server reads the latest cached values from a shared cache table and returns them immediately. That response does not wait for Google APIs.&lt;/p&gt;
&lt;p&gt;If the cache is stale or missing for a requested range, the server triggers one refresh in the background after returning the response. If it succeeds, the next viewer gets fresh data. If it fails, the previous good value stays in place.&lt;/p&gt;
&lt;p&gt;The contract of the screen became:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;show something first&lt;/li&gt;
&lt;li&gt;fix stale values in the background&lt;/li&gt;
&lt;li&gt;do not destroy the last good snapshot on refresh failure&lt;/li&gt;
&lt;li&gt;avoid duplicate refreshes when multiple people open the same range at once&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The sequence diagram at the top is a compressed version of that flow.&lt;/p&gt;
&lt;h2 id=&quot;Why-the-Cache-Belongs-on-the-Server-Not-in-the-Browser&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-the-Cache-Belongs-on-the-Server-Not-in-the-Browser&quot; aria-label=&quot;Why the Cache Belongs on the Server Not in the Browser permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why the Cache Belongs on the Server, Not in the Browser&lt;/h2&gt;
&lt;p&gt;I did consider a client-side version first: show the last stored value, then let the browser silently fetch fresh data and swap it in.&lt;/p&gt;
&lt;p&gt;That is fine for some UI patterns. It is the wrong boundary here.&lt;/p&gt;
&lt;p&gt;Growth OS numbers are not personalized. Team members should all be looking at the same metrics. That means the freshness state also should not be different in each browser tab.&lt;/p&gt;
&lt;p&gt;If every browser performs its own live fetch, the same request multiplies as usage grows. Failure handling becomes fragmented across clients. Worst of all, &quot;when was this number last refreshed?&quot; stops being a shared server-side fact and becomes a per-tab state.&lt;/p&gt;
&lt;p&gt;That is why the cache belongs in the server and database. Repeatedly viewed preset metrics should read from shared cache. Ad hoc date ranges can still be queried live because they behave more like one-off investigative questions than like shared operational metrics.&lt;/p&gt;
&lt;h2 id=&quot;The-Permission-Problem-Was-Not-Just-Authentication&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Permission-Problem-Was-Not-Just-Authentication&quot; aria-label=&quot;The Permission Problem Was Not Just Authentication permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Permission Problem Was Not Just &quot;Authentication&quot;&lt;/h2&gt;
&lt;p&gt;The most confusing part of this work was Google access.&lt;/p&gt;
&lt;p&gt;It is easy to think &quot;we have a service-account key and the server can mint a token, so authentication is done.&quot; But that only proves identity. It does not prove the right to read a GA4 property or a Search Console property.&lt;/p&gt;
&lt;p&gt;If you treat those as one blended problem, debugging gets slow. In practice, there were three separate gates:&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/e4ad33337d1ca01d5f11a21a41a4f809/c7a69/google-auth-gates.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 50%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsTAAALEwEAmpwYAAABuUlEQVR42m2S32vbQAzH/f+/Bwp7CN3TYC8j6zYo6eYUmsRx6LJCvTQsaZo4ce278/l++Hx3vh8jLmOUTXwQEkLii6SgNQ5iRbmumGa8xVQTrl9STFRFNWG6Iso5/68FxthjwSEWAAlY1iVuSKXoCZnDGpQSYAVKKZVR2vjXM4LOO++d7Qq1UVsJX+BGeU1Nk5kmb0VmtaiVLZkumcK8VdoG3hm5vib3X8TDpWdwXRfnaNZPx+c4XtbAkCXNr8D+qoEjw3e7Qt5u2HyFfjwJxNrAW0Nv34Nxn8Rvfb55gI+9dNR7CnuH0YIcyt0EbQbg1wXeDCRIfq7zmwRFSzhOYFHJv7Kdt957bJpIpGO+m4o9Mo0XhWUrS1YWL52sMDNHpA6oeS41b9pTs0Gofc5NUZg8dwB4WHZgB6AtoGtktwvLWiWMxIptSS6tss4F3jk2mWw/DPYXn3cfP8HLIQtDFobk6zcWhvVwaNK99f7dcXa2v36T3pxtR73HsJ9NsRanZp0kdBrRKCbRrJpGbBbzeF5FMxrP6WQqs8x5n/DsO0sXPF2c/OGuPkrbyXbO+VfYjj+x/99/dHf+DerDKSDyfSgQAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;A diagram showing identity, product access, and runtime delivery as separate Google access gates&apos; title=&apos;&apos; src=&apos;/static/e4ad33337d1ca01d5f11a21a41a4f809/ca1dc/google-auth-gates.png&apos; srcset=&apos;/static/e4ad33337d1ca01d5f11a21a41a4f809/e7570/google-auth-gates.png 170w,
/static/e4ad33337d1ca01d5f11a21a41a4f809/f46e7/google-auth-gates.png 340w,
/static/e4ad33337d1ca01d5f11a21a41a4f809/ca1dc/google-auth-gates.png 680w,
/static/e4ad33337d1ca01d5f11a21a41a4f809/02d09/google-auth-gates.png 1020w,
/static/e4ad33337d1ca01d5f11a21a41a4f809/9d567/google-auth-gates.png 1360w,
/static/e4ad33337d1ca01d5f11a21a41a4f809/c7a69/google-auth-gates.png 2560w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;A diagram showing identity, product access, and runtime delivery as separate Google access gates&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The first gate is identity. The server must be able to read a credential and mint a Google token.&lt;/p&gt;
&lt;p&gt;The second gate is product access. That identity must also be authorized inside GA4 and Search Console.&lt;/p&gt;
&lt;p&gt;The third gate is runtime delivery. The deployed container must actually receive and read the credential file. A manual fix on the server can vanish at the next deploy if the secret mount is not part of the deployable infrastructure definition.&lt;/p&gt;
&lt;p&gt;Once those became separate checks, the debugging path got much shorter:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;can the identity mint a token?&lt;/li&gt;
&lt;li&gt;does it have product-level access?&lt;/li&gt;
&lt;li&gt;can the running container read the credential at deploy time?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;The-Standard-I-Used-While-Implementing-It&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Standard-I-Used-While-Implementing-It&quot; aria-label=&quot;The Standard I Used While Implementing It permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Standard I Used While Implementing It&lt;/h2&gt;
&lt;p&gt;The most important standard in this work was not &quot;how fast can we fetch the newest number?&quot; It was &quot;what failure mode should the screen have?&quot;&lt;/p&gt;
&lt;p&gt;Growth OS is an operations cockpit. When a user opens it, the first thing they should not see is an empty dashboard or a crash because an external analytics API had a temporary problem.&lt;/p&gt;
&lt;p&gt;That led to these rules:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the preset metrics screen should not wait on Google APIs&lt;/li&gt;
&lt;li&gt;refresh failure should not overwrite the previous good value&lt;/li&gt;
&lt;li&gt;the same range should not refresh several times concurrently&lt;/li&gt;
&lt;li&gt;authentication, product authorization, and runtime credential delivery should be verified independently&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once I set those rules, cron became a supporting tool instead of the main path. It can still be useful for backfills or manual recovery, but the dashboard should not depend on a daily scheduled job quietly succeeding.&lt;/p&gt;
&lt;h2 id=&quot;What-I-Verified-After-Deploy&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-I-Verified-After-Deploy&quot; aria-label=&quot;What I Verified After Deploy permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What I Verified After Deploy&lt;/h2&gt;
&lt;p&gt;I did not stop at code-level testing. I checked the running production container directly.&lt;/p&gt;
&lt;p&gt;I verified that the credential file was readable inside the container, that preset metric responses included cache-status information, and that both GA and Search Console values appeared in the response.&lt;/p&gt;
&lt;p&gt;The final behavior was:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the UI returned the stored snapshot immediately&lt;/li&gt;
&lt;li&gt;the cache state was fresh&lt;/li&gt;
&lt;li&gt;GA and Search Console values were both populated for preset ranges&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The important claim here is not just &quot;numbers showed up.&quot; The more important change is what happens the next time Google fetch fails. The screen now keeps serving the previous successful snapshot. The failure shows up in logs and cache state instead of turning the dashboard into an empty surface.&lt;/p&gt;
&lt;h2 id=&quot;What-I-Deliberately-Left-Out-of-the-Public-Write-Up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-I-Deliberately-Left-Out-of-the-Public-Write-Up&quot; aria-label=&quot;What I Deliberately Left Out of the Public Write Up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What I Deliberately Left Out of the Public Write-Up&lt;/h2&gt;
&lt;p&gt;This post does not include:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the actual service-account email&lt;/li&gt;
&lt;li&gt;the GA property ID&lt;/li&gt;
&lt;li&gt;the DNS verification token&lt;/li&gt;
&lt;li&gt;the credential filename or absolute server path&lt;/li&gt;
&lt;li&gt;repository or server secret values&lt;/li&gt;
&lt;li&gt;internal API route names&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The useful lesson is not the identifier itself. It is the boundary: what permission is needed, what order the checks should follow, and which failure modes the UI must survive.&lt;/p&gt;
&lt;h2 id=&quot;Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Next-Time&quot; aria-label=&quot;Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Next Time&lt;/h2&gt;
&lt;p&gt;When connecting external analytics APIs to a product surface, I will not start with &quot;does the API call work?&quot; I will start with &quot;what state does the screen hold when refresh fails?&quot;&lt;/p&gt;
&lt;p&gt;Cron is simple, but it can fail quietly. Live fetch on every request is fresh, but it couples the UI to external latency. For a shared operational dashboard, a DB-backed stale-while-revalidate cache is a better default.&lt;/p&gt;
&lt;p&gt;And I will keep Google access split into separate gates:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;token minting is identity&lt;/li&gt;
&lt;li&gt;GA4 and Search Console access are product permissions&lt;/li&gt;
&lt;li&gt;container-side credential readability is runtime delivery&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When those are separated explicitly, the debugging path becomes much shorter.&lt;/p&gt;
&lt;p&gt;Growth metrics screens should behave like an operations cockpit, not like a thin Google API client. A cockpit should keep showing the last trustworthy state even when one of its external instruments starts failing.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Growth OS의 GA fetch를 cron에서 self-healing cache로 바꾼 이유]]></title><description><![CDATA[Growth 관련 정보를 한곳에서 보려고 내부 지표 화면을 만들기 시작했다. 일반적인 서버처럼 DB 정보를 쿼리하는 작업이 아니라 Google Analytics, Mixpanel, Google Search Console 같은 외부 source…]]></description><link>https://sewon.dev/place2page-growth-os-ga-cache-self-healing/</link><guid isPermaLink="false">https://sewon.dev/place2page-growth-os-ga-cache-self-healing/</guid><pubDate>Thu, 04 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c3809b538d62deb2d32e41b7f06c8b7d/00f4c/growth-os-ga-swr-sequence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 52.94117647058824%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAABQElEQVR42nWS2XLDMAhF8/8fmtiJY9lmlVjUUZZO2k4ZHhikAxeJ076Ru0f4vul1lt67e86TMHnvvawynSkiM/rljAjWe4ejXc5kFicAFBFmUtGybsxMhGXdw6P3njH8ae7Z3xaP+BTvVGa25hHj7jTNpRREAIDW7BP4D37WTjNblvtyWxDxOACRPk5/qPiAIxkbAsKBhOIP2e5JKGOE7NYy4uXW/nRWtdGI+NiHWmEpZVvXDQCsmVt8d/4N994J5Th2RJjnW9U6eFEirrWGh7C2t1nzPzPbK64az7xKXZZCxCq13HdhUVURrfo/bC3cxssT0u26rOtaSrnOt4j8IVuliUitisgE9TU8e1UzcwI9NhauVVu5g1tkpHtWfcCEam6ZUQpfzvt7w4h5CNs3vV15bFj260xE488R2jyNDfsCcAmDLEdj5boAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Growth OS GA 캐시 흐름&apos; title=&apos;&apos; src=&apos;/static/c3809b538d62deb2d32e41b7f06c8b7d/ca1dc/growth-os-ga-swr-sequence.png&apos; srcset=&apos;/static/c3809b538d62deb2d32e41b7f06c8b7d/e7570/growth-os-ga-swr-sequence.png 170w,
/static/c3809b538d62deb2d32e41b7f06c8b7d/f46e7/growth-os-ga-swr-sequence.png 340w,
/static/c3809b538d62deb2d32e41b7f06c8b7d/ca1dc/growth-os-ga-swr-sequence.png 680w,
/static/c3809b538d62deb2d32e41b7f06c8b7d/02d09/growth-os-ga-swr-sequence.png 1020w,
/static/c3809b538d62deb2d32e41b7f06c8b7d/9d567/growth-os-ga-swr-sequence.png 1360w,
/static/c3809b538d62deb2d32e41b7f06c8b7d/00f4c/growth-os-ga-swr-sequence.png 1568w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Growth OS GA 캐시 흐름&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Growth 관련 정보를 한곳에서 보려고 내부 지표 화면을 만들기 시작했다. 일반적인 서버처럼 DB 정보를 쿼리하는 작업이 아니라 Google Analytics, Mixpanel, Google Search Console 같은 외부 source에서 정보를 가져와 합치는 일이어서 생각보다 많이 헤맸다. 그 과정을 기록해둔다.&lt;/p&gt;
&lt;p&gt;기획은 노션에 있고, 실제 고객 상태는 DB에 있고, 유입은 GA에 있고, 검색 성과는 Search Console에 있고, 제품 이벤트는 Mixpanel에 있었다. 뭔가 하나를 판단하려면 탭을 여러 개 열어야 했다. &quot;이번 주에 뭘 봐야 하지?&quot;라는 질문에 바로 답하기 어려웠다.&lt;/p&gt;
&lt;p&gt;그래서 Growth OS는 계획과 액션이 아니라 결과와 지표를 보여주는 쪽으로 역할을 잡았다.&lt;/p&gt;
&lt;p&gt;그런데 GA와 Search Console을 붙이면서 알게 됐다. 외부 분석 데이터를 화면에 붙이는 일은 API 호출 하나를 성공시키는 문제가 아니었다. 인증이 끊길 수 있고, 권한이 빠질 수 있고, 갱신 작업이 조용히 실패할 수 있다. 화면은 그 실패를 그대로 맞으면 안 된다.&lt;/p&gt;
&lt;p&gt;이번 작업은 Growth 화면이 외부 분석 API 실패에 덜 흔들리게 만드는 일이었다.&lt;/p&gt;
&lt;h2 id=&quot;처음에-헷갈린-지점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C%EC%97%90-%ED%97%B7%EA%B0%88%EB%A6%B0-%EC%A7%80%EC%A0%90&quot; aria-label=&quot;처음에 헷갈린 지점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음에 헷갈린 지점&lt;/h2&gt;
&lt;p&gt;처음에는 선택지가 cadence 문제처럼 보였다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;정해진 시간마다 미리 가져올까.&lt;/li&gt;
&lt;li&gt;사용자가 볼 때마다 바로 가져올까.&lt;/li&gt;
&lt;li&gt;저장된 값을 먼저 보여주고, 뒤에서 새 값으로 바꿀까.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;하지만 다시 보니 핵심은 cadence가 아니었다. 정해진 시간에 가져오든 사용자가 볼 때 가져오든, 둘 다 같은 불안정한 Google fetch 위에 올라가 있었다. 인증이나 권한이 한 번 막히면 어느 쪽도 안정적이지 않았다.&lt;/p&gt;
&lt;p&gt;정해진 시간마다 밀어 넣는 방식도 마음에 걸렸다. 아무도 보지 않는 동안 실패하면 티가 잘 안 난다. 숫자가 오래된 건지, 갱신이 죽은 건지, 단지 방문자가 없었던 건지 구분하기 어렵다.&lt;/p&gt;
&lt;p&gt;반대로 매번 실시간으로 가져오면 화면이 외부 API 속도와 quota에 묶인다. Growth cockpit은 숫자를 빠르게 훑어보는 도구다. 들어갈 때마다 분석 API를 기다리게 만들고 싶지는 않았다.&lt;/p&gt;
&lt;p&gt;그래서 구조를 바꿨다. 화면은 항상 저장된 값을 먼저 본다. 오래됐거나 비어 있으면 서버가 뒤에서 갱신한다. 실패하면 직전 값을 그대로 둔다.&lt;/p&gt;
&lt;h2 id=&quot;바꾼-구조&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%94%EA%BE%BC-%EA%B5%AC%EC%A1%B0&quot; aria-label=&quot;바꾼 구조 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;바꾼 구조&lt;/h2&gt;
&lt;p&gt;프리셋 기간의 GA/Search Console 데이터는 서버에서 stale-while-revalidate 방식으로 다룬다.&lt;/p&gt;
&lt;p&gt;사용자가 Growth OS를 열면 서버는 공유 캐시 테이블에서 최근 값을 읽어 바로 반환한다. 이 응답은 Google API를 기다리지 않는다.&lt;/p&gt;
&lt;p&gt;그 값이 오래됐거나 빠진 구간이 있으면 응답을 보낸 뒤 백그라운드에서 한 번만 갱신한다. 성공하면 다음 방문자는 새 값을 보고, 실패하면 기존 값을 계속 본다.&lt;/p&gt;
&lt;p&gt;이 구조에서 화면의 약속은 단순하다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;먼저 보여준다.&lt;/li&gt;
&lt;li&gt;오래됐으면 뒤에서 고친다.&lt;/li&gt;
&lt;li&gt;실패해도 마지막으로 성공한 값을 망치지 않는다.&lt;/li&gt;
&lt;li&gt;여러 사람이 동시에 들어와도 같은 구간을 중복 갱신하지 않는다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;맨 위 sequence diagram은 이 흐름을 압축한 것이다.&lt;/p&gt;
&lt;h2 id=&quot;왜-브라우저가-아니라-서버-캐시인가&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EB%B8%8C%EB%9D%BC%EC%9A%B0%EC%A0%80%EA%B0%80-%EC%95%84%EB%8B%88%EB%9D%BC-%EC%84%9C%EB%B2%84-%EC%BA%90%EC%8B%9C%EC%9D%B8%EA%B0%80&quot; aria-label=&quot;왜 브라우저가 아니라 서버 캐시인가 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 브라우저가 아니라 서버 캐시인가&lt;/h2&gt;
&lt;p&gt;처음 프론트에서 생각했던 방식도 있었다. 저장된 값을 먼저 보여주고, 브라우저가 조용히 live 값을 가져와 갈아끼우는 방식이다. UX만 보면 괜찮다.&lt;/p&gt;
&lt;p&gt;하지만 Growth OS의 숫자는 개인화된 값이 아니다. 같은 팀원이 같은 숫자를 봐야 한다. 그러면 이 데이터의 현재 상태도 브라우저마다 따로 있으면 안 된다.&lt;/p&gt;
&lt;p&gt;브라우저가 각자 live fetch를 하면 사용자가 늘어날수록 같은 요청이 반복된다. 실패 처리도 각 브라우저에 흩어진다. 무엇보다 &quot;이 숫자는 언제 갱신됐는가&quot;가 서버의 공통 사실이 아니라 각 탭의 상태가 된다.&lt;/p&gt;
&lt;p&gt;그래서 캐시는 서버와 DB에 두는 편이 맞았다. 프리셋 지표는 공유 캐시를 읽고, 임의로 고른 기간만 그때그때 직접 조회한다. 둘의 성격이 다르기 때문이다.&lt;/p&gt;
&lt;p&gt;프리셋은 팀이 반복해서 보는 운영 지표다. 임의 기간 조회는 특정 질문에 대한 일회성 확인에 가깝다. 같은 API처럼 보여도 운영 기준은 다르게 가져가는 편이 낫다.&lt;/p&gt;
&lt;h2 id=&quot;권한-문제는-인증-문제가-아니었다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B6%8C%ED%95%9C-%EB%AC%B8%EC%A0%9C%EB%8A%94-%EC%9D%B8%EC%A6%9D-%EB%AC%B8%EC%A0%9C%EA%B0%80-%EC%95%84%EB%8B%88%EC%97%88%EB%8B%A4&quot; aria-label=&quot;권한 문제는 인증 문제가 아니었다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;권한 문제는 인증 문제가 아니었다&lt;/h2&gt;
&lt;p&gt;이번에 가장 헷갈렸던 부분은 Google 권한이었다.&lt;/p&gt;
&lt;p&gt;서비스 계정 키가 있고 서버가 그 키로 token을 만들 수 있으면 &quot;이제 됐다&quot;고 생각하기 쉽다. 그런데 그건 누구인지 증명한 것뿐이다. GA4 property나 Search Console property를 읽을 권한이 있다는 뜻은 아니다.&lt;/p&gt;
&lt;p&gt;이걸 한 덩어리로 보면 디버깅이 길어진다. 실제로는 세 개의 문을 따로 통과해야 했다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/e4ad33337d1ca01d5f11a21a41a4f809/c7a69/google-auth-gates.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 50%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAIAAAA7N+mxAAAACXBIWXMAAAsTAAALEwEAmpwYAAABuUlEQVR42m2S32vbQAzH/f+/Bwp7CN3TYC8j6zYo6eYUmsRx6LJCvTQsaZo4ce278/l++Hx3vh8jLmOUTXwQEkLii6SgNQ5iRbmumGa8xVQTrl9STFRFNWG6Iso5/68FxthjwSEWAAlY1iVuSKXoCZnDGpQSYAVKKZVR2vjXM4LOO++d7Qq1UVsJX+BGeU1Nk5kmb0VmtaiVLZkumcK8VdoG3hm5vib3X8TDpWdwXRfnaNZPx+c4XtbAkCXNr8D+qoEjw3e7Qt5u2HyFfjwJxNrAW0Nv34Nxn8Rvfb55gI+9dNR7CnuH0YIcyt0EbQbg1wXeDCRIfq7zmwRFSzhOYFHJv7Kdt957bJpIpGO+m4o9Mo0XhWUrS1YWL52sMDNHpA6oeS41b9pTs0Gofc5NUZg8dwB4WHZgB6AtoGtktwvLWiWMxIptSS6tss4F3jk2mWw/DPYXn3cfP8HLIQtDFobk6zcWhvVwaNK99f7dcXa2v36T3pxtR73HsJ9NsRanZp0kdBrRKCbRrJpGbBbzeF5FMxrP6WQqs8x5n/DsO0sXPF2c/OGuPkrbyXbO+VfYjj+x/99/dHf+DerDKSDyfSgQAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Google access gates&apos; title=&apos;&apos; src=&apos;/static/e4ad33337d1ca01d5f11a21a41a4f809/ca1dc/google-auth-gates.png&apos; srcset=&apos;/static/e4ad33337d1ca01d5f11a21a41a4f809/e7570/google-auth-gates.png 170w,
/static/e4ad33337d1ca01d5f11a21a41a4f809/f46e7/google-auth-gates.png 340w,
/static/e4ad33337d1ca01d5f11a21a41a4f809/ca1dc/google-auth-gates.png 680w,
/static/e4ad33337d1ca01d5f11a21a41a4f809/02d09/google-auth-gates.png 1020w,
/static/e4ad33337d1ca01d5f11a21a41a4f809/9d567/google-auth-gates.png 1360w,
/static/e4ad33337d1ca01d5f11a21a41a4f809/c7a69/google-auth-gates.png 2560w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Google access gates&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;첫 번째 문은 identity다. 서버가 credential을 읽고 Google token을 만들 수 있어야 한다.&lt;/p&gt;
&lt;p&gt;두 번째 문은 제품 권한이다. 같은 identity가 GA4와 Search Console에서 읽기 권한을 가져야 한다. 여기서 빠지면 token은 정상이어도 데이터 접근은 막힌다.&lt;/p&gt;
&lt;p&gt;세 번째 문은 런타임 전달이다. 배포된 컨테이너가 그 credential 파일을 실제로 읽을 수 있어야 한다. 서버에서 수동으로 한 번 맞춰도 배포가 compose 파일을 다시 동기화하면 사라질 수 있다. 그래서 secret mount도 배포 가능한 인프라 정의 안에 들어가야 했다.&lt;/p&gt;
&lt;p&gt;이 순서를 분리하고 나서야 문제가 빨리 좁혀졌다. token이 되는지, 제품 권한이 있는지, 컨테이너 안에서 파일을 읽는지. 이 세 가지는 서로 다른 체크다.&lt;/p&gt;
&lt;h2 id=&quot;구현하면서-정한-기준&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B5%AC%ED%98%84%ED%95%98%EB%A9%B4%EC%84%9C-%EC%A0%95%ED%95%9C-%EA%B8%B0%EC%A4%80&quot; aria-label=&quot;구현하면서 정한 기준 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;구현하면서 정한 기준&lt;/h2&gt;
&lt;p&gt;이 작업에서 중요한 기준은 &quot;최신 값을 얼마나 빨리 가져오느냐&quot;가 아니었다. 화면이 어떤 실패 모드를 갖느냐가 더 중요했다.&lt;/p&gt;
&lt;p&gt;Growth OS는 운영 cockpit이다. 사용자가 들어왔을 때 빈 화면이나 크래시를 먼저 보여주면 안 된다. 외부 API가 잠깐 실패해도, 적어도 마지막으로 확인된 숫자는 보여줘야 한다.&lt;/p&gt;
&lt;p&gt;그래서 구현 기준을 이렇게 잡았다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;프리셋 지표 화면은 Google API를 기다리지 않는다.&lt;/li&gt;
&lt;li&gt;갱신 실패는 기존 값을 덮어쓰지 않는다.&lt;/li&gt;
&lt;li&gt;같은 구간 갱신은 동시에 여러 번 돌리지 않는다.&lt;/li&gt;
&lt;li&gt;인증, 제품 권한, 컨테이너 설정은 각각 따로 검증한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 기준을 잡고 나니 cron은 주 경로가 아니라 보조 도구가 됐다. 수동 복구나 백필에는 여전히 쓸 수 있지만, 매일 돌아야만 화면이 살아 있는 구조는 피했다.&lt;/p&gt;
&lt;h2 id=&quot;배포-후-확인한-것&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%ED%8F%AC-%ED%9B%84-%ED%99%95%EC%9D%B8%ED%95%9C-%EA%B2%83&quot; aria-label=&quot;배포 후 확인한 것 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배포 후 확인한 것&lt;/h2&gt;
&lt;p&gt;배포 후에는 코드 테스트만 보고 끝내지 않았다. 배포된 런타임에서 확인했다.&lt;/p&gt;
&lt;p&gt;credential 파일을 읽을 수 있는지 봤고, 프리셋 지표 응답에 캐시 상태가 포함되는지 봤고, GA와 Search Console 값이 모두 들어오는지 봤다.&lt;/p&gt;
&lt;p&gt;최종적으로 화면은 저장된 값을 즉시 반환했고, 캐시는 fresh 상태였고, 프리셋 구간 전체에서 GA와 Search Console 값이 채워졌다.&lt;/p&gt;
&lt;p&gt;여기서 중요한 건 &quot;숫자가 나왔다&quot;보다 &quot;다음에 실패해도 어떤 일이 일어나는가&quot;였다. 이제 Google fetch가 잠깐 실패해도 화면은 직전 snapshot을 보여준다. 실패는 운영자가 볼 로그와 캐시 상태로 남고, 사용자는 빈 화면을 보지 않는다.&lt;/p&gt;
&lt;h2 id=&quot;공개-글에-일부러-안-쓴-것&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B3%B5%EA%B0%9C-%EA%B8%80%EC%97%90-%EC%9D%BC%EB%B6%80%EB%9F%AC-%EC%95%88-%EC%93%B4-%EA%B2%83&quot; aria-label=&quot;공개 글에 일부러 안 쓴 것 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;공개 글에 일부러 안 쓴 것&lt;/h2&gt;
&lt;p&gt;이 글에서는 실제 설정값을 쓰지 않았다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;서비스 계정 이메일&lt;/li&gt;
&lt;li&gt;GA property id&lt;/li&gt;
&lt;li&gt;DNS verification token&lt;/li&gt;
&lt;li&gt;credential 파일명과 서버 절대 경로&lt;/li&gt;
&lt;li&gt;repository 또는 서버 secret 값&lt;/li&gt;
&lt;li&gt;내부 API 경로 이름&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;문제를 이해하는 데 필요한 건 값 자체가 아니라 경계다. 어떤 권한이 필요한지, 어떤 순서로 확인해야 하는지, 어떤 실패를 막아야 하는지가 중요하다. 구체 식별자는 공개 글에 남길수록 위험만 늘어난다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;외부 분석 API를 제품 화면에 붙일 때는 &quot;API 호출이 되나?&quot;보다 먼저 &quot;실패하면 화면이 어떤 상태를 유지하나?&quot;를 본다.&lt;/p&gt;
&lt;p&gt;cron은 단순하지만 조용히 죽을 수 있다. 매번 live 조회는 신선하지만 화면을 외부 API latency에 묶는다. 여러 사람이 같이 보는 운영 지표라면, DB-backed stale-while-revalidate가 더 좋은 기본값이었다.&lt;/p&gt;
&lt;p&gt;그리고 Google 권한은 한 문장으로 묶지 않는다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;token minting은 identity다.&lt;/li&gt;
&lt;li&gt;GA4/Search Console access는 제품 권한이다.&lt;/li&gt;
&lt;li&gt;container file readability는 런타임 전달이다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 셋을 분리해서 보면 문제를 훨씬 빨리 좁힐 수 있다.&lt;/p&gt;
&lt;p&gt;Growth 지표 화면은 분석 API client가 아니라 운영 cockpit이어야 한다. cockpit은 외부 계기가 흔들려도, 적어도 마지막으로 믿을 수 있었던 상태를 계속 보여줘야 한다.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Layered Debugging for a Cloudflare Tunnel Outage]]></title><description><![CDATA[Backend developers usually live at layer 7. We look at API paths, status codes, request headers, and CORS. I reacted the same way when I saw…]]></description><link>https://sewon.dev/en/cloudflare-tunnel-caddy-cors-l7-debugging/</link><guid isPermaLink="false">https://sewon.dev/en/cloudflare-tunnel-caddy-cors-l7-debugging/</guid><pubDate>Wed, 03 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c1c878b5c7885bda90b19287e3d6dbb2/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAAC1klEQVR42k2T3WscVRjG9+/wol4oBRMpIiqFVBChFnrRf8ErIb2Q1iJobIpVRPyqodgbG2up3nmhF4XSbNZso/ixaa2Y3eymM7OzszvJZHdm9mNm53Nn5vxkZ9X4wu+ch/NyHt7n4i0EUUp730PWHDqGR9vwUHWXujJE1lyUzlSPaOke2p6H4LD+r/+tQpJk9GwPw/Swhz4jJ6LX9/O3oRNgDnwMc4znTwjClDQTJKkgywRCzHSSZoh/7AuZgO8qNiulPr80AxRjxLVSjy9/HrHf91mvznq3qwHm0GX1Xpdrm2OqewFbss2VYo9bFQ8nTGaGQsB91ePutovSixm4MaUdl41HIW6Y0TiIuVMLeKgnBHHK5q7H+o5Hz8k46MeU6wFbrYRwks0Mp8fQCfOIXdsjTrI8CmSk4y6ZtwehAXEPEduQOKQiRQ/7dII+RmxjRDbdiUuaZRSmX2tti8quwQPpgL+0PqrlI7IYp30XU/oeU/qBQWcNzywRW1v0ojFXtQ1WmiVW1A2uamW+te/jptEscn1/yB+qyZ8ti4eajTaISOMAs11Gb66hK0X2m0UsvUhkP6Dj9FltbXJD/SnnunKPW/pveFlMASFotbvUGho7u20aUoeD7ojRsI9rlPHNMr41ZTOfMDIr6O6A1d6v3LQqfG1VuGH+zjfWFm4aTg0zYknCq9YYT9neJlZVRDZBRHVIajCZISbbEMmMkpC1WGY9aeYUkyY/Rk38dDKNLOgoKlK1jlSrI1V3kGsN5KaGJClIj2QkSUaWlRxFUVFaHXYV9T8achOl1SZJUwrJJOHMq4s8+eJJjp06w9MLp5l/4RTzz7/C3HMnOfrsyzxx7CWOzJ045KkFjszNeHz+BI8dPc4zC6fpmtZ0U1I+/+Ir3rr0EZfev8LF9z7jncufsnT5k/x++92P896FpQ84e36ZxXMXWTx/yNk3lnnt9SXeXP6QkePyNzW/OH6mSLbYAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;A diagram showing where HTTP semantics conflicted behind Cloudflare Tunnel&apos; title=&apos;&apos; src=&apos;/static/c1c878b5c7885bda90b19287e3d6dbb2/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/c1c878b5c7885bda90b19287e3d6dbb2/e7570/situation-diagram.png 170w,
/static/c1c878b5c7885bda90b19287e3d6dbb2/f46e7/situation-diagram.png 340w,
/static/c1c878b5c7885bda90b19287e3d6dbb2/ca1dc/situation-diagram.png 680w,
/static/c1c878b5c7885bda90b19287e3d6dbb2/02d09/situation-diagram.png 1020w,
/static/c1c878b5c7885bda90b19287e3d6dbb2/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;A diagram showing where HTTP semantics conflicted behind Cloudflare Tunnel&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Backend developers usually live at layer 7. We look at API paths, status codes, request headers, and CORS. I reacted the same way when I saw &lt;code class=&quot;language-text&quot;&gt;ERR_TOO_MANY_REDIRECTS&lt;/code&gt; in the browser after putting a stage API behind Cloudflare. I immediately suspected redirects and CORS.&lt;/p&gt;
&lt;p&gt;But once Cloudflare Tunnel sits in the path, it becomes dangerous to name the problem too early. It may look like TLS. It may look like origin connectivity. It may turn out to be an HTTP interpretation problem inside the reverse proxy. What helped here was not guessing &quot;this is L7&quot; quickly. It was clearing layer 3/4 connectivity, clearing layer 6 TLS, and then returning to layer 7 with better evidence.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: Behind Cloudflare Tunnel, a stage API showed what looked like one blended failure: redirect loops, &lt;code class=&quot;language-text&quot;&gt;308&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Connection reset&lt;/code&gt;, and CORS errors.&lt;/li&gt;
&lt;li&gt;Approach: Instead of concluding from the familiar layer-7 symptoms, I split the debugging path into DNS/connectivity, TLS, reverse-proxy behavior, and application headers.&lt;/li&gt;
&lt;li&gt;Decision: Layer 3/4 and layer 6 were not the main cause. The decisive signals were back in layer 7: &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;via: 1.1 Caddy&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Host&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;OPTIONS&lt;/code&gt; preflight behavior.&lt;/li&gt;
&lt;li&gt;Fix: I separated the Tunnel route, Caddy &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt; listener, Host-based routing, and CORS preflight handling, and corrected each independently.&lt;/li&gt;
&lt;li&gt;Lesson: Layered debugging is less about naming the right layer early and more about eliminating the wrong layers quickly.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;The stack looked roughly like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Browser
  -&gt; Cloudflare Edge
  -&gt; Cloudflare Tunnel
  -&gt; Ubuntu origin
  -&gt; Docker port 80
  -&gt; Caddy
  -&gt; FastAPI&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Cloudflare was set to &lt;code class=&quot;language-text&quot;&gt;Full (strict)&lt;/code&gt; for SSL/TLS. According to Cloudflare&apos;s docs, the SSL/TLS mode separately affects the visitor-to-Cloudflare connection and the Cloudflare-to-origin connection. &lt;code class=&quot;language-text&quot;&gt;Full (strict)&lt;/code&gt; also verifies the origin certificate.&lt;/p&gt;
&lt;p&gt;That is why the common explanation, &quot;Flexible mode causes an HTTP/HTTPS redirect loop,&quot; was not enough here. With Tunnel in the path, I also needed to understand how &lt;code class=&quot;language-text&quot;&gt;cloudflared&lt;/code&gt; forwarded the request to origin and how Caddy interpreted the incoming host and scheme.&lt;/p&gt;
&lt;h2 id=&quot;Why-I-Had-to-Split-It-by-Layer&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-I-Had-to-Split-It-by-Layer&quot; aria-label=&quot;Why I Had to Split It by Layer permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why I Had to Split It by Layer&lt;/h2&gt;
&lt;p&gt;If you only look at &lt;code class=&quot;language-text&quot;&gt;ERR_TOO_MANY_REDIRECTS&lt;/code&gt;, the browser makes it feel as though the problem has already been named. But that message is only the final layer-7 symptom seen by the browser.&lt;/p&gt;
&lt;p&gt;The earlier questions were:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Layer 3/4: Does the request reach the domain and port?
Layer 6: Is TLS negotiation or certificate validation failing?
Layer 7: Do the HTTP status, Location, Host, and Origin headers match the intended route?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once I forced the debugging into that order, &quot;Cloudflare issue,&quot; &quot;CORS issue,&quot; and &quot;server issue&quot; became smaller, more testable claims. In this case, the lower layers were mostly healthy. The misalignment was in HTTP redirect semantics and header interpretation.&lt;/p&gt;
&lt;h2 id=&quot;At-First-I-Treated-It-Like-TLS-Trouble&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#At-First-I-Treated-It-Like-TLS-Trouble&quot; aria-label=&quot;At First I Treated It Like TLS Trouble permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;At First I Treated It Like TLS Trouble&lt;/h2&gt;
&lt;p&gt;My first hypothesis was a conflict between SSL/TLS mode and HTTPS enforcement. The browser said redirect loop. The Cloudflare dashboard had SSL/TLS controls. So I initially focused near layer 6.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Cloudflare: receives HTTPS
Origin: thinks the request arrived as HTTP
Caddy or app: redirects to HTTPS
Cloudflare: forwards back to origin&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If that were the real path, the &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt; header would keep pointing back into the same scheme bounce. So the first check was a simple &lt;code class=&quot;language-text&quot;&gt;curl -I&lt;/code&gt; to inspect the redirect target.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/a8319deb56ba0c49a18191edee1972a4/c852c/tls-hypothesis-sequence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 42.35294117647059%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAIAAAB2/0i6AAAACXBIWXMAAAsTAAALEwEAmpwYAAABOElEQVR42k2RSW7DMAxFc//T9BJF0U2nVRI3A5rRki1bMy2JZGE7LqrVh4hPPn6umFn3RtQNDFEp28hoTCZiIu46EHWIsTBzCNRIiJHSwI0EYwoRr6ZCaGQLANba4+EYguPllUSzIKI/XRLRJEczIZWMc+H0c5ZCeGeds9baBGUxc044e1JCxMWMyHnp2ikzDCXEHGL2Hq7Xputd33sptXdpIsCUyjx6NWH00a4L7DLsvN46vW7rD3F7U+KrvryD3+b4DW5zv3wijiD5PzYWXWJFac/lAK6KbhvtJpg1+CraCqf/MlRGPhn1bNSrbl5y0g/zAAxhbOUsnk+xbR9pS5kuZ/Bu3M8YPOyurbxpdd9/7xvhHmlb46wZEw4+i9p3CgiJEFUbpfAhZGYKHjuVx1Ml7lSxZiT/BY6azD1FU/O4AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;A sequence diagram testing the TLS redirect-loop hypothesis&apos; title=&apos;&apos; src=&apos;/static/a8319deb56ba0c49a18191edee1972a4/ca1dc/tls-hypothesis-sequence.png&apos; srcset=&apos;/static/a8319deb56ba0c49a18191edee1972a4/e7570/tls-hypothesis-sequence.png 170w,
/static/a8319deb56ba0c49a18191edee1972a4/f46e7/tls-hypothesis-sequence.png 340w,
/static/a8319deb56ba0c49a18191edee1972a4/ca1dc/tls-hypothesis-sequence.png 680w,
/static/a8319deb56ba0c49a18191edee1972a4/c852c/tls-hypothesis-sequence.png 784w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;A sequence diagram testing the TLS redirect-loop hypothesis&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;The-Evidence-That-Mattered&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Evidence-That-Mattered&quot; aria-label=&quot;The Evidence That Mattered permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Evidence That Mattered&lt;/h2&gt;
&lt;p&gt;The first useful clue came from &lt;code class=&quot;language-text&quot;&gt;/health&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;GET http://stage-api.example.com/health
-&gt; 307 Internal Redirect
-&gt; Location: https://stage-api.example.com/health

GET https://stage-api.example.com/health
-&gt; 200 OK
-&gt; via: 1.1 Caddy&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That result showed that the HTTP-to-HTTPS redirect itself was not the main problem. The more important signal was that &lt;code class=&quot;language-text&quot;&gt;https://.../health&lt;/code&gt; returned &lt;code class=&quot;language-text&quot;&gt;200 OK&lt;/code&gt; and included &lt;code class=&quot;language-text&quot;&gt;via: 1.1 Caddy&lt;/code&gt;. The request had reached Caddy. It was not ending only at Cloudflare edge.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/24a6fe8469c67ba6b56314e96987f18c/c852c/health-evidence-sequence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 44.11764705882353%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAIAAAC9o5sfAAAACXBIWXMAAAsTAAALEwEAmpwYAAABVElEQVR42m2RW2sbMRSE8///UfoUSKgDpU3oa6A1TmxLq11pdb+cixJ5ndCHDkJIBz5pmLnpvQeHRNw/pee637sYsDXa/7Xnc2TuhF2KKkVh7mqqp2OG1m9676+vb1pra63WZl1XpfSsLFFn5hRbybg9WjLVQr33VilFZL7Ak1RSSiHE6aKzOCs1MzMRItCXKULmwXbmjjCGAw4+AgAgfEkK5Zzz3hmzxhAbtFJKye0/8Hb6V7UA8xg665dZhxBDCGqavQ/ruqaYoOEVbhWIkIetsRNBiqnWDFARN9vjR+d8CKmUEmM2xn7C6QXiT0jPmJ4gPVF5NtNuFg+LfFjVo552cf3B9bdTd36+beE+22+Q/1zhmukSxXWVXM0SWgNENDp4l5iHyWCFOu68+aVO3+1yuKatZw+AWxLjqtvhEFJCaHx8C9OUt56VwmUZDRlDUsJHz+9ecQZHOsiJQgAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;A sequence diagram using the health endpoint to verify origin reachability&apos; title=&apos;&apos; src=&apos;/static/24a6fe8469c67ba6b56314e96987f18c/ca1dc/health-evidence-sequence.png&apos; srcset=&apos;/static/24a6fe8469c67ba6b56314e96987f18c/e7570/health-evidence-sequence.png 170w,
/static/24a6fe8469c67ba6b56314e96987f18c/f46e7/health-evidence-sequence.png 340w,
/static/24a6fe8469c67ba6b56314e96987f18c/ca1dc/health-evidence-sequence.png 680w,
/static/24a6fe8469c67ba6b56314e96987f18c/c852c/health-evidence-sequence.png 784w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;A sequence diagram using the health endpoint to verify origin reachability&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The root path looked different:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;curl -I https://stage-api.example.com/

HTTP/2 404
content-type: application/json
via: 1.1 Caddy&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That was not a redirect loop either. It was a normal JSON &lt;code class=&quot;language-text&quot;&gt;404&lt;/code&gt; because the API did not expose &lt;code class=&quot;language-text&quot;&gt;/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Another signal was a &lt;code class=&quot;language-text&quot;&gt;308 Permanent Redirect&lt;/code&gt; on &lt;code class=&quot;language-text&quot;&gt;https://stage-api.example.com/health&lt;/code&gt; during one stage of testing. I treated that not as a TLS failure but as an HTTP redirect caused by a mismatch between Tunnel&apos;s origin HTTP boundary and Caddy&apos;s scheme or host handling.&lt;/p&gt;
&lt;p&gt;There was also a &lt;code class=&quot;language-text&quot;&gt;Connection reset by peer&lt;/code&gt; when hitting &lt;code class=&quot;language-text&quot;&gt;localhost:80&lt;/code&gt; in some local checks. Seeing &lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt; there can be misleading. &lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt; only bridges the host port to the container port. The real question is whether Caddy is actually listening on &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt; behind it.&lt;/p&gt;
&lt;p&gt;The last cluster of evidence came from CORS:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;http&quot;&gt;&lt;pre class=&quot;language-http&quot;&gt;&lt;code class=&quot;language-http&quot;&gt;&lt;span class=&quot;token header&quot;&gt;&lt;span class=&quot;token header-name keyword&quot;&gt;Access-Control-Allow-Origin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token header-value&quot;&gt;{request.header.Origin}&lt;/span&gt;&lt;/span&gt;
Access-Control-Allow-Headers:&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The first line showed that a Caddy placeholder was leaking as a literal string instead of being substituted. The second line meant the browser had no usable allowed-header list during preflight.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/13e545fe811fe85f8bc06d8134a81331/c852c/cors-preflight-sequence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 69.41176470588235%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB40lEQVR42l1T2W7cMAzc//+7pGmDoE1itOtrfeqkRPEoZG9SpHwQpCFnRI6gi6qCLwlYjxDWrg1NY6Ln9uqaxsCRKqh9n8Yh5ax9B32XiPSiqsbYaZqttcMwrOu6Li6GwqIxUgxFTllRiJyA5cDh2FRyjGB2i5hDCIh53/Zpmrx3B4iIOedc14SnEJGcm0vOHBwyqUiVV1VEKplyzl03vL6+b+tujDPGGhOo1LKShamWXpiESKiISIVEBJGm29w07+Nww1xqy4coxHweCWv9nXwbp67r+SOosLXeWhN8JDoQomrNbiBCJZcPsrB6G63xKipU3T5zCdK2mC84CtG97X9k5nvbZzDJuu5te12XvWA1hw5S8JAz1mf7vFlVvQ/7bksp27ZVZxNa452z3kXmu6KqWusA0leyaIIUfKjDFlTlfduXeYkxGGNjiEQlxkCEBYlZ/ptZmPVw5B6n/8f7J+dAREPMxGr2ao3zLob0QRbFZKJrMLXgf9vtzaxv3jTb8rO/Po3t9235hdAy9t68Brcwyzwvzvr7zCUtGJ4FXwo8B/M09w9z/+i2p2V8mIdHu34r8FzgxW8/IOxMGgPHwMKnYQ4h0ufHGIZ0/RMTyDik6xVSOufUcSy3W8as4wDjUD/GX04cKuPzKb8PAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;A sequence diagram showing the CORS preflight failure at the Caddy boundary&apos; title=&apos;&apos; src=&apos;/static/13e545fe811fe85f8bc06d8134a81331/ca1dc/cors-preflight-sequence.png&apos; srcset=&apos;/static/13e545fe811fe85f8bc06d8134a81331/e7570/cors-preflight-sequence.png 170w,
/static/13e545fe811fe85f8bc06d8134a81331/f46e7/cors-preflight-sequence.png 340w,
/static/13e545fe811fe85f8bc06d8134a81331/ca1dc/cors-preflight-sequence.png 680w,
/static/13e545fe811fe85f8bc06d8134a81331/c852c/cors-preflight-sequence.png 784w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;A sequence diagram showing the CORS preflight failure at the Caddy boundary&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;What-This-Was-Not&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-This-Was-Not&quot; aria-label=&quot;What This Was Not permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What This Was Not&lt;/h2&gt;
&lt;p&gt;This was not a generic &quot;network is broken&quot; problem.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DNS and Cloudflare edge reachability were working.&lt;/li&gt;
&lt;li&gt;TCP connectivity was working.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;/health&lt;/code&gt; could pass through Caddy to FastAPI.&lt;/li&gt;
&lt;li&gt;The main issue was not a certificate-validation failure.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So the accurate summary was narrower: this was a layer-7 failure around reverse-proxy and gateway behavior.&lt;/p&gt;
&lt;p&gt;The three actual breakpoints were:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;HTTP redirect semantics: who enforces HTTPS&lt;/li&gt;
&lt;li&gt;Host-based routing: which host Caddy thinks it is serving&lt;/li&gt;
&lt;li&gt;CORS preflight behavior: whether the browser receives the headers it needs from &lt;code class=&quot;language-text&quot;&gt;OPTIONS&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;How-I-Fixed-It&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Fixed-It&quot; aria-label=&quot;How I Fixed It permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Fixed It&lt;/h2&gt;
&lt;p&gt;First, I cleaned up the Cloudflare Tunnel routes explicitly.&lt;/p&gt;
&lt;p&gt;In the broken configuration, a wildcard route could absorb the stage host unintentionally. If one Tunnel application route claims every subdomain, it becomes easy for a host to land on the wrong origin service.&lt;/p&gt;
&lt;p&gt;The target shape I wanted was:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;stage-api.example.com -&gt; http://localhost:80
ssh.example.com       -&gt; ssh://localhost:22
static asset domain   -&gt; not routed through this Tunnel application&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Second, I made Caddy&apos;s origin HTTP entrypoint explicit:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;{
  auto_https off
}

:80 {
  @stage host stage-api.example.com

  handle @stage {
    reverse_proxy app-api-1:8000
  }

  respond 404
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Behind Tunnel, Cloudflare already owns the visitor-facing HTTPS boundary. Letting origin Caddy clearly accept HTTP on &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt; made the model much simpler. The important point was not to hope &quot;Caddy will figure it out,&quot; but to declare &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt; directly.&lt;/p&gt;
&lt;p&gt;Third, I made the local Host-based test match the real Host-based routing logic:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Host: stage-api.example.com&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  http://127.0.0.1/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If Caddy routes by &lt;code class=&quot;language-text&quot;&gt;Host&lt;/code&gt;, then &lt;code class=&quot;language-text&quot;&gt;curl http://127.0.0.1/health&lt;/code&gt; is not the same request. Its host is &lt;code class=&quot;language-text&quot;&gt;127.0.0.1&lt;/code&gt;, not the stage domain.&lt;/p&gt;
&lt;p&gt;Fourth, I debugged CORS starting from &lt;code class=&quot;language-text&quot;&gt;OPTIONS&lt;/code&gt;, not from a failing GET:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-X&lt;/span&gt; OPTIONS &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Origin: http://127.0.0.1:5500&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Access-Control-Request-Method: GET&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Access-Control-Request-Headers: authorization,content-type&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  https://stage-api.example.com/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For development, an explicit header list was easier to reason about:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;handle @options {
  header Access-Control-Allow-Origin &quot;{http.request.header.Origin}&quot;
  header Access-Control-Allow-Credentials &quot;true&quot;
  header Access-Control-Allow-Methods &quot;GET, POST, PUT, PATCH, DELETE, OPTIONS&quot;
  header Access-Control-Allow-Headers &quot;Authorization, Content-Type, Accept, Origin, X-Requested-With&quot;
  header Access-Control-Max-Age &quot;86400&quot;
  respond 204
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Reflecting headers from the request dynamically can fail if &lt;code class=&quot;language-text&quot;&gt;Access-Control-Request-Headers&lt;/code&gt; is absent or gets lost across a proxy boundary. For the development stage, the fixed list was more explicit and easier to verify.&lt;/p&gt;
&lt;p&gt;That said, reflecting &lt;code class=&quot;language-text&quot;&gt;Origin&lt;/code&gt; together with &lt;code class=&quot;language-text&quot;&gt;Credentials=true&lt;/code&gt; is not a good production default. If the API uses cookies or authenticated browser calls, production should move to an allowlist.&lt;/p&gt;
&lt;h2 id=&quot;Verification&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Verification&quot; aria-label=&quot;Verification permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Verification&lt;/h2&gt;
&lt;p&gt;I verified this layer by layer instead of by asking &quot;does it work now?&quot; once.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-I&lt;/span&gt; https://stage-api.example.com/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Here I wanted &lt;code class=&quot;language-text&quot;&gt;200 OK&lt;/code&gt; plus &lt;code class=&quot;language-text&quot;&gt;via: 1.1 Caddy&lt;/code&gt;. Seeing only &lt;code class=&quot;language-text&quot;&gt;server: cloudflare&lt;/code&gt; makes it hard to tell whether the response came from Cloudflare edge or origin.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Host: stage-api.example.com&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  http://127.0.0.1/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This checked whether Docker port mapping and Caddy Host matching were aligned.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-X&lt;/span&gt; OPTIONS &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Origin: http://127.0.0.1:5500&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Access-Control-Request-Method: GET&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Access-Control-Request-Headers: authorization,content-type&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  https://stage-api.example.com/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This checked &lt;code class=&quot;language-text&quot;&gt;Access-Control-Allow-Origin&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Access-Control-Allow-Credentials&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Access-Control-Allow-Methods&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;Access-Control-Allow-Headers&lt;/code&gt; together.&lt;/p&gt;
&lt;p&gt;The verified scope here is limited. I am not claiming that every browser-side CORS issue disappeared forever. The verified result is that the stage API request path reaches Caddy and FastAPI through Cloudflare, and that a representative preflight request now receives the headers the browser needs.&lt;/p&gt;
&lt;h2 id=&quot;What-I-Learned&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-I-Learned&quot; aria-label=&quot;What I Learned permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What I Learned&lt;/h2&gt;
&lt;p&gt;One reason we learn the network stack in layers is not to memorize labels. It is to stop wasting time on the wrong layer.&lt;/p&gt;
&lt;p&gt;I began by looking at Cloudflare&apos;s SSL/TLS mode. That was a valid check, but it was not enough. In a Tunnel setup, TLS mode alone does not explain the whole origin path.&lt;/p&gt;
&lt;p&gt;The good decision in this incident was not &quot;I identified it as L7 immediately.&quot; The better decision was to let the TLS-looking symptoms stay hypotheses, verify that layer 3/4 and layer 6 were mostly alive, and then return to layer 7 with concrete signals: &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Host&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Origin&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;Access-Control-*&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Backend developers spend most of their time in layer 7. But production debugging sometimes requires briefly dropping to lower layers so that, when you come back up, you know whether the HTTP status is application behavior or proxy behavior.&lt;/p&gt;
&lt;p&gt;The decision rule changed like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When I see &lt;code class=&quot;language-text&quot;&gt;ERR_TOO_MANY_REDIRECTS&lt;/code&gt;, I inspect the &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt; header first.&lt;/li&gt;
&lt;li&gt;On Cloudflare responses, I look for origin-hop signals such as &lt;code class=&quot;language-text&quot;&gt;via: 1.1 Caddy&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If there is Host-based routing, I include the Host header in local tests.&lt;/li&gt;
&lt;li&gt;I reproduce CORS failures from &lt;code class=&quot;language-text&quot;&gt;OPTIONS&lt;/code&gt; preflight first, not from the final GET.&lt;/li&gt;
&lt;li&gt;If &lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt; appears, I treat it only as evidence of Docker port mapping, not proof that the app behind it is actually listening.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Next-Time&quot; aria-label=&quot;Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Next Time&lt;/h2&gt;
&lt;p&gt;When an API behind Cloudflare Tunnel behaves strangely, I will not name it &quot;certificate trouble&quot; or &quot;a CORS bug&quot; immediately. I will walk the layers in order:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;1. Layer 3/4: Does the request reach the domain and port?
2. Layer 6: Is TLS negotiation or certificate validation failing?
3. Layer 7: Is the Tunnel route sending traffic to the intended service?
4. Layer 7: Does the Caddy Host matcher agree with the request Host?
5. Layer 7: Does the request reach FastAPI?
6. Layer 7: Does the browser receive a valid preflight response?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In cases where the network path is fine but only the browser fails, I still need to read the HTTP evidence closely: status, &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Host&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Origin&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;Access-Control-*&lt;/code&gt;. But only after I have ruled out lower-layer failure.&lt;/p&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/&quot;&gt;Cloudflare Docs: SSL/TLS encryption modes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/tunnel/advanced/origin-parameters/&quot;&gt;Cloudflare Docs: Origin parameters for Cloudflare Tunnel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/ssl/troubleshooting/too-many-redirects/&quot;&gt;Cloudflare Docs: ERR_TOO_MANY_REDIRECTS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/matchers&quot;&gt;Caddy Docs: Request matchers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/directives/reverse_proxy&quot;&gt;Caddy Docs: reverse_proxy directive&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Cloudflare Tunnel 장애에서 배운 계층화 디버깅]]></title><description><![CDATA[백엔드 개발자는 보통 7계층에서 산다. API path, status code, request header, CORS를 본다. 나도 Cloudflare로 stage API를 붙였을 때 브라우저의 를 보고 곧바로 redirect와 CORS…]]></description><link>https://sewon.dev/cloudflare-tunnel-caddy-cors-l7-debugging/</link><guid isPermaLink="false">https://sewon.dev/cloudflare-tunnel-caddy-cors-l7-debugging/</guid><pubDate>Wed, 03 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c1c878b5c7885bda90b19287e3d6dbb2/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAAC1klEQVR42k2T3WscVRjG9+/wol4oBRMpIiqFVBChFnrRf8ErIb2Q1iJobIpVRPyqodgbG2up3nmhF4XSbNZso/ixaa2Y3eymM7OzszvJZHdm9mNm53Nn5vxkZ9X4wu+ch/NyHt7n4i0EUUp730PWHDqGR9vwUHWXujJE1lyUzlSPaOke2p6H4LD+r/+tQpJk9GwPw/Swhz4jJ6LX9/O3oRNgDnwMc4znTwjClDQTJKkgywRCzHSSZoh/7AuZgO8qNiulPr80AxRjxLVSjy9/HrHf91mvznq3qwHm0GX1Xpdrm2OqewFbss2VYo9bFQ8nTGaGQsB91ePutovSixm4MaUdl41HIW6Y0TiIuVMLeKgnBHHK5q7H+o5Hz8k46MeU6wFbrYRwks0Mp8fQCfOIXdsjTrI8CmSk4y6ZtwehAXEPEduQOKQiRQ/7dII+RmxjRDbdiUuaZRSmX2tti8quwQPpgL+0PqrlI7IYp30XU/oeU/qBQWcNzywRW1v0ojFXtQ1WmiVW1A2uamW+te/jptEscn1/yB+qyZ8ti4eajTaISOMAs11Gb66hK0X2m0UsvUhkP6Dj9FltbXJD/SnnunKPW/pveFlMASFotbvUGho7u20aUoeD7ojRsI9rlPHNMr41ZTOfMDIr6O6A1d6v3LQqfG1VuGH+zjfWFm4aTg0zYknCq9YYT9neJlZVRDZBRHVIajCZISbbEMmMkpC1WGY9aeYUkyY/Rk38dDKNLOgoKlK1jlSrI1V3kGsN5KaGJClIj2QkSUaWlRxFUVFaHXYV9T8achOl1SZJUwrJJOHMq4s8+eJJjp06w9MLp5l/4RTzz7/C3HMnOfrsyzxx7CWOzJ045KkFjszNeHz+BI8dPc4zC6fpmtZ0U1I+/+Ir3rr0EZfev8LF9z7jncufsnT5k/x++92P896FpQ84e36ZxXMXWTx/yNk3lnnt9SXeXP6QkePyNzW/OH6mSLbYAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Cloudflare Tunnel 뒤에서 HTTP 의미론이 충돌한 지점을 정리한 도식&apos; title=&apos;&apos; src=&apos;/static/c1c878b5c7885bda90b19287e3d6dbb2/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/c1c878b5c7885bda90b19287e3d6dbb2/e7570/situation-diagram.png 170w,
/static/c1c878b5c7885bda90b19287e3d6dbb2/f46e7/situation-diagram.png 340w,
/static/c1c878b5c7885bda90b19287e3d6dbb2/ca1dc/situation-diagram.png 680w,
/static/c1c878b5c7885bda90b19287e3d6dbb2/02d09/situation-diagram.png 1020w,
/static/c1c878b5c7885bda90b19287e3d6dbb2/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Cloudflare Tunnel 뒤에서 HTTP 의미론이 충돌한 지점을 정리한 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;백엔드 개발자는 보통 7계층에서 산다. API path, status code, request header, CORS를 본다. 나도 Cloudflare로 stage API를 붙였을 때 브라우저의 &lt;code class=&quot;language-text&quot;&gt;ERR_TOO_MANY_REDIRECTS&lt;/code&gt;를 보고 곧바로 redirect와 CORS를 의심했다.&lt;/p&gt;
&lt;p&gt;그런데 Cloudflare Tunnel이 끼면 한 계층에서 바로 이름 붙일 수 없다. TLS 문제처럼 보일 수도 있고, origin 연결 문제처럼 보일 수도 있고, 실제로는 reverse proxy가 HTTP 요청을 해석하는 방식이 문제일 수도 있다. 이번에 배운 것은 &quot;이건 L7이다&quot;를 빨리 맞히는 법이 아니라 L3/L4 연결과 L6 TLS를 지우고 다시 L7로 돌아오는 순서였다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: Cloudflare Tunnel 뒤의 stage API에서 TLS 문제처럼 보이는 redirect loop, &lt;code class=&quot;language-text&quot;&gt;308&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Connection reset&lt;/code&gt;, CORS 실패가 한 덩어리처럼 보였다.&lt;/li&gt;
&lt;li&gt;접근: 백엔드가 익숙한 L7에서 바로 결론내리지 않고 DNS/연결, TLS, reverse proxy, application header를 차례로 나눴다.&lt;/li&gt;
&lt;li&gt;판단: L3/L4와 L6은 주원인이 아니었고, 결정적인 신호는 &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;via: 1.1 Caddy&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Host&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;OPTIONS preflight&lt;/code&gt;처럼 다시 L7에 있었다.&lt;/li&gt;
&lt;li&gt;해결: Tunnel route, Caddy &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt; listen, Host 기반 라우팅, CORS preflight 응답을 각각 분리해서 고쳤다.&lt;/li&gt;
&lt;li&gt;배운 점: 계층화 디버깅은 정답 계층을 맞히는 기술이 아니라, 틀린 계층을 빨리 지우고 올바른 증거로 돌아오는 기술이다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;구조는 대략 이랬다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Browser
  -&gt; Cloudflare Edge
  -&gt; Cloudflare Tunnel
  -&gt; Ubuntu origin
  -&gt; Docker port 80
  -&gt; Caddy
  -&gt; FastAPI&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Cloudflare 대시보드의 SSL/TLS 모드는 &lt;code class=&quot;language-text&quot;&gt;Full (strict)&lt;/code&gt;였다. Cloudflare 공식 문서 기준으로 SSL/TLS encryption mode는 방문자와 Cloudflare 사이의 연결, Cloudflare와 origin 사이의 연결을 따로 다룬다. &lt;code class=&quot;language-text&quot;&gt;Full (strict)&lt;/code&gt;는 origin certificate까지 검증하는 모드다.&lt;/p&gt;
&lt;p&gt;그래서 &quot;Flexible이라서 origin HTTP와 HTTPS redirect가 루프를 만든다&quot;는 흔한 설명만으로는 부족했다. Tunnel을 쓰는 상황에서는 Cloudflare Edge가 방문자 쪽 HTTPS를 맡고, &lt;code class=&quot;language-text&quot;&gt;cloudflared&lt;/code&gt;가 origin으로 어떻게 넘기는지, Caddy가 그 요청을 어떤 Host와 scheme으로 해석하는지를 같이 봐야 했다.&lt;/p&gt;
&lt;h2 id=&quot;왜-계층으로-나눠야-했나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EA%B3%84%EC%B8%B5%EC%9C%BC%EB%A1%9C-%EB%82%98%EB%88%A0%EC%95%BC-%ED%96%88%EB%82%98&quot; aria-label=&quot;왜 계층으로 나눠야 했나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 계층으로 나눠야 했나&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;ERR_TOO_MANY_REDIRECTS&lt;/code&gt;라는 브라우저 메시지만 보면 문제 이름이 이미 정해진 것처럼 느껴진다. 하지만 그 메시지는 브라우저가 마지막에 본 7계층 증상일 뿐이다.&lt;/p&gt;
&lt;p&gt;먼저 물어야 할 것은 달랐다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Layer 3/4: 도메인과 포트까지 도달하는가?
Layer 6: TLS 협상 또는 인증서 검증에서 막히는가?
Layer 7: HTTP status, Location, Host, Origin header가 의도와 맞는가?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 순서로 보면 &quot;Cloudflare 문제&quot;, &quot;CORS 문제&quot;, &quot;서버 문제&quot; 같은 큰 이름이 작아진다. 이번 케이스에서도 하위 계층 연결은 대체로 살아 있었고, 실제로 어긋난 것은 HTTP redirect와 header 해석이었다.&lt;/p&gt;
&lt;h2 id=&quot;처음에는-TLS-문제로-봤다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C%EC%97%90%EB%8A%94-TLS-%EB%AC%B8%EC%A0%9C%EB%A1%9C-%EB%B4%A4%EB%8B%A4&quot; aria-label=&quot;처음에는 TLS 문제로 봤다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음에는 TLS 문제로 봤다&lt;/h2&gt;
&lt;p&gt;첫 가설은 SSL/TLS와 HTTPS 강제 설정 충돌이었다. 브라우저는 redirect loop라고 말했고, Cloudflare 대시보드에는 SSL/TLS 모드가 있었다. 그래서 처음에는 Layer 6 근처를 잡고 있었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Cloudflare: HTTPS로 받음
Origin: HTTP로 들어왔다고 봄
Caddy 또는 app: HTTPS로 redirect
Cloudflare: 다시 origin으로 전달&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 경로가 맞다면 &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt; 헤더가 같은 URL을 반복하거나, HTTP와 HTTPS 사이를 계속 왕복해야 한다. 그래서 먼저 &lt;code class=&quot;language-text&quot;&gt;curl -I&lt;/code&gt;로 redirect 방향을 확인했다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/a8319deb56ba0c49a18191edee1972a4/c852c/tls-hypothesis-sequence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 42.35294117647059%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAICAIAAAB2/0i6AAAACXBIWXMAAAsTAAALEwEAmpwYAAABOElEQVR42k2RSW7DMAxFc//T9BJF0U2nVRI3A5rRki1bMy2JZGE7LqrVh4hPPn6umFn3RtQNDFEp28hoTCZiIu46EHWIsTBzCNRIiJHSwI0EYwoRr6ZCaGQLANba4+EYguPllUSzIKI/XRLRJEczIZWMc+H0c5ZCeGeds9baBGUxc044e1JCxMWMyHnp2ikzDCXEHGL2Hq7Xputd33sptXdpIsCUyjx6NWH00a4L7DLsvN46vW7rD3F7U+KrvryD3+b4DW5zv3wijiD5PzYWXWJFac/lAK6KbhvtJpg1+CraCqf/MlRGPhn1bNSrbl5y0g/zAAxhbOUsnk+xbR9pS5kuZ/Bu3M8YPOyurbxpdd9/7xvhHmlb46wZEw4+i9p3CgiJEFUbpfAhZGYKHjuVx1Ml7lSxZiT/BY6azD1FU/O4AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;TLS redirect loop 가설을 검증하는 sequence diagram&apos; title=&apos;&apos; src=&apos;/static/a8319deb56ba0c49a18191edee1972a4/ca1dc/tls-hypothesis-sequence.png&apos; srcset=&apos;/static/a8319deb56ba0c49a18191edee1972a4/e7570/tls-hypothesis-sequence.png 170w,
/static/a8319deb56ba0c49a18191edee1972a4/f46e7/tls-hypothesis-sequence.png 340w,
/static/a8319deb56ba0c49a18191edee1972a4/ca1dc/tls-hypothesis-sequence.png 680w,
/static/a8319deb56ba0c49a18191edee1972a4/c852c/tls-hypothesis-sequence.png 784w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;TLS redirect loop 가설을 검증하는 sequence diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;확인한-증거&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%95%EC%9D%B8%ED%95%9C-%EC%A6%9D%EA%B1%B0&quot; aria-label=&quot;확인한 증거 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;확인한 증거&lt;/h2&gt;
&lt;p&gt;첫 번째 단서는 &lt;code class=&quot;language-text&quot;&gt;/health&lt;/code&gt;였다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;GET http://stage-api.example.com/health
-&gt; 307 Internal Redirect
-&gt; Location: https://stage-api.example.com/health

GET https://stage-api.example.com/health
-&gt; 200 OK
-&gt; via: 1.1 Caddy&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 결과만 보면 HTTP에서 HTTPS로 올라가는 redirect는 정상이다. 더 중요한 신호는 &lt;code class=&quot;language-text&quot;&gt;https://.../health&lt;/code&gt;가 &lt;code class=&quot;language-text&quot;&gt;200 OK&lt;/code&gt;였고 응답에 &lt;code class=&quot;language-text&quot;&gt;via: 1.1 Caddy&lt;/code&gt;가 있었다는 점이다. 이 요청은 Cloudflare Edge에서 끝난 것이 아니라 Caddy까지 도달했다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/24a6fe8469c67ba6b56314e96987f18c/c852c/health-evidence-sequence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 44.11764705882353%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAIAAAC9o5sfAAAACXBIWXMAAAsTAAALEwEAmpwYAAABVElEQVR42m2RW2sbMRSE8///UfoUSKgDpU3oa6A1TmxLq11pdb+cixJ5ndCHDkJIBz5pmLnpvQeHRNw/pee637sYsDXa/7Xnc2TuhF2KKkVh7mqqp2OG1m9676+vb1pra63WZl1XpfSsLFFn5hRbybg9WjLVQr33VilFZL7Ak1RSSiHE6aKzOCs1MzMRItCXKULmwXbmjjCGAw4+AgAgfEkK5Zzz3hmzxhAbtFJKye0/8Hb6V7UA8xg665dZhxBDCGqavQ/ruqaYoOEVbhWIkIetsRNBiqnWDFARN9vjR+d8CKmUEmM2xn7C6QXiT0jPmJ4gPVF5NtNuFg+LfFjVo552cf3B9bdTd36+beE+22+Q/1zhmukSxXWVXM0SWgNENDp4l5iHyWCFOu68+aVO3+1yuKatZw+AWxLjqtvhEFJCaHx8C9OUt56VwmUZDRlDUsJHz+9ecQZHOsiJQgAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;health endpoint로 하위 계층과 origin hop을 확인하는 sequence diagram&apos; title=&apos;&apos; src=&apos;/static/24a6fe8469c67ba6b56314e96987f18c/ca1dc/health-evidence-sequence.png&apos; srcset=&apos;/static/24a6fe8469c67ba6b56314e96987f18c/e7570/health-evidence-sequence.png 170w,
/static/24a6fe8469c67ba6b56314e96987f18c/f46e7/health-evidence-sequence.png 340w,
/static/24a6fe8469c67ba6b56314e96987f18c/ca1dc/health-evidence-sequence.png 680w,
/static/24a6fe8469c67ba6b56314e96987f18c/c852c/health-evidence-sequence.png 784w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;health endpoint로 하위 계층과 origin hop을 확인하는 sequence diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;반대로 루트 경로는 이랬다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;curl -I https://stage-api.example.com/

HTTP/2 404
content-type: application/json
via: 1.1 Caddy&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이것도 redirect loop가 아니었다. API 서버가 &lt;code class=&quot;language-text&quot;&gt;/&lt;/code&gt;를 열어두지 않았기 때문에 JSON &lt;code class=&quot;language-text&quot;&gt;404&lt;/code&gt;가 내려온 것이다. 이 시점에 &quot;도메인 전체가 무한 redirect한다&quot;는 가설은 약해졌다.&lt;/p&gt;
&lt;p&gt;다음 증상은 더 구체적이었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;GET https://stage-api.example.com/health
-&gt; 308 Permanent Redirect&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 &lt;code class=&quot;language-text&quot;&gt;308&lt;/code&gt;은 TLS 실패가 아니라 Caddy의 자동 HTTPS/Host 처리와 Tunnel origin HTTP 경계가 맞지 않을 때 나타난 HTTP redirect 신호로 봤다. Layer 6에서 인증서가 깨진 것이 아니라 Layer 7에서 &quot;이 요청을 어떤 scheme/host로 해석할 것인가&quot;가 흔들린 것이다.&lt;/p&gt;
&lt;p&gt;그리고 어떤 로컬 테스트에서는 &lt;code class=&quot;language-text&quot;&gt;localhost:80&lt;/code&gt; 요청이 &lt;code class=&quot;language-text&quot;&gt;Connection reset by peer&lt;/code&gt;를 냈다. 여기서 &lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt;가 보였지만, &lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt;는 웹 서버가 아니라 Docker의 host port를 container port로 넘기는 중계 프로세스다. 진짜 질문은 &lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt; 뒤에서 Caddy가 실제로 &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt;을 듣고 있느냐였다.&lt;/p&gt;
&lt;p&gt;마지막으로 CORS 응답에는 이런 문제가 있었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;http&quot;&gt;&lt;pre class=&quot;language-http&quot;&gt;&lt;code class=&quot;language-http&quot;&gt;&lt;span class=&quot;token header&quot;&gt;&lt;span class=&quot;token header-name keyword&quot;&gt;Access-Control-Allow-Origin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token header-value&quot;&gt;{request.header.Origin}&lt;/span&gt;&lt;/span&gt;
Access-Control-Allow-Headers:&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;첫 줄은 Caddy placeholder가 치환되지 않고 문자열 그대로 나간 상태였다. 두 번째 줄은 preflight에서 브라우저가 허용 헤더를 확인할 수 없게 만들었다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/13e545fe811fe85f8bc06d8134a81331/c852c/cors-preflight-sequence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 69.41176470588235%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAIAAACgpqunAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB40lEQVR42l1T2W7cMAzc//+7pGmDoE1itOtrfeqkRPEoZG9SpHwQpCFnRI6gi6qCLwlYjxDWrg1NY6Ln9uqaxsCRKqh9n8Yh5ax9B32XiPSiqsbYaZqttcMwrOu6Li6GwqIxUgxFTllRiJyA5cDh2FRyjGB2i5hDCIh53/Zpmrx3B4iIOedc14SnEJGcm0vOHBwyqUiVV1VEKplyzl03vL6+b+tujDPGGhOo1LKShamWXpiESKiISIVEBJGm29w07+Nww1xqy4coxHweCWv9nXwbp67r+SOosLXeWhN8JDoQomrNbiBCJZcPsrB6G63xKipU3T5zCdK2mC84CtG97X9k5nvbZzDJuu5te12XvWA1hw5S8JAz1mf7vFlVvQ/7bksp27ZVZxNa452z3kXmu6KqWusA0leyaIIUfKjDFlTlfduXeYkxGGNjiEQlxkCEBYlZ/ptZmPVw5B6n/8f7J+dAREPMxGr2ao3zLob0QRbFZKJrMLXgf9vtzaxv3jTb8rO/Po3t9235hdAy9t68Brcwyzwvzvr7zCUtGJ4FXwo8B/M09w9z/+i2p2V8mIdHu34r8FzgxW8/IOxMGgPHwMKnYQ4h0ufHGIZ0/RMTyDik6xVSOufUcSy3W8as4wDjUD/GX04cKuPzKb8PAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;CORS preflight가 Caddy 경계에서 실패하는 sequence diagram&apos; title=&apos;&apos; src=&apos;/static/13e545fe811fe85f8bc06d8134a81331/ca1dc/cors-preflight-sequence.png&apos; srcset=&apos;/static/13e545fe811fe85f8bc06d8134a81331/e7570/cors-preflight-sequence.png 170w,
/static/13e545fe811fe85f8bc06d8134a81331/f46e7/cors-preflight-sequence.png 340w,
/static/13e545fe811fe85f8bc06d8134a81331/ca1dc/cors-preflight-sequence.png 680w,
/static/13e545fe811fe85f8bc06d8134a81331/c852c/cors-preflight-sequence.png 784w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;CORS preflight가 Caddy 경계에서 실패하는 sequence diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;문제가-아니었던-것&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%A0%9C%EA%B0%80-%EC%95%84%EB%8B%88%EC%97%88%EB%8D%98-%EA%B2%83&quot; aria-label=&quot;문제가 아니었던 것 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문제가 아니었던 것&lt;/h2&gt;
&lt;p&gt;이 문제는 네트워크가 끊긴 것이 아니었다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;DNS와 Cloudflare edge 도달은 됐다.&lt;/li&gt;
&lt;li&gt;TCP 연결도 됐다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;/health&lt;/code&gt;는 Caddy를 거쳐 FastAPI까지 도달했다.&lt;/li&gt;
&lt;li&gt;TLS certificate 오류도 아니었다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;그래서 &quot;네트워크가 이상하다&quot;는 말은 너무 넓었다. 더 정확히는 1-6계층의 전형적인 장애가 아니라, reverse proxy/gateway 경계에서 생긴 7계층 문제였다.&lt;/p&gt;
&lt;p&gt;이번에 깨진 것은 이 세 가지였다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;HTTP redirect semantics: 누가 HTTPS 강제를 맡는가&lt;/li&gt;
&lt;li&gt;Host-based routing: Caddy가 어떤 Host를 기준으로 route를 고르는가&lt;/li&gt;
&lt;li&gt;CORS preflight: 브라우저가 &lt;code class=&quot;language-text&quot;&gt;OPTIONS&lt;/code&gt; 응답 header를 어떻게 해석하는가&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;해결한-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%B4%EA%B2%B0%ED%95%9C-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;해결한 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;해결한 방식&lt;/h2&gt;
&lt;p&gt;첫째, Cloudflare Tunnel route를 명시적으로 정리했다.&lt;/p&gt;
&lt;p&gt;문제 상황에서는 wildcard route가 stage host까지 잡아먹을 수 있었다. Tunnel의 published application routes에서 와일드카드로 모든 서브도메인을 받으면 의도하지 않은 host가 잘못된 service로 들어갈 수 있다.&lt;/p&gt;
&lt;p&gt;정리 기준은 간단했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;stage-api.example.com -&gt; http://localhost:80
ssh.example.com       -&gt; ssh://localhost:22
static asset domain   -&gt; Tunnel route로 넣지 않음&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;둘째, Caddy가 origin HTTP entrypoint를 명시적으로 열게 했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;{
  auto_https off
}

:80 {
  @stage host stage-api.example.com

  handle @stage {
    reverse_proxy app-api-1:8000
  }

  respond 404
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Tunnel 뒤에서는 Cloudflare가 visitor-facing HTTPS를 맡고 origin Caddy는 HTTP &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt;을 받는 구조가 더 단순했다. 여기서 중요한 것은 &quot;Caddy가 알아서 하겠지&quot;가 아니라 &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt;을 명시하는 것이다.&lt;/p&gt;
&lt;p&gt;셋째, Host 기반 테스트를 로컬에서도 같은 조건으로 했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Host: stage-api.example.com&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  http://127.0.0.1/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Caddy가 Host matcher로 route를 고르는 구조라면 그냥 &lt;code class=&quot;language-text&quot;&gt;curl http://127.0.0.1/health&lt;/code&gt;는 같은 테스트가 아니다. 그 요청의 Host는 &lt;code class=&quot;language-text&quot;&gt;127.0.0.1&lt;/code&gt;이기 때문이다.&lt;/p&gt;
&lt;p&gt;넷째, CORS는 GET이 아니라 OPTIONS부터 봤다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-X&lt;/span&gt; OPTIONS &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Origin: http://127.0.0.1:5500&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Access-Control-Request-Method: GET&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Access-Control-Request-Headers: authorization,content-type&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  https://stage-api.example.com/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;개발용으로는 아래처럼 명시 리스트를 내려주는 편이 안정적이었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;handle @options {
  header Access-Control-Allow-Origin &quot;{http.request.header.Origin}&quot;
  header Access-Control-Allow-Credentials &quot;true&quot;
  header Access-Control-Allow-Methods &quot;GET, POST, PUT, PATCH, DELETE, OPTIONS&quot;
  header Access-Control-Allow-Headers &quot;Authorization, Content-Type, Accept, Origin, X-Requested-With&quot;
  header Access-Control-Max-Age &quot;86400&quot;
  respond 204
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;Access-Control-Allow-Headers&lt;/code&gt;를 요청 header에서 그대로 반사하는 방식은 요청에 &lt;code class=&quot;language-text&quot;&gt;Access-Control-Request-Headers&lt;/code&gt;가 없거나 프록시 경계에서 비면 빈 응답을 만들 수 있었다. 그래서 개발 단계에서는 고정 리스트가 더 설명 가능했다.&lt;/p&gt;
&lt;p&gt;단, &lt;code class=&quot;language-text&quot;&gt;Origin&lt;/code&gt; 반사와 &lt;code class=&quot;language-text&quot;&gt;Credentials=true&lt;/code&gt;는 운영 기본값으로 두면 위험하다. 쿠키나 인증 정보를 쓰는 API라면 운영에서는 허용 origin allowlist로 좁혀야 한다.&lt;/p&gt;
&lt;h2 id=&quot;검증&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%80%EC%A6%9D&quot; aria-label=&quot;검증 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;검증&lt;/h2&gt;
&lt;p&gt;검증은 한 번에 &quot;이제 된다&quot;가 아니라 계층별로 나눴다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-I&lt;/span&gt; https://stage-api.example.com/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;여기서는 &lt;code class=&quot;language-text&quot;&gt;200 OK&lt;/code&gt;와 &lt;code class=&quot;language-text&quot;&gt;via: 1.1 Caddy&lt;/code&gt;를 봤다. &lt;code class=&quot;language-text&quot;&gt;server: cloudflare&lt;/code&gt;만 보이면 Cloudflare edge 응답인지 origin 응답인지 구분이 어렵다. &lt;code class=&quot;language-text&quot;&gt;via: 1.1 Caddy&lt;/code&gt;는 요청이 Caddy까지 도달했다는 중요한 신호였다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Host: stage-api.example.com&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  http://127.0.0.1/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;여기서는 Docker port mapping과 Caddy Host matcher가 같은 방향을 보고 있는지 확인했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-i&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-X&lt;/span&gt; OPTIONS &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Origin: http://127.0.0.1:5500&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Access-Control-Request-Method: GET&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-H&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Access-Control-Request-Headers: authorization,content-type&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  https://stage-api.example.com/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;여기서는 &lt;code class=&quot;language-text&quot;&gt;Access-Control-Allow-Origin&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Access-Control-Allow-Credentials&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Access-Control-Allow-Methods&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Access-Control-Allow-Headers&lt;/code&gt;를 같이 확인했다.&lt;/p&gt;
&lt;p&gt;검증 범위는 &quot;모든 browser CORS 문제가 사라졌다&quot;가 아니다. 이 글에서 확인한 것은 stage API 요청이 Cloudflare edge를 지나 Caddy와 FastAPI까지 도달하고, 대표 preflight 조건에서 브라우저가 필요한 header를 받을 수 있다는 점이다.&lt;/p&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;우리가 네트워크 과목에서 7계층을 배우는 이유는 각 계층 이름을 외우기 위해서만은 아니었다. 장애가 났을 때 틀린 층을 붙잡고 시간을 쓰지 않기 위해서였다.&lt;/p&gt;
&lt;p&gt;처음에는 Cloudflare 설정 화면의 SSL/TLS 모드부터 봤다. 그건 필요한 확인이었지만 충분하지 않았다. Tunnel 환경에서는 TLS mode만 보고 문제를 끝낼 수 없다.&lt;/p&gt;
&lt;p&gt;이번 문제에서 좋았던 판단은 &quot;L7 문제다&quot;라고 빨리 말한 것이 아니었다. 오히려 L6처럼 보이는 증상을 의심하고, L3/L4 연결과 L6 TLS가 실제로 막힌 지점인지 확인한 뒤, 다시 L7의 &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Host&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Origin&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Access-Control-*&lt;/code&gt; header로 돌아온 것이다.&lt;/p&gt;
&lt;p&gt;백엔드 개발자는 대부분의 시간을 L7에서 보낸다. 하지만 운영 장애에서는 필요하면 L6, L5, L4까지 내려갈 수 있어야 한다. 그래야 다시 L7로 올라왔을 때 지금 보는 status code가 애플리케이션 로직의 결과인지, 프록시 경계가 만든 신호인지 구분할 수 있다.&lt;/p&gt;
&lt;p&gt;이번 문제의 기준은 이렇게 바뀌었다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;ERR_TOO_MANY_REDIRECTS&lt;/code&gt;를 보면 먼저 &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt; 헤더가 어디를 가리키는지 본다.&lt;/li&gt;
&lt;li&gt;Cloudflare 응답에서는 &lt;code class=&quot;language-text&quot;&gt;via: 1.1 Caddy&lt;/code&gt;처럼 origin hop 신호를 찾는다.&lt;/li&gt;
&lt;li&gt;Host matcher가 있으면 로컬 테스트에서도 Host header를 맞춘다.&lt;/li&gt;
&lt;li&gt;CORS는 GET 실패가 아니라 OPTIONS preflight 실패로 먼저 재현한다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt;가 보이면 Docker 포트 매핑이 있다는 뜻이지, 그 뒤의 app이 실제로 listen한다는 뜻은 아니다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;Cloudflare Tunnel 뒤의 API가 이상하게 동작하면 바로 &quot;인증서 문제&quot;나 &quot;CORS 문제&quot;라고 이름 붙이지 않는다. 증상 이름보다 계층을 먼저 본다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;1. Layer 3/4: 도메인과 포트까지 도달하나?
2. Layer 6: TLS 협상 또는 인증서 검증에서 막히나?
3. Layer 7: Tunnel route가 맞는 service로 보내나?
4. Layer 7: Caddy Host matcher가 요청 Host와 맞나?
5. Layer 7: FastAPI까지 도달했나?
6. Layer 7: 브라우저가 preflight 응답을 통과시킬 수 있나?&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 순서로 보면 계층을 오르내리는 기준이 생긴다. 네트워크는 정상인데 브라우저만 실패하는 상황일수록 packet보다 HTTP status, &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Host&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Origin&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Access-Control-*&lt;/code&gt; header를 먼저 읽어야 한다. 다만 그 전에 연결과 TLS가 정말 살아 있는지 지워야 한다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/ssl/origin-configuration/ssl-modes/&quot;&gt;Cloudflare Docs: SSL/TLS encryption modes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/tunnel/advanced/origin-parameters/&quot;&gt;Cloudflare Docs: Origin parameters for Cloudflare Tunnel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/ssl/troubleshooting/too-many-redirects/&quot;&gt;Cloudflare Docs: ERR_TOO_MANY_REDIRECTS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/matchers&quot;&gt;Caddy Docs: Request matchers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/directives/reverse_proxy&quot;&gt;Caddy Docs: reverse_proxy directive&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Running a Home Server as a Runtime-Only Docker Host]]></title><description><![CDATA[The hard part of this home-server setup was not installing Ubuntu or Docker. It was deciding the operational boundaries first. How should…]]></description><link>https://sewon.dev/en/home-server-runtime-docker-caddy-cloudflare-guide/</link><guid isPermaLink="false">https://sewon.dev/en/home-server-runtime-docker-caddy-cloudflare-guide/</guid><pubDate>Wed, 03 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/f77d59d92c3594da0d3d32ccacc20b0c/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACnklEQVR42mXOW0sUYRgH8LkKsbtCoSgsqFALuggqCoQu+gLd9wm68UBq7SKUrktBZSWm5hHzEFrGmsmamqVY7rqeW1fX067uzu6cZ3Z25p3D+z4xF11EDz/+PDcP/4dChs1LBicaaR6xAuIlxIrOwgg6wyNOQE6KSJQN+G8oy8IcLwuczLESx0mipLFclmEdHK9xQjaRVnhJkzOIEGITbGLLsB2EEAoIRmG/Huo3fvvI7oSmoI2gEQmicMBg4zhKZ1q+pbvnhO6AHjlEIWmvJxkYEdaHxTXOUJ1jeq43OvZyd7wxu9Qr88p3f3LKHxsfje+sa4GoeL93u85Heyf0hW1tMrHsXfS92ZxoZ3+mkEwBQFbipXRSSid1kSUE2JTGpRSFUy3NMi07yYiJtBhjVGSBbOrbAnOYldNW1iKYAkIQt4bS85awYmc2TGER0MFWCg0ucB+C3OAvZnRV/bFjGFnN3ozYkU2yFYW9fYgdgK47bwv7X+MbQyo9DpkZLE+DvOZf5ivfx2s+HjzyMXV+7fWsySQYNhBMzC/sz84p4Q0SjWJZpoDYfGyK3vksHPrFA7+aGify2nRYrhmmPSO09wv7dBI1zagSw/OhRTq0lAyG+JVVKxzGikIBECA6gA6g/WXoNggmiCaIBvAGSCYQTABjIMQBBGwLMKYwxs+au+65a8sfPylz1ZdV15dWe8qraytddZWuuiq3p8pdX+mqr3joKXd5y13eCre39IGnxtMgKxnKMMzbd+6euHT93NVbZy+XFBTdPF1448zFklOFN48XXMnNL87JK8rJK8rNL8rNcxzNLz5y7MLJ89cOE7TTPPRprKmlp61z4G3XQEtHX2tnf2tnf3N7b1Pbu1fNXS+aOhr+9byxraWjT1WzfwBUoThMZfFsFgAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;An operations diagram showing SSH access, shared Caddy ingress, and isolated Docker Compose services on a home server&apos; title=&apos;&apos; src=&apos;/static/f77d59d92c3594da0d3d32ccacc20b0c/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/f77d59d92c3594da0d3d32ccacc20b0c/e7570/situation-diagram.png 170w,
/static/f77d59d92c3594da0d3d32ccacc20b0c/f46e7/situation-diagram.png 340w,
/static/f77d59d92c3594da0d3d32ccacc20b0c/ca1dc/situation-diagram.png 680w,
/static/f77d59d92c3594da0d3d32ccacc20b0c/02d09/situation-diagram.png 1020w,
/static/f77d59d92c3594da0d3d32ccacc20b0c/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;An operations diagram showing SSH access, shared Caddy ingress, and isolated Docker Compose services on a home server&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The hard part of this home-server setup was not installing Ubuntu or Docker. It was deciding the operational boundaries first. How should SSH access work? Where should HTTP requests enter? Which Docker networks should each app join? Should the server hold source code or only runtime images? Those decisions mattered more than the package installs.&lt;/p&gt;
&lt;p&gt;This note is a record of the questions that were easy to mix up during setup, and the operating model I would recommend to someone building a first home server now.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: At first, Cloudflare Tunnel, SSH, Termius, Docker, Caddy, and Docker Compose all looked like overlapping tools.&lt;/li&gt;
&lt;li&gt;Decision: I treated the home server as a runtime machine, not a development machine, and separated access boundaries from service boundaries.&lt;/li&gt;
&lt;li&gt;Chosen structure: SSH access is handled through a separate boundary such as Cloudflare Tunnel or Access, while public HTTP traffic enters through a shared Caddy on &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt; and routes to services on a shared Docker &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Lesson: Once you need to run more than one service, a single shared reverse proxy and per-app Compose projects are much easier to operate than opening ports for every app.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;The first things I prepared were a USB installer, Ethernet, and an Ubuntu image. That immediately triggered a pile of questions.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If I use Cloudflare Tunnel, do I still need a public IP or port forwarding?&lt;/li&gt;
&lt;li&gt;Do I really need a wired keyboard and mouse?&lt;/li&gt;
&lt;li&gt;Why should SSH go through Cloudflare?&lt;/li&gt;
&lt;li&gt;Does Termius replace Cloudflare Tunnel?&lt;/li&gt;
&lt;li&gt;Why do Docker docs make me add a GPG key and an apt repository?&lt;/li&gt;
&lt;li&gt;If I run several services, do I need a separate Caddy per service?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;The-Principles-I-Picked-First&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Principles-I-Picked-First&quot; aria-label=&quot;The Principles I Picked First permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Principles I Picked First&lt;/h2&gt;
&lt;p&gt;If you want to run a home server like a server, you need clear layers.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Access layer: SSH, Cloudflare Tunnel, physical console
Ingress layer: shared Caddy
Service layer: one docker compose project per app
Data layer: volumes, data, secrets, databases
Deploy layer: GHCR image pull, docker compose up&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Once you split it that way, &quot;something is broken&quot; becomes a smaller question. Is SSH broken? Is Cloudflare failing to reach origin? Is Caddy missing the Host match? Is Docker DNS unable to resolve the service name? Is the app health check failing? Each layer has its own failure mode.&lt;/p&gt;
&lt;h2 id=&quot;Hardware-and-First-Boot&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Hardware-and-First-Boot&quot; aria-label=&quot;Hardware and First Boot permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Hardware and First Boot&lt;/h2&gt;
&lt;p&gt;Using Cloudflare Tunnel does not remove the need for a physical console. Tunnel and SSH only help after the server has booted correctly and joined the network.&lt;/p&gt;
&lt;p&gt;For the first setup, I still needed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a USB installer&lt;/li&gt;
&lt;li&gt;a wired keyboard and mouse&lt;/li&gt;
&lt;li&gt;an HDMI monitor or TV&lt;/li&gt;
&lt;li&gt;Ethernet&lt;/li&gt;
&lt;li&gt;optionally, a UPS&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the server does not boot or loses network, neither SSH nor Tunnel will help. That is when you need BIOS access, the local console, and boot logs.&lt;/p&gt;
&lt;h2 id=&quot;The-First-Commands-After-Ubuntu-Install&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-First-Commands-After-Ubuntu-Install&quot; aria-label=&quot;The First Commands After Ubuntu Install permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The First Commands After Ubuntu Install&lt;/h2&gt;
&lt;p&gt;During the Ubuntu install, it is worth enabling the OpenSSH server. After the install finishes, check the LAN IP from the physical console, then move to the laptop you actually work from.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ip&lt;/span&gt; a
&lt;span class=&quot;token function&quot;&gt;ssh&lt;/span&gt; user@192.168.x.x&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The next step is base packages and Docker. I followed the official Docker apt repository flow instead of ad hoc install scripts.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; update
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-y&lt;/span&gt; ca-certificates &lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; 0755 &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; /etc/apt/keyrings
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-fsSL&lt;/span&gt; https://download.docker.com/linux/ubuntu/gpg &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-o&lt;/span&gt; /etc/apt/keyrings/docker.asc
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;chmod&lt;/span&gt; a+r /etc/apt/keyrings/docker.asc

&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;tee&lt;/span&gt; /etc/apt/sources.list.d/docker.sources &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: &lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt; /etc/os-release &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;${UBUNTU_CODENAME&lt;span class=&quot;token operator&quot;&gt;:-&lt;/span&gt;$VERSION_CODENAME}&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
Components: stable
Architectures: &lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;dpkg --print-architecture&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
Signed-By: /etc/apt/keyrings/docker.asc
EOF&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; update
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-y&lt;/span&gt; docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;At first the GPG-key step looked like ceremony. It is not. It is the point where apt verifies that the Docker packages on this bare-metal runtime host were signed by Docker.&lt;/p&gt;
&lt;p&gt;Verification is simple:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--version&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose version
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; run &lt;span class=&quot;token parameter variable&quot;&gt;--rm&lt;/span&gt; hello-world&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If you want to use &lt;code class=&quot;language-text&quot;&gt;docker&lt;/code&gt; without &lt;code class=&quot;language-text&quot;&gt;sudo&lt;/code&gt;, you can add your user to the &lt;code class=&quot;language-text&quot;&gt;docker&lt;/code&gt; group:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;usermod&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-aG&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token environment constant&quot;&gt;$USER&lt;/span&gt;&quot;&lt;/span&gt;
newgrp &lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But that is effectively Docker daemon control, so on an operations host it is worth being deliberate about who gets that access.&lt;/p&gt;
&lt;h2 id=&quot;Cloudflare-Tunnel-and-SSH&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Cloudflare-Tunnel-and-SSH&quot; aria-label=&quot;Cloudflare Tunnel and SSH permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Cloudflare Tunnel and SSH&lt;/h2&gt;
&lt;p&gt;One of the first confusing questions was whether Termius makes Cloudflare Tunnel unnecessary. They are not the same kind of tool.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Termius is an SSH client.&lt;/li&gt;
&lt;li&gt;Cloudflare Tunnel and Access define the network path and access policy.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Termius makes &lt;code class=&quot;language-text&quot;&gt;ssh&lt;/code&gt; easier to use. Cloudflare Tunnel changes how the server becomes reachable from outside.&lt;/p&gt;
&lt;p&gt;In Cloudflare&apos;s documented model, Tunnel creates an outbound-only connection from origin to the Cloudflare network. That means the server does not need a directly routable public IP to expose resources through Cloudflare. SSH is also a documented use case, with options such as client-side &lt;code class=&quot;language-text&quot;&gt;cloudflared&lt;/code&gt;, browser-rendered SSH, and Access for Infrastructure.&lt;/p&gt;
&lt;p&gt;The initial flow looked roughly like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;cloudflared tunnel login
cloudflared tunnel create home-server
cloudflared tunnel route dns home-server ssh.example.com
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; cloudflared &lt;span class=&quot;token function&quot;&gt;service&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; systemctl &lt;span class=&quot;token builtin class-name&quot;&gt;enable&lt;/span&gt; cloudflared
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; systemctl start cloudflared&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In operations, I run &lt;code class=&quot;language-text&quot;&gt;cloudflared&lt;/code&gt; as a systemd service:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;cloudflared.service
ExecStart=/usr/bin/cloudflared --no-autoupdate --config /etc/cloudflared/config.yml tunnel run&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;An SSH ingress can look like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;ingress&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;hostname&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ssh.example.com
    &lt;span class=&quot;token key atrule&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ssh&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;//localhost&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;22&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; http_status&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;404&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The important point is that Cloudflare Tunnel does not replace the SSH daemon. The server still runs SSH on &lt;code class=&quot;language-text&quot;&gt;localhost:22&lt;/code&gt; or another internal interface, and Tunnel adds an access boundary in front of it. Your actual exposure then depends on the Cloudflare route, Access policy, and local network rules.&lt;/p&gt;
&lt;p&gt;Also, creating the Tunnel DNS route is not the end of the SSH design. If you use Cloudflare Access, you still need to choose who can connect, how they authenticate, and whether they use a local &lt;code class=&quot;language-text&quot;&gt;cloudflared&lt;/code&gt; client or browser-based SSH.&lt;/p&gt;
&lt;h2 id=&quot;Put-Public-HTTP-Behind-One-Shared-Caddy&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Put-Public-HTTP-Behind-One-Shared-Caddy&quot; aria-label=&quot;Put Public HTTP Behind One Shared Caddy permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Put Public HTTP Behind One Shared Caddy&lt;/h2&gt;
&lt;p&gt;The easiest mistake with multiple services is opening host ports for each app:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;service A -&gt; 8000
service B -&gt; 8001
service C -&gt; 3000
service D -&gt; 5000&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That quickly makes it unclear which ports should be public, which domain maps to which service, and where TLS, CORS, and logs should be handled.&lt;/p&gt;
&lt;p&gt;The structure I wanted was simpler:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Cloudflare or client
  -&gt; host :80
  -&gt; infra-caddy
  -&gt; Docker proxy network
  -&gt; service containers&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If Cloudflare Tunnel fronts the public HTTP traffic too, its ingress can route &lt;code class=&quot;language-text&quot;&gt;app.example.com -&gt; http://localhost:80&lt;/code&gt;, and the shared Caddy can handle the Host-based dispatch. If you use Cloudflare DNS proxy and router port forwarding instead, the origin-side pattern is still the same, but the TLS and forwarding settings become a different concern. Tunnel-origin HTTP entrypoints and DNS-proxied origin TLS should not be treated as the same problem.&lt;/p&gt;
&lt;p&gt;The shared Caddy Compose lives in its own infra directory and exposes only host &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;caddy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; caddy&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; infra&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;caddy
    &lt;span class=&quot;token key atrule&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;80:80&quot;&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; ./Caddyfile&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;/etc/caddy/Caddyfile&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;ro
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; proxy&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;net
    &lt;span class=&quot;token key atrule&quot;&gt;restart&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; unless&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;stopped

&lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;proxy-net&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;external&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean important&quot;&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The Caddyfile receives every request on &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt; and branches by &lt;code class=&quot;language-text&quot;&gt;Host&lt;/code&gt;:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;:80 {
  @service-a host app-a.example.com
  handle @service-a {
    reverse_proxy service-a:8000
  }

  @service-b host app-b.example.com
  handle @service-b {
    reverse_proxy service-b:3000
  }

  respond 404
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The important detail is that the upstreams are Docker service names, not IPs.&lt;/p&gt;
&lt;h2 id=&quot;Use-Docker-Networks-as-Service-Boundaries&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Use-Docker-Networks-as-Service-Boundaries&quot; aria-label=&quot;Use Docker Networks as Service Boundaries permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Use Docker Networks as Service Boundaries&lt;/h2&gt;
&lt;p&gt;Docker Compose creates project-scoped bridge networks by default, and containers on the same network can resolve each other by service name. You can also create custom networks shared across Compose projects.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/e3c6797febbbc2dbf527da53838bef3a/c1ae8/infra-network-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 63.52941176470588%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAAsTAAALEwEAmpwYAAACqUlEQVR42n3SyU8TYQAF8PnXvOpBWQ5sFxOFevSs/4AJnoyJFyFoaQvSNrWIQIECEsShC11m6cx0mf2bb5autLN/BjEeffnl3d7tYaJ6q8CxpI2BPublES+PFO22LQ0F5VYzJui/wWQF6oalQVMFOjR7qmapmiUDa2L7tut7fvCPH4R+EPj+X0EQYuOr9cn1J7sYDRpZqzu4pAcFbljgBqzmMMBuArul2S3NYVWbkia0PGFUh1EdSrYV08a80ppTXHdL66jyGQJYpr16w6vRLt0ObtqTTKGbvLZ28G6u1iNlh5RdFiIWIhqEguFgvas1+WLN+rXhFdZBiyNKNn6un+cEouzgdefNvvl6u/lqR9zERx0zZOEdDoY0CETDwbxq1K1uetVNRCR0o0fwIdV265zNiEFD888b44NqP4PDM7LH6agBgnuk+mccEnFEJu6a2NKNLgEQZyAGItZA5fbkrCxd1JQfFTlfEn5Sxg0/JhSfVLwy7/LQxtx2ps9k7HY2JBNQUSWZVYQSkMoANCsdBye612SvSA9wolekR7QYUELAyqjK+7xuY7a4C9nsSNz3iZja4jQRt4SjrnRkqeWiMNztcF9bzG6HSzL0ToPaE5q7Aneg8kXlVjZdLKC2QjrpU18QtaWbXVLxm5rHam4ThJeq8bbxbbWWXa1n37Vz74XjD+rpxgj/OLw8kVXF8LHaTb1QbpQqLCjsaUDrDJA0ROIQySPEDNxDQzjQOzlDyJnCoc4fGsLpCJyOAdmfqJaLGUCHWhcC07YUSelF0/nN9FE0dSeWPo6n8ol0PpY6iaVO4ul8PJWPJU+i27m1+PeODLH7l4ZhiBDqD8eLz15OL6xML0Sm5ldmliJTC8uzSy8ezz1/Mr88sxSZWYxML0YezT598HCuVCF+A+i0kM19lJBSAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;A Docker network diagram showing a shared proxy-net for ingress and separate internal app networks&apos; title=&apos;&apos; src=&apos;/static/e3c6797febbbc2dbf527da53838bef3a/ca1dc/infra-network-diagram.png&apos; srcset=&apos;/static/e3c6797febbbc2dbf527da53838bef3a/e7570/infra-network-diagram.png 170w,
/static/e3c6797febbbc2dbf527da53838bef3a/f46e7/infra-network-diagram.png 340w,
/static/e3c6797febbbc2dbf527da53838bef3a/ca1dc/infra-network-diagram.png 680w,
/static/e3c6797febbbc2dbf527da53838bef3a/02d09/infra-network-diagram.png 1020w,
/static/e3c6797febbbc2dbf527da53838bef3a/9d567/infra-network-diagram.png 1360w,
/static/e3c6797febbbc2dbf527da53838bef3a/c1ae8/infra-network-diagram.png 4448w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;A Docker network diagram showing a shared proxy-net for ingress and separate internal app networks&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The key point in this diagram is that &lt;code class=&quot;language-text&quot;&gt;infra-caddy&lt;/code&gt; is the only container directly attached to the public ingress path. Public-facing app containers can join both &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt; and their own app network. Databases and private state stay on the app-local network only.&lt;/p&gt;
&lt;p&gt;That produces a topology like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;proxy-net
  infra-caddy
  app-a-web
  app-a-api
  app-b-api

app-a-net
  app-a-web
  app-a-api
  postgres&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A concrete example looks like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;api&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ghcr.io/example/app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;api&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;latest
    &lt;span class=&quot;token key atrule&quot;&gt;env_file&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; .env
    &lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; ./data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;/data
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; proxy&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;net
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;net
    &lt;span class=&quot;token key atrule&quot;&gt;restart&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; unless&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;stopped

  &lt;span class=&quot;token key atrule&quot;&gt;postgres&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; postgres&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;16&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;alpine
    &lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; postgres_data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;/var/lib/postgresql/data
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;net
    &lt;span class=&quot;token key atrule&quot;&gt;healthcheck&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;CMD-SHELL&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pg_isready -U $POSTGRES_USER -d $POSTGRES_DB&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;proxy-net&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;external&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean important&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;app-net&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;driver&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; bridge

&lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  postgres_data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In that setup, Caddy can reach &lt;code class=&quot;language-text&quot;&gt;api:8000&lt;/code&gt;, but the database is not exposed on &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;. If you really need a host-side database port for administration, binding it to loopback only is safer than exposing it publicly:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;127.0.0.1:5432 -&gt; container 5432&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;Treat-the-Server-as-Runtime-Only&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Treat-the-Server-as-Runtime-Only&quot; aria-label=&quot;Treat the Server as Runtime Only permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Treat the Server as Runtime-Only&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;The server is where images run, not where source code gets developed.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;It is tempting to &lt;code class=&quot;language-text&quot;&gt;git clone&lt;/code&gt; repositories directly on the server, build Dockerfiles there, and manage &lt;code class=&quot;language-text&quot;&gt;node_modules&lt;/code&gt; or Python dependencies by hand. That gets messy fast once you have several services.&lt;/p&gt;
&lt;p&gt;I wanted the runtime host to look more like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;~/infra/
  caddy/
    docker-compose.yml
    Caddyfile

~/services/
  app-a/
    docker-compose.yml
    .env
    data/
    secrets/

  app-b/
    docker-compose.yml
    .env
    data/

~/backups/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Application images come from a registry such as GHCR:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/services/app-a
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose pull
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose up &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose &lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose logs &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That gives you a standard runtime loop:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker compose pull&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker compose up -d&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker compose ps&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker compose logs -f&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker restart infra-caddy&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker exec infra-caddy wget http://service:port/health&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The benefit is that deployment becomes an image-and-compose problem, not an on-host build problem.&lt;/p&gt;
&lt;h2 id=&quot;The-Parts-That-Were-Easy-to-Mix-Up&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Parts-That-Were-Easy-to-Mix-Up&quot; aria-label=&quot;The Parts That Were Easy to Mix Up permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Parts That Were Easy to Mix Up&lt;/h2&gt;
&lt;h3 id=&quot;Cloudflare-Tunnel-and-HTTP-Reverse-Proxy-Are-Not-the-Same-Thing&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Cloudflare-Tunnel-and-HTTP-Reverse-Proxy-Are-Not-the-Same-Thing&quot; aria-label=&quot;Cloudflare Tunnel and HTTP Reverse Proxy Are Not the Same Thing permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Cloudflare Tunnel and HTTP Reverse Proxy Are Not the Same Thing&lt;/h3&gt;
&lt;p&gt;Tunnel creates the path between Cloudflare and origin. Caddy is the reverse proxy inside origin that splits requests by &lt;code class=&quot;language-text&quot;&gt;Host&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;path&lt;/code&gt;, and upstream. If you blur those together, Tunnel problems and Caddy routing problems get mixed into one vague &quot;Cloudflare issue.&quot;&lt;/p&gt;
&lt;h3 id=&quot;Termius-Is-Not-the-Network-Path&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Termius-Is-Not-the-Network-Path&quot; aria-label=&quot;Termius Is Not the Network Path permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Termius Is Not the Network Path&lt;/h3&gt;
&lt;p&gt;Termius is an SSH client. Whether the underlying route is a public IP, a VPN, Cloudflare Tunnel, or Zero Trust Access, Termius is the app used on top of that path.&lt;/p&gt;
&lt;h3 id=&quot;Docker-GPG-Setup-Is-a-Trust-Boundary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Docker-GPG-Setup-Is-a-Trust-Boundary&quot; aria-label=&quot;Docker GPG Setup Is a Trust Boundary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Docker GPG Setup Is a Trust Boundary&lt;/h3&gt;
&lt;p&gt;Registering Docker&apos;s keyring and apt source is not just annoying ceremony. It is the point where package signatures get verified. On a bare-metal runtime host, that is more defensible than &lt;code class=&quot;language-text&quot;&gt;curl | sh&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;docker-proxy-Is-Not-Your-Web-Server&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#docker-proxy-Is-Not-Your-Web-Server&quot; aria-label=&quot;docker proxy Is Not Your Web Server permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt; Is Not Your Web Server&lt;/h3&gt;
&lt;p&gt;If &lt;code class=&quot;language-text&quot;&gt;ss -lntp&lt;/code&gt; shows &lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt;, that only proves Docker is forwarding a host port to a container port. It does not prove that the service behind it is actually listening or healthy.&lt;/p&gt;
&lt;h3 id=&quot;Caddy-Is-the-Fastest-Narrowing-Point&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Caddy-Is-the-Fastest-Narrowing-Point&quot; aria-label=&quot;Caddy Is the Fastest Narrowing Point permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Caddy Is the Fastest Narrowing Point&lt;/h3&gt;
&lt;p&gt;When something breaks in the browser, I do not jump straight to blaming the app. Checking upstreams from inside the Caddy container quickly separates Docker network issues from application issues:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;exec&lt;/span&gt; infra-caddy &lt;span class=&quot;token function&quot;&gt;wget&lt;/span&gt; -qO- http://app-api:8000/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If that fails, the problem is already inside origin. If it succeeds, the next step is Host routing, CORS, or Cloudflare settings.&lt;/p&gt;
&lt;h2 id=&quot;The-Order-I-Would-Follow-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Order-I-Would-Follow-Next-Time&quot; aria-label=&quot;The Order I Would Follow Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Order I Would Follow Next Time&lt;/h2&gt;
&lt;p&gt;If I had to set this up again from scratch, I would use this sequence:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Enable the OpenSSH server during Ubuntu install.&lt;/li&gt;
&lt;li&gt;Use a wired keyboard, mouse, and monitor for first boot and LAN IP verification.&lt;/li&gt;
&lt;li&gt;SSH from the laptop over the local network.&lt;/li&gt;
&lt;li&gt;Install Docker through the official apt repository flow.&lt;/li&gt;
&lt;li&gt;Verify runtime basics with &lt;code class=&quot;language-text&quot;&gt;docker run hello-world&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;docker compose version&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create a shared Docker network such as &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Create a shared Caddy Compose under &lt;code class=&quot;language-text&quot;&gt;~/infra/caddy&lt;/code&gt; and expose only host &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Decide explicitly whether origin entry is via Cloudflare Tunnel or DNS/proxy + port forwarding.&lt;/li&gt;
&lt;li&gt;Manage SSH access through a separate boundary such as Cloudflare Access, Tunnel, or a VPN.&lt;/li&gt;
&lt;li&gt;Keep each app under &lt;code class=&quot;language-text&quot;&gt;~/services/&amp;lt;app&gt;&lt;/code&gt; with its own Compose, env, data, and secrets.&lt;/li&gt;
&lt;li&gt;Attach only public-facing app containers to &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;; keep databases on internal app networks.&lt;/li&gt;
&lt;li&gt;Standardize deployment as &lt;code class=&quot;language-text&quot;&gt;docker compose pull &amp;amp;&amp;amp; docker compose up -d&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;During incidents, check &lt;code class=&quot;language-text&quot;&gt;docker compose ps&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;docker logs&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;docker exec infra-caddy wget .../health&lt;/code&gt; in that order.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The core idea is to start with a structure that can support several services, not just one throwaway app.&lt;/p&gt;
&lt;h2 id=&quot;What-I-Learned&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-I-Learned&quot; aria-label=&quot;What I Learned permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What I Learned&lt;/h2&gt;
&lt;p&gt;Over time, home-server quality depends on how clearly you separate boundaries:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the SSH access boundary&lt;/li&gt;
&lt;li&gt;the HTTP ingress boundary&lt;/li&gt;
&lt;li&gt;the Docker network boundary&lt;/li&gt;
&lt;li&gt;the app data and secret boundary&lt;/li&gt;
&lt;li&gt;the build/runtime boundary&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If those are separated up front, running several services on one machine stays understandable. If everything opens host ports, every repo gets cloned directly on the server, and Caddy, apps, and databases all share the same network without intent, even a small incident becomes harder to localize.&lt;/p&gt;
&lt;p&gt;A home server can be operated like a small cloud. The difference is that you have to treat it like a runtime machine, not like a laptop with some services on it.&lt;/p&gt;
&lt;p&gt;This also made the cost of cloud abstractions much more concrete to me. In AWS or GCP, a few clicks hide the boundaries around networks, proxies, services, cron jobs, volumes, secrets, and health checks. Running the same ideas directly with Docker and Linux is more manual, but it makes the infrastructure model much easier to understand.&lt;/p&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/engine/install/ubuntu/&quot;&gt;Docker Docs: Install Docker Engine on Ubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/engine/network/&quot;&gt;Docker Docs: Networking overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/compose/how-tos/networking/&quot;&gt;Docker Docs: Networking in Compose&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/&quot;&gt;Cloudflare Docs: Cloudflare Tunnel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/use-cases/ssh/&quot;&gt;Cloudflare Docs: SSH with Cloudflare One&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/directives/reverse_proxy&quot;&gt;Caddy Docs: reverse_proxy directive&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[홈서버를 런타임 전용 Docker 서버로 운영하기]]></title><description><![CDATA[홈서버 세팅의 핵심은 Ubuntu와 Docker 설치보다 운영 경계를 정하는 일이었다. SSH는 어떻게 들어갈 것인가, HTTP 요청은 어디로 모을 것인가, 각 앱은 어떤 Docker network…]]></description><link>https://sewon.dev/home-server-runtime-docker-caddy-cloudflare-guide/</link><guid isPermaLink="false">https://sewon.dev/home-server-runtime-docker-caddy-cloudflare-guide/</guid><pubDate>Wed, 03 Jun 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/f77d59d92c3594da0d3d32ccacc20b0c/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACnklEQVR42mXOW0sUYRgH8LkKsbtCoSgsqFALuggqCoQu+gLd9wm68UBq7SKUrktBZSWm5hHzEFrGmsmamqVY7rqeW1fX067uzu6cZ3Z25p3D+z4xF11EDz/+PDcP/4dChs1LBicaaR6xAuIlxIrOwgg6wyNOQE6KSJQN+G8oy8IcLwuczLESx0mipLFclmEdHK9xQjaRVnhJkzOIEGITbGLLsB2EEAoIRmG/Huo3fvvI7oSmoI2gEQmicMBg4zhKZ1q+pbvnhO6AHjlEIWmvJxkYEdaHxTXOUJ1jeq43OvZyd7wxu9Qr88p3f3LKHxsfje+sa4GoeL93u85Heyf0hW1tMrHsXfS92ZxoZ3+mkEwBQFbipXRSSid1kSUE2JTGpRSFUy3NMi07yYiJtBhjVGSBbOrbAnOYldNW1iKYAkIQt4bS85awYmc2TGER0MFWCg0ucB+C3OAvZnRV/bFjGFnN3ozYkU2yFYW9fYgdgK47bwv7X+MbQyo9DpkZLE+DvOZf5ivfx2s+HjzyMXV+7fWsySQYNhBMzC/sz84p4Q0SjWJZpoDYfGyK3vksHPrFA7+aGify2nRYrhmmPSO09wv7dBI1zagSw/OhRTq0lAyG+JVVKxzGikIBECA6gA6g/WXoNggmiCaIBvAGSCYQTABjIMQBBGwLMKYwxs+au+65a8sfPylz1ZdV15dWe8qraytddZWuuiq3p8pdX+mqr3joKXd5y13eCre39IGnxtMgKxnKMMzbd+6euHT93NVbZy+XFBTdPF1448zFklOFN48XXMnNL87JK8rJK8rNL8rNcxzNLz5y7MLJ89cOE7TTPPRprKmlp61z4G3XQEtHX2tnf2tnf3N7b1Pbu1fNXS+aOhr+9byxraWjT1WzfwBUoThMZfFsFgAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;홈서버에서 SSH 접근, 공용 Caddy, Docker Compose 서비스를 분리한 운영 구조&apos; title=&apos;&apos; src=&apos;/static/f77d59d92c3594da0d3d32ccacc20b0c/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/f77d59d92c3594da0d3d32ccacc20b0c/e7570/situation-diagram.png 170w,
/static/f77d59d92c3594da0d3d32ccacc20b0c/f46e7/situation-diagram.png 340w,
/static/f77d59d92c3594da0d3d32ccacc20b0c/ca1dc/situation-diagram.png 680w,
/static/f77d59d92c3594da0d3d32ccacc20b0c/02d09/situation-diagram.png 1020w,
/static/f77d59d92c3594da0d3d32ccacc20b0c/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;홈서버에서 SSH 접근, 공용 Caddy, Docker Compose 서비스를 분리한 운영 구조&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;홈서버 세팅의 핵심은 Ubuntu와 Docker 설치보다 운영 경계를 정하는 일이었다. SSH는 어떻게 들어갈 것인가, HTTP 요청은 어디로 모을 것인가, 각 앱은 어떤 Docker network에 붙일 것인가, 서버에는 소스코드를 둘 것인가 이미지만 둘 것인가를 먼저 정해야 했다.&lt;/p&gt;
&lt;p&gt;이 글은 그 세팅 과정에서 헷갈렸던 질문을 바탕으로 처음 홈서버를 만드는 사람이 따라갈 수 있는 운영 기준을 정리한 기록이다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: 처음에는 Cloudflare Tunnel, SSH, Termius, Docker, Caddy, Docker Compose가 각각 무엇을 책임지는지 섞여 보였다.&lt;/li&gt;
&lt;li&gt;판단: 홈서버는 &quot;개발 머신&quot;이 아니라 &quot;런타임 머신&quot;으로 보고 접근 경계와 서비스 경계를 나눴다.&lt;/li&gt;
&lt;li&gt;기준 구조: SSH 접근은 Cloudflare Tunnel/Access 같은 별도 접근 경계로 관리하고, HTTP 서비스는 공용 Caddy가 &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt;에서 받아 Docker &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;에 붙은 서비스로 라우팅한다.&lt;/li&gt;
&lt;li&gt;배운 점: 여러 서비스를 운영하려면 앱마다 포트를 열기보다 공용 reverse proxy 하나와 서비스별 compose 프로젝트를 두는 구조가 훨씬 관리하기 쉽다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;처음 준비한 것은 USB, 랜선, Ubuntu 설치 이미지였다. 여기서 바로 막히는 질문이 많았다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cloudflare Tunnel을 쓰면 공인 IP나 포트포워딩이 필요한가?&lt;/li&gt;
&lt;li&gt;유선 키보드와 마우스가 꼭 필요한가?&lt;/li&gt;
&lt;li&gt;SSH는 왜 Cloudflare로 열어야 하나?&lt;/li&gt;
&lt;li&gt;Termius는 Cloudflare Tunnel을 대체하는가?&lt;/li&gt;
&lt;li&gt;Docker GPG key와 apt repository 등록은 왜 필요한가?&lt;/li&gt;
&lt;li&gt;여러 서비스를 한 서버에 올릴 때 Caddy를 서비스마다 둬야 하나?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;먼저-정한-원칙&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%A8%BC%EC%A0%80-%EC%A0%95%ED%95%9C-%EC%9B%90%EC%B9%99&quot; aria-label=&quot;먼저 정한 원칙 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;먼저 정한 원칙&lt;/h2&gt;
&lt;p&gt;홈서버를 서버답게 운영하려면 역할을 나눠야 한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;접근 계층: SSH, Cloudflare Tunnel, 물리 콘솔
진입 계층: 공용 Caddy
서비스 계층: 앱별 docker compose
데이터 계층: volume, data, secrets, database
배포 계층: GHCR image pull, docker compose up&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이렇게 나누면 &quot;뭐가 안 된다&quot;는 말도 더 작게 쪼개진다. SSH가 안 되는지, Cloudflare에서 origin까지 못 오는지, Caddy가 Host를 못 맞추는지, Docker network에서 서비스명을 못 찾는지, 앱 health check가 실패하는지 따로 확인할 수 있다.&lt;/p&gt;
&lt;h2 id=&quot;장비와-첫-부팅&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9E%A5%EB%B9%84%EC%99%80-%EC%B2%AB-%EB%B6%80%ED%8C%85&quot; aria-label=&quot;장비와 첫 부팅 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;장비와 첫 부팅&lt;/h2&gt;
&lt;p&gt;Cloudflare Tunnel을 쓴다고 해서 물리 콘솔이 필요 없어지는 것은 아니다. Tunnel과 SSH가 작동하려면 먼저 서버가 정상 부팅하고 네트워크에 붙어야 한다.&lt;/p&gt;
&lt;p&gt;처음 세팅할 때는 아래가 필요하다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;USB 설치 디스크&lt;/li&gt;
&lt;li&gt;유선 키보드와 유선 마우스&lt;/li&gt;
&lt;li&gt;HDMI 모니터 또는 TV&lt;/li&gt;
&lt;li&gt;랜선&lt;/li&gt;
&lt;li&gt;선택: UPS&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;서버가 부팅하지 않거나 네트워크가 죽으면 SSH와 Tunnel은 모두 쓸 수 없다. 그때 BIOS, 콘솔, 부팅 로그를 보기 위해 유선 입력 장치와 화면이 필요하다.&lt;/p&gt;
&lt;h2 id=&quot;Ubuntu-설치-후-첫-명령&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Ubuntu-%EC%84%A4%EC%B9%98-%ED%9B%84-%EC%B2%AB-%EB%AA%85%EB%A0%B9&quot; aria-label=&quot;Ubuntu 설치 후 첫 명령 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Ubuntu 설치 후 첫 명령&lt;/h2&gt;
&lt;p&gt;Ubuntu 설치 단계에서는 OpenSSH server를 켜두는 것이 좋다. 설치가 끝나면 물리 콘솔에서 LAN IP를 확인하고, 이후부터는 작업용 노트북에서 접속한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;ip&lt;/span&gt; a
&lt;span class=&quot;token function&quot;&gt;ssh&lt;/span&gt; user@192.168.x.x&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그 다음은 기본 패키지와 Docker 설치다. Docker는 공식 문서 기준으로 Docker의 apt repository를 등록해서 설치하는 방식을 쓴다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; update
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-y&lt;/span&gt; ca-certificates &lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-m&lt;/span&gt; 0755 &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt; /etc/apt/keyrings
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-fsSL&lt;/span&gt; https://download.docker.com/linux/ubuntu/gpg &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token parameter variable&quot;&gt;-o&lt;/span&gt; /etc/apt/keyrings/docker.asc
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;chmod&lt;/span&gt; a+r /etc/apt/keyrings/docker.asc

&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;tee&lt;/span&gt; /etc/apt/sources.list.d/docker.sources &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: &lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;.&lt;/span&gt; /etc/os-release &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token variable&quot;&gt;${UBUNTU_CODENAME&lt;span class=&quot;token operator&quot;&gt;:-&lt;/span&gt;$VERSION_CODENAME}&lt;/span&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
Components: stable
Architectures: &lt;span class=&quot;token variable&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$(&lt;/span&gt;dpkg --print-architecture&lt;span class=&quot;token variable&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
Signed-By: /etc/apt/keyrings/docker.asc
EOF&lt;/span&gt;

&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; update
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;apt&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-y&lt;/span&gt; docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;처음에는 GPG key 단계가 불필요한 의식처럼 보였다. 하지만 이 단계는 &quot;이 Docker 패키지가 Docker가 서명한 공식 패키지인지&quot;를 apt가 검증하게 만드는 과정이다. 서버에 설치되는 런타임은 신뢰 경계 안에 있어야 한다.&lt;/p&gt;
&lt;p&gt;설치 확인은 간단하다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;--version&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose version
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; run &lt;span class=&quot;token parameter variable&quot;&gt;--rm&lt;/span&gt; hello-world&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;docker&lt;/code&gt;를 매번 &lt;code class=&quot;language-text&quot;&gt;sudo&lt;/code&gt; 없이 쓰려면 사용자를 &lt;code class=&quot;language-text&quot;&gt;docker&lt;/code&gt; 그룹에 넣을 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;usermod&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-aG&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;&lt;span class=&quot;token environment constant&quot;&gt;$USER&lt;/span&gt;&quot;&lt;/span&gt;
newgrp &lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;다만 이 권한은 사실상 Docker daemon 제어 권한이다. 운영 서버에서는 누가 Docker 그룹에 들어가는지 신중하게 봐야 한다.&lt;/p&gt;
&lt;h2 id=&quot;Cloudflare-Tunnel과-SSH&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Cloudflare-Tunnel%EA%B3%BC-SSH&quot; aria-label=&quot;Cloudflare Tunnel과 SSH permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Cloudflare Tunnel과 SSH&lt;/h2&gt;
&lt;p&gt;처음에는 &quot;Termius를 쓰면 Cloudflare Tunnel이 필요 없는가?&quot;가 헷갈렸다. 둘은 같은 층의 도구가 아니다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Termius는 SSH 클라이언트다.&lt;/li&gt;
&lt;li&gt;Cloudflare Tunnel/Access는 네트워크 경로와 접근 정책을 만든다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;즉 Termius는 &lt;code class=&quot;language-text&quot;&gt;ssh&lt;/code&gt;를 보기 좋게 쓰는 도구이고, Cloudflare Tunnel은 서버가 외부에서 어떻게 도달 가능한지를 바꾼다.&lt;/p&gt;
&lt;p&gt;Cloudflare 공식 문서 기준으로 Tunnel은 origin에서 Cloudflare 네트워크로 outbound-only 연결을 만든다. 이 방식은 서버에 공개적으로 routable한 IP가 없어도 Cloudflare를 통해 리소스를 제공할 수 있게 해준다. SSH use case도 따로 문서화되어 있고, client-side &lt;code class=&quot;language-text&quot;&gt;cloudflared&lt;/code&gt;를 통한 native terminal 접속, browser-rendered SSH, Access for Infrastructure 같은 선택지가 있다.&lt;/p&gt;
&lt;p&gt;처음 세팅 흐름은 대략 이랬다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;cloudflared tunnel login
cloudflared tunnel create home-server
cloudflared tunnel route dns home-server ssh.example.com
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; cloudflared &lt;span class=&quot;token function&quot;&gt;service&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;install&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; systemctl &lt;span class=&quot;token builtin class-name&quot;&gt;enable&lt;/span&gt; cloudflared
&lt;span class=&quot;token function&quot;&gt;sudo&lt;/span&gt; systemctl start cloudflared&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;운영에서는 &lt;code class=&quot;language-text&quot;&gt;cloudflared&lt;/code&gt;를 systemd 서비스로 실행한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;cloudflared.service
ExecStart=/usr/bin/cloudflared --no-autoupdate --config /etc/cloudflared/config.yml tunnel run&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;SSH ingress는 이런 형태로 둘 수 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;ingress&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;hostname&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ssh.example.com
    &lt;span class=&quot;token key atrule&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ssh&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;//localhost&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;22&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token key atrule&quot;&gt;service&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; http_status&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;404&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;여기서 중요한 점은 &quot;서버 안에서 SSH daemon이 사라진다&quot;가 아니다. 서버는 여전히 &lt;code class=&quot;language-text&quot;&gt;localhost:22&lt;/code&gt; 또는 내부 SSH daemon을 갖고 있고, Cloudflare Tunnel이 그 앞에 접근 경계를 하나 더 둔다. 라우터, 방화벽, Cloudflare Access 정책을 어떻게 잡느냐에 따라 실제 노출 표면은 달라진다.&lt;/p&gt;
&lt;p&gt;또한 Tunnel DNS route만 만든다고 SSH 접근 정책이 끝나는 것은 아니다. Cloudflare Access를 쓴다면 접근 가능한 사용자, 인증 방식, 클라이언트 &lt;code class=&quot;language-text&quot;&gt;cloudflared&lt;/code&gt; 또는 브라우저 SSH 방식을 별도로 정해야 한다.&lt;/p&gt;
&lt;h2 id=&quot;HTTP-서비스는-공용-Caddy로-모은다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#HTTP-%EC%84%9C%EB%B9%84%EC%8A%A4%EB%8A%94-%EA%B3%B5%EC%9A%A9-Caddy%EB%A1%9C-%EB%AA%A8%EC%9D%80%EB%8B%A4&quot; aria-label=&quot;HTTP 서비스는 공용 Caddy로 모은다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;HTTP 서비스는 공용 Caddy로 모은다&lt;/h2&gt;
&lt;p&gt;여러 서비스를 한 서버에 올릴 때 가장 쉬운 실수는 서비스마다 host port를 열어버리는 것이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;service A -&gt; 8000
service B -&gt; 8001
service C -&gt; 3000
service D -&gt; 5000&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이렇게 하면 어느 포트가 외부에 열려야 하는지, 어떤 서비스가 어떤 도메인을 받는지, TLS와 CORS와 로그가 어디서 처리되는지 금방 흐려진다.&lt;/p&gt;
&lt;p&gt;기준 구조는 더 단순하다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Cloudflare or client
  -&gt; host :80
  -&gt; infra-caddy
  -&gt; Docker proxy network
  -&gt; service containers&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Cloudflare Tunnel로 public HTTP까지 붙인다면 Tunnel ingress는 &lt;code class=&quot;language-text&quot;&gt;app.example.com -&gt; http://localhost:80&lt;/code&gt;처럼 공용 Caddy로 보내면 된다. Cloudflare DNS proxy와 라우터 포트포워딩을 쓰는 경우에도 Caddy가 Host 기준으로 각 서비스에 넘기는 origin 쪽 패턴은 같다. 다만 이 경우에는 Cloudflare SSL/TLS mode, origin certificate, 포워딩 포트를 별도로 맞춰야 한다. Tunnel 내부 HTTP entrypoint와 DNS proxy 기반 origin TLS 설정을 같은 문제로 보면 안 된다.&lt;/p&gt;
&lt;p&gt;공용 Caddy compose는 별도 infra 디렉터리에 있고, host &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt;만 받는다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;caddy&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; caddy&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;token number&quot;&gt;2&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; infra&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;caddy
    &lt;span class=&quot;token key atrule&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;80:80&quot;&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; ./Caddyfile&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;/etc/caddy/Caddyfile&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;ro
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; proxy&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;net
    &lt;span class=&quot;token key atrule&quot;&gt;restart&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; unless&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;stopped

&lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;proxy-net&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;external&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean important&quot;&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Caddyfile은 &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt;에서 모든 요청을 받고 Host matcher로 분기한다.&lt;/p&gt;
&lt;p&gt;Docker에서 app container port를 host에 직접 publish하면 방화벽 정책과 실제 노출 범위가 헷갈릴 수 있다. 처음에는 앱별 host port를 열지 말고, 공개 진입점은 공용 Caddy 하나로 제한하는 편이 관리하기 쉽다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;:80 {
  @service-a host app-a.example.com
  handle @service-a {
    reverse_proxy service-a:8000
  }

  @service-b host app-b.example.com
  handle @service-b {
    reverse_proxy service-b:3000
  }

  respond 404
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Caddy 공식 문서 기준으로 &lt;code class=&quot;language-text&quot;&gt;reverse_proxy&lt;/code&gt;는 matched request를 upstream으로 프록시하는 directive다. 여기서 upstream을 IP로 쓰지 않고 Docker service/container name으로 쓰는 것이 핵심이다.&lt;/p&gt;
&lt;h2 id=&quot;Docker-network를-서비스-경계로-쓴다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Docker-network%EB%A5%BC-%EC%84%9C%EB%B9%84%EC%8A%A4-%EA%B2%BD%EA%B3%84%EB%A1%9C-%EC%93%B4%EB%8B%A4&quot; aria-label=&quot;Docker network를 서비스 경계로 쓴다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Docker network를 서비스 경계로 쓴다&lt;/h2&gt;
&lt;p&gt;Docker 공식 문서 기준으로 Compose는 기본적으로 프로젝트별 bridge network를 만들고, 같은 network에 붙은 컨테이너는 서비스명으로 서로를 찾을 수 있다. 또한 custom network를 정의해서 여러 Compose 프로젝트가 같은 network를 공유할 수도 있다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/e3c6797febbbc2dbf527da53838bef3a/c1ae8/infra-network-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 63.52941176470588%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAANCAIAAAAmMtkJAAAACXBIWXMAAAsTAAALEwEAmpwYAAACqUlEQVR42n3SyU8TYQAF8PnXvOpBWQ5sFxOFevSs/4AJnoyJFyFoaQvSNrWIQIECEsShC11m6cx0mf2bb5autLN/BjEeffnl3d7tYaJ6q8CxpI2BPublES+PFO22LQ0F5VYzJui/wWQF6oalQVMFOjR7qmapmiUDa2L7tut7fvCPH4R+EPj+X0EQYuOr9cn1J7sYDRpZqzu4pAcFbljgBqzmMMBuArul2S3NYVWbkia0PGFUh1EdSrYV08a80ppTXHdL66jyGQJYpr16w6vRLt0ObtqTTKGbvLZ28G6u1iNlh5RdFiIWIhqEguFgvas1+WLN+rXhFdZBiyNKNn6un+cEouzgdefNvvl6u/lqR9zERx0zZOEdDoY0CETDwbxq1K1uetVNRCR0o0fwIdV265zNiEFD888b44NqP4PDM7LH6agBgnuk+mccEnFEJu6a2NKNLgEQZyAGItZA5fbkrCxd1JQfFTlfEn5Sxg0/JhSfVLwy7/LQxtx2ps9k7HY2JBNQUSWZVYQSkMoANCsdBye612SvSA9wolekR7QYUELAyqjK+7xuY7a4C9nsSNz3iZja4jQRt4SjrnRkqeWiMNztcF9bzG6HSzL0ToPaE5q7Aneg8kXlVjZdLKC2QjrpU18QtaWbXVLxm5rHam4ThJeq8bbxbbWWXa1n37Vz74XjD+rpxgj/OLw8kVXF8LHaTb1QbpQqLCjsaUDrDJA0ROIQySPEDNxDQzjQOzlDyJnCoc4fGsLpCJyOAdmfqJaLGUCHWhcC07YUSelF0/nN9FE0dSeWPo6n8ol0PpY6iaVO4ul8PJWPJU+i27m1+PeODLH7l4ZhiBDqD8eLz15OL6xML0Sm5ldmliJTC8uzSy8ezz1/Mr88sxSZWYxML0YezT598HCuVCF+A+i0kM19lJBSAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;홈서버에서 공용 proxy-net과 앱 내부 network를 분리한 Docker network 구조&apos; title=&apos;&apos; src=&apos;/static/e3c6797febbbc2dbf527da53838bef3a/ca1dc/infra-network-diagram.png&apos; srcset=&apos;/static/e3c6797febbbc2dbf527da53838bef3a/e7570/infra-network-diagram.png 170w,
/static/e3c6797febbbc2dbf527da53838bef3a/f46e7/infra-network-diagram.png 340w,
/static/e3c6797febbbc2dbf527da53838bef3a/ca1dc/infra-network-diagram.png 680w,
/static/e3c6797febbbc2dbf527da53838bef3a/02d09/infra-network-diagram.png 1020w,
/static/e3c6797febbbc2dbf527da53838bef3a/9d567/infra-network-diagram.png 1360w,
/static/e3c6797febbbc2dbf527da53838bef3a/c1ae8/infra-network-diagram.png 4448w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;홈서버에서 공용 proxy-net과 앱 내부 network를 분리한 Docker network 구조&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;이 그림에서 핵심은 &lt;code class=&quot;language-text&quot;&gt;infra-caddy&lt;/code&gt;만 host의 공개 진입점에 붙고, 공개 앱 컨테이너는 &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;과 앱 내부 network에 동시에 붙는다는 점이다. Docker network가 서로를 포함하는 것은 아니다. 컨테이너가 여러 network에 가입해서 Caddy와도 만나고 같은 앱의 DB와도 만난다. 데이터베이스와 파일 경계는 앱 내부 network와 mount로 따로 둔다.&lt;/p&gt;
&lt;p&gt;이 원칙을 적용하면 network는 이렇게 나뉜다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;proxy-net
  infra-caddy
  app-a-web
  app-a-api
  app-b-api

app-a-net
  app-a-web
  app-a-api
  postgres&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;공개 reverse proxy가 붙어야 하는 컨테이너만 &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;에 붙인다. &lt;code class=&quot;language-text&quot;&gt;app-a-web&lt;/code&gt;과 &lt;code class=&quot;language-text&quot;&gt;app-a-api&lt;/code&gt;처럼 외부 Host route를 받아야 하는 컨테이너는 &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;과 &lt;code class=&quot;language-text&quot;&gt;app-a-net&lt;/code&gt;에 함께 붙을 수 있다. DB처럼 외부에서 직접 접근할 필요가 없는 컨테이너는 앱 내부 network에만 둔다.&lt;/p&gt;
&lt;p&gt;예시는 이런 형태다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;api&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ghcr.io/example/app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;api&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;latest
    &lt;span class=&quot;token key atrule&quot;&gt;env_file&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; .env
    &lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; ./data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;/data
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; proxy&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;net
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;net
    &lt;span class=&quot;token key atrule&quot;&gt;restart&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; unless&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;stopped

  &lt;span class=&quot;token key atrule&quot;&gt;postgres&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; postgres&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;16&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;alpine
    &lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; postgres_data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;/var/lib/postgresql/data
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;net
    &lt;span class=&quot;token key atrule&quot;&gt;healthcheck&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;test&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;CMD-SHELL&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pg_isready -U $POSTGRES_USER -d $POSTGRES_DB&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;proxy-net&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;external&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean important&quot;&gt;true&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;app-net&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;driver&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; bridge

&lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  postgres_data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이렇게 하면 Caddy는 &lt;code class=&quot;language-text&quot;&gt;api:8000&lt;/code&gt;으로 접근할 수 있고, DB는 &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;에 노출되지 않는다. host port를 열어야 하는 경우도 줄어든다. 관리 목적으로 DB host port를 열어야 한다면 public interface가 아니라 로컬 loopback에만 묶는 편이 안전하다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;127.0.0.1:5432 -&gt; container 5432&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;서버는-런타임-전용이어야-한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%84%9C%EB%B2%84%EB%8A%94-%EB%9F%B0%ED%83%80%EC%9E%84-%EC%A0%84%EC%9A%A9%EC%9D%B4%EC%96%B4%EC%95%BC-%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;서버는 런타임 전용이어야 한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;서버는 런타임 전용이어야 한다&lt;/h2&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;서버는 소스코드를 개발하는 곳이 아니라 이미지를 실행하는 곳이다.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;처음에는 서버 안에 repo를 clone하고, Dockerfile을 빌드하고, node_modules와 Python dependency를 직접 만지기 쉽다. 하지만 서비스가 여러 개가 되면 이 방식은 금방 지저분해진다.&lt;/p&gt;
&lt;p&gt;더 나은 기준은 이렇다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;~/infra/
  caddy/
    docker-compose.yml
    Caddyfile

~/services/
  app-a/
    docker-compose.yml
    .env
    data/
    secrets/

  app-b/
    docker-compose.yml
    .env
    data/

~/backups/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;앱 이미지는 GHCR 같은 registry에서 가져온다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; ~/services/app-a
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose pull
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose up &lt;span class=&quot;token parameter variable&quot;&gt;-d&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose &lt;span class=&quot;token function&quot;&gt;ps&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose logs &lt;span class=&quot;token parameter variable&quot;&gt;-f&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;운영 루틴은 이 패턴으로 표준화한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker compose pull&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker compose up -d&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker compose ps&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker compose logs -f&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker restart infra-caddy&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker exec infra-caddy wget http://service:port/health&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 루틴이 좋은 이유는 서버에서 코드를 빌드하지 않아도 되기 때문이다. 배포는 image tag를 바꾸고 compose를 다시 올리는 문제로 줄어든다.&lt;/p&gt;
&lt;h2 id=&quot;헷갈렸던-지점들&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%97%B7%EA%B0%88%EB%A0%B8%EB%8D%98-%EC%A7%80%EC%A0%90%EB%93%A4&quot; aria-label=&quot;헷갈렸던 지점들 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;헷갈렸던 지점들&lt;/h2&gt;
&lt;h3 id=&quot;Cloudflare-Tunnel과-HTTP-reverse-proxy는-같은-것이-아니다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Cloudflare-Tunnel%EA%B3%BC-HTTP-reverse-proxy%EB%8A%94-%EA%B0%99%EC%9D%80-%EA%B2%83%EC%9D%B4-%EC%95%84%EB%8B%88%EB%8B%A4&quot; aria-label=&quot;Cloudflare Tunnel과 HTTP reverse proxy는 같은 것이 아니다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Cloudflare Tunnel과 HTTP reverse proxy는 같은 것이 아니다&lt;/h3&gt;
&lt;p&gt;Tunnel은 Cloudflare와 origin 사이의 경로를 만든다. Caddy는 origin 안에서 Host, path, upstream을 나누는 reverse proxy다. 둘을 섞어서 생각하면 &quot;Cloudflare 설정을 바꿔야 하는 문제&quot;와 &quot;Caddyfile route를 바꿔야 하는 문제&quot;가 섞인다.&lt;/p&gt;
&lt;h3 id=&quot;Termius는-네트워크-경로가-아니다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Termius%EB%8A%94-%EB%84%A4%ED%8A%B8%EC%9B%8C%ED%81%AC-%EA%B2%BD%EB%A1%9C%EA%B0%80-%EC%95%84%EB%8B%88%EB%8B%A4&quot; aria-label=&quot;Termius는 네트워크 경로가 아니다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Termius는 네트워크 경로가 아니다&lt;/h3&gt;
&lt;p&gt;Termius는 SSH client다. 공인 IP, VPN, Cloudflare Tunnel, Zero Trust Access 중 어떤 경로를 쓰든 그 위에서 접속을 편하게 해주는 앱에 가깝다.&lt;/p&gt;
&lt;h3 id=&quot;Docker-GPG-key는-귀찮은-단계가-아니라-신뢰-경계다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Docker-GPG-key%EB%8A%94-%EA%B7%80%EC%B0%AE%EC%9D%80-%EB%8B%A8%EA%B3%84%EA%B0%80-%EC%95%84%EB%8B%88%EB%9D%BC-%EC%8B%A0%EB%A2%B0-%EA%B2%BD%EA%B3%84%EB%8B%A4&quot; aria-label=&quot;Docker GPG key는 귀찮은 단계가 아니라 신뢰 경계다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Docker GPG key는 귀찮은 단계가 아니라 신뢰 경계다&lt;/h3&gt;
&lt;p&gt;Docker를 설치할 때 keyring과 apt source를 등록하는 작업은 패키지 서명을 검증하기 위한 단계다. 베어메탈 서버에 올리는 런타임일수록 &lt;code class=&quot;language-text&quot;&gt;curl | sh&lt;/code&gt;보다 공식 repository 기반 설치가 설명 가능하다.&lt;/p&gt;
&lt;h3 id=&quot;docker-proxy는-웹-서버가-아니다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#docker-proxy%EB%8A%94-%EC%9B%B9-%EC%84%9C%EB%B2%84%EA%B0%80-%EC%95%84%EB%8B%88%EB%8B%A4&quot; aria-label=&quot;docker proxy는 웹 서버가 아니다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;&lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt;는 웹 서버가 아니다&lt;/h3&gt;
&lt;p&gt;host에서 &lt;code class=&quot;language-text&quot;&gt;ss -lntp&lt;/code&gt;를 보면 &lt;code class=&quot;language-text&quot;&gt;docker-proxy&lt;/code&gt;가 포트를 잡고 있는 것처럼 보일 수 있다. 이것은 host port를 container port로 넘기는 Docker의 중계 경로다. 진짜 확인할 것은 그 뒤 컨테이너가 해당 port에서 listen 중인지, 그리고 Caddy가 upstream service name을 해석할 수 있는지다.&lt;/p&gt;
&lt;h3 id=&quot;Caddy에서-검증하면-문제가-빨리-좁혀진다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Caddy%EC%97%90%EC%84%9C-%EA%B2%80%EC%A6%9D%ED%95%98%EB%A9%B4-%EB%AC%B8%EC%A0%9C%EA%B0%80-%EB%B9%A8%EB%A6%AC-%EC%A2%81%ED%98%80%EC%A7%84%EB%8B%A4&quot; aria-label=&quot;Caddy에서 검증하면 문제가 빨리 좁혀진다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Caddy에서 검증하면 문제가 빨리 좁혀진다&lt;/h3&gt;
&lt;p&gt;브라우저에서 안 된다고 바로 앱을 의심하지 않는다. Caddy 컨테이너 안에서 upstream을 직접 확인하면 Docker network 문제인지 앱 문제인지 빨리 갈린다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; &lt;span class=&quot;token builtin class-name&quot;&gt;exec&lt;/span&gt; infra-caddy &lt;span class=&quot;token function&quot;&gt;wget&lt;/span&gt; -qO- http://app-api:8000/health&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 명령이 실패하면 Cloudflare나 브라우저보다 안쪽 문제다. 성공하면 외부 Host route, CORS, Cloudflare 설정 쪽을 본다.&lt;/p&gt;
&lt;h2 id=&quot;처음-하는-사람을-위한-순서&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C-%ED%95%98%EB%8A%94-%EC%82%AC%EB%9E%8C%EC%9D%84-%EC%9C%84%ED%95%9C-%EC%88%9C%EC%84%9C&quot; aria-label=&quot;처음 하는 사람을 위한 순서 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음 하는 사람을 위한 순서&lt;/h2&gt;
&lt;p&gt;내가 다시 처음부터 세팅한다면 순서는 이렇게 잡는다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Ubuntu 설치 때 OpenSSH server를 켠다.&lt;/li&gt;
&lt;li&gt;유선 키보드/마우스/모니터로 첫 부팅과 LAN IP를 확인한다.&lt;/li&gt;
&lt;li&gt;작업용 노트북에서 LAN SSH로 접속한다.&lt;/li&gt;
&lt;li&gt;Docker를 공식 apt repository 방식으로 설치한다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;docker run hello-world&lt;/code&gt;와 &lt;code class=&quot;language-text&quot;&gt;docker compose version&lt;/code&gt;으로 런타임을 확인한다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt; 같은 공용 Docker network를 만든다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;~/infra/caddy&lt;/code&gt;에 공용 Caddy compose를 만들고 host &lt;code class=&quot;language-text&quot;&gt;:80&lt;/code&gt;만 연다.&lt;/li&gt;
&lt;li&gt;Cloudflare Tunnel 또는 DNS/proxy가 어떤 방식으로 origin에 들어오는지 명확히 정한다.&lt;/li&gt;
&lt;li&gt;SSH 접근은 Cloudflare Access/Tunnel 또는 VPN 등 별도 접근 경계로 관리한다.&lt;/li&gt;
&lt;li&gt;앱은 &lt;code class=&quot;language-text&quot;&gt;~/services/&amp;lt;app&gt;&lt;/code&gt; 아래 compose, env, data, secrets로 분리한다.&lt;/li&gt;
&lt;li&gt;공개 앱 컨테이너만 &lt;code class=&quot;language-text&quot;&gt;proxy-net&lt;/code&gt;에 붙이고, DB는 앱 내부 network에 둔다.&lt;/li&gt;
&lt;li&gt;배포는 &lt;code class=&quot;language-text&quot;&gt;docker compose pull &amp;amp;&amp;amp; docker compose up -d&lt;/code&gt;로 표준화한다.&lt;/li&gt;
&lt;li&gt;장애가 나면 &lt;code class=&quot;language-text&quot;&gt;docker compose ps&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;docker logs&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;docker exec infra-caddy wget .../health&lt;/code&gt; 순서로 본다.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;이 순서의 핵심은 처음부터 &quot;여러 서버를 운영할 수 있는 구조&quot;를 만든다는 점이다. 앱 하나만 띄울 때는 대충 포트를 열어도 되지만, 앱이 둘 이상이 되는 순간 공용 entrypoint와 network 경계가 필요해진다.&lt;/p&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;시간이 지나면 홈서버 운영 품질은 경계를 얼마나 잘 나눴는지에서 갈린다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;SSH 접근 경계&lt;/li&gt;
&lt;li&gt;HTTP 진입 경계&lt;/li&gt;
&lt;li&gt;Docker network 경계&lt;/li&gt;
&lt;li&gt;앱 데이터와 secret 경계&lt;/li&gt;
&lt;li&gt;빌드와 런타임 경계&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 경계를 나눠두면 여러 서비스를 한 서버에서 운영해도 구조가 무너지지 않는다. 반대로 처음부터 모든 앱이 host port를 열고, 서버에 repo를 clone해서 직접 빌드하고, Caddy와 앱과 DB가 한 network에 섞이면 작은 장애도 어디서 봐야 할지 흐려진다.&lt;/p&gt;
&lt;p&gt;홈서버는 작은 클라우드처럼 운영할 수 있다. 다만 그렇게 하려면 서버를 노트북처럼 쓰지 않고 런타임 전용 머신으로 대해야 한다.&lt;/p&gt;
&lt;p&gt;AWS나 GCP에서 몇 번의 클릭으로 끝내던 배포 기능이 왜 비싼지 이번에 체감했다. VPC에 해당하는 network 경계, reverse proxy, systemd service, cron, volume, secret, health check를 직접 명령어로 다루다 보니 쉽지는 않았지만, 인프라 운영을 훨씬 구체적으로 이해하게 됐다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/engine/install/ubuntu/&quot;&gt;Docker Docs: Install Docker Engine on Ubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/engine/network/&quot;&gt;Docker Docs: Networking overview&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/compose/how-tos/networking/&quot;&gt;Docker Docs: Networking in Compose&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/&quot;&gt;Cloudflare Docs: Cloudflare Tunnel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/use-cases/ssh/&quot;&gt;Cloudflare Docs: SSH with Cloudflare One&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/directives/reverse_proxy&quot;&gt;Caddy Docs: reverse_proxy directive&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[The Hard Part of AI Landing Page Localization Was Validation]]></title><description><![CDATA[At first, I thought this would be a straightforward i18n task. Take a Korean store landing page, translate it into English, Japanese, and…]]></description><link>https://sewon.dev/en/place2page-ai-landing-localization-quality-gates/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-ai-landing-localization-quality-gates/</guid><pubDate>Sun, 31 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/35ab9035af33ff1cd17f6c3bc772456d/d5c6c/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 56.470588235294116%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACRklEQVR42m3SS0tUYRgH8LOoTxCYUBuhVm76Bn2CWgUF0S4KoUW0aJMbKYI0zVLLBCUGMSKt6MJUGt6b1NIsdXSccU4zZ+bMnOv7nst73vsbI9Ei+vNfPJsfDzw8musjvQJNO647seOhmh1ablSth9V6CAJEGVP/Rv6dNBAQH+IwppxLyjhmAjPBOOdCcN6oUooJSYWiXEq5L6X4g3F5zfzy1P72nFr5idWo81216729XsZ1PVlb9jZXoWvR1Gf3ztvKg09uyaEsKLilaUFgA0tQ4KU5ZiwoZM3qsm+y9nDa26wQq4z1HHYNgZGcLPDBGW9oAZY8KmIdmvOSBg08l/na0TPQNThy6/7g0PAoCHEYxVEUKaXSUzO9j0cGhlN9j54YZVMxIlEsHA8D30exkFK7fL1dO9x8sLVVO9Jy6PiJXcOxbN+oVCEMT54+qzU1H2g5pjUdnXj1muUL+cWM++Mnym5bRkkopY0+e3nq3MXzl66eudDWdu2GAyJKOaGUUjb24k377Z6bd/s7uvv3CkWq/3I2snF+L9jesWtVqZRGGI8QjZJGE8oI40JK9Z8IpbjgBGHEME0IkUpqgROAiuNXnNj2VRhKCCUmSqky8rYCczuoZQOzBJ2lop/ecJaLYUjwRmRW6f61I13Pz80XFzPG0or9fV3kctLzlFLj5mpnNt279aG7MLni6alMciW1d+9jmAvsXn1qzFxpYIExBgADiHw/8YGMIrn/VYAjE0MzATUaEMl2TTS7aa3rQULJjm/W4sbm322qNrTqk7wUAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/35ab9035af33ff1cd17f6c3bc772456d/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/35ab9035af33ff1cd17f6c3bc772456d/e7570/situation-diagram.png 170w,
/static/35ab9035af33ff1cd17f6c3bc772456d/f46e7/situation-diagram.png 340w,
/static/35ab9035af33ff1cd17f6c3bc772456d/ca1dc/situation-diagram.png 680w,
/static/35ab9035af33ff1cd17f6c3bc772456d/02d09/situation-diagram.png 1020w,
/static/35ab9035af33ff1cd17f6c3bc772456d/9d567/situation-diagram.png 1360w,
/static/35ab9035af33ff1cd17f6c3bc772456d/d5c6c/situation-diagram.png 4816w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;At first, I thought this would be a straightforward i18n task. Take a Korean store landing page, translate it into English, Japanese, and Simplified Chinese, then serve those versions under &lt;code class=&quot;language-text&quot;&gt;/en/&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;/ja/&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;/zh-Hans/&lt;/code&gt;. Once I implemented it, the hard part was not calling a translation model. It was validating the result enough to call it a real public page.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: Translating only visible text was not enough when AI-generated HTML became public pages in other languages.&lt;/li&gt;
&lt;li&gt;Decision: Treat body text, metadata, image alt text, JSON-LD, canonical URLs, &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt;, and the language switcher as one public surface.&lt;/li&gt;
&lt;li&gt;Implementation: Attach &lt;code class=&quot;language-text&quot;&gt;landing_localizations&lt;/code&gt; to a published landing version, then send only translatable HTML segments to the model instead of the whole document.&lt;/li&gt;
&lt;li&gt;Validation: Add locale-specific gates for leftover Hangul, leftover English nav/CTA text, and Traditional Chinese characters in &lt;code class=&quot;language-text&quot;&gt;zh-Hans&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Lesson: In AI landing page localization, the hard problem was less &quot;translation&quot; and more &quot;QA that decides whether this page is safe to publish.&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This note follows &lt;a href=&quot;/en/place2page-copy-quality-grounding-rules/&quot;&gt;Treating AI Copy Quality as a Grounding Problem, Not a Forbidden-Words List&lt;/a&gt;. That post was about grounding the original generated copy in real place data. This one is about preserving the same principle when sending that HTML to public URLs in other languages.&lt;/p&gt;
&lt;p&gt;Other Place2Page operations notes are collected in &lt;a href=&quot;/en/series/Place2Page-Engineering-Notes/&quot;&gt;Place2Page Engineering Notes&lt;/a&gt;. I plan to keep expanding that series with records that make the problem, evidence, and changed decision criteria explicit.&lt;/p&gt;
&lt;h2 id=&quot;Verified-Output&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Verified-Output&quot; aria-label=&quot;Verified Output permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Verified Output&lt;/h2&gt;
&lt;p&gt;This work gave one store landing page the following locale-specific public URL shape.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;https://example.place2page.com/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;https://example.place2page.com/en/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;https://example.place2page.com/ja/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;https://example.place2page.com/zh-Hans/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;What I verified here was not &quot;the page was indexed by search engines.&quot; The verified scope was that each public URL returned 200, had the correct locale-specific &lt;code class=&quot;language-text&quot;&gt;html lang&lt;/code&gt;, exposed a language switcher, and included &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt; alternates. Indexing and ranking are decisions made by search engines, so I did not describe them as guaranteed outcomes.&lt;/p&gt;
&lt;h2 id=&quot;The-Problem-Was-The-Public-Surface-Not-Translation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Problem-Was-The-Public-Surface-Not-Translation&quot; aria-label=&quot;The Problem Was The Public Surface Not Translation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Problem Was The Public Surface, Not Translation&lt;/h2&gt;
&lt;p&gt;The initial flow looked simple.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Korean landing HTML
-&gt; call translation model
-&gt; save English/Japanese/Chinese pages
-&gt; serve them under /en, /ja, /zh-Hans&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That structure was too optimistic. A Place2Page landing page is not static HTML written by a person. It is generated from place data, photos, reviews, menus, opening information, and prompt output.&lt;/p&gt;
&lt;p&gt;So the questions multiplied quickly.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is translating only visible text in &lt;code class=&quot;language-text&quot;&gt;&amp;lt;body&gt;&lt;/code&gt; enough?&lt;/li&gt;
&lt;li&gt;Should &lt;code class=&quot;language-text&quot;&gt;&amp;lt;title&gt;&lt;/code&gt; and meta description be in the same language as the page?&lt;/li&gt;
&lt;li&gt;How much of Open Graph, Twitter card, and JSON-LD fields such as &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;description&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;address&lt;/code&gt; should be translated?&lt;/li&gt;
&lt;li&gt;Should image &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt; text remain as-is?&lt;/li&gt;
&lt;li&gt;URL, script, style, and tracking snippets must never change. Is it safe to hand the whole HTML document to a model?&lt;/li&gt;
&lt;li&gt;Is &quot;looks Chinese&quot; enough for &lt;code class=&quot;language-text&quot;&gt;/zh-Hans/&lt;/code&gt;, or does it need to be cleaned up as Simplified Chinese?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Until those questions were answered, this was not really multilingual publishing. It was closer to &quot;send an entire HTML document to a translation model.&quot; That felt too risky for a public page.&lt;/p&gt;
&lt;h2 id=&quot;I-Defined-The-Storage-Boundary-Before-The-URL-Shape&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#I-Defined-The-Storage-Boundary-Before-The-URL-Shape&quot; aria-label=&quot;I Defined The Storage Boundary Before The URL Shape permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;I Defined The Storage Boundary Before The URL Shape&lt;/h2&gt;
&lt;p&gt;The first decision was not URL shape. It was the storage boundary. Place2Page serves public pages based on the published landing version. So localization belongs to a specific landing version, not just to a project.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;project
-&gt; published landing version
-&gt; landing_localizations
   -&gt; en
   -&gt; ja
   -&gt; zh-Hans&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Each &lt;code class=&quot;language-text&quot;&gt;landing_localizations&lt;/code&gt; row stores &lt;code class=&quot;language-text&quot;&gt;project_id&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;landing_id&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;locale&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;rendered_html&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;metadata_json&lt;/code&gt;. The key value here is &lt;code class=&quot;language-text&quot;&gt;landing_id&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If a project publishes a new landing version, old localizations are not automatically reused. Even for the same store, the HTML structure and copy may have changed. Falling back to the default page when a locale row does not exist is safer than attaching an old translation to a new page.&lt;/p&gt;
&lt;p&gt;The public route follows the same rule.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Request
-&gt; validate slug and locale
-&gt; load published project and active landing
-&gt; if a locale row exists for that landing_id, return localized HTML
-&gt; if not, or if the locale is unsupported, redirect to the default public page&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;A locale URL is not just a path alias. It becomes a public surface only when that published landing version has a real localization row and the row contains the metadata required for a public response.&lt;/p&gt;
&lt;h2 id=&quot;I-Did-Not-Translate-The-Whole-HTML-Document&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#I-Did-Not-Translate-The-Whole-HTML-Document&quot; aria-label=&quot;I Did Not Translate The Whole HTML Document permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;I Did Not Translate The Whole HTML Document&lt;/h2&gt;
&lt;p&gt;The second decision was to avoid giving the entire HTML document to the translation model.&lt;/p&gt;
&lt;p&gt;If I send full HTML and ask the model to translate it into English, it will usually produce something plausible. But for a public page, it might modify scripts, change URLs, break attribute quotes, or turn JSON-LD into invalid JSON. An AI translation failure could break the page itself, not just produce weak copy.&lt;/p&gt;
&lt;p&gt;So I parsed the HTML and extracted only translatable segments.&lt;/p&gt;
&lt;p&gt;Translated targets:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;visible text&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;title&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;description, Open Graph, and Twitter metadata&lt;/li&gt;
&lt;li&gt;image &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;title&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;aria-label&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;placeholder&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;text fields inside JSON-LD, such as &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;description&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;headline&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;caption&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;address&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Non-translated targets:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;script&lt;/li&gt;
&lt;li&gt;style&lt;/li&gt;
&lt;li&gt;URL&lt;/li&gt;
&lt;li&gt;image &lt;code class=&quot;language-text&quot;&gt;src&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;structural HTML&lt;/li&gt;
&lt;li&gt;tracking code&lt;/li&gt;
&lt;li&gt;values required for map/provider integrations&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The model received only segment id, kind, context, and source text. The response was JSON mapping, not HTML.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;translations&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;text:0&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;A quiet pasta bar near the station&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;attr:3&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Photo of the signature pasta set&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;jsonld:5&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Italian restaurant in Seoul&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Instead of asking the model to rewrite HTML, I made the editable pieces explicit.&lt;/p&gt;
&lt;h2 id=&quot;Metadata-And-The-Normalizer-Were-Also-Part-Of-The-Page&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Metadata-And-The-Normalizer-Were-Also-Part-Of-The-Page&quot; aria-label=&quot;Metadata And The Normalizer Were Also Part Of The Page permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Metadata And The Normalizer Were Also Part Of The Page&lt;/h2&gt;
&lt;p&gt;At first, body text got most of my attention. But on a public page, metadata is part of the page. Users may not directly read &lt;code class=&quot;language-text&quot;&gt;&amp;lt;title&gt;&lt;/code&gt; or Open Graph tags, but search results, share cards, crawlers, and structured data do.&lt;/p&gt;
&lt;p&gt;So metadata and JSON-LD text fields also became translation targets. Structural values such as &lt;code class=&quot;language-text&quot;&gt;url&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;@context&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;@type&lt;/code&gt; were preserved. Only natural-language fields such as names, descriptions, and addresses became segments.&lt;/p&gt;
&lt;p&gt;Stored localized HTML was not returned as-is. Right before the public response, it went through the HTML normalizer again.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;canonical URL&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt; alternate links&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;x-default&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;html lang&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;favicon&lt;/li&gt;
&lt;li&gt;site name metadata&lt;/li&gt;
&lt;li&gt;visible language switcher&lt;/li&gt;
&lt;li&gt;public page responsive guard&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, the default page and localized page need different canonical URLs.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;canonical&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://example.place2page.com/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;canonical&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://example.place2page.com/en/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Only locales with actual rows were exposed as alternates. If a Japanese row does not exist yet, putting &lt;code class=&quot;language-text&quot;&gt;/ja/&lt;/code&gt; in &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt; would tell crawlers about a page that is not actually available.&lt;/p&gt;
&lt;h2 id=&quot;QA-Had-To-Be-Locale-Specific&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#QA-Had-To-Be-Locale-Specific&quot; aria-label=&quot;QA Had To Be Locale Specific permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;QA Had To Be Locale-Specific&lt;/h2&gt;
&lt;p&gt;A successful response from a translation model does not mean localization succeeded. The most dangerous failure is the kind that looks mostly fine at a glance: a few source-language or wrong-language fragments remain, while the page still feels localized overall.&lt;/p&gt;
&lt;p&gt;So I split the quality gates by locale.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;en
-&gt; fail if translated segments still contain Hangul

ja
-&gt; fail if kana presence is too low
-&gt; fail if English nav, CTA, or hero copy remains

zh-Hans
-&gt; fail if Han script presence is too low
-&gt; fail if English nav, CTA, or hero copy remains
-&gt; fail if common Traditional Chinese characters remain in a Simplified Chinese page&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For &lt;code class=&quot;language-text&quot;&gt;zh-Hans&lt;/code&gt;, &quot;looks Chinese&quot; was not enough. If Traditional Chinese characters are mixed into a Simplified Chinese URL, users will notice immediately.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;鷺梁津  -&gt; includes Traditional Chinese characters
鹭梁津  -&gt; expected form for a Simplified Chinese page&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;These checks are not perfect language-quality evaluation. They are guardrails against obvious failures that should not reach production.&lt;/p&gt;
&lt;p&gt;Exceptions were necessary. Brand names, Instagram handles, reviewer handles, currency labels, and text around URLs can naturally remain in Latin characters. On the other hand, words such as &lt;code class=&quot;language-text&quot;&gt;Menu&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Story&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Book Now&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;Get Directions&lt;/code&gt; look like nav or CTA copy and should not remain.&lt;/p&gt;
&lt;p&gt;The quality gate should behave like a production blocker, not a language critic.&lt;/p&gt;
&lt;h2 id=&quot;The-Language-Switcher-And-Sitemap-Followed-The-Same-Rule&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Language-Switcher-And-Sitemap-Followed-The-Same-Rule&quot; aria-label=&quot;The Language Switcher And Sitemap Followed The Same Rule permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Language Switcher And Sitemap Followed The Same Rule&lt;/h2&gt;
&lt;p&gt;A language switcher looks like a small UI element, but on a public page it is also a crawler surface. So I inserted real &lt;code class=&quot;language-text&quot;&gt;&amp;lt;a&gt;&lt;/code&gt; links inside a &lt;code class=&quot;language-text&quot;&gt;&amp;lt;nav&gt;&lt;/code&gt;, not a client-side-only script.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;nav&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;data-p2p-language-switcher&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Language selector&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://example.place2page.com/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;hreflang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ko-KR&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ko&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    한국어
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://example.place2page.com/en/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;hreflang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    English
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For users, this is a language switcher. For crawlers, it is an internal link through which locale URLs can be discovered. The current language receives &lt;code class=&quot;language-text&quot;&gt;aria-current=&quot;page&quot;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The sitemap followed the same principle. It included only locale rows that actually existed for the current published landing, not every theoretically supported locale.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;published landing
-&gt; existing localization rows
-&gt; sitemap URL entries
-&gt; xhtml:link locale alternates&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;robots.txt&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;sitemap.xml&lt;/code&gt;, canonical, &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt;, and IndexNow requests are discovery and freshness signals. They do not guarantee immediate indexing or search exposure.&lt;/p&gt;
&lt;h2 id=&quot;Verified-Scope&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Verified-Scope&quot; aria-label=&quot;Verified Scope permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Verified Scope&lt;/h2&gt;
&lt;p&gt;I separated local validation, deploy validation, and production checks.&lt;/p&gt;
&lt;p&gt;Locally, I first passed &lt;code class=&quot;language-text&quot;&gt;ruff check&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;tests/test_landing_localization_service.py&lt;/code&gt;. The point was not to score translation quality. It was to make sure HTML segment extraction and locale-specific guardrails did not break.&lt;/p&gt;
&lt;p&gt;After CI/CD passed and the production deploy completed, I checked the public URLs.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;https://example.place2page.com/en/
-&gt; 200
-&gt; &amp;lt;html lang=&quot;en&quot;&gt;
-&gt; language switcher present
-&gt; hreflang alternates present
-&gt; Hangul residual 0

https://example.place2page.com/ja/
-&gt; 200
-&gt; &amp;lt;html lang=&quot;ja&quot;&gt;
-&gt; language switcher present
-&gt; hreflang alternates present
-&gt; Hangul residual 0

https://example.place2page.com/zh-Hans/
-&gt; 200
-&gt; &amp;lt;html lang=&quot;zh-Hans&quot;&gt;
-&gt; language switcher present
-&gt; hreflang alternates present
-&gt; Hangul residual 0
-&gt; English nav/CTA residual blocked
-&gt; Traditional Chinese probe blocked

https://example.place2page.com/fr/
-&gt; root fallback&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Again, this does not prove that the translation is literary or native-level. It verifies that the implementation blocks failure modes that should not be published.&lt;/p&gt;
&lt;h2 id=&quot;Remaining-Limits&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Remaining-Limits&quot; aria-label=&quot;Remaining Limits permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Remaining Limits&lt;/h2&gt;
&lt;p&gt;This work made multilingual public pages operational, but it is not the complete product experience yet.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Operator UI for triggering locale generation&lt;/li&gt;
&lt;li&gt;Per-locale generation progress and failure reasons&lt;/li&gt;
&lt;li&gt;An editor where a person can polish final copy&lt;/li&gt;
&lt;li&gt;Screenshot or visual regression QA by language&lt;/li&gt;
&lt;li&gt;A workflow for marking pages that need native-speaker review&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Automated quality gates do not replace native review. But they prevent failures such as &quot;an English page with leftover Korean,&quot; &quot;a Chinese page with leftover English CTAs,&quot; and &quot;a Simplified Chinese URL with Traditional Chinese characters&quot; from going straight to production.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Will-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Will-Judge-This-Next-Time&quot; aria-label=&quot;How I Will Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Will Judge This Next Time&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Treat AI localization first as public-surface validation, not as a translation-call problem.&lt;/li&gt;
&lt;li&gt;Check that body text, metadata, JSON-LD, canonical, &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt;, and the language switcher all point to the same locale.&lt;/li&gt;
&lt;li&gt;Do not give the whole HTML document to the model. Send only segments that are allowed to change.&lt;/li&gt;
&lt;li&gt;Do not expose a locale in URLs, switchers, sitemaps, or &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt; unless it actually exists.&lt;/li&gt;
&lt;li&gt;Do not mix &quot;we sent search engine signals&quot; with actual indexing or ranking outcomes.&lt;/li&gt;
&lt;li&gt;Automated QA is not native review. It is a production blocker for failures that obviously should not go public.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.google.com/search/docs/specialty/international/localized-versions&quot;&gt;Google Search Central: Tell Google about localized versions of your page&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/lang&quot;&gt;MDN: HTML lang global attribute&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[AI 랜딩페이지 현지화의 진짜 문제는 검증이었다]]></title><description><![CDATA[처음에는 단순한 i18n 작업이라고 생각했다. 한국어로 잘 만들어진 매장 랜딩을 영어, 일본어, 중국어 간체로 번역해서 , , 에 붙이면 된다고 봤다. 막상 구현해보니 어려운 부분은 번역 호출이 아니라 그 결과를 실제 public page…]]></description><link>https://sewon.dev/place2page-ai-landing-localization-quality-gates/</link><guid isPermaLink="false">https://sewon.dev/place2page-ai-landing-localization-quality-gates/</guid><pubDate>Sun, 31 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/35ab9035af33ff1cd17f6c3bc772456d/d5c6c/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 56.470588235294116%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACRklEQVR42m3SS0tUYRgH8LOoTxCYUBuhVm76Bn2CWgUF0S4KoUW0aJMbKYI0zVLLBCUGMSKt6MJUGt6b1NIsdXSccU4zZ+bMnOv7nst73vsbI9Ei+vNfPJsfDzw8musjvQJNO647seOhmh1ablSth9V6CAJEGVP/Rv6dNBAQH+IwppxLyjhmAjPBOOdCcN6oUooJSYWiXEq5L6X4g3F5zfzy1P72nFr5idWo81216729XsZ1PVlb9jZXoWvR1Gf3ztvKg09uyaEsKLilaUFgA0tQ4KU5ZiwoZM3qsm+y9nDa26wQq4z1HHYNgZGcLPDBGW9oAZY8KmIdmvOSBg08l/na0TPQNThy6/7g0PAoCHEYxVEUKaXSUzO9j0cGhlN9j54YZVMxIlEsHA8D30exkFK7fL1dO9x8sLVVO9Jy6PiJXcOxbN+oVCEMT54+qzU1H2g5pjUdnXj1muUL+cWM++Mnym5bRkkopY0+e3nq3MXzl66eudDWdu2GAyJKOaGUUjb24k377Z6bd/s7uvv3CkWq/3I2snF+L9jesWtVqZRGGI8QjZJGE8oI40JK9Z8IpbjgBGHEME0IkUpqgROAiuNXnNj2VRhKCCUmSqky8rYCczuoZQOzBJ2lop/ecJaLYUjwRmRW6f61I13Pz80XFzPG0or9fV3kctLzlFLj5mpnNt279aG7MLni6alMciW1d+9jmAvsXn1qzFxpYIExBgADiHw/8YGMIrn/VYAjE0MzATUaEMl2TTS7aa3rQULJjm/W4sbm322qNrTqk7wUAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/35ab9035af33ff1cd17f6c3bc772456d/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/35ab9035af33ff1cd17f6c3bc772456d/e7570/situation-diagram.png 170w,
/static/35ab9035af33ff1cd17f6c3bc772456d/f46e7/situation-diagram.png 340w,
/static/35ab9035af33ff1cd17f6c3bc772456d/ca1dc/situation-diagram.png 680w,
/static/35ab9035af33ff1cd17f6c3bc772456d/02d09/situation-diagram.png 1020w,
/static/35ab9035af33ff1cd17f6c3bc772456d/9d567/situation-diagram.png 1360w,
/static/35ab9035af33ff1cd17f6c3bc772456d/d5c6c/situation-diagram.png 4816w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;처음에는 단순한 i18n 작업이라고 생각했다. 한국어로 잘 만들어진 매장 랜딩을 영어, 일본어, 중국어 간체로 번역해서 &lt;code class=&quot;language-text&quot;&gt;/en/&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;/ja/&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;/zh-Hans/&lt;/code&gt;에 붙이면 된다고 봤다. 막상 구현해보니 어려운 부분은 번역 호출이 아니라 그 결과를 실제 public page라고 말할 수 있을 만큼 검증하는 일이었다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: AI가 만든 HTML을 다른 언어 URL로 내보낼 때 visible text만 번역하면 public page로는 부족했다.&lt;/li&gt;
&lt;li&gt;판단: body, metadata, 이미지 alt, JSON-LD, canonical, &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt;, language switcher를 하나의 public surface로 봤다.&lt;/li&gt;
&lt;li&gt;구현: &lt;code class=&quot;language-text&quot;&gt;landing_localizations&lt;/code&gt;를 published landing version에 묶고, HTML 전체가 아니라 번역 가능한 segment만 모델에게 넘겼다.&lt;/li&gt;
&lt;li&gt;검증: locale별로 한글 잔여, 영어 nav/CTA 잔여, &lt;code class=&quot;language-text&quot;&gt;zh-Hans&lt;/code&gt;의 번체 혼입을 따로 막았다.&lt;/li&gt;
&lt;li&gt;배운 점: AI 랜딩페이지 현지화에서 진짜 어려운 부분은 &quot;번역&quot;보다 &quot;이 페이지를 공개해도 되는지 판단하는 QA&quot;였다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 글은 앞서 쓴 &lt;a href=&quot;/place2page-copy-quality-grounding-rules/&quot;&gt;AI 마케팅 문구를 덜 AI처럼 만들기&lt;/a&gt;와 이어진다. 그 글이 원문 생성 단계에서 데이터에 근거한 문장을 만들자는 기록이었다면, 이번 글은 그 HTML을 다른 언어의 공개 URL로 내보낼 때 같은 원칙을 어떻게 지켰는지에 가깝다.&lt;/p&gt;
&lt;p&gt;Place2Page의 다른 운영 기록은 &lt;a href=&quot;/series/Place2Page-Engineering-Notes/&quot;&gt;Place2Page Engineering Notes&lt;/a&gt;에 모아두었다. 이 글처럼 문제, 확인한 증거, 바뀐 판단 기준이 분명한 기록을 우선해서 이어갈 생각이다.&lt;/p&gt;
&lt;h2 id=&quot;확인한-산출물&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%95%EC%9D%B8%ED%95%9C-%EC%82%B0%EC%B6%9C%EB%AC%BC&quot; aria-label=&quot;확인한 산출물 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;확인한 산출물&lt;/h2&gt;
&lt;p&gt;이번 작업의 결과로 한 매장 랜딩은 아래와 같은 locale별 public URL 구조를 갖게 됐다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;https://example.place2page.com/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;https://example.place2page.com/en/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;https://example.place2page.com/ja/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;https://example.place2page.com/zh-Hans/&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;여기서 확인한 것은 &quot;검색엔진에 색인됐다&quot;가 아니다. 확인 범위는 public URL이 200으로 응답하고, locale별 &lt;code class=&quot;language-text&quot;&gt;html lang&lt;/code&gt;, language switcher, &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt; alternate가 붙어 있다는 점이다. 색인과 노출은 검색엔진이 결정하는 영역이라 보장처럼 쓰지 않았다.&lt;/p&gt;
&lt;h2 id=&quot;번역보다-public-surface가-문제였다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B2%88%EC%97%AD%EB%B3%B4%EB%8B%A4-public-surface%EA%B0%80-%EB%AC%B8%EC%A0%9C%EC%98%80%EB%8B%A4&quot; aria-label=&quot;번역보다 public surface가 문제였다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;번역보다 public surface가 문제였다&lt;/h2&gt;
&lt;p&gt;처음 생각한 흐름은 단순했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;한국어 랜딩 HTML
-&gt; 번역 모델 호출
-&gt; 영어/일본어/중국어 페이지 저장
-&gt; /en, /ja, /zh-Hans 로 서빙&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 구조는 너무 낙관적이었다. Place2Page의 랜딩은 사람이 직접 작성한 정적 HTML이 아니라 장소 데이터, 사진, 리뷰, 메뉴, 영업 정보, 프롬프트 결과가 합쳐진 AI 생성 HTML이다.&lt;/p&gt;
&lt;p&gt;그래서 곧 질문이 늘어났다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;body&gt;&lt;/code&gt;에 보이는 텍스트만 번역하면 되는가&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;title&gt;&lt;/code&gt;과 meta description은 본문과 같은 언어여야 하지 않나&lt;/li&gt;
&lt;li&gt;Open Graph, Twitter card, JSON-LD 안의 &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;description&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;address&lt;/code&gt;는 어디까지 번역해야 하나&lt;/li&gt;
&lt;li&gt;이미지 &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt;는 그대로 두면 되는가&lt;/li&gt;
&lt;li&gt;URL, script, style, tracking snippet은 절대 바뀌면 안 되는데 HTML 전체를 모델에게 맡겨도 괜찮나&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;/zh-Hans/&lt;/code&gt;가 중국어처럼 보이는 것과 간체로 충분히 정리된 것은 같은 말인가&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 질문을 풀기 전까지는 다국어 기능이 아니라 &quot;HTML을 번역 모델에게 통째로 맡기는 기능&quot;에 가까웠다. public page에 그렇게 내보내기에는 불안했다.&lt;/p&gt;
&lt;h2 id=&quot;URL보다-저장-경계를-먼저-정했다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#URL%EB%B3%B4%EB%8B%A4-%EC%A0%80%EC%9E%A5-%EA%B2%BD%EA%B3%84%EB%A5%BC-%EB%A8%BC%EC%A0%80-%EC%A0%95%ED%96%88%EB%8B%A4&quot; aria-label=&quot;URL보다 저장 경계를 먼저 정했다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;URL보다 저장 경계를 먼저 정했다&lt;/h2&gt;
&lt;p&gt;첫 번째로 정한 것은 URL 모양이 아니라 저장 경계였다. Place2Page는 공개 페이지를 published landing version 기준으로 서비스한다. 그래서 localization도 project 전체에 붙이지 않고 특정 landing version에 붙였다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;project
-&gt; published landing version
-&gt; landing_localizations
   -&gt; en
   -&gt; ja
   -&gt; zh-Hans&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;landing_localizations&lt;/code&gt; row는 &lt;code class=&quot;language-text&quot;&gt;project_id&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;landing_id&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;locale&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;rendered_html&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;metadata_json&lt;/code&gt;을 가진다. 여기서 중요한 값은 &lt;code class=&quot;language-text&quot;&gt;landing_id&lt;/code&gt;였다.&lt;/p&gt;
&lt;p&gt;프로젝트가 새 landing version을 publish하면 예전 localization을 자동으로 재사용하지 않는다. 같은 매장이라도 HTML 구조와 문구가 달라졌을 수 있기 때문이다. 오래된 번역을 새 페이지에 붙이는 것보다 해당 locale이 없으면 기본 페이지로 돌리는 쪽이 더 안전했다.&lt;/p&gt;
&lt;p&gt;public route도 같은 원칙을 따르게 했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Request
-&gt; slug와 locale 검증
-&gt; published project와 active landing 조회
-&gt; 해당 landing_id에 locale row가 있으면 localized HTML 응답
-&gt; 없거나 지원하지 않는 locale이면 default public page로 redirect&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;locale URL은 단순한 path alias가 아니었다. 특정 published landing version에 실제 localization row가 있고, 그 row가 public response에 필요한 metadata까지 갖췄을 때만 공개 surface가 된다.&lt;/p&gt;
&lt;h2 id=&quot;HTML-전체를-번역하지-않았다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#HTML-%EC%A0%84%EC%B2%B4%EB%A5%BC-%EB%B2%88%EC%97%AD%ED%95%98%EC%A7%80-%EC%95%8A%EC%95%98%EB%8B%A4&quot; aria-label=&quot;HTML 전체를 번역하지 않았다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;HTML 전체를 번역하지 않았다&lt;/h2&gt;
&lt;p&gt;두 번째 결정은 번역 모델에게 HTML 문서 전체를 맡기지 않는 것이었다.&lt;/p&gt;
&lt;p&gt;HTML 전체를 &quot;영어로 번역해줘&quot;라고 넘기면 모델은 그럴듯한 결과를 만든다. 하지만 public page에서는 script가 바뀌거나, URL이 바뀌거나, attribute quote가 깨지거나, JSON-LD가 invalid JSON이 될 수 있다. AI 번역 실패가 copy 품질 문제에서 끝나지 않고 페이지 자체를 깨뜨릴 수 있다.&lt;/p&gt;
&lt;p&gt;그래서 HTML을 parsing해서 번역 가능한 segment만 뽑았다.&lt;/p&gt;
&lt;p&gt;번역 대상으로 본 것:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;visible text&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;&amp;lt;title&gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;description, OG, Twitter metadata&lt;/li&gt;
&lt;li&gt;이미지 &lt;code class=&quot;language-text&quot;&gt;alt&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;title&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;aria-label&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;placeholder&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;JSON-LD 안의 &lt;code class=&quot;language-text&quot;&gt;name&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;description&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;headline&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;caption&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;address&lt;/code&gt; 같은 text field&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;번역하지 않은 것:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;script&lt;/li&gt;
&lt;li&gt;style&lt;/li&gt;
&lt;li&gt;URL&lt;/li&gt;
&lt;li&gt;image &lt;code class=&quot;language-text&quot;&gt;src&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;structural HTML&lt;/li&gt;
&lt;li&gt;tracking code&lt;/li&gt;
&lt;li&gt;map/provider integration에 필요한 값&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;모델에게는 segment id, kind, context, 원문 text만 보냈다. 응답도 HTML이 아니라 JSON mapping으로 받았다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;translations&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;text:0&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;A quiet pasta bar near the station&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;attr:3&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Photo of the signature pasta set&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;jsonld:5&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Italian restaurant in Seoul&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;모델에게 HTML을 다시 쓰게 하지 않고, 모델이 바꿔도 되는 조각만 명시했다.&lt;/p&gt;
&lt;h2 id=&quot;Metadata와-normalizer도-page의-일부였다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Metadata%EC%99%80-normalizer%EB%8F%84-page%EC%9D%98-%EC%9D%BC%EB%B6%80%EC%98%80%EB%8B%A4&quot; aria-label=&quot;Metadata와 normalizer도 page의 일부였다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Metadata와 normalizer도 page의 일부였다&lt;/h2&gt;
&lt;p&gt;처음에는 본문 텍스트에 더 신경이 갔다. 그런데 public page에서는 metadata도 페이지다. 사용자는 &lt;code class=&quot;language-text&quot;&gt;&amp;lt;title&gt;&lt;/code&gt;이나 Open Graph tag를 직접 보지 않지만, 검색 결과, 공유 카드, crawler, 구조화 데이터는 이 값을 본다.&lt;/p&gt;
&lt;p&gt;그래서 metadata와 JSON-LD text field도 번역 대상에 포함했다. 단, &lt;code class=&quot;language-text&quot;&gt;url&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;@context&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;@type&lt;/code&gt; 같은 구조 값은 보존했다. 이름, 설명, 주소처럼 자연어인 field만 segment로 뽑았다.&lt;/p&gt;
&lt;p&gt;저장된 localized HTML도 그대로 응답하지 않았다. public response 직전에 HTML normalizer를 한 번 더 태웠다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;canonical URL&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt; alternate links&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;x-default&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;html lang&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;favicon&lt;/li&gt;
&lt;li&gt;site name metadata&lt;/li&gt;
&lt;li&gt;visible language switcher&lt;/li&gt;
&lt;li&gt;public page responsive guard&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;예를 들어 default page와 localized page는 canonical이 달라야 한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;canonical&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://example.place2page.com/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;link&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;rel&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;canonical&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://example.place2page.com/en/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그리고 locale row가 실제로 존재하는 언어만 alternate로 노출했다. 아직 일본어 row가 없는데 &lt;code class=&quot;language-text&quot;&gt;/ja/&lt;/code&gt;를 &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt;에 넣으면 crawler에게 없는 페이지를 알려주는 꼴이 된다.&lt;/p&gt;
&lt;h2 id=&quot;QA는-언어별로-달라야-했다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#QA%EB%8A%94-%EC%96%B8%EC%96%B4%EB%B3%84%EB%A1%9C-%EB%8B%AC%EB%9D%BC%EC%95%BC-%ED%96%88%EB%8B%A4&quot; aria-label=&quot;QA는 언어별로 달라야 했다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;QA는 언어별로 달라야 했다&lt;/h2&gt;
&lt;p&gt;번역 모델이 성공 응답을 줬다고 localization이 성공한 것은 아니다. 가장 위험한 실패는 &quot;대충 보면 괜찮아 보이는 실패&quot;였다. 몇 군데에 원문이나 다른 언어가 남아 있는데도 전체적으로는 현지화된 것처럼 보이는 경우다.&lt;/p&gt;
&lt;p&gt;그래서 locale별 품질 게이트를 나눴다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;en
-&gt; translated segment에 Hangul이 남아 있으면 실패

ja
-&gt; kana가 너무 적으면 실패
-&gt; 일본어/한자가 없는 영어 nav, CTA, hero copy가 남으면 실패

zh-Hans
-&gt; Han script가 너무 적으면 실패
-&gt; 영어 nav, CTA, hero copy가 남으면 실패
-&gt; 간체 페이지에 자주 보이는 번체 문자가 남으면 실패&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;특히 &lt;code class=&quot;language-text&quot;&gt;zh-Hans&lt;/code&gt;는 &quot;중국어처럼 보이는가&quot;만으로 부족했다. 간체 URL에 번체가 섞이면 사용자는 바로 어색함을 느낀다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;鷺梁津  -&gt; 번체가 섞인 표기
鹭梁津  -&gt; 간체 페이지에서 기대한 표기&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 검사는 완벽한 언어 품질 평가가 아니다. 대신 production으로 내보내면 안 되는 명백한 실패를 막는 guardrail이다.&lt;/p&gt;
&lt;p&gt;예외도 필요했다. 브랜드명, 인스타그램 handle, reviewer handle, 통화 단위, URL 주변 text는 라틴 문자열로 남는 것이 자연스러울 수 있다. 반대로 &lt;code class=&quot;language-text&quot;&gt;Menu&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Story&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Location&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Book Now&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Get Directions&lt;/code&gt;처럼 nav나 CTA로 보이는 단어는 남기지 않도록 했다.&lt;/p&gt;
&lt;p&gt;품질 게이트는 언어 감정가가 아니라 production 차단기여야 했다.&lt;/p&gt;
&lt;h2 id=&quot;Language-switcher와-sitemap도-같은-기준을-따랐다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Language-switcher%EC%99%80-sitemap%EB%8F%84-%EA%B0%99%EC%9D%80-%EA%B8%B0%EC%A4%80%EC%9D%84-%EB%94%B0%EB%9E%90%EB%8B%A4&quot; aria-label=&quot;Language switcher와 sitemap도 같은 기준을 따랐다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Language switcher와 sitemap도 같은 기준을 따랐다&lt;/h2&gt;
&lt;p&gt;언어 전환은 작은 UI처럼 보이지만 public page에서는 crawler surface이기도 하다. 그래서 client-side script가 아니라 &lt;code class=&quot;language-text&quot;&gt;&amp;lt;nav&gt;&lt;/code&gt; 안의 실제 &lt;code class=&quot;language-text&quot;&gt;&amp;lt;a&gt;&lt;/code&gt; 링크로 넣었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;html&quot;&gt;&lt;pre class=&quot;language-html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;nav&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;data-p2p-language-switcher&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-label&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;Language selector&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://example.place2page.com/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;hreflang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ko-KR&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;ko&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    한국어
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;https://example.place2page.com/en/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;hreflang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;lang&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;en&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
    English
  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;nav&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;사용자에게는 전환 버튼이고, crawler에게는 locale URL을 발견할 수 있는 내부 링크다. 현재 언어에는 &lt;code class=&quot;language-text&quot;&gt;aria-current=&quot;page&quot;&lt;/code&gt;를 붙였다.&lt;/p&gt;
&lt;p&gt;sitemap도 같은 기준을 따랐다. 지원 가능한 locale 목록이 아니라, 현재 published landing에 실제 row가 있는 locale만 넣었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;published landing
-&gt; existing localization rows
-&gt; sitemap URL entries
-&gt; xhtml:link locale alternates&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;robots.txt&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;sitemap.xml&lt;/code&gt;, canonical, &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt;, IndexNow 요청은 발견과 갱신 신호다. 즉시 색인이나 검색 노출을 보장하지는 않는다.&lt;/p&gt;
&lt;h2 id=&quot;검증한-범위&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%80%EC%A6%9D%ED%95%9C-%EB%B2%94%EC%9C%84&quot; aria-label=&quot;검증한 범위 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;검증한 범위&lt;/h2&gt;
&lt;p&gt;검증은 로컬, 배포, 운영 확인을 분리했다.&lt;/p&gt;
&lt;p&gt;로컬에서는 &lt;code class=&quot;language-text&quot;&gt;ruff check&lt;/code&gt;와 &lt;code class=&quot;language-text&quot;&gt;tests/test_landing_localization_service.py&lt;/code&gt;를 먼저 통과시켰다. 목적은 번역 모델 품질을 점수화하는 것이 아니라, HTML segment 추출과 locale별 guardrail이 깨지지 않았는지 확인하는 것이었다.&lt;/p&gt;
&lt;p&gt;그 다음 CI/CD가 성공하고 production deploy가 끝난 뒤 public URL을 확인했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;https://example.place2page.com/en/
-&gt; 200
-&gt; &amp;lt;html lang=&quot;en&quot;&gt;
-&gt; language switcher present
-&gt; hreflang alternates present
-&gt; Hangul residual 0

https://example.place2page.com/ja/
-&gt; 200
-&gt; &amp;lt;html lang=&quot;ja&quot;&gt;
-&gt; language switcher present
-&gt; hreflang alternates present
-&gt; Hangul residual 0

https://example.place2page.com/zh-Hans/
-&gt; 200
-&gt; &amp;lt;html lang=&quot;zh-Hans&quot;&gt;
-&gt; language switcher present
-&gt; hreflang alternates present
-&gt; Hangul residual 0
-&gt; English nav/CTA residual blocked
-&gt; Traditional Chinese probe blocked

https://example.place2page.com/fr/
-&gt; root fallback&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;다시 말하지만 이것은 &quot;번역이 문학적으로 훌륭하다&quot;는 검증이 아니다. &quot;public page로 내보내면 안 되는 형태의 실패는 막았다&quot;는 검증이다.&lt;/p&gt;
&lt;h2 id=&quot;남은-한계&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%82%A8%EC%9D%80-%ED%95%9C%EA%B3%84&quot; aria-label=&quot;남은 한계 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;남은 한계&lt;/h2&gt;
&lt;p&gt;이번 작업은 다국어 public page를 운영 가능한 수준으로 만드는 것이었다. 하지만 아직 제품적으로 끝난 기능은 아니다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;관리자 UI에서 locale generation을 실행하는 화면&lt;/li&gt;
&lt;li&gt;locale별 generation progress와 실패 사유 표시&lt;/li&gt;
&lt;li&gt;사람이 최종 copy를 고칠 수 있는 editor&lt;/li&gt;
&lt;li&gt;언어별 screenshot/visual regression QA&lt;/li&gt;
&lt;li&gt;native speaker review가 필요한 페이지를 표시하는 workflow&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;자동 품질 게이트는 native review를 대체하지 않는다. 다만 &quot;한글이 남아 있는 영어 페이지&quot;, &quot;영어 CTA가 남아 있는 중국어 페이지&quot;, &quot;간체 URL에 번체가 섞인 페이지&quot; 같은 실패를 production에 그대로 내보내지 않게 해준다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;AI 현지화는 번역 호출보다 public surface 검증 문제로 먼저 본다.&lt;/li&gt;
&lt;li&gt;body text, metadata, JSON-LD, canonical, &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt;, language switcher가 같은 locale을 가리키는지 확인한다.&lt;/li&gt;
&lt;li&gt;HTML 전체를 모델에게 맡기지 않고, 바꿔도 되는 segment만 넘긴다.&lt;/li&gt;
&lt;li&gt;없는 locale은 URL, switcher, sitemap, &lt;code class=&quot;language-text&quot;&gt;hreflang&lt;/code&gt; 어디에도 노출하지 않는다.&lt;/li&gt;
&lt;li&gt;검색엔진 신호를 보냈다는 사실과 실제 indexing/ranking 결과를 섞어 말하지 않는다.&lt;/li&gt;
&lt;li&gt;자동 QA는 native review가 아니라 production 차단기다. 명백히 공개하면 안 되는 실패부터 막는다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://developers.google.com/search/docs/specialty/international/localized-versions&quot;&gt;Google Search Central: Tell Google about localized versions of your page&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/lang&quot;&gt;MDN: HTML lang global attribute&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Stopping Scanner Requests Seen in Sentry Profiles at Caddy]]></title><description><![CDATA[When repeated , , , and SQL dump probes showed up in Sentry Profiles, the easiest first move was to hide them in Sentry. But that only…]]></description><link>https://sewon.dev/en/caddy-sensitive-probe-blocklist-sentry-profiles/</link><guid isPermaLink="false">https://sewon.dev/en/caddy-sensitive-probe-blocklist-sentry-profiles/</guid><pubDate>Fri, 29 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/6a1db9ce4ea159c81a35e5228e2af861/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACu0lEQVR42lXSX0gTcQAH8IPe9SGomahZy0wrw/w7x5JykllGkhSh5mMF/aEUIjAjM/APpQ9GJvUQ9FQPiZGk0WxTkxDScNttu93mbrs/3ububnfe7e5+9wuLiL58Xr8PX/giazEhQgo4wa1F+bUYj60l2Q05SovBCB9jRILaQjISQUkxZpOJy3R8M0JJvKhCCBFNNzQANB3owNB0Q9WAJKcFUeYEWRDTvKjwoiKIiqLqmmr8BrS0AXS4VX71+u29B0M9fcM9j0e6e58MDL/gBRFCaKj8XxwEimHAZSk6y/ldHObiMAfvDysJpKbxwvbiMlNxpamgcoe5PP/IMV8wAnWODU8liJlE9PN66KPELhPcxpuNpVHK1b88+RT9NBqfcwpBpK69I9tu29Nkzz9Vl1NmLay2o/4glEg6POV3T/pWJ3HvhJJc0Qz4fTM6IwamGPd0Ap0RMUxJICea27NKqndX1uaV23IP1BSV1aMeH1RoTVjgqdmN2Jc05wKix+BSkKK1SFQnKT1G6hECcjxSf/ay+WBtUan9cEVDTqElp7AGC0Wodcb5dXpxwbH4zTHvnHF7VkGSA1iAXfnpdjj9c/Oi22OQJHLtdo+t4WJdU+vJ5o4ae0vdmVaWTV66egfJK8gsrcgwH92WWXjIcjrFpyDNyHg4iWJJb0DGQkY8gQAADMOAfwMAgBB2D46Un2s+3tZe29Ja1Xi+7UqnIisqT0jrPi0ZhKkw4DAgJxCaYYfGXg48Hx98Nj4wOt4/MjY4Mn6/b/hmV++Nzt7rXQ9v3X3U2d0fjRA86cQ97wjfBBX8QGPvBWYFWfqxmlVt3VllybJZTeUWk7nCtLcya19V9n7LH7lF1oxdJQ7XIoSqnKJViU2L62mR0VURSauqDw+hARzFQyiGo34cDeBef9Dr+8+mrGw959++rYf9Ao/BCd1OHLLmAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Situation diagram&apos; title=&apos;&apos; src=&apos;/static/6a1db9ce4ea159c81a35e5228e2af861/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/6a1db9ce4ea159c81a35e5228e2af861/e7570/situation-diagram.png 170w,
/static/6a1db9ce4ea159c81a35e5228e2af861/f46e7/situation-diagram.png 340w,
/static/6a1db9ce4ea159c81a35e5228e2af861/ca1dc/situation-diagram.png 680w,
/static/6a1db9ce4ea159c81a35e5228e2af861/02d09/situation-diagram.png 1020w,
/static/6a1db9ce4ea159c81a35e5228e2af861/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Situation diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;When repeated &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;credentials&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;actuator&lt;/code&gt;, and SQL dump probes showed up in Sentry Profiles, the easiest first move was to hide them in Sentry. But that only quiets the dashboard. The requests still reach the app container. So the standard for this change was not &quot;build a security appliance.&quot; It was &quot;end obvious scanner traffic at the reverse proxy, while verifying normal routes and exception policy.&quot;&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: Sentry Profiles and spans repeatedly showed scanner paths such as &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;, credentials, config, actuator, and SQL dump probes.&lt;/li&gt;
&lt;li&gt;Decision: Instead of hiding them in Sentry, it was better to return an empty &lt;code class=&quot;language-text&quot;&gt;404&lt;/code&gt; from the shared Caddy layer in front of the app.&lt;/li&gt;
&lt;li&gt;Verification: Normal routes and health checks still passed, while blocked probes no longer appeared in app logs or new Sentry profiles.&lt;/li&gt;
&lt;li&gt;Rule: A global blocklist can create false positives, so names that may be legitimate public assets, such as &lt;code class=&quot;language-text&quot;&gt;config.js&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;app.json&lt;/code&gt;, need narrow host/path exceptions.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;While reviewing Sentry Profiles for a production service, I saw transactions that did not match user behavior.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;https://*/.env
https://*/backend/.env.local
https://*/.config/gcloud/credentials.db
https://*/config/application.properties
https://*/app/actuator/heapdump
https://*/wp-json/gravitysmtp/v1/config
https://*/backup.sql.gz&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;These requests are not part of a normal user flow. There is no reason for someone clicking through the web app or calling the API to request &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;credentials.db&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;heapdump&lt;/code&gt;, or &lt;code class=&quot;language-text&quot;&gt;wp-config.php&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;So I separated the conclusion into three parts.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It is reasonable to treat this traffic as attack traffic or automated scanning.&lt;/li&gt;
&lt;li&gt;This log alone does not prove that the server was compromised.&lt;/li&gt;
&lt;li&gt;The goal is not incident response. The goal is to reduce unnecessary probes before they reach origin.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Why-Not-Only-Hide-It-in-Sentry&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-Not-Only-Hide-It-in-Sentry&quot; aria-label=&quot;Why Not Only Hide It in Sentry permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why Not Only Hide It in Sentry?&lt;/h2&gt;
&lt;p&gt;The easiest option is to filter those transactions in Sentry. That makes the dashboard quieter.&lt;/p&gt;
&lt;p&gt;But the request flow stays the same.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;scanner -&gt; reverse proxy -&gt; app container -&gt; framework routing -&gt; 404 -&gt; Sentry&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In that path, the app still receives the request, writes logs, passes through middleware, and may leave a profile or span. Even if the service does not actually expose those sensitive files, sending this traffic to the app every time has no upside.&lt;/p&gt;
&lt;p&gt;So I moved the blocking point from Sentry to Caddy, which sits in front of the app.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;scanner -&gt; reverse proxy -&gt; empty 404
normal user -&gt; reverse proxy -&gt; app container&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is not a replacement for authentication or authorization. The app still needs its own auth, routing, and permission checks. The Caddy blocklist is a defensive layer that reduces common public-internet scanner requests before they reach the origin app.&lt;/p&gt;
&lt;h2 id=&quot;What-Was-Blocked&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-Was-Blocked&quot; aria-label=&quot;What Was Blocked permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What Was Blocked&lt;/h2&gt;
&lt;p&gt;Blocking every suspicious-looking string from the start can break legitimate traffic. I grouped the rules by paths that had actually appeared in Sentry and by common probe patterns.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Environment files: &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.env.*&lt;/code&gt;, URL-encoded &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Cloud credentials: &lt;code class=&quot;language-text&quot;&gt;.aws&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.gcloud&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.config/gcloud&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Secret/config files: &lt;code class=&quot;language-text&quot;&gt;credentials&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;service-account.json&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;application.*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;config.*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;settings.*&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Framework debug endpoints: &lt;code class=&quot;language-text&quot;&gt;actuator&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;heapdump&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;threaddump&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;_profiler&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;PHP/WordPress probes: &lt;code class=&quot;language-text&quot;&gt;phpinfo.php&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;wp-config*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;wp-json/*&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;DB/backup artifacts: &lt;code class=&quot;language-text&quot;&gt;*.sql&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;*.sql.gz&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;dump.*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;backup.*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;*.zip&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;VCS/editor/deploy artifacts: &lt;code class=&quot;language-text&quot;&gt;.git&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.npmrc&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.pypirc&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.vscode&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.idea&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;docker-compose*.yml&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Jenkinsfile&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The important point is that this list is not a security product that blocks every attack. It is a rule set that quickly ends the automated probes the service was actually receiving.&lt;/p&gt;
&lt;h2 id=&quot;Caddy-Rules&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Caddy-Rules&quot; aria-label=&quot;Caddy Rules permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Caddy Rules&lt;/h2&gt;
&lt;p&gt;The production Caddy setup had multiple services behind the same reverse proxy. Instead of copying rules into each service, I made a reusable snippet.&lt;/p&gt;
&lt;p&gt;Reduced for public writing, the structure looks like this.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;(sensitive_probe_block) {
	@sensitive-probe-paths {
		path /.env /.env.* */.env* /%2e%65%6e%76 */%2e%65%6e%76
		path /.git* */.git* /.npmrc /.pypirc /.netrc /.vscode/* /.idea/*
		path /.aws/* */.aws/* /.gcloud/* */.gcloud/* /.config/gcloud/* */.config/gcloud/*
		path /actuator* */actuator* /heapdump */heapdump /threaddump */threaddump */_profiler*
		path /credentials */credentials */*credentials*.json */service-account.json
		path /application.* */application.* /config.* */config.* */config/application.*
		path */backup.sql* */dump.* *.sql *.sql.gz *.key *.zip
		path /local-config.php */config.php */settings.php */database.php */wp-config* *.php
	}

	respond @sensitive-probe-paths 404
}

example.com {
	import sensitive_probe_block
	reverse_proxy app:3000
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The real production rule was longer, but the structure was the same.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Put the sensitive-probe matcher in a shared Caddy snippet.&lt;/li&gt;
&lt;li&gt;Import it before each host&apos;s &lt;code class=&quot;language-text&quot;&gt;reverse_proxy&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Return a body-less &lt;code class=&quot;language-text&quot;&gt;404&lt;/code&gt; when it matches.&lt;/li&gt;
&lt;li&gt;Send everything else to the existing app upstream.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;According to the Caddy docs, matcher tokens limit the requests to which a directive applies. A named matcher such as &lt;code class=&quot;language-text&quot;&gt;@sensitive-probe-paths&lt;/code&gt; can group multiple &lt;code class=&quot;language-text&quot;&gt;path&lt;/code&gt; conditions for reuse. The &lt;code class=&quot;language-text&quot;&gt;path&lt;/code&gt; matcher is exact by default, so prefix or suffix behavior has to be expressed with &lt;code class=&quot;language-text&quot;&gt;*&lt;/code&gt;. That is why the rule splits patterns such as &lt;code class=&quot;language-text&quot;&gt;/.env&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;/.env.*&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;*/.env*&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;respond @sensitive-probe-paths 404&lt;/code&gt; writes a fixed response for matching requests. Because no body is provided, this returns an empty &lt;code class=&quot;language-text&quot;&gt;404&lt;/code&gt;. The snippet is then inserted into each site block with &lt;code class=&quot;language-text&quot;&gt;import&lt;/code&gt;, which lets the same probe-blocking rule run before each host&apos;s &lt;code class=&quot;language-text&quot;&gt;reverse_proxy&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This is convenient when multiple services share one Caddy layer. A single change can give new services the same basic defensive layer.&lt;/p&gt;
&lt;h2 id=&quot;Verification&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Verification&quot; aria-label=&quot;Verification permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Verification&lt;/h2&gt;
&lt;p&gt;For this kind of rule, verification matters more than adding the rule itself. A global rule can break normal routes, so I checked both blocked and allowed paths.&lt;/p&gt;
&lt;p&gt;First I confirmed that representative probes ended as &lt;code class=&quot;language-text&quot;&gt;404&lt;/code&gt; responses with empty bodies.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-sS&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-o&lt;/span&gt; /dev/null &lt;span class=&quot;token parameter variable&quot;&gt;-w&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;status=%{http_code} bytes=%{size_download}\n&apos;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  https://&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;host&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;/%2e%65%6e%76

&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-sS&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-o&lt;/span&gt; /dev/null &lt;span class=&quot;token parameter variable&quot;&gt;-w&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;status=%{http_code} bytes=%{size_download}\n&apos;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  https://&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;host&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;/service-account.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The expected result was:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;status=404 bytes=0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then I checked normal routes.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-sS&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-o&lt;/span&gt; /dev/null &lt;span class=&quot;token parameter variable&quot;&gt;-w&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;status=%{http_code}\n&apos;&lt;/span&gt; https://&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;host&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;/health
&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-sS&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-o&lt;/span&gt; /dev/null &lt;span class=&quot;token parameter variable&quot;&gt;-w&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;status=%{http_code}\n&apos;&lt;/span&gt; https://&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;host&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, I checked app container logs and Sentry.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; logs &lt;span class=&quot;token parameter variable&quot;&gt;--since&lt;/span&gt; 5m &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;app-container&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;2&lt;/span&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;&amp;amp;1&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-E&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;/%2e%65%6e%76|/service-account\.json|/actuator|/wp-config&apos;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If the block works, probes stopped at Caddy should not appear in app logs. They also should not appear as new Sentry profiles or spans from the app.&lt;/p&gt;
&lt;h2 id=&quot;A-Deployment-Trap&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#A-Deployment-Trap&quot; aria-label=&quot;A Deployment Trap permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;A Deployment Trap&lt;/h2&gt;
&lt;p&gt;One issue I actually hit was the way the Caddyfile was deployed.&lt;/p&gt;
&lt;p&gt;The production container bind-mounted the Caddyfile from the host. I replaced the host file with &lt;code class=&quot;language-text&quot;&gt;mv&lt;/code&gt;. From the host it looked like the file had changed, but inside the container Caddy was still looking at the old inode.&lt;/p&gt;
&lt;p&gt;In that situation, &lt;code class=&quot;language-text&quot;&gt;caddy reload&lt;/code&gt; may not load the expected configuration. There are two safer options.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Overwrite the existing file in place, then run &lt;code class=&quot;language-text&quot;&gt;caddy reload&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;If file replacement is necessary, restart the container so it remounts the file.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Changing the configuration file was not enough. I had to check the Caddyfile as seen from inside the container, run &lt;code class=&quot;language-text&quot;&gt;caddy validate&lt;/code&gt;, and confirm the actual &lt;code class=&quot;language-text&quot;&gt;curl&lt;/code&gt; responses.&lt;/p&gt;
&lt;h2 id=&quot;False-Positive-Policy&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#False-Positive-Policy&quot; aria-label=&quot;False Positive Policy permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;False Positive Policy&lt;/h2&gt;
&lt;p&gt;The riskiest names in a global blocklist are generic file names.&lt;/p&gt;
&lt;p&gt;For example, &lt;code class=&quot;language-text&quot;&gt;config.json&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;config.js&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;app.json&lt;/code&gt; can be sensitive config probes in one service, but legitimate public assets in another. SPAs, PWAs, SDK documentation, and mobile app link flows may expose files with those names intentionally.&lt;/p&gt;
&lt;p&gt;So I used this rule:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If a public path needed by a new service conflicts with the blocklist, do not disable the whole blocklist.&lt;/li&gt;
&lt;li&gt;Add a narrow exception for that host and path.&lt;/li&gt;
&lt;li&gt;After adding the exception, verify both &quot;the exception path passes&quot; and &quot;representative probes are still blocked.&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Security rules last longer when operators can add narrow, safe exceptions instead of choosing between a broken service and disabling the entire rule.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Would-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Would-Judge-This-Next-Time&quot; aria-label=&quot;How I Would Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Would Judge This Next Time&lt;/h2&gt;
&lt;p&gt;When attack-like transactions show up in Sentry, I do not need to immediately conclude that the service was compromised. Public servers constantly receive automated scanner traffic.&lt;/p&gt;
&lt;p&gt;But &quot;this is common, so ignore it&quot; is not a good operating standard either. When these requests accumulate in profiles and spans, they make real performance or error signals harder to see.&lt;/p&gt;
&lt;p&gt;If I see similar probe traffic again, I will check three things together.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Observation: Build the blocklist from transactions that actually appeared in Sentry.&lt;/li&gt;
&lt;li&gt;Location: End the request quickly at the reverse proxy, not inside application code.&lt;/li&gt;
&lt;li&gt;Verification: Check blocked responses, normal routes, app logs, and Sentry re-entry together.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Even a small security change is easier to operate and explain later when it goes through those three steps.&lt;/p&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/matchers&quot;&gt;Caddy docs: Request matchers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/directives/respond&quot;&gt;Caddy docs: respond directive&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/directives/import&quot;&gt;Caddy docs: import directive&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Sentry Profiles에 찍힌 스캐너 요청을 Caddy에서 끊기]]></title><description><![CDATA[Sentry Profiles에 , , , SQL dump probe가 반복해서 찍혔을 때 처음 할 수 있는 일은 Sentry에서 숨기는 것이었다. 하지만 그건 dashboard만 조용하게 만들 뿐, 요청은 여전히 app container…]]></description><link>https://sewon.dev/caddy-sensitive-probe-blocklist-sentry-profiles/</link><guid isPermaLink="false">https://sewon.dev/caddy-sensitive-probe-blocklist-sentry-profiles/</guid><pubDate>Fri, 29 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/6a1db9ce4ea159c81a35e5228e2af861/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAACu0lEQVR42lXSX0gTcQAH8IPe9SGomahZy0wrw/w7x5JykllGkhSh5mMF/aEUIjAjM/APpQ9GJvUQ9FQPiZGk0WxTkxDScNttu93mbrs/3ububnfe7e5+9wuLiL58Xr8PX/giazEhQgo4wa1F+bUYj60l2Q05SovBCB9jRILaQjISQUkxZpOJy3R8M0JJvKhCCBFNNzQANB3owNB0Q9WAJKcFUeYEWRDTvKjwoiKIiqLqmmr8BrS0AXS4VX71+u29B0M9fcM9j0e6e58MDL/gBRFCaKj8XxwEimHAZSk6y/ldHObiMAfvDysJpKbxwvbiMlNxpamgcoe5PP/IMV8wAnWODU8liJlE9PN66KPELhPcxpuNpVHK1b88+RT9NBqfcwpBpK69I9tu29Nkzz9Vl1NmLay2o/4glEg6POV3T/pWJ3HvhJJc0Qz4fTM6IwamGPd0Ap0RMUxJICea27NKqndX1uaV23IP1BSV1aMeH1RoTVjgqdmN2Jc05wKix+BSkKK1SFQnKT1G6hECcjxSf/ay+WBtUan9cEVDTqElp7AGC0Wodcb5dXpxwbH4zTHvnHF7VkGSA1iAXfnpdjj9c/Oi22OQJHLtdo+t4WJdU+vJ5o4ae0vdmVaWTV66egfJK8gsrcgwH92WWXjIcjrFpyDNyHg4iWJJb0DGQkY8gQAADMOAfwMAgBB2D46Un2s+3tZe29Ja1Xi+7UqnIisqT0jrPi0ZhKkw4DAgJxCaYYfGXg48Hx98Nj4wOt4/MjY4Mn6/b/hmV++Nzt7rXQ9v3X3U2d0fjRA86cQ97wjfBBX8QGPvBWYFWfqxmlVt3VllybJZTeUWk7nCtLcya19V9n7LH7lF1oxdJQ7XIoSqnKJViU2L62mR0VURSauqDw+hARzFQyiGo34cDeBef9Dr+8+mrGw959++rYf9Ao/BCd1OHLLmAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/6a1db9ce4ea159c81a35e5228e2af861/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/6a1db9ce4ea159c81a35e5228e2af861/e7570/situation-diagram.png 170w,
/static/6a1db9ce4ea159c81a35e5228e2af861/f46e7/situation-diagram.png 340w,
/static/6a1db9ce4ea159c81a35e5228e2af861/ca1dc/situation-diagram.png 680w,
/static/6a1db9ce4ea159c81a35e5228e2af861/02d09/situation-diagram.png 1020w,
/static/6a1db9ce4ea159c81a35e5228e2af861/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Sentry Profiles에 &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;credentials&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;actuator&lt;/code&gt;, SQL dump probe가 반복해서 찍혔을 때 처음 할 수 있는 일은 Sentry에서 숨기는 것이었다. 하지만 그건 dashboard만 조용하게 만들 뿐, 요청은 여전히 app container까지 들어온다. 그래서 이 변경의 기준은 &quot;보안 장비를 만들자&quot;가 아니라 &quot;명백한 scanner traffic은 reverse proxy에서 끝내고 정상 route와 예외 정책은 검증하자&quot;였다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: Sentry Profiles와 spans에 &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;, credentials, config, actuator, SQL dump 같은 scanner path가 반복해서 찍혔다.&lt;/li&gt;
&lt;li&gt;판단: Sentry에서 숨기는 대신, app 앞단의 shared Caddy에서 명백한 probe를 빈 &lt;code class=&quot;language-text&quot;&gt;404&lt;/code&gt;로 끝내는 편이 맞았다.&lt;/li&gt;
&lt;li&gt;검증: 정상 route와 health check는 그대로 통과시키고, 차단된 probe가 앱 로그와 Sentry profile에 더 이상 남지 않는지 확인했다.&lt;/li&gt;
&lt;li&gt;기준: 전역 blocklist는 오탐 가능성이 있으므로, &lt;code class=&quot;language-text&quot;&gt;config.js&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;app.json&lt;/code&gt;처럼 정상 public asset이 될 수 있는 이름은 host/path 단위 예외 정책을 같이 둬야 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;운영 중인 서비스의 Sentry Profiles를 보다가 사용자 행동과 맞지 않는 transaction들이 보였다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;https://*/.env
https://*/backend/.env.local
https://*/.config/gcloud/credentials.db
https://*/config/application.properties
https://*/app/actuator/heapdump
https://*/wp-json/gravitysmtp/v1/config
https://*/backup.sql.gz&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이런 요청은 사용자 플로우와 연결되지 않는다. 웹 앱 화면을 누르거나 API를 쓰는 과정에서 &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;credentials.db&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;heapdump&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;wp-config.php&lt;/code&gt;를 요청할 이유는 없다.&lt;/p&gt;
&lt;p&gt;그래서 먼저 결론을 이렇게 나눴다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;이 트래픽은 공격 또는 자동 스캔으로 보는 게 맞다.&lt;/li&gt;
&lt;li&gt;하지만 이 로그만으로 서버가 뚫렸다고 말할 수는 없다.&lt;/li&gt;
&lt;li&gt;처리 목표는 &quot;침해 대응&quot;이 아니라 &quot;origin까지 불필요한 probe가 들어오지 않게 줄이는 것&quot;이다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;왜-Sentry에서만-숨기지-않았나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-Sentry%EC%97%90%EC%84%9C%EB%A7%8C-%EC%88%A8%EA%B8%B0%EC%A7%80-%EC%95%8A%EC%95%98%EB%82%98&quot; aria-label=&quot;왜 Sentry에서만 숨기지 않았나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 Sentry에서만 숨기지 않았나&lt;/h2&gt;
&lt;p&gt;가장 쉬운 방법은 Sentry에서 해당 transaction을 필터링하는 것이다. 그러면 대시보드는 조용해진다.&lt;/p&gt;
&lt;p&gt;하지만 요청 흐름은 그대로 남는다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;scanner -&gt; reverse proxy -&gt; app container -&gt; framework routing -&gt; 404 -&gt; Sentry&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 경우 앱은 여전히 request를 받고, 로그도 만들고, middleware도 통과하고, 경우에 따라 profile/span도 남긴다. 보안상 민감한 파일이 실제로 없는 서비스라 해도, 이런 요청을 매번 앱까지 보내는 것은 이득이 없다.&lt;/p&gt;
&lt;p&gt;그래서 차단 위치를 Sentry가 아니라 앱 앞단의 Caddy로 잡았다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;scanner -&gt; reverse proxy -&gt; empty 404
normal user -&gt; reverse proxy -&gt; app container&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 조치는 인증이나 권한 검사의 대체물이 아니다. 앱은 여전히 자체 인증, 라우팅, 권한 검사를 해야 한다. Caddy blocklist는 공개 인터넷의 흔한 스캐너 요청을 origin 앱에 닿기 전에 줄이는 방어층이다.&lt;/p&gt;
&lt;h2 id=&quot;무엇을-차단했나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B4%EC%97%87%EC%9D%84-%EC%B0%A8%EB%8B%A8%ED%96%88%EB%82%98&quot; aria-label=&quot;무엇을 차단했나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;무엇을 차단했나&lt;/h2&gt;
&lt;p&gt;처음부터 모든 수상한 문자열을 막으면 정상 트래픽도 같이 막을 수 있다. 그래서 실제 Sentry에 찍힌 경로와 널리 알려진 probe 패턴을 기준으로 카테고리를 나눴다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;환경 변수 파일: &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.env.*&lt;/code&gt;, URL-encoded &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;클라우드 credential: &lt;code class=&quot;language-text&quot;&gt;.aws&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.gcloud&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.config/gcloud&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;secret/config 파일: &lt;code class=&quot;language-text&quot;&gt;credentials&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;service-account.json&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;application.*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;config.*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;settings.*&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;framework debug endpoint: &lt;code class=&quot;language-text&quot;&gt;actuator&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;heapdump&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;threaddump&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;_profiler&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;PHP/WordPress probe: &lt;code class=&quot;language-text&quot;&gt;phpinfo.php&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;wp-config*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;wp-json/*&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;DB/backup artifact: &lt;code class=&quot;language-text&quot;&gt;*.sql&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;*.sql.gz&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;dump.*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;backup.*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;*.zip&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;VCS/editor/deploy artifact: &lt;code class=&quot;language-text&quot;&gt;.git&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.npmrc&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.pypirc&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.vscode&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.idea&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;docker-compose*.yml&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;Jenkinsfile&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;중요한 점은 이 목록이 &quot;모든 공격을 막는 보안 장비&quot;가 아니라는 점이다. 지금 실제로 맞고 있는 자동 probe를 앱 앞에서 빨리 끝내는 rule이다.&lt;/p&gt;
&lt;h2 id=&quot;Caddy-규칙&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Caddy-%EA%B7%9C%EC%B9%99&quot; aria-label=&quot;Caddy 규칙 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Caddy 규칙&lt;/h2&gt;
&lt;p&gt;운영 Caddy는 여러 서비스를 같은 reverse proxy 뒤에 두고 있었다. 그래서 각 서비스마다 따로 복사하지 않고, 재사용 가능한 snippet으로 만들었다.&lt;/p&gt;
&lt;p&gt;공개 글에 맞게 줄이면 이런 형태다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;(sensitive_probe_block) {
	@sensitive-probe-paths {
		path /.env /.env.* */.env* /%2e%65%6e%76 */%2e%65%6e%76
		path /.git* */.git* /.npmrc /.pypirc /.netrc /.vscode/* /.idea/*
		path /.aws/* */.aws/* /.gcloud/* */.gcloud/* /.config/gcloud/* */.config/gcloud/*
		path /actuator* */actuator* /heapdump */heapdump /threaddump */threaddump */_profiler*
		path /credentials */credentials */*credentials*.json */service-account.json
		path /application.* */application.* /config.* */config.* */config/application.*
		path */backup.sql* */dump.* *.sql *.sql.gz *.key *.zip
		path /local-config.php */config.php */settings.php */database.php */wp-config* *.php
	}

	respond @sensitive-probe-paths 404
}

example.com {
	import sensitive_probe_block
	reverse_proxy app:3000
}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;실제 운영 규칙은 더 길지만 구조는 같다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;shared Caddy snippet에 민감 probe matcher를 둔다.&lt;/li&gt;
&lt;li&gt;host별 &lt;code class=&quot;language-text&quot;&gt;reverse_proxy&lt;/code&gt;보다 먼저 &lt;code class=&quot;language-text&quot;&gt;import&lt;/code&gt;한다.&lt;/li&gt;
&lt;li&gt;매칭되면 body 없는 &lt;code class=&quot;language-text&quot;&gt;404&lt;/code&gt;로 끝낸다.&lt;/li&gt;
&lt;li&gt;매칭되지 않으면 기존 app upstream으로 보낸다.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Caddy 공식 문서 기준으로 matcher token은 directive가 적용될 request 범위를 제한한다. &lt;code class=&quot;language-text&quot;&gt;@sensitive-probe-paths&lt;/code&gt;처럼 이름을 붙인 matcher는 여러 &lt;code class=&quot;language-text&quot;&gt;path&lt;/code&gt; 조건을 묶어 재사용할 수 있다. &lt;code class=&quot;language-text&quot;&gt;path&lt;/code&gt; matcher는 기본적으로 정확히 매칭하고, prefix나 suffix가 필요하면 &lt;code class=&quot;language-text&quot;&gt;*&lt;/code&gt;를 명시해야 한다. 이 글의 규칙이 &lt;code class=&quot;language-text&quot;&gt;/.env&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;/.env.*&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;*/.env*&lt;/code&gt;처럼 여러 패턴을 나눠 둔 이유도 이 때문이다.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;respond @sensitive-probe-paths 404&lt;/code&gt;는 매칭된 요청에 고정 응답을 쓰는 directive다. body를 주지 않았기 때문에 여기서는 빈 &lt;code class=&quot;language-text&quot;&gt;404&lt;/code&gt;를 돌려준다. 그리고 snippet은 &lt;code class=&quot;language-text&quot;&gt;import&lt;/code&gt;로 site block 안에 끼워 넣는다. 이 구조 덕분에 각 host의 &lt;code class=&quot;language-text&quot;&gt;reverse_proxy&lt;/code&gt; 앞에서 같은 probe 차단 규칙을 재사용할 수 있었다.&lt;/p&gt;
&lt;p&gt;여러 서비스가 같은 Caddy를 쓰고 있다면 이 방식이 편하다. 한 번 고치면 새 서비스에도 같은 기본 방어층을 적용하기 쉽다.&lt;/p&gt;
&lt;h2 id=&quot;검증&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%80%EC%A6%9D&quot; aria-label=&quot;검증 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;검증&lt;/h2&gt;
&lt;p&gt;이런 규칙은 넣는 것보다 확인이 더 중요하다. 특히 전역 규칙이면 정상 route를 망가뜨리지 않았는지도 같이 봐야 한다.&lt;/p&gt;
&lt;p&gt;먼저 대표 probe가 &lt;code class=&quot;language-text&quot;&gt;404&lt;/code&gt;와 빈 body로 끝나는지 확인했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-sS&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-o&lt;/span&gt; /dev/null &lt;span class=&quot;token parameter variable&quot;&gt;-w&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;status=%{http_code} bytes=%{size_download}\n&apos;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  https://&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;host&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;/%2e%65%6e%76

&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-sS&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-o&lt;/span&gt; /dev/null &lt;span class=&quot;token parameter variable&quot;&gt;-w&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;status=%{http_code} bytes=%{size_download}\n&apos;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  https://&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;host&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;/service-account.json&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;기대값은 이렇다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;status=404 bytes=0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그다음 정상 route를 확인했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-sS&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-o&lt;/span&gt; /dev/null &lt;span class=&quot;token parameter variable&quot;&gt;-w&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;status=%{http_code}\n&apos;&lt;/span&gt; https://&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;host&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;/health
&lt;span class=&quot;token function&quot;&gt;curl&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-sS&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-o&lt;/span&gt; /dev/null &lt;span class=&quot;token parameter variable&quot;&gt;-w&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;status=%{http_code}\n&apos;&lt;/span&gt; https://&lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;host&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;/&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;마지막으로 앱 컨테이너 로그와 Sentry를 봤다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; logs &lt;span class=&quot;token parameter variable&quot;&gt;--since&lt;/span&gt; 5m &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;app-container&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;2&lt;/span&gt;&gt;&lt;/span&gt;&lt;span class=&quot;token file-descriptor important&quot;&gt;&amp;amp;1&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token operator&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;token parameter variable&quot;&gt;-E&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&apos;/%2e%65%6e%76|/service-account\.json|/actuator|/wp-config&apos;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  &lt;span class=&quot;token operator&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;true&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;차단이 제대로 됐다면 Caddy에서 끝난 probe는 앱 로그에 남지 않아야 한다. Sentry에서도 새 profile/span으로 들어오지 않아야 한다.&lt;/p&gt;
&lt;h2 id=&quot;운영하면서-걸린-함정&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%B4%EC%98%81%ED%95%98%EB%A9%B4%EC%84%9C-%EA%B1%B8%EB%A6%B0-%ED%95%A8%EC%A0%95&quot; aria-label=&quot;운영하면서 걸린 함정 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;운영하면서 걸린 함정&lt;/h2&gt;
&lt;p&gt;이번에 실제로 한 번 걸린 부분은 Caddyfile 배포 방식이었다.&lt;/p&gt;
&lt;p&gt;운영 컨테이너가 host의 Caddyfile을 bind mount하고 있었는데, host에서 새 파일을 &lt;code class=&quot;language-text&quot;&gt;mv&lt;/code&gt;로 교체했다. 파일 내용은 바뀐 것처럼 보였지만, 컨테이너 안에서는 예전 inode를 계속 보고 있었다.&lt;/p&gt;
&lt;p&gt;이런 상황에서는 &lt;code class=&quot;language-text&quot;&gt;caddy reload&lt;/code&gt;만으로 기대한 설정이 안 들어갈 수 있다. 해결은 둘 중 하나다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;기존 파일에 in-place로 덮어쓴 뒤 &lt;code class=&quot;language-text&quot;&gt;caddy reload&lt;/code&gt;를 한다.&lt;/li&gt;
&lt;li&gt;파일 교체가 필요했다면 컨테이너를 재시작해서 mount를 새로 잡게 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;설정 파일을 바꿨다고 끝내지 않고 컨테이너 안에서 보이는 Caddyfile, &lt;code class=&quot;language-text&quot;&gt;caddy validate&lt;/code&gt;, 실제 &lt;code class=&quot;language-text&quot;&gt;curl&lt;/code&gt; 결과까지 봐야 했다.&lt;/p&gt;
&lt;h2 id=&quot;오탐-정책&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%98%A4%ED%83%90-%EC%A0%95%EC%B1%85&quot; aria-label=&quot;오탐 정책 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;오탐 정책&lt;/h2&gt;
&lt;p&gt;전역 blocklist에서 제일 위험한 이름은 너무 일반적인 파일명이다.&lt;/p&gt;
&lt;p&gt;예를 들면 &lt;code class=&quot;language-text&quot;&gt;config.json&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;config.js&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;app.json&lt;/code&gt;은 어떤 서비스에서는 민감한 설정 파일 probe일 수 있지만, 다른 서비스에서는 정상 public asset일 수 있다. 특히 SPA, PWA, 일부 SDK 문서, mobile app link 파일을 제공하는 서비스에서는 이런 이름이 정상일 때가 있다.&lt;/p&gt;
&lt;p&gt;그래서 원칙을 이렇게 잡았다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;새 서비스에 필요한 public path가 blocklist와 충돌하면 전체 blocklist를 끄지 않는다.&lt;/li&gt;
&lt;li&gt;해당 host와 path만 좁게 예외 처리한다.&lt;/li&gt;
&lt;li&gt;예외 추가 뒤에는 &quot;예외 path는 통과&quot;와 &quot;대표 probe는 여전히 차단&quot;을 둘 다 확인한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;보안 규칙은 강하게 만드는 것보다 운영자가 안전하게 예외를 줄 수 있게 만드는 쪽이 더 오래 간다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;Sentry에 공격성 transaction이 찍혔을 때 바로 &quot;해킹당했다&quot;라고 볼 필요는 없다. 공개 서버에는 늘 자동 scanner가 붙는다.&lt;/p&gt;
&lt;p&gt;하지만 &quot;흔한 일이니까 무시한다&quot;도 좋은 운영은 아니다. 특히 profile과 span에 이런 요청이 계속 쌓이면 진짜 성능 문제나 에러를 보는 데 방해가 된다.&lt;/p&gt;
&lt;p&gt;비슷한 probe traffic을 다시 보면 세 가지를 같이 본다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;관측: Sentry에서 실제로 들어온 transaction을 보고 blocklist를 만든다.&lt;/li&gt;
&lt;li&gt;위치: 앱 코드가 아니라 reverse proxy에서 빠르게 끝낸다.&lt;/li&gt;
&lt;li&gt;검증: 차단 응답, 정상 route, 앱 로그, Sentry 재유입을 같이 확인한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;작은 보안 조치라도 이 세 단계를 거치면 운영 노이즈를 줄이면서 나중에 설명 가능한 변경으로 남길 수 있다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/matchers&quot;&gt;Caddy docs: Request matchers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/directives/respond&quot;&gt;Caddy docs: respond directive&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://caddyserver.com/docs/caddyfile/directives/import&quot;&gt;Caddy docs: import directive&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Building an Agentic Prompt Experiment Loop]]></title><description><![CDATA[Place2Page's landing page generation was already publishable. The question for this experiment was not "does it work?" It was "can we…]]></description><link>https://sewon.dev/en/place2page-agentic-research-hallmark-combined-loop/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-agentic-research-hallmark-combined-loop/</guid><pubDate>Sun, 24 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Place2Page&apos;s landing page generation was already publishable. The question for this experiment was not &quot;does it work?&quot; It was &quot;can we improve place-specific structure and visual rhythm without breaking the production baseline?&quot; I fixed the actual production baseline instead of relying on a prompt file in the repo, then used external writing and design standards as experiment criteria rather than as prompt dependencies.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/e9b6cc51228b04eee6603603df878ca4/cd15d/agentic-research-loop.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 54.11764705882353%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACGElEQVR42lWRy2sTURTGZyeCCzcutAi68lXIVqV2JUXwX9OFLsQqVkvR2iIaTVuQYsFFsUGbirFtbBuTyWsmmSRz596Z+z73iCFI/Thnczjfge93vHqLtgIaRqnfZu1u1h3woJcBADhnAf6WBWstHJNzDkfySGZIZhJuYiZZJkgshkPOEskSGQ84TUTGpdJmvP6/vLTrx/5u0txPWQaIWkCayHqThAEVqVUCELHqdx7N5+deFZ69LMzOv6sc+ojonPN0Za3+6TEpvkDadohSKW2M0hYRuRBKa0ScW1g+ceXquemps7nrJ89cvv/wKSJaaz0gvgzLOtpHI4aEdYKQdPjuDqtVBKWm1goQcfbJ8qnJ3MWZ2xdy06cncvf+mUmw2a6u9OprOmkYLoZRbxDwg3LWOFJpant9goALiyvnb96anLl7berOxKUbs88Xx2ZOfNav0KgCiiGAMUZqbcEpraVSRgEAquHgYPNLZatY+7bdKX3XUR9Hob3j9MBokFwKGcXpMKbGGBxRBsZo9TepNajfst0upmxMG51Dd+wRzoFRzhqw4GA0d+NO6YCnA0Q0YHuSUiO8z6yaT37m+z+WGl9f+8XF2taSX3zb2ynQvVW6R40YHUTLo+BoLTwqyKS5HbceHK6/CUreVup/pL9Ww3K+vv2hufPeL+XrpdWwvE4PNughE9Rmic6IZkNFfMNDBGPABjKJNf8DpMxEo96/vwMAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Agentic research loop diagram showing human framing, agent-run experiments, durable evidence artifacts, and a human promotion decision&apos; title=&apos;&apos; src=&apos;/static/e9b6cc51228b04eee6603603df878ca4/ca1dc/agentic-research-loop.png&apos; srcset=&apos;/static/e9b6cc51228b04eee6603603df878ca4/e7570/agentic-research-loop.png 170w,
/static/e9b6cc51228b04eee6603603df878ca4/f46e7/agentic-research-loop.png 340w,
/static/e9b6cc51228b04eee6603603df878ca4/ca1dc/agentic-research-loop.png 680w,
/static/e9b6cc51228b04eee6603603df878ca4/02d09/agentic-research-loop.png 1020w,
/static/e9b6cc51228b04eee6603603df878ca4/9d567/agentic-research-loop.png 1360w,
/static/e9b6cc51228b04eee6603603df878ca4/cd15d/agentic-research-loop.png 5000w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Agentic research loop diagram showing human framing, agent-run experiments, durable evidence artifacts, and a human promotion decision&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: Place2Page generated publishable landing pages, but some outputs stayed close to a safe baseline structure.&lt;/li&gt;
&lt;li&gt;Decision: The experiment baseline had to be the current production baseline, not a local prompt file.&lt;/li&gt;
&lt;li&gt;Approach: Split structure, anti-slop, and responsive rules into candidates, then repeated them against a fixed input set.&lt;/li&gt;
&lt;li&gt;Result: The &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; candidate was the most practical direction because it preserved publish stability while improving structural variation.&lt;/li&gt;
&lt;li&gt;Lesson: By &quot;agentic research,&quot; I do not mean handing judgment to AI. I mean having a person define the problem and evaluation criteria, then using AI agents to run repeatable experiment loops faster.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;Place2Page generates landing pages from Google Maps or Naver Map URLs. It gathers data such as place names, addresses, photos, opening hours, reviews, menus, and booking links, then turns them into HTML.&lt;/p&gt;
&lt;p&gt;The feature was already usable. The problem was not whether it worked, but whether the result felt specific enough from place to place.&lt;/p&gt;
&lt;p&gt;Local business landing pages easily converge to the same structure: hero, a few photos, menu or service cards, reviews, map, and CTA. That structure is not wrong. But if every result feels similar, a generative product starts to lose the expectation that it can adapt.&lt;/p&gt;
&lt;p&gt;I wanted to answer two questions.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Can the same place produce a better information flow and visual rhythm than the baseline?&lt;/li&gt;
&lt;li&gt;Can a more aggressive prompt stay publishable without mobile overflow or unsupported AI marketing copy?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;I-Started-With-The-Production-Baseline&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#I-Started-With-The-Production-Baseline&quot; aria-label=&quot;I Started With The Production Baseline permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;I Started With The Production Baseline&lt;/h2&gt;
&lt;p&gt;The first step was to confirm what production was actually using as the baseline. Looking only at prompt files in the repo was not enough because the active production default can differ from the file default.&lt;/p&gt;
&lt;p&gt;So the experiment started only after I matched the local baseline to the production baseline, not to the local file state.&lt;/p&gt;
&lt;p&gt;This baseline was not bad. It included the basic information, used photos, and had reviews and a map. But the result still looked close to a safe restaurant landing page. The photos appeared placed inside an already-decided structure rather than strongly driving the page structure.&lt;/p&gt;
&lt;p&gt;That created an important rule.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The experiment should ask whether the result improved over the current production baseline, not whether my local prompt became better.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;I-Used-External-Standards-As-Criteria-Not-Dependencies&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#I-Used-External-Standards-As-Criteria-Not-Dependencies&quot; aria-label=&quot;I Used External Standards As Criteria Not Dependencies permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;I Used External Standards As Criteria, Not Dependencies&lt;/h2&gt;
&lt;p&gt;Next, I read external writing and design criteria. What I took from them was not a package or runtime dependency, but a set of prompt quality standards.&lt;/p&gt;
&lt;p&gt;The initial candidates were split like this.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;control-production
structure-first
anti-slop
responsive-hardening
combined&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Each candidate had a different role.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;structure-first&lt;/code&gt;: prioritize section hierarchy and information flow instead of listing cards.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;anti-slop&lt;/code&gt;: reduce unsupported AI marketing phrases such as &quot;premium&quot; and &quot;special experience.&quot;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;responsive-hardening&lt;/code&gt;: prevent mobile overflow, overlapping elements, and fragile grids at the prompt stage.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;: merge the three directions into one profile.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The experiment was repeated across four fixed places.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Google restaurant&lt;/li&gt;
&lt;li&gt;Google fitness studio&lt;/li&gt;
&lt;li&gt;Naver workshop&lt;/li&gt;
&lt;li&gt;Naver beauty&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The reason for using a fixed input set was simple. If every run used a different place, it would be hard to tell whether the result improved because of the prompt or because of the place data.&lt;/p&gt;
&lt;h2 id=&quot;Before-And-After-Baseline-To-Combined&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Before-And-After-Baseline-To-Combined&quot; aria-label=&quot;Before And After Baseline To Combined permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Before And After: Baseline To Combined&lt;/h2&gt;
&lt;p&gt;Applying &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; to the same restaurant input made the structure clearer.&lt;/p&gt;
&lt;p&gt;Compared with the baseline, several things changed.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The hero became more concise.&lt;/li&gt;
&lt;li&gt;The photo grid looked more like visual evidence than a simple gallery.&lt;/li&gt;
&lt;li&gt;The menu section connected better with the food photos.&lt;/li&gt;
&lt;li&gt;Reviews and visit information landed in a steadier rhythm.&lt;/li&gt;
&lt;li&gt;The CTA and map area felt less detached than in the baseline.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The important point is not that it became flashier. It tried a more varied structure while still preserving publishable stability.&lt;/p&gt;
&lt;p&gt;I also checked whether &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; became too aggressive in other domains.&lt;/p&gt;
&lt;p&gt;For the fitness studio, the structure differed from the restaurant result. Photos centered on the workout space and class scenes, and service cards did not look like restaurant menu cards. The same prompt candidate produced a different landing rhythm based on the business type.&lt;/p&gt;
&lt;p&gt;I also tested a Korean place from Naver data.&lt;/p&gt;
&lt;p&gt;This result showed an important point for local business generation. The same prompt quality standard worked across Korean, Naver data, and a workshop/craft domain. In other words, &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; was not overfitted to one restaurant sample.&lt;/p&gt;
&lt;h2 id=&quot;Stability-Was-Not-Just-An-Automated-Score&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Stability-Was-Not-Just-An-Automated-Score&quot; aria-label=&quot;Stability Was Not Just An Automated Score permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Stability Was Not Just An Automated Score&lt;/h2&gt;
&lt;p&gt;The representative full run summary looked like this.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Candidate&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Results&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Published&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Average score&lt;/th&gt;
&lt;th&gt;Judgment mix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;control-production&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;structure-first&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;anti-slop&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;88.0&lt;/td&gt;
&lt;td&gt;2 pass, 2 review&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;responsive-hardening&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Both &lt;code class=&quot;language-text&quot;&gt;control-production&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; scored 100. So it would be wrong to say that &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; won by automated score.&lt;/p&gt;
&lt;p&gt;The more accurate interpretation was this.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;anti-slop&lt;/code&gt; alone helped copy quality, but produced mobile overflow review cases.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;responsive-hardening&lt;/code&gt; strengthened layout guardrails.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; merged structure, copy, and responsive rules while keeping 4/4 published and 4/4 pass.&lt;/li&gt;
&lt;li&gt;In human review, its information flow and visual variation were better than the baseline.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The automated score was a guardrail. It helped catch publish failures, overflow, and obvious quality issues. Deciding which page was better still required human review.&lt;/p&gt;
&lt;p&gt;The assets from this experiment were not only generated page screenshots. I also kept &lt;code class=&quot;language-text&quot;&gt;dashboard.html&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;variant_graph.html&lt;/code&gt; outputs so each run could show its candidates, scores, publish state, and prompt lineage in one place. After a later DB reset, some older prompt diffs became difficult to fully reconstruct, but these HTML artifacts still preserved the experiment flow.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/9f1f5aa69fbc821ddac3cc615574638c/89066/06-variant-lineage-graph.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAACYklEQVR42lWS2Y7bOBRE+xsSa3NbohaKEvd7SXGR3U4H6QQz//9FiRxPAwOch6qHQhUu+XK+dNIAl3oR6tx250t36fpzS84taS7d+UKKqvk/9ad+OZU15Uq7yI2DLTGhXsnY9lPb07an3TA/+CsomZaeCTLzdpyPcFHWjXTV9la6a42Zb/vt/Ve8f6hwE2ZbtZsFMIlPFDIBi98nu52K6ggXEr646xfcT5AYRoOBa9QYuEK66pHJflzpqnrKx1lQJnvKCV2fzaWEr27/irm0cZQ4Kt+uhnDouCUcRu1H7XuBnwzSESaf4UrA6ajNpQkLhP37r+uPf3F/F5g4ZoFJYOaQ+GHTarbFX8fP2ZWwJ8wnSKUJzHhwyUCwGIVCoZArWLiRxnEJQjuhcJxFT/l/zdwWkAoba71NCgftWwGjDYPxRLvZJQphsoEo1wropDt4zq7qipvCxsKESntmN7z/hPvHjHmGPNm4+qsIbxQShTTZOGg/+dugXXHMruqam8rG8hFeYYvp5rbdQtDGa+OlPgYb2JR2SnvGJOVm4Loo65eiaqpFnZQv9dYoRxWOynXcMIiTdoPCxSVq/Gy3XgLhdpDQrbqb1ucPI8bT/XttHmHt13Rn4Y2Y0EMkJkxuZ+F2WBuJDcRsvb8ShcfsU1l3ytH9vTFbLUC49P7jn+v9A/xuXbaYDSaN0fp8WJfBZczfmA2Pp6qamqlCQCXxLHGWQBfV03V5CLpIJsw480XYcRbjLOZFDdNKRvb32s15UY1yjcRXAZPCabv2mHt30EFk6b7ke+8ygdja0JrQQupW8+dgvwGW646ucqr3dQAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Prompt variant graph showing local experiment lineage, per-variant publish counts, and quality scores&apos; title=&apos;&apos; src=&apos;/static/9f1f5aa69fbc821ddac3cc615574638c/ca1dc/06-variant-lineage-graph.png&apos; srcset=&apos;/static/9f1f5aa69fbc821ddac3cc615574638c/e7570/06-variant-lineage-graph.png 170w,
/static/9f1f5aa69fbc821ddac3cc615574638c/f46e7/06-variant-lineage-graph.png 340w,
/static/9f1f5aa69fbc821ddac3cc615574638c/ca1dc/06-variant-lineage-graph.png 680w,
/static/9f1f5aa69fbc821ddac3cc615574638c/02d09/06-variant-lineage-graph.png 1020w,
/static/9f1f5aa69fbc821ddac3cc615574638c/9d567/06-variant-lineage-graph.png 1360w,
/static/9f1f5aa69fbc821ddac3cc615574638c/89066/06-variant-lineage-graph.png 1440w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Prompt variant graph showing local experiment lineage, per-variant publish counts, and quality scores&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The more important feature in that graph is prompt diff. The control has no diff, while experiment variants can open the exact prompt slots they changed. Below is the diff for the LOGI Korean few-shot candidate. It separates changes by slots such as &lt;code class=&quot;language-text&quot;&gt;freeform_html.map_instruction_suffix.v1&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;meta_prompt.contextual.v1&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;meta_prompt.fixed.v1&lt;/code&gt;, which gives a human reviewer a way to inspect why a result changed.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c3f99305b8e482e56ae20e10cd55ef82/89066/10-prompt-diff-few-shot.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAABv0lEQVR42o3SC27bMAwG4Bxgi23JeouUKFmJmzhxMyxr0WG7/7E2P5am3VAM+EAQAgj+Arj5XDXQ7cswUioxF8o76nZC2Y+10lQN33za1v1wfvr+88v1+XJ9/vby4+vTi/FBO1woBze3R2l81bDNtmbGYcod5ZxKcYA140woLhSb8TvagfXBQlAW5uGGa+tSjjFiQIfgrNNKq5uGi79xqafYVcOk8ZgLULYeHUYI5OcKgYwDbb22fmleh8U6zIW2gXLMxXjQzis70W7Cpb5PzoRcrJunP8eADwX6DvedoaAD6jiRAdQ/RZDer8OWYvd4yOOhG4/p1MdhT0PfPR6xLzqiofBeCgqgqtmmqplGhH2G3SvXkU3RpLBEeI9w3sz+bB4P+TwbJzT08VD+a9hQ2F/P5XIsl6Fchin8+SGdHnzJlqJNbxiKJsU19rZufEz9OO5PZ0dJAQrjWm1bbYV2wrzhAkHKIXcGwnb6c8OVtggOwHpnhFQ3XEjGxR3J2tXtSLg0zgbUzkoppFZCSTnjragYr1m71mapbVUz1qqa8c22mW4bYkbqkLKDOPUxeySkjDFN95PK0iDlMHMQf8f+Bf9eYCTCXe/UAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Prompt diff drawer showing changed prompt slots for the Korean few-shot copy editor variant&apos; title=&apos;&apos; src=&apos;/static/c3f99305b8e482e56ae20e10cd55ef82/ca1dc/10-prompt-diff-few-shot.png&apos; srcset=&apos;/static/c3f99305b8e482e56ae20e10cd55ef82/e7570/10-prompt-diff-few-shot.png 170w,
/static/c3f99305b8e482e56ae20e10cd55ef82/f46e7/10-prompt-diff-few-shot.png 340w,
/static/c3f99305b8e482e56ae20e10cd55ef82/ca1dc/10-prompt-diff-few-shot.png 680w,
/static/c3f99305b8e482e56ae20e10cd55ef82/02d09/10-prompt-diff-few-shot.png 1020w,
/static/c3f99305b8e482e56ae20e10cd55ef82/9d567/10-prompt-diff-few-shot.png 1360w,
/static/c3f99305b8e482e56ae20e10cd55ef82/89066/10-prompt-diff-few-shot.png 1440w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Prompt diff drawer showing changed prompt slots for the Korean few-shot copy editor variant&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The per-run dashboard separates automated guardrails from the parts that still require human review. In the English hero-copy run below, publish state, score, screenshot status, and variant rows are visible together, which makes it easier to spot copy that technically passed but still needs editorial judgment.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/32b1b5d3eee5997df641db01d9bbb098/89066/07-english-hero-copy-dashboard.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAABX0lEQVR42pVTiY6dMAzk/3+0u0AOO5ft2KEKvFLU3X1SRyiywTODBrOEiB/r/rHumwuVmKQTSyNuLDaGjTHG8SqOo6uSCLGwdJa+AOYQ0cYQVZYuXbsaYN52n0tVG8Tz5vlUZ3GejabEgrkQi9poxKU2NbMxQgTA1LWbWSOWPgsRUbU+1bXUJqKLqh1fAJi8D6fOhE2Mq7M/6Go/kj/XXVWf05eWmemJH8kRMAI+bP+HHACdD2fAx3jgai8hfeO8O3+3F+2uL7wjb7u75+7kvg9sfAlsd/72+8f5kvrG+ZoLMa7r9rJ641wbpVyI+PV655hIZ+Y7Y7v28++nnmfvuqRcMWUiTrnWSoA5QgLMkArmAqmEmHKuLkCE5AL4AJDy6kJtvKTS9gCYK7FIn+s991aE59VF1GFymLYIHvMO+BnAYf7lPHFfiDud/8MzlSd8IizsU8PKsXDDmCHuSL3bb4A9cBIBX4K6AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;English hero copy experiment dashboard showing published counts, per-variant scores, and review states&apos; title=&apos;&apos; src=&apos;/static/32b1b5d3eee5997df641db01d9bbb098/ca1dc/07-english-hero-copy-dashboard.png&apos; srcset=&apos;/static/32b1b5d3eee5997df641db01d9bbb098/e7570/07-english-hero-copy-dashboard.png 170w,
/static/32b1b5d3eee5997df641db01d9bbb098/f46e7/07-english-hero-copy-dashboard.png 340w,
/static/32b1b5d3eee5997df641db01d9bbb098/ca1dc/07-english-hero-copy-dashboard.png 680w,
/static/32b1b5d3eee5997df641db01d9bbb098/02d09/07-english-hero-copy-dashboard.png 1020w,
/static/32b1b5d3eee5997df641db01d9bbb098/9d567/07-english-hero-copy-dashboard.png 1360w,
/static/32b1b5d3eee5997df641db01d9bbb098/89066/07-english-hero-copy-dashboard.png 1440w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;English hero copy experiment dashboard showing published counts, per-variant scores, and review states&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;For a concrete output from this line of work, I can point to the &lt;a href=&quot;https://logi.place2page.com/&quot;&gt;LOGI Hannam landing page&lt;/a&gt;. I would frame it as a reference output from the experiment loop, not as a claim that this exact variant became the permanent production default.&lt;/p&gt;
&lt;h2 id=&quot;I-Also-Tested-A-More-Aggressive-Dynamic-Branch&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#I-Also-Tested-A-More-Aggressive-Dynamic-Branch&quot; aria-label=&quot;I Also Tested A More Aggressive Dynamic Branch permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;I Also Tested A More Aggressive Dynamic Branch&lt;/h2&gt;
&lt;p&gt;Once the experiment loop existed, it became easy to ask the next question.&lt;/p&gt;
&lt;p&gt;If &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; was stable, what would happen if I pushed macrostructure and theme variation further?&lt;/p&gt;
&lt;p&gt;That question led to the &lt;code class=&quot;language-text&quot;&gt;dynamic&lt;/code&gt; candidate.&lt;/p&gt;
&lt;p&gt;This direction clearly created larger structural variation. But it was not a straightforward runtime default candidate. Place2Page&apos;s core promise is stable local business landing page generation. The dynamic branch was interesting, but depending on the business type and data quality, it could make the information flow less reliable.&lt;/p&gt;
&lt;p&gt;So the conclusion of the loop was not &quot;choose the boldest structure.&quot;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; is more practical as a product default, while &lt;code class=&quot;language-text&quot;&gt;dynamic&lt;/code&gt; remains a candidate for the next experiment.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;What-I-Mean-By-Agentic-Research&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-I-Mean-By-Agentic-Research&quot; aria-label=&quot;What I Mean By Agentic Research permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What I Mean By Agentic Research&lt;/h2&gt;
&lt;p&gt;I would call this work &quot;agentic research.&quot;&lt;/p&gt;
&lt;p&gt;By that, I do not mean asking AI to &quot;research this for me&quot; and accepting whatever it produces. It is closer to a workflow where a person defines the problem and judgment criteria, and an AI agent executes a repeatable experiment loop quickly.&lt;/p&gt;
&lt;p&gt;This loop looked like this.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;1. A person defines the problem
   - The page is publishable, but place-specific variation and visual specificity are weak.

2. The current production baseline is fixed
   - Confirm the actual production default, not just the repo file.

3. The agent creates the experiment surface
   - Experiment group, candidate, screenshot, score, and human judgment record.

4. Generation is repeated on a fixed input set
   - Google restaurant, Google fitness, Naver workshop, Naver beauty.

5. Automated checks are used as guardrails
   - Published status, score, overflow flag, pass/review judgment.

6. A person reviews the result
   - A score of 100 does not mean &quot;best,&quot; so design and product review still matter.

7. Good directions and risky directions are separated
   - Combined becomes a production-default candidate, dynamic stays as a future experiment.

8. The result is documented and handed to the next product question
   - Record which prompt insight may become product behavior.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The point is not that AI writes a lot of code. The point is using AI as an experiment runner, observer, and repetitive-work assistant so that a person can spend more attention on higher-level judgment.&lt;/p&gt;
&lt;h2 id=&quot;Follow-Up-Korean-Hero-Copy-Felt-More-Obvious&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Follow-Up-Korean-Hero-Copy-Felt-More-Obvious&quot; aria-label=&quot;Follow Up Korean Hero Copy Felt More Obvious permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Follow-Up: Korean Hero Copy Felt More Obvious&lt;/h2&gt;
&lt;p&gt;When I revisited the experiment, one more thing stood out. Awkward Korean copy felt much more obvious to me than awkward English copy. That may be because Korean is my native language, but phrases like &quot;special experience,&quot; &quot;sensory space,&quot; or &quot;the pinnacle of dining&quot; expose the AI&apos;s atmospheric filler before they expose the actual place.&lt;/p&gt;
&lt;p&gt;So I also looked at a 2026-06-05 LOGI Hannam hero-copy run that still existed in local artifacts. I did not touch the DB for this update; I used the remaining HTML and result JSON. The copy criteria were simple: as Shopify&apos;s landing copy guide puts it, the first screen should quickly tell readers who you are, what you offer, why they should care, and what to do next. Live product pages such as Stripe and Linear also make category, value, audience, and action readable immediately.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/896b3fab41c38661756011aa09d8cfc5/89066/08-korean-hero-copy-dashboard.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAABwUlEQVR42nVTSW4cMQzs/78xl+QUe6Y3LRSXIhVQdpwBAteBTRFgsVRib+dd3h777/fncz9ZjdWIZbAYPOb0iIiMmcxpAKuyqKiJ2naXet7FIxQQNTWY4Sr1sZ+tEzxYsqgG0Yya0QcnxVZqZ1F4EEunAXefcV73XSqQJxZRM3dXNcAt2Y3GUMUG+PwP112O85pzxoIvfOUAItzg3zSXWlv76PUXfDU78G3zkl3+TY5PzGXhYnHAN1vN8YI5Z62t1vaq83U+Fsyw3bU990PSszQjLYFLGhTuIcsk4NOtTMxWlpWtE7dORKM1ojHmnKC2//pxv/2kLItHIFn0wzJVWysQOZlZiAazpMLkjoBpL9KbLbGxJAAeMZf8pMB6ue28csNK61frbTDc91KHWBt81SZqtY+7kXuctTViUTvrxxcbDRmc6/Y4TmrNgbfHDhmd6Lkf03GWct/3dDyOQwap6vtzd5V0u/VxldaSY4CHw4QIwg7T0d1UhW10hxkzeMBMiULZkJM593mZjM9/YPq6Hnz63wo8bfM58/7r5VN2qW3fj07ps5n1Tvt+tFyvqaq1tv04iUZEiEgp9TgvGnkcQ/4AY/Nt5eBguhsAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Korean hero copy experiment dashboard for LOGI, comparing control, evidence selector, few-shot editor, and combined variants&apos; title=&apos;&apos; src=&apos;/static/896b3fab41c38661756011aa09d8cfc5/ca1dc/08-korean-hero-copy-dashboard.png&apos; srcset=&apos;/static/896b3fab41c38661756011aa09d8cfc5/e7570/08-korean-hero-copy-dashboard.png 170w,
/static/896b3fab41c38661756011aa09d8cfc5/f46e7/08-korean-hero-copy-dashboard.png 340w,
/static/896b3fab41c38661756011aa09d8cfc5/ca1dc/08-korean-hero-copy-dashboard.png 680w,
/static/896b3fab41c38661756011aa09d8cfc5/02d09/08-korean-hero-copy-dashboard.png 1020w,
/static/896b3fab41c38661756011aa09d8cfc5/9d567/08-korean-hero-copy-dashboard.png 1360w,
/static/896b3fab41c38661756011aa09d8cfc5/89066/08-korean-hero-copy-dashboard.png 1440w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Korean hero copy experiment dashboard for LOGI, comparing control, evidence selector, few-shot editor, and combined variants&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The few-shot copy editor candidate showed both progress and limits. It moved away from inflated control copy and brought source-grounded words such as fire, smoke, and charcoal into the first viewport. But using only &lt;code class=&quot;language-text&quot;&gt;LOGI&lt;/code&gt; as the H1 is too thin for a product default; a more concrete promise such as &quot;Hannam wood-fire dining&quot; still needs to sit next to the brand.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/df8931743bfb459054c3d1ed265f7015/89066/09-korean-few-shot-page.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAACkElEQVR42l2TyWsUQRTGy/RaW/d0dXd19fQsPT0LcZJJJjkEEkfDOE6iRAxzCAGJAc0iUUENxIsiHoIaopeAIhiXg0QR8eDRgxcvwZP4F0lnlow+PupS78d730cVwJhQavi+TwjFmBBMemd8RdpFKaXMYsxiVsKyLKvdDHC3D3cxgxqE0IRhYkwgIggTHSJCDdqndnMMI4Q1RaGaIqASIFUDIGnRc2MFAAY8rCaZVRkaDlMp4fmO47mucF3RNxlhXZYsVS5iuYS1K42xetlp1SIAwPVGbnokV6vVi/liLhulU2EymREiRYhxDCNZ4rqSAeByY/Lru52JAK9fKJ0fNF+sDJ4dz3CRKRZL+agYZnOZdOj76X8mM1lKqUoIwHJzfHOxvlIvfXu5drCaWT6pGxp1edK2Pdv2HNtzHOE4om27AydkOdAUDsBGvXx/Yerg2dbvH++3R9RpQ7Gp6fKk6/pHEl3PXRgibChKQ5itAN5brO+u1Xfurn94tft6zloKVRMaLvfbA3vqwAQTHWEH6QtZPp+0RzGsBYkZV29K0tu57OPTjMZrxzn369gzwYTKkq/JGaylNLmaZqcCOmJozUG7mjUpNrgrnCPPPfUHhgLbKgguDIwUSRqQQFwnABgYAPFqCVuYzGM2t7vqwDpEwnU+7m18/7r/af/5k43mrAduXxranI+WKny1GVXK6SxLRNy2bc6Y21YHVjUYZoNfPz//OfxyuNfYahVutibfLE08GtVW0nB7hjeG/VsV40aV5aNCj+/AEBLO0IM7s08fXrt6JjGaZ7tbUxdLJAeUsq5XFYUi7HKfx2+TmyZrqwMjhA3DLOQLUZT3gxAjpKi6hgiMc4yjRJhAiCFECKH/ftFfcJFrWwiC0LwAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Korean few-shot hero copy output showing a concise LOGI hero with source-grounded fire and smoke wording&apos; title=&apos;&apos; src=&apos;/static/df8931743bfb459054c3d1ed265f7015/ca1dc/09-korean-few-shot-page.png&apos; srcset=&apos;/static/df8931743bfb459054c3d1ed265f7015/e7570/09-korean-few-shot-page.png 170w,
/static/df8931743bfb459054c3d1ed265f7015/f46e7/09-korean-few-shot-page.png 340w,
/static/df8931743bfb459054c3d1ed265f7015/ca1dc/09-korean-few-shot-page.png 680w,
/static/df8931743bfb459054c3d1ed265f7015/02d09/09-korean-few-shot-page.png 1020w,
/static/df8931743bfb459054c3d1ed265f7015/9d567/09-korean-few-shot-page.png 1360w,
/static/df8931743bfb459054c3d1ed265f7015/89066/09-korean-few-shot-page.png 1440w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Korean few-shot hero copy output showing a concise LOGI hero with source-grounded fire and smoke wording&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;Lessons&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Lessons&quot; aria-label=&quot;Lessons permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Lessons&lt;/h2&gt;
&lt;p&gt;First, a prompt experiment is meaningless if the baseline is wrong.&lt;/p&gt;
&lt;p&gt;Because I matched the production baseline first, the before/after comparison was explainable. If I had started from the repo file only, I might have been experimenting against an already-drifted baseline.&lt;/p&gt;
&lt;p&gt;Second, variation and stability have to be evaluated together.&lt;/p&gt;
&lt;p&gt;New structure is valuable, but if it causes mobile overflow or weak information delivery, it is hard to use as a product default. On the other hand, if the output is only stable and always looks the same, the generative product loses part of its value.&lt;/p&gt;
&lt;p&gt;Third, evidence still matters when working with AI.&lt;/p&gt;
&lt;p&gt;Without experiment groups, candidates, screenshots, scores, and human review, a fast experiment becomes fast memory loss. What mattered here was not that AI generated many outputs quickly, but that the loop left repeatable evidence.&lt;/p&gt;
&lt;p&gt;Fourth, a good experiment creates the next product question.&lt;/p&gt;
&lt;p&gt;The next question after the combined experiment was, &quot;Should I tighten the prompt so it uses photos better?&quot; In practice, a better direction appeared: analyze the photos first, then pass that information into generation input. That leads to the separate note on the photo intelligence pipeline.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Will-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Will-Judge-This-Next-Time&quot; aria-label=&quot;How I Will Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Will Judge This Next Time&lt;/h2&gt;
&lt;p&gt;When I run another prompt experiment, I will fix the baseline first. Repo files, local overrides, and the production baseline can differ, and if the comparison point is wrong, the result cannot be explained.&lt;/p&gt;
&lt;p&gt;I will use automated scores as guardrails for whether a candidate can be promoted as a product default. Whether a page is better still needs human design and product review. When scores tie, I will compare structural variation, information flow, and failure risk together.&lt;/p&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.shopify.com/blog/landing-page-copy&quot;&gt;Shopify - Landing Page Copy: Essential Elements + Tips&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://stripe.com/&quot;&gt;Stripe homepage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://linear.app/&quot;&gt;Linear homepage&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[AI 에이전트로 반복 가능한 실험 루프 만들기]]></title><description><![CDATA[AI 기능을 개선할 때 가장 위험한 흐름은 의외로 단순하다. Place2Page…]]></description><link>https://sewon.dev/place2page-agentic-research-hallmark-combined-loop/</link><guid isPermaLink="false">https://sewon.dev/place2page-agentic-research-hallmark-combined-loop/</guid><pubDate>Sun, 24 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;AI 기능을 개선할 때 가장 위험한 흐름은 의외로 단순하다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;프롬프트를 고친다
결과가 좋아 보인다
채택한다
며칠 뒤 다시 고친다
왜 좋아졌는지 모른다&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Place2Page에서도 비슷한 문제가 생길 수 있었다. 랜딩페이지 생성 결과는 이미 공개 가능한 수준이었지만, 장소마다 구조와 시각적 리듬이 비슷하게 모이는 경향이 있었다. 프롬프트를 몇 줄 고치면 당장은 더 좋아 보일 수 있다. 하지만 어떤 입력에서, 어떤 후보안이, 왜 더 나았는지 남지 않으면 다음 실험은 다시 감으로 돌아간다.&lt;/p&gt;
&lt;p&gt;그래서 이번 작업의 핵심은 &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; 프롬프트를 찾는 것이 아니었다. 진짜 목표는 사람이 문제를 정의하고, AI 에이전트가 같은 기준으로 반복 실험을 돌리고, 그 결과를 나중에 다시 설명할 수 있는 증거로 남기는 루프를 만드는 것이었다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/e9b6cc51228b04eee6603603df878ca4/cd15d/agentic-research-loop.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 54.11764705882353%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACGElEQVR42lWRy2sTURTGZyeCCzcutAi68lXIVqV2JUXwX9OFLsQqVkvR2iIaTVuQYsFFsUGbirFtbBuTyWsmmSRz596Z+z73iCFI/Thnczjfge93vHqLtgIaRqnfZu1u1h3woJcBADhnAf6WBWstHJNzDkfySGZIZhJuYiZZJkgshkPOEskSGQ84TUTGpdJmvP6/vLTrx/5u0txPWQaIWkCayHqThAEVqVUCELHqdx7N5+deFZ69LMzOv6sc+ojonPN0Za3+6TEpvkDadohSKW2M0hYRuRBKa0ScW1g+ceXquemps7nrJ89cvv/wKSJaaz0gvgzLOtpHI4aEdYKQdPjuDqtVBKWm1goQcfbJ8qnJ3MWZ2xdy06cncvf+mUmw2a6u9OprOmkYLoZRbxDwg3LWOFJpant9goALiyvnb96anLl7berOxKUbs88Xx2ZOfNav0KgCiiGAMUZqbcEpraVSRgEAquHgYPNLZatY+7bdKX3XUR9Hob3j9MBokFwKGcXpMKbGGBxRBsZo9TepNajfst0upmxMG51Dd+wRzoFRzhqw4GA0d+NO6YCnA0Q0YHuSUiO8z6yaT37m+z+WGl9f+8XF2taSX3zb2ynQvVW6R40YHUTLo+BoLTwqyKS5HbceHK6/CUreVup/pL9Ww3K+vv2hufPeL+XrpdWwvE4PNughE9Rmic6IZkNFfMNDBGPABjKJNf8DpMxEo96/vwMAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Agentic research loop diagram showing human framing, agent-run experiments, durable evidence artifacts, and a human promotion decision&apos; title=&apos;&apos; src=&apos;/static/e9b6cc51228b04eee6603603df878ca4/ca1dc/agentic-research-loop.png&apos; srcset=&apos;/static/e9b6cc51228b04eee6603603df878ca4/e7570/agentic-research-loop.png 170w,
/static/e9b6cc51228b04eee6603603df878ca4/f46e7/agentic-research-loop.png 340w,
/static/e9b6cc51228b04eee6603603df878ca4/ca1dc/agentic-research-loop.png 680w,
/static/e9b6cc51228b04eee6603603df878ca4/02d09/agentic-research-loop.png 1020w,
/static/e9b6cc51228b04eee6603603df878ca4/9d567/agentic-research-loop.png 1360w,
/static/e9b6cc51228b04eee6603603df878ca4/cd15d/agentic-research-loop.png 5000w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Agentic research loop diagram showing human framing, agent-run experiments, durable evidence artifacts, and a human promotion decision&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: Place2Page의 생성 결과는 공개 가능했지만, 프롬프트 실험이 기억과 스크린샷에만 남으면 나중에 왜 좋아졌는지 설명하기 어려웠다.&lt;/li&gt;
&lt;li&gt;판단: 중요한 것은 어떤 프롬프트가 이겼는가보다, 같은 입력에서 여러 가설을 반복 검증하고 증거를 남길 수 있는가였다.&lt;/li&gt;
&lt;li&gt;접근: 현재 기준선을 고정하고, 후보안을 같은 입력 세트에서 반복 생성한 뒤, 점수와 스크린샷, prompt diff, 통과 여부를 함께 남겼다.&lt;/li&gt;
&lt;li&gt;결과: &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; 후보안이 가장 실용적인 방향으로 보였지만, 더 큰 결과는 실험 lineage와 판단 기록이 남는 연구 루프였다.&lt;/li&gt;
&lt;li&gt;배운 점: 내가 말하는 에이전틱 리서치는 AI에게 판단을 맡기는 것이 아니라, 사람이 기준을 세우고 AI 에이전트가 반복 가능한 실험과 기록을 빠르게 만들게 하는 방식이다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;Place2Page는 Google Maps나 Naver Map URL을 넣으면 AI가 장소 기반 랜딩페이지를 생성한다. 장소명, 주소, 사진, 영업시간, 리뷰, 메뉴, 예약 링크 같은 데이터를 모아 HTML로 만든다.&lt;/p&gt;
&lt;p&gt;이 기능은 이미 쓸 수 있는 수준이었다. 문제는 &quot;동작하느냐&quot;보다 &quot;결과물이 장소마다 충분히 달라 보이느냐&quot;에 가까웠다.&lt;/p&gt;
&lt;p&gt;로컬 비즈니스 랜딩페이지는 쉽게 비슷한 구조로 모인다. 첫 화면, 사진 몇 장, 메뉴나 서비스 카드, 리뷰, 지도, CTA. 이 구성이 틀린 것은 아니지만, 매번 비슷하게 나오면 생성형 제품에 기대하는 적응력이 약해 보인다.&lt;/p&gt;
&lt;p&gt;처음에는 자연스럽게 프롬프트를 더 잘 쓰는 쪽으로 생각이 갔다. 구조를 더 다양하게 만들고, AI식 마케팅 문구를 줄이고, 모바일 화면이 깨지지 않게 지시를 더 강하게 넣으면 될 것 같았다.&lt;/p&gt;
&lt;p&gt;하지만 곧 질문이 바뀌었다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;이 프롬프트가 좋아 보인다는 판단을 나중에도 다시 설명할 수 있는가?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;프롬프트 실험은 작은 변경이 자주 일어난다. 그래서 더 쉽게 흩어진다. 결과 페이지 몇 장만 보고 &quot;이게 더 낫네&quot;라고 끝내면, 며칠 뒤에는 어떤 문구가 어떤 결과를 만들었는지 복원하기 어렵다.&lt;/p&gt;
&lt;h2 id=&quot;기존-방식이-실패하는-이유&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B8%B0%EC%A1%B4-%EB%B0%A9%EC%8B%9D%EC%9D%B4-%EC%8B%A4%ED%8C%A8%ED%95%98%EB%8A%94-%EC%9D%B4%EC%9C%A0&quot; aria-label=&quot;기존 방식이 실패하는 이유 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;기존 방식이 실패하는 이유&lt;/h2&gt;
&lt;p&gt;프롬프트 실험을 가장 쉽게 하는 방법은 파일을 열고 문구를 바꾸는 것이다. 그 다음 몇 개 결과를 보고 마음에 들면 채택한다.&lt;/p&gt;
&lt;p&gt;이 방식은 빠르다. 하지만 운영 제품에서는 곧 한계가 온다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;기준선이 무엇이었는지 흐려진다.&lt;/li&gt;
&lt;li&gt;어떤 입력에서 좋아졌는지 알기 어렵다.&lt;/li&gt;
&lt;li&gt;성공한 후보와 실패한 후보가 같이 사라진다.&lt;/li&gt;
&lt;li&gt;&quot;좋아 보였다&quot;는 판단만 남고 근거가 남지 않는다.&lt;/li&gt;
&lt;li&gt;현재 기본값이 파일의 기본값과 달라져도 알아차리기 어렵다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;특히 파일 기본값과 제품에서 선택된 기본값이 따로 존재하는 구조에서는 repo만 봐서는 현재 기준선을 알 수 없다. 그래서 실험의 첫 단계는 프롬프트 수정이 아니라 기준선 고정이었다.&lt;/p&gt;
&lt;h2 id=&quot;먼저-기준선을-맞췄다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%A8%BC%EC%A0%80-%EA%B8%B0%EC%A4%80%EC%84%A0%EC%9D%84-%EB%A7%9E%EC%B7%84%EB%8B%A4&quot; aria-label=&quot;먼저 기준선을 맞췄다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;먼저 기준선을 맞췄다&lt;/h2&gt;
&lt;p&gt;가장 먼저 한 일은 현재 실제로 쓰이는 기준선을 확인하는 것이었다. repo의 프롬프트 파일만 보는 것으로는 부족했다. 제품에서 선택된 기본값은 파일에 남아 있는 기본 문구와 달라질 수 있기 때문이다.&lt;/p&gt;
&lt;p&gt;그래서 실험은 로컬 파일 상태가 아니라, 현재 기준선을 맞춘 뒤 시작했다.&lt;/p&gt;
&lt;p&gt;이 기준선은 나쁘지 않았다. 기본 정보가 들어가고, 사진도 쓰고, 리뷰와 지도까지 있었다. 다만 결과를 보면 여전히 안전한 음식점 랜딩페이지 형태에 가까웠다. 사진이 페이지 구조를 이끈다기보다 이미 정해진 틀 안에 들어간 느낌이었다.&lt;/p&gt;
&lt;p&gt;여기서 중요한 기준이 생겼다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;실험은 &quot;내 로컬 프롬프트가 좋아졌는가&quot;가 아니라 &quot;현재 기준선보다 좋아졌는가&quot;를 봐야 한다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;가설은-압축하고-반복-가능성을-더-봤다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B0%80%EC%84%A4%EC%9D%80-%EC%95%95%EC%B6%95%ED%95%98%EA%B3%A0-%EB%B0%98%EB%B3%B5-%EA%B0%80%EB%8A%A5%EC%84%B1%EC%9D%84-%EB%8D%94-%EB%B4%A4%EB%8B%A4&quot; aria-label=&quot;가설은 압축하고 반복 가능성을 더 봤다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;가설은 압축하고, 반복 가능성을 더 봤다&lt;/h2&gt;
&lt;p&gt;초기 후보안은 여러 방향으로 나눴다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;정보 구조를 먼저 잡는 방향&lt;/li&gt;
&lt;li&gt;과장된 문구를 제거하는 방향&lt;/li&gt;
&lt;li&gt;반응형 안정성을 강화하는 방향&lt;/li&gt;
&lt;li&gt;세 가지를 결합한 방향&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;각 후보안의 세부 문구보다 더 중요했던 것은 모든 가설을 같은 입력에서 반복 검증할 수 있는가였다.&lt;/p&gt;
&lt;p&gt;실험은 네 개의 고정 장소에서 반복했다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Google 음식점&lt;/li&gt;
&lt;li&gt;Google 피트니스 스튜디오&lt;/li&gt;
&lt;li&gt;Naver 공방&lt;/li&gt;
&lt;li&gt;Naver 뷰티&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;고정 입력 세트를 둔 이유는 단순하다. 매번 다른 장소를 넣으면 결과가 좋아진 이유가 프롬프트 때문인지 장소 데이터 때문인지 구분하기 어렵다.&lt;/p&gt;
&lt;h2 id=&quot;결과보다-증거가-더-중요했다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%B0%EA%B3%BC%EB%B3%B4%EB%8B%A4-%EC%A6%9D%EA%B1%B0%EA%B0%80-%EB%8D%94-%EC%A4%91%EC%9A%94%ED%96%88%EB%8B%A4&quot; aria-label=&quot;결과보다 증거가 더 중요했다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;결과보다 증거가 더 중요했다&lt;/h2&gt;
&lt;p&gt;대표 실행 묶음의 자동 요약은 이랬다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Candidate&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Results&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Passed&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Average score&lt;/th&gt;
&lt;th&gt;Judgment mix&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;control-baseline&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;structure-first&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;anti-slop&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;88.0&lt;/td&gt;
&lt;td&gt;2 pass, 2 review&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;responsive-hardening&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;여기서 &lt;code class=&quot;language-text&quot;&gt;control-baseline&lt;/code&gt;도 100점이고 &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;도 100점이다. 그래서 &quot;combined가 자동 점수에서 이겼다&quot;고 말하면 틀리다.&lt;/p&gt;
&lt;p&gt;더 정확한 해석은 이렇다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;자동 점수는 공개 실패, 화면 깨짐, 명백한 품질 문제를 잡는 안전장치였다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;는 구조, 문구, 반응형 규칙을 함께 묶으면서 4/4 공개, 4/4 통과를 유지했다.&lt;/li&gt;
&lt;li&gt;사람이 봤을 때 기본값보다 정보 흐름과 시각적 다양성이 더 좋았다.&lt;/li&gt;
&lt;li&gt;하지만 최종 판단은 숫자 하나가 아니라 스크린샷, diff, 통과 여부, 사람의 리뷰를 같이 보고 내렸다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;좋은 실험은 좋은 결과만 남기지 않는다. 좋은 증거를 남긴다.&lt;/p&gt;
&lt;p&gt;이번 실험에서 가장 가치 있었던 산출물은 새 프롬프트 자체가 아니라, 아래를 연결한 증거 체계였다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;실험 lineage&lt;/li&gt;
&lt;li&gt;후보안별 점수와 통과 여부&lt;/li&gt;
&lt;li&gt;prompt diff&lt;/li&gt;
&lt;li&gt;스크린샷과 리뷰 상태&lt;/li&gt;
&lt;li&gt;사람이 왜 통과 또는 보류로 봤는지 남긴 판단 기록&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 실험에서 남긴 자산은 페이지 스크린샷만이 아니었다. 실행 묶음별 후보안, 점수, 통과 여부, 프롬프트 계보를 한 화면에서 볼 수 있게 실험 대시보드와 variant graph도 같이 만들었다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/9f1f5aa69fbc821ddac3cc615574638c/89066/06-variant-lineage-graph.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAACYklEQVR42lWS2Y7bOBRE+xsSa3NbohaKEvd7SXGR3U4H6QQz//9FiRxPAwOch6qHQhUu+XK+dNIAl3oR6tx250t36fpzS84taS7d+UKKqvk/9ad+OZU15Uq7yI2DLTGhXsnY9lPb07an3TA/+CsomZaeCTLzdpyPcFHWjXTV9la6a42Zb/vt/Ve8f6hwE2ZbtZsFMIlPFDIBi98nu52K6ggXEr646xfcT5AYRoOBa9QYuEK66pHJflzpqnrKx1lQJnvKCV2fzaWEr27/irm0cZQ4Kt+uhnDouCUcRu1H7XuBnwzSESaf4UrA6ajNpQkLhP37r+uPf3F/F5g4ZoFJYOaQ+GHTarbFX8fP2ZWwJ8wnSKUJzHhwyUCwGIVCoZArWLiRxnEJQjuhcJxFT/l/zdwWkAoba71NCgftWwGjDYPxRLvZJQphsoEo1wropDt4zq7qipvCxsKESntmN7z/hPvHjHmGPNm4+qsIbxQShTTZOGg/+dugXXHMruqam8rG8hFeYYvp5rbdQtDGa+OlPgYb2JR2SnvGJOVm4Loo65eiaqpFnZQv9dYoRxWOynXcMIiTdoPCxSVq/Gy3XgLhdpDQrbqb1ucPI8bT/XttHmHt13Rn4Y2Y0EMkJkxuZ+F2WBuJDcRsvb8ShcfsU1l3ytH9vTFbLUC49P7jn+v9A/xuXbaYDSaN0fp8WJfBZczfmA2Pp6qamqlCQCXxLHGWQBfV03V5CLpIJsw480XYcRbjLOZFDdNKRvb32s15UY1yjcRXAZPCabv2mHt30EFk6b7ke+8ygdja0JrQQupW8+dgvwGW646ucqr3dQAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Prompt variant graph showing local experiment lineage, per-variant publish counts, and quality scores&apos; title=&apos;&apos; src=&apos;/static/9f1f5aa69fbc821ddac3cc615574638c/ca1dc/06-variant-lineage-graph.png&apos; srcset=&apos;/static/9f1f5aa69fbc821ddac3cc615574638c/e7570/06-variant-lineage-graph.png 170w,
/static/9f1f5aa69fbc821ddac3cc615574638c/f46e7/06-variant-lineage-graph.png 340w,
/static/9f1f5aa69fbc821ddac3cc615574638c/ca1dc/06-variant-lineage-graph.png 680w,
/static/9f1f5aa69fbc821ddac3cc615574638c/02d09/06-variant-lineage-graph.png 1020w,
/static/9f1f5aa69fbc821ddac3cc615574638c/9d567/06-variant-lineage-graph.png 1360w,
/static/9f1f5aa69fbc821ddac3cc615574638c/89066/06-variant-lineage-graph.png 1440w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Prompt variant graph showing local experiment lineage, per-variant publish counts, and quality scores&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;이 그래프에서 더 중요한 기능은 프롬프트 diff였다. control에는 diff가 없고, 실험 후보안에서는 어떤 프롬프트 영역을 바꿨는지 바로 열어볼 수 있다. 변경 지점을 나눠 보여주면 나중에 &quot;이 결과가 왜 나왔는가&quot;를 사람이 다시 검토할 수 있다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c3f99305b8e482e56ae20e10cd55ef82/89066/10-prompt-diff-few-shot.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAABv0lEQVR42o3SC27bMAwG4Bxgi23JeouUKFmJmzhxMyxr0WG7/7E2P5am3VAM+EAQAgj+Arj5XDXQ7cswUioxF8o76nZC2Y+10lQN33za1v1wfvr+88v1+XJ9/vby4+vTi/FBO1woBze3R2l81bDNtmbGYcod5ZxKcYA140woLhSb8TvagfXBQlAW5uGGa+tSjjFiQIfgrNNKq5uGi79xqafYVcOk8ZgLULYeHUYI5OcKgYwDbb22fmleh8U6zIW2gXLMxXjQzis70W7Cpb5PzoRcrJunP8eADwX6DvedoaAD6jiRAdQ/RZDer8OWYvd4yOOhG4/p1MdhT0PfPR6xLzqiofBeCgqgqtmmqplGhH2G3SvXkU3RpLBEeI9w3sz+bB4P+TwbJzT08VD+a9hQ2F/P5XIsl6Fchin8+SGdHnzJlqJNbxiKJsU19rZufEz9OO5PZ0dJAQrjWm1bbYV2wrzhAkHKIXcGwnb6c8OVtggOwHpnhFQ3XEjGxR3J2tXtSLg0zgbUzkoppFZCSTnjragYr1m71mapbVUz1qqa8c22mW4bYkbqkLKDOPUxeySkjDFN95PK0iDlMHMQf8f+Bf9eYCTCXe/UAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Prompt diff drawer showing changed prompt slots for the Korean few-shot copy editor variant&apos; title=&apos;&apos; src=&apos;/static/c3f99305b8e482e56ae20e10cd55ef82/ca1dc/10-prompt-diff-few-shot.png&apos; srcset=&apos;/static/c3f99305b8e482e56ae20e10cd55ef82/e7570/10-prompt-diff-few-shot.png 170w,
/static/c3f99305b8e482e56ae20e10cd55ef82/f46e7/10-prompt-diff-few-shot.png 340w,
/static/c3f99305b8e482e56ae20e10cd55ef82/ca1dc/10-prompt-diff-few-shot.png 680w,
/static/c3f99305b8e482e56ae20e10cd55ef82/02d09/10-prompt-diff-few-shot.png 1020w,
/static/c3f99305b8e482e56ae20e10cd55ef82/9d567/10-prompt-diff-few-shot.png 1360w,
/static/c3f99305b8e482e56ae20e10cd55ef82/89066/10-prompt-diff-few-shot.png 1440w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Prompt diff drawer showing changed prompt slots for the Korean few-shot copy editor variant&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;개별 실행 대시보드는 자동 점수와 사람이 봐야 하는 지점을 분리해준다. 첫 화면 문구 실험처럼 통과 여부, 점수, 스크린샷 상태가 한 화면에 있으면 &quot;점수는 통과했지만 사람이 다시 봐야 하는 문구&quot;를 빠르게 골라낼 수 있다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/32b1b5d3eee5997df641db01d9bbb098/89066/07-english-hero-copy-dashboard.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAABX0lEQVR42pVTiY6dMAzk/3+0u0AOO5ft2KEKvFLU3X1SRyiywTODBrOEiB/r/rHumwuVmKQTSyNuLDaGjTHG8SqOo6uSCLGwdJa+AOYQ0cYQVZYuXbsaYN52n0tVG8Tz5vlUZ3GejabEgrkQi9poxKU2NbMxQgTA1LWbWSOWPgsRUbU+1bXUJqKLqh1fAJi8D6fOhE2Mq7M/6Go/kj/XXVWf05eWmemJH8kRMAI+bP+HHACdD2fAx3jgai8hfeO8O3+3F+2uL7wjb7u75+7kvg9sfAlsd/72+8f5kvrG+ZoLMa7r9rJ641wbpVyI+PV655hIZ+Y7Y7v28++nnmfvuqRcMWUiTrnWSoA5QgLMkArmAqmEmHKuLkCE5AL4AJDy6kJtvKTS9gCYK7FIn+s991aE59VF1GFymLYIHvMO+BnAYf7lPHFfiDud/8MzlSd8IizsU8PKsXDDmCHuSL3bb4A9cBIBX4K6AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;English hero copy experiment dashboard showing pass counts, per-variant scores, and review states&apos; title=&apos;&apos; src=&apos;/static/32b1b5d3eee5997df641db01d9bbb098/ca1dc/07-english-hero-copy-dashboard.png&apos; srcset=&apos;/static/32b1b5d3eee5997df641db01d9bbb098/e7570/07-english-hero-copy-dashboard.png 170w,
/static/32b1b5d3eee5997df641db01d9bbb098/f46e7/07-english-hero-copy-dashboard.png 340w,
/static/32b1b5d3eee5997df641db01d9bbb098/ca1dc/07-english-hero-copy-dashboard.png 680w,
/static/32b1b5d3eee5997df641db01d9bbb098/02d09/07-english-hero-copy-dashboard.png 1020w,
/static/32b1b5d3eee5997df641db01d9bbb098/9d567/07-english-hero-copy-dashboard.png 1360w,
/static/32b1b5d3eee5997df641db01d9bbb098/89066/07-english-hero-copy-dashboard.png 1440w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;English hero copy experiment dashboard showing pass counts, per-variant scores, and review states&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;실험 결과물은 실제 페이지 수준의 산출물까지 만들 수 있었다. 다만 이 글에서는 &quot;기본값으로 확정된 최종안&quot;이라기보다 프롬프트 실험이 어떤 품질의 페이지까지 이어질 수 있는지 보여주는 참고 산출물로 보는 편이 맞다.&lt;/p&gt;
&lt;h2 id=&quot;기록이-사라지면-더-분명해진다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B8%B0%EB%A1%9D%EC%9D%B4-%EC%82%AC%EB%9D%BC%EC%A7%80%EB%A9%B4-%EB%8D%94-%EB%B6%84%EB%AA%85%ED%95%B4%EC%A7%84%EB%8B%A4&quot; aria-label=&quot;기록이 사라지면 더 분명해진다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;기록이 사라지면 더 분명해진다&lt;/h2&gt;
&lt;p&gt;이 교훈은 실험 기록 일부를 다시 잇기 어려웠던 뒤 더 강해졌다.&lt;/p&gt;
&lt;p&gt;결과 페이지나 스크린샷 일부는 남아 있어도, &quot;왜 이 프롬프트를 채택했는가&quot;, &quot;정확히 어떤 영역이 바뀌었는가&quot;, &quot;그 후보가 어떤 입력에서 실패했는가&quot;가 빠지면 실험을 복원하기 어렵다.&lt;/p&gt;
&lt;p&gt;그때 분명해진 것이 있다.&lt;/p&gt;
&lt;p&gt;실험은 기억에 의존하면 안 된다. 결과만 남겨도 부족하다. 결과가 나오기까지의 경로가 남아야 한다.&lt;/p&gt;
&lt;p&gt;그래서 이후에는 단순히 프롬프트를 잘 쓰는 것보다, 실험 과정 자체를 남기는 시스템이 더 중요해졌다. 최소한 HTML 산출물, variant graph, prompt diff, 평가 기록으로 실험 흐름을 다시 추적할 수 있어야 했다.&lt;/p&gt;
&lt;p&gt;이 경험 때문에 실험 대시보드와 variant graph는 부가 산출물이 아니라 핵심 산출물이 됐다.&lt;/p&gt;
&lt;h2 id=&quot;내가-말하는-에이전틱-리서치&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%82%B4%EA%B0%80-%EB%A7%90%ED%95%98%EB%8A%94-%EC%97%90%EC%9D%B4%EC%A0%84%ED%8B%B1-%EB%A6%AC%EC%84%9C%EC%B9%98&quot; aria-label=&quot;내가 말하는 에이전틱 리서치 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;내가 말하는 에이전틱 리서치&lt;/h2&gt;
&lt;p&gt;이번 작업을 나는 &quot;에이전틱 리서치&quot;라고 부르고 싶다.&lt;/p&gt;
&lt;p&gt;여기서 말하는 에이전틱 리서치는 AI에게 &quot;알아서 연구해줘&quot;라고 던지는 것이 아니다. 사람이 문제와 판단 기준을 정하고 AI 에이전트가 반복 가능한 실험 루프를 빠르게 실행하게 만드는 방식에 가깝다.&lt;/p&gt;
&lt;p&gt;이번 루프는 이렇게 생겼다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;1. 사람이 문제를 정의한다
   - 페이지는 공개 가능한 수준이지만, 장소별 다양성과 시각적 구체성이 약하다.

2. 현재 기준선을 고정한다
   - repo 파일이 아니라 실제 기본값을 확인한다.

3. 여러 가설을 만든다
   - 구조, 문구, 반응형 안정성 같은 방향을 나눠 본다.

4. 에이전트가 고정 입력 세트로 반복 생성한다
   - Google 음식점, Google 피트니스, Naver 공방, Naver 뷰티.

5. 자동 검사를 안전장치로 쓴다
   - 통과 여부, 점수, 화면 깨짐 여부, 통과/검토 판단.

6. 증거 artifact를 남긴다
   - 실험 대시보드, variant graph, prompt diff, 스크린샷, 판단 기록.

7. 사람이 결과를 본다
   - 100점이 &quot;가장 좋다&quot;는 뜻은 아니므로 사람이 제품 관점에서 다시 본다.

8. 좋은 방향과 위험한 방향을 나눈다
   - 기본값 후보와 다음 실험 후보를 분리한다.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 방식의 핵심은 AI가 코드를 많이 쓴다는 점이 아니다. AI를 실험 실행자, 관찰 기록자, 반복 작업자로 써서 사람이 더 높은 수준의 판단에 집중하는 데 있다.&lt;/p&gt;
&lt;h2 id=&quot;후속-실험도-같은-루프-위에서-봤다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%9B%84%EC%86%8D-%EC%8B%A4%ED%97%98%EB%8F%84-%EA%B0%99%EC%9D%80-%EB%A3%A8%ED%94%84-%EC%9C%84%EC%97%90%EC%84%9C-%EB%B4%A4%EB%8B%A4&quot; aria-label=&quot;후속 실험도 같은 루프 위에서 봤다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;후속 실험도 같은 루프 위에서 봤다&lt;/h2&gt;
&lt;p&gt;실험 루프가 생기면 좋은 점은 다음 질문을 바로 던질 수 있다는 것이다.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;가 안정적이라면, 큰 구조나 테마 다양화까지 더 밀어붙이면 어떨까?&lt;/p&gt;
&lt;p&gt;이 질문으로 &lt;code class=&quot;language-text&quot;&gt;dynamic&lt;/code&gt; 후보안도 돌렸다. 이 방향은 확실히 구조적 다양성을 더 크게 만들었다. 하지만 바로 기본값으로 올리기에는 애매했다. Place2Page의 기본 약속은 안정적인 로컬 비즈니스 랜딩페이지 생성이다. &lt;code class=&quot;language-text&quot;&gt;dynamic&lt;/code&gt; 방향은 흥미롭지만 업종과 데이터 품질에 따라 정보 전달이 흔들릴 가능성이 있었다.&lt;/p&gt;
&lt;p&gt;그래서 이 루프의 결론은 &quot;가장 과감한 구조를 고르자&quot;가 아니었다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;제품 기본값으로는 &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;가 더 실용적이고, &lt;code class=&quot;language-text&quot;&gt;dynamic&lt;/code&gt;은 다음 실험 후보로 남긴다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;이후 한국어 첫 화면 문구도 같은 관점에서 봤다. 영어 문구의 어색함보다 한국어 문구의 어색함이 훨씬 크게 느껴졌다. &quot;특별한 경험&quot;, &quot;감각적인 공간&quot;, &quot;미식의 정점&quot; 같은 문구는 실제 장소의 증거보다 AI가 만든 분위기를 먼저 드러낸다.&lt;/p&gt;
&lt;p&gt;그래서 기존 산출물에 남아 있던 한국어 첫 화면 문구 실험도 같이 봤다. 이번에는 새 실행을 만들지 않고 남아 있던 HTML과 결과 JSON을 기준으로 했다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/896b3fab41c38661756011aa09d8cfc5/89066/08-korean-hero-copy-dashboard.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAABwUlEQVR42nVTSW4cMQzs/78xl+QUe6Y3LRSXIhVQdpwBAteBTRFgsVRib+dd3h777/fncz9ZjdWIZbAYPOb0iIiMmcxpAKuyqKiJ2naXet7FIxQQNTWY4Sr1sZ+tEzxYsqgG0Yya0QcnxVZqZ1F4EEunAXefcV73XSqQJxZRM3dXNcAt2Y3GUMUG+PwP112O85pzxoIvfOUAItzg3zSXWlv76PUXfDU78G3zkl3+TY5PzGXhYnHAN1vN8YI5Z62t1vaq83U+Fsyw3bU990PSszQjLYFLGhTuIcsk4NOtTMxWlpWtE7dORKM1ojHmnKC2//pxv/2kLItHIFn0wzJVWysQOZlZiAazpMLkjoBpL9KbLbGxJAAeMZf8pMB6ue28csNK61frbTDc91KHWBt81SZqtY+7kXuctTViUTvrxxcbDRmc6/Y4TmrNgbfHDhmd6Lkf03GWct/3dDyOQwap6vtzd5V0u/VxldaSY4CHw4QIwg7T0d1UhW10hxkzeMBMiULZkJM593mZjM9/YPq6Hnz63wo8bfM58/7r5VN2qW3fj07ps5n1Tvt+tFyvqaq1tv04iUZEiEgp9TgvGnkcQ/4AY/Nt5eBguhsAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Korean hero copy experiment dashboard comparing control, evidence selector, few-shot editor, and combined variants&apos; title=&apos;&apos; src=&apos;/static/896b3fab41c38661756011aa09d8cfc5/ca1dc/08-korean-hero-copy-dashboard.png&apos; srcset=&apos;/static/896b3fab41c38661756011aa09d8cfc5/e7570/08-korean-hero-copy-dashboard.png 170w,
/static/896b3fab41c38661756011aa09d8cfc5/f46e7/08-korean-hero-copy-dashboard.png 340w,
/static/896b3fab41c38661756011aa09d8cfc5/ca1dc/08-korean-hero-copy-dashboard.png 680w,
/static/896b3fab41c38661756011aa09d8cfc5/02d09/08-korean-hero-copy-dashboard.png 1020w,
/static/896b3fab41c38661756011aa09d8cfc5/9d567/08-korean-hero-copy-dashboard.png 1360w,
/static/896b3fab41c38661756011aa09d8cfc5/89066/08-korean-hero-copy-dashboard.png 1440w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Korean hero copy experiment dashboard comparing control, evidence selector, few-shot editor, and combined variants&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;few-shot 문구 편집 후보안은 좋은 방향과 한계를 함께 보여줬다. control의 과한 수사보다 훨씬 담백해졌고, 실제 장소 데이터에 가까운 단어를 앞으로 가져왔다. 다만 H1이 너무 짧아지는 결과도 있었다. 기본값으로 올리려면 장소명만 두기보다 구체적인 약속을 같이 잡아야 한다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/df8931743bfb459054c3d1ed265f7015/89066/09-korean-few-shot-page.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 76.47058823529412%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAIAAABr+ngCAAAACXBIWXMAAAsTAAALEwEAmpwYAAACkElEQVR42l2TyWsUQRTGy/RaW/d0dXd19fQsPT0LcZJJJjkEEkfDOE6iRAxzCAGJAc0iUUENxIsiHoIaopeAIhiXg0QR8eDRgxcvwZP4F0lnlow+PupS78d730cVwJhQavi+TwjFmBBMemd8RdpFKaXMYsxiVsKyLKvdDHC3D3cxgxqE0IRhYkwgIggTHSJCDdqndnMMI4Q1RaGaIqASIFUDIGnRc2MFAAY8rCaZVRkaDlMp4fmO47mucF3RNxlhXZYsVS5iuYS1K42xetlp1SIAwPVGbnokV6vVi/liLhulU2EymREiRYhxDCNZ4rqSAeByY/Lru52JAK9fKJ0fNF+sDJ4dz3CRKRZL+agYZnOZdOj76X8mM1lKqUoIwHJzfHOxvlIvfXu5drCaWT6pGxp1edK2Pdv2HNtzHOE4om27AydkOdAUDsBGvXx/Yerg2dbvH++3R9RpQ7Gp6fKk6/pHEl3PXRgibChKQ5itAN5brO+u1Xfurn94tft6zloKVRMaLvfbA3vqwAQTHWEH6QtZPp+0RzGsBYkZV29K0tu57OPTjMZrxzn369gzwYTKkq/JGaylNLmaZqcCOmJozUG7mjUpNrgrnCPPPfUHhgLbKgguDIwUSRqQQFwnABgYAPFqCVuYzGM2t7vqwDpEwnU+7m18/7r/af/5k43mrAduXxranI+WKny1GVXK6SxLRNy2bc6Y21YHVjUYZoNfPz//OfxyuNfYahVutibfLE08GtVW0nB7hjeG/VsV40aV5aNCj+/AEBLO0IM7s08fXrt6JjGaZ7tbUxdLJAeUsq5XFYUi7HKfx2+TmyZrqwMjhA3DLOQLUZT3gxAjpKi6hgiMc4yjRJhAiCFECKH/ftFfcJFrWwiC0LwAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Korean few-shot hero copy output showing a concise hero with source-grounded wording&apos; title=&apos;&apos; src=&apos;/static/df8931743bfb459054c3d1ed265f7015/ca1dc/09-korean-few-shot-page.png&apos; srcset=&apos;/static/df8931743bfb459054c3d1ed265f7015/e7570/09-korean-few-shot-page.png 170w,
/static/df8931743bfb459054c3d1ed265f7015/f46e7/09-korean-few-shot-page.png 340w,
/static/df8931743bfb459054c3d1ed265f7015/ca1dc/09-korean-few-shot-page.png 680w,
/static/df8931743bfb459054c3d1ed265f7015/02d09/09-korean-few-shot-page.png 1020w,
/static/df8931743bfb459054c3d1ed265f7015/9d567/09-korean-few-shot-page.png 1360w,
/static/df8931743bfb459054c3d1ed265f7015/89066/09-korean-few-shot-page.png 1440w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Korean few-shot hero copy output showing a concise hero with source-grounded wording&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;첫째, 프롬프트 실험은 기준선이 틀리면 의미가 없다.&lt;/p&gt;
&lt;p&gt;기준선을 먼저 맞췄기 때문에 전후 비교를 설명할 수 있었다. repo 파일만 보고 시작했다면 이미 어긋난 기준을 놓고 실험했을 수 있다.&lt;/p&gt;
&lt;p&gt;둘째, 자동 점수는 결론이 아니라 안전장치다.&lt;/p&gt;
&lt;p&gt;100점이 가장 좋은 페이지라는 뜻은 아니다. 공개 실패, 화면 깨짐, 명백한 품질 문제를 걸러주는 최소한의 장치에 가깝다. 더 좋은 페이지인지는 여전히 사람이 제품과 디자인 관점에서 봐야 한다.&lt;/p&gt;
&lt;p&gt;셋째, 좋은 실험은 증거를 남긴다.&lt;/p&gt;
&lt;p&gt;실험 묶음, 후보안, 스크린샷, 점수, prompt diff, 사람의 판단 기록이 없으면 빠른 실험은 빠른 기억 손실이 된다. 이번에 의미 있었던 것은 AI가 빨리 많이 만든 것이 아니라, 반복 가능한 증거 체계를 만들었다는 점이다.&lt;/p&gt;
&lt;p&gt;넷째, 좋은 실험은 다음 제품 질문을 만든다.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt; 실험의 다음 질문은 &quot;사진을 더 잘 쓰도록 프롬프트를 조일까?&quot;였다. 그런데 실제로는 프롬프트보다 더 나은 방향이 보였다. 사진 자체를 먼저 분석해서 생성 입력으로 넘기는 것이다. 이 다음 이야기는 별도 글인 photo intelligence pipeline 기록으로 이어진다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;이번 실험의 결과는 &lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;가 아니었다.&lt;/p&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;는 언젠가 또 바뀔 수 있다. 제품 기본값은 더 나은 데이터 경로, 더 나은 사진 분석, 더 나은 품질 기준이 생기면 계속 바뀌어야 한다.&lt;/p&gt;
&lt;p&gt;진짜 결과는 문제를 정의하고, 기준선을 고정하고, 가설을 만들고, 같은 입력에서 반복하고, 증거를 남기고, 채택 여부를 결정하는 연구 시스템이었다.&lt;/p&gt;
&lt;p&gt;앞으로 프롬프트 실험을 다시 할 때도 문구가 마음에 드는지보다, 나중에 같은 결정을 재현할 수 있는지 먼저 본다. 기록되지 않은 prompt win은 운영 자산이 아니라 기억에 가깝다.&lt;/p&gt;
&lt;p&gt;이후의 photo intelligence pipeline도, 다음 프롬프트 실험도, 같은 루프 위에서 진행될 것이다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.shopify.com/blog/landing-page-copy&quot;&gt;Shopify - Landing Page Copy: Essential Elements + Tips&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://stripe.com/&quot;&gt;Stripe homepage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://linear.app/&quot;&gt;Linear homepage&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Using Photos as Generation Metadata, Not Prompt Decoration]]></title><description><![CDATA[Adding more photos did not automatically make Place2Page landing pages better. My first instinct was to add another prompt rule telling the…]]></description><link>https://sewon.dev/en/place2page-photo-intelligence-multimodal-metadata-pipeline/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-photo-intelligence-multimodal-metadata-pipeline/</guid><pubDate>Sun, 24 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Adding more photos did not automatically make Place2Page landing pages better. My first instinct was to add another prompt rule telling the model to &quot;use the photos well.&quot; After looking at the actual output, the problem was not wording. It was the data path. Once the photos were analyzed first and passed as structured &lt;code class=&quot;language-text&quot;&gt;photo_intelligence&lt;/code&gt; metadata, the final HTML model could use them as hero candidates, gallery evidence, brand color cues, and alt text sources instead of treating them as a loose asset list.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: Even after the Hallmark combined prompt, the final HTML model still had to infer photo roles, color usage, and alt text on its own.&lt;/li&gt;
&lt;li&gt;Decision: Instead of making the prompt longer, I analyzed photos first and added explicit visual metadata to the generation payload.&lt;/li&gt;
&lt;li&gt;Result: The automated score tied the previous variant, but human review showed more intentional photo placement and color use, and the debug screen made the cause easier to inspect.&lt;/li&gt;
&lt;li&gt;Lesson: Multimodal product quality is less about &quot;including images&quot; and more about turning image understanding into stable pipeline input.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;The-limit-of-the-previous-step&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-limit-of-the-previous-step&quot; aria-label=&quot;The limit of the previous step permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The limit of the previous step&lt;/h2&gt;
&lt;p&gt;The earlier Hallmark combined experiment helped. Combining structure, anti-slop copy, and responsive hardening improved the information flow and visual rhythm compared with the baseline. Photos, however, were still mostly outside the text prompt.&lt;/p&gt;
&lt;p&gt;For a restaurant photo set, the model has to answer questions like these:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Which photo should be the hero?&lt;/li&gt;
&lt;li&gt;Which photos are menu or detail evidence?&lt;/li&gt;
&lt;li&gt;Which photos would make text overlays hard to read?&lt;/li&gt;
&lt;li&gt;Which colors can work as natural brand accents?&lt;/li&gt;
&lt;li&gt;How should the alt text describe the photo without inventing details?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;When all of those decisions were left to the final HTML model at once, the result often felt vague. Photos were present, but the page did not always look as if it understood them.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/a03caa42edb43a6057aca9e75d78126a/64756/01-combined-before-photo-intelligence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 341.764705882353%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAABECAIAAAAOZYKtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKAklEQVR42o2X2XPb1hWHAa4ALnYQIAASJBaSIMFVC0VRkrVbovbdsSxZXqTYji3bsrzKVpXYqe3GSesmTcaZpp3YbdNxM2ndTNvMpJmmM5npQ/PShz51+tK/os8dAFodu/Y39wHAvT8c3HMu7j0HommSpqlINCLJcjgcpkiKwG0IggA4zjIMSRIAAD7EUVy4lifvTXFX+2mWAhjAofa+rtaWUkJX45JQshLlUkZThEiUM5NSzlJ6e7skWUZRlHAAOI4Bu7lAupnJ1ddnkkY2qY4NtB45WNvXbGUyYrU50dNbGhiuyZGIK3YFwGmbYkUReJYUBYbn6FLOGOwutzWmsjm1v6vY32F193REo1EMw1zL+F6gQoOVVEJmXCim1a5Kqi4t1+nCgUOjQ/tbR6qZSjnPcVwgEEBRNBgMPi0WeFYJs1FFMUwzV18c6GiodTTNjvd1Ntf3D/TVBvp0XVcUxXAgSRIAsCOWeEaLcJIcpkU5LEsjnY2j3eWRwZ7O1ubR3urCdK2p3FAslhIJI5VKPS2uy8YqRT1vKtlkpLmgtxTijZlYZ09va3vHaHfjocHmumJe03UAwDM+W1WkeFSSRF6RhXg0HJVCUTkciSqiHIlKQlwOUeQmz3AYgmIIiqEYhm5eAOcaxTaf7P7Mp4EIArcbju9cOMvLDc13jO0V4/8XiiQYimQoinYbTTEMzTDMi8UEjgcxHPKjsC/gCwa8/iDs9UMQBMOwO5lNMfEM8AAK2tPSlcHshYmWE8PtZyY7Ls0PXls5c+ryJYbnMQzbFKMoiiAI2AVJkrDHe2pu4qO761dOTX3/52fPXpk7ujB5fePyo989FmUJRRDIHZfP53O5nGmaiqKoqmqapiSKsMc7MzW1ODNaX1ZOflBbeefIxWuTS4uDPd1lgiRxAGzLJEnqup5OpyORCEmStAtF+YNYf5s11qqmEqHT81N/evL4X19c+Pb3l9cuzlM0BVwxQRCxWFxR4vG4qmm6phmqqiUSCUAw8wMN65NmMiYsDLY9fvSLjy51fn0t+5e7h3mWRrEtsSyGhRDHh1iOZViWpWkmxLF+lJ5vx/6wzPWXIiwbmi+rH53s+fuJ6hcnaixDYK5lnCDIUARnJJyVWSEiy5FIJCqJUjCINjerb502b47yD6aFfxyl/32977+fv/PVuQYG9WE4CQGA0yQ+VRFeqYpzbVJ7VmBY3iUYQLsn6s6tT52dMp7Mc19PQF+Mgb8tx++8WsEJxnaYIwbjdeR0mTlYYZoNPIhgAMNw+zdC6krm7JHhA0dqKzP1G9N1V+d7Tx+deG35RIhjN+MMcBz245APQF7gRwjSWSIkSQQxvC1BjBRCRSPSmFXbGlKjvQ3n57se36hJIRrBbMvOkiAASeCk/WNsLhJ38ZAEQRGABCgBUArHGALjGSLEkO4YSHoO4XA4LNjwQliUJLuJdhPCovPABlIdNAd1C13XLYdsNmtZlq7rmrY5ZvdIKO4Q24umaXmHYrFYKBQ0TdvdG98CisViiUQil8tlMhn3rfF43DRNy7JSqZTirDtN09LptGN/0+yO2DCMdDqTyViJRELXjXhcTSZT2WwulTINw0gkEpqmp1KmaabdDdg1sGM5m83qurFtOZVKZbNZd5xryn63ZW3danssW1bWtewY15LJpGVlU6mU+0TTdNNMW1Y2nU47A/Qdse1eQ1c1eyZKTFHVuGq7ULE9p7oTjDmzjLnTVbd8DNE0DQDweX0IggIcpygKwXAUAzRNEyRp78QAx0kKA7h9C4C9bnFAEARFUZDf788X8pfWLnXWWhoLJs8Q3WWrWkiQJBHX4qOdlZ76dF4Ry2nVUuTR9ramTFN7Y7MiRxEEgTywd/9Az6++enzp1upYR50api7MDS2OthMAZVn249eXnvz4wr0bCzfHK2+tDt27c/Tq4sTq9FCdmQwgCOT3BcqthbUP3+ieGG4v6emEkkoa1VKyZBlxJXrz1PgnD9c/u3/ql8uVb++03T/ftbZSu7U8XtCVAIJCXq+vrav65afvb5ycGNpfX+vMD/aWhjoa3l2Zuzq7/9WZ7p/8cOn9lY63b06+udC4MW2cWmhZPtirizyCYZDP629pb3p4c/HqTKW7tTQ93jM+2K7E1NWT0/evz4Ro+oClPRprPGrGq7pYjpP7TM7icSVEogCHvD5/z77y4/eurhzdf3i27+TRwWPHhqdrHdMj5bGxysFi+lx787WJ/tXm/Gw5dffsyE9vzWwsDqZELogBCII9k0N9//zs3p/vHnzzzOjy1aV3319fO3to5cQrh2utSxlhQiJmI3QOhm6cmfn09tTnb1T/8/UPZsb7IQiGfP5AtSH/o2unfnZ79cHl4SuH9l08MrJ+5vDJ2ZH+9jJLECUh1CjxqRA7M9Qy2ZI+PmK9vXagu7Pq9frsPYxlqMXjc1/+ZvaTjb63rlz4bO3cB3cu9vc1tbV2Hjs0cnqiZWG46/r5WZZhfEE0iAKvLxgMIgRBQBiGRcTwg3tnvvmw7ePXF9ZuzP32g431W3P7WlLzB6a/t7r45MHGr98998axTjHEOhsWvp1WQSiK6bHo9TMH/nhr6dG983+9f/rR7eO9g9H5mbGlpdfWj089XF/+5uHd925fUiIiimK7kwt7AwxxrK5EK8VMazk1WckP7KukjWghX0qls02WUZ/R26qNtZ5WjmWwvTkG5GRniM8fgD0eCPZCkAeGYa8v4PF6fD4v7PXDXh8EwxAEIwiC7gWC3KMehj0w7PHAXg/s8XicB7Dd4zQPDHs9HuglCQQCYQdRFAVBCAQCzx3q8Xi838HvEAgE/H7/U10+n8+z/SEAgEwmk8vl8vl8oVBQFCUUChUKhewWHMeparxYLOYcDMOwDyoXDMPKTU3VarWpqSmfz8uyLAhCpdJcLpcrzc2NjY0syxqGUW1pKTc1VSqVdDq95S0IwnGQt0zLNOz9SVUjkYjA8+mkZhpxwzkoeJ5XonI6oer2tmmfJ3acXPx+P7EroQIAIAhCudmmfVySbqJEkZs5FkmSfr+dkEFer3c7Nm543NhBO0Hc6nKai+vjpzNA4qXZzABJktw+6yiKwjDMPZ8BAAzDiKIY3osgCJtiN4mLxWIRB2ELjuMwDOM4LhqNRvYiy/IesXuIKorivtXtwzCMZVl39G4kSdr5bIIgQqGQmym43mYYJhwOMw4vFouiSJLkZtkFAMdxsiy/lNid87YYwzCe53Vd53mepukXigkxHKJJOxuiaJpl7SzuZS3b/mHDcAD3o4DneUmyu0VRZFn2BWIM4CyFr+5n3hwPjZWIILpTlAAAWJZ1R+9GFMWtUNmZGl6I4Q0aros75e32giN31VW7l9dOjeFDcE/QLkcIHAfP4bml0e4SyrVGUZTo4FxS27F4QV1F2fWTXUrRdgXFuEXDM8X/A0p/GQqkA41FAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;combined result before photo intelligence&apos; title=&apos;&apos; src=&apos;/static/a03caa42edb43a6057aca9e75d78126a/ca1dc/01-combined-before-photo-intelligence.png&apos; srcset=&apos;/static/a03caa42edb43a6057aca9e75d78126a/e7570/01-combined-before-photo-intelligence.png 170w,
/static/a03caa42edb43a6057aca9e75d78126a/f46e7/01-combined-before-photo-intelligence.png 340w,
/static/a03caa42edb43a6057aca9e75d78126a/ca1dc/01-combined-before-photo-intelligence.png 680w,
/static/a03caa42edb43a6057aca9e75d78126a/02d09/01-combined-before-photo-intelligence.png 1020w,
/static/a03caa42edb43a6057aca9e75d78126a/64756/01-combined-before-photo-intelligence.png 1200w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;combined result before photo intelligence&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;This page was publishable. The problem was that important decisions were hidden inside model inference. The part I needed to change was not prompt wording. It was the data path.&lt;/p&gt;
&lt;h2 id=&quot;I-changed-the-question&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#I-changed-the-question&quot; aria-label=&quot;I changed the question permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;I changed the question&lt;/h2&gt;
&lt;p&gt;The first question was, &quot;Should I adjust the prompt so it uses photos better?&quot; I changed it midway.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;What if I analyze the photos first and pass structured visual metadata that the final HTML model can use?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The core of the new payload was &lt;code class=&quot;language-text&quot;&gt;photo_intelligence&lt;/code&gt;. The actual payload was longer, but the decision unit passed to the model looked roughly like this.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;analysis_status&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;complete&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;analyzed_photo_count&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;brand_key_color&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;hex&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#FF4500&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;source&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;photo_analysis&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;photos&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;alt_text&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Interior of the restaurant with blue chairs...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;visible_subjects&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;restaurant bar&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;dining table&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pendant lights&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;dominant_colors&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;hex&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#005680&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;accent&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;hex&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#B5845E&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;surface&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;suggested_roles&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;hero&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;gallery&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;placement_hint&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Use as the opening atmosphere image.&quot;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This metadata tells the model three things: what is visible, where each photo may fit, and which colors or atmosphere can influence the style. To make multimodal input a product feature, this intermediate layer was necessary.&lt;/p&gt;
&lt;h2 id=&quot;What-changed-in-the-output&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-changed-in-the-output&quot; aria-label=&quot;What changed in the output permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What changed in the output&lt;/h2&gt;
&lt;p&gt;In the restaurant result, an interior photo became the center of the hero and atmosphere, while food photos moved into menu and detail sections. The orange accent was no longer random decoration. It could be tied back to open-fire cooking and food photography cues.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/b80c53d64dba6e266a9aa9f243f0589e/64756/02-photo-intelligence-restaurant.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 294.1176470588235%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAA7CAIAAAD0ET25AAAACXBIWXMAAAsTAAALEwEAmpwYAAAJR0lEQVR42u1W609b5xn3sgZsn/Pezv343OxzjI1tbGyDIVzscAsQCIGEhARaCKVdLuuitE2z0CptlbRZskVV2kgNkPVD13ajBKXVJm3apn2p1C/7H6becyFXCGkb7tOxHULVqVq1r/vpp1fv7Xfe87zv8zzv64AIcRhqDJQxlAlECGGEMMYsy3IcxwsCx3GEEIwQDZGHwPNlaLwKNymgACAHhFASOU1hvZqIMXK73U6X0+100m43R5DAEgRoyu2m3C5AuVlMewWoc5AnCCLkAADIisfyG9GIJQo8T5CIkakIsWJvNGKVBHSOoQhxcxylKtDQiaozhqkQjkUQOiAAgiwHS+NWKGgamk/iTU0uj1qZDdH6dKIiGYoUqbIHqhosLuJ9Bp+I6RurSxmet8UYY5qi3JQbYowZAiFFEDBUMZUIpjdEG2pi6YqwKGFRoquSRV6LL4kpVsDDiwKE0IEQghC4nAWAcgLKBWiXs3A9g+mAV6wrD1REjBK/xLMuhodFplAaUarKrWCRxAm8LYYQ8QLLY7chApkpLDaVhnRF08aK5rpUR0umsbaiIVnU3ljVP7Szs6uxPmHtqo+lS1R+VczyDE9ohaM9PK5MlW3t2NzdtXlnx8butprGmmQmERjY3XF4+JkDTz1RGTFq4/7yYgVlkf9tBjg1Hhb7vcmIP1OVrKtJpmvKNtXGgn4tGTI31Sa2dbRUl8UCfnNDdVWmLiPJMgDAFiMIJFjAsXA9wIU0dBHOoQXjpv7XJv5PadRZhMsT/sakVWUADlH+YKAkHlc0NS/GCKicWxEREQVWlmnV55Y0vwh7o9xgmdwQ5MvDSry02JSJAJ0WX1jhx5qIAUQO2z0Z6FdRiY/1K0QVoMIBiVCmylbGraqEVRHgyyO+0rKk6PEQSMUNelu1L2gIFA0dAEDdw6WTvpqkL1KkBHxivFhNRb3NVcG26lB93Kgt8WyoSFTWZkpK46ZlJUzyaFM4YnncNHDQNPAZclNNdGNlOB7xxUJGJhVIlwfqUsF00l8VNVIRrTyVqqxNx1MVsbJULKB2VPsDhmSvjBAiGPEMEVjCcwzHMQxDGIIJRhjbQ4RgwpBsb5bEHsUY20cFs2KDwyaPWUIQInkwNhDCEKLciaB8jUCYr9ohyTCMYXh13fD5fIqiiKLI87wgCKIoMgxD06DA6XbRyEXR612FTudPaeB86CSEEFVVdV2TZZnJ/piiKKqqSpIEIDQ0pW9Lw8Ed6aZEybZ0a+em/UFvA8EMQvChWFVVj8cjSRLHcZqm5XoAwvGgOX5s8IXeqn11sZNDu07sfWmofa8qKwDQebGmaYqicNntYhgm9yGe5zHDRi11/NdPjJzY8+5g8bsv1wwfyBztzXh4DsAHKyuKIklSzsicWFVVRfEQlgsZntFTA/94a9cfXqp9e0g/9YuyQ7szIsFg1WZd10VR5LJgWVbXdcMwFEVBmAS88i/70i8907B9c7Q5pQ40Bzb47NQGc2KEUE5FMM4eoZ06WZZlGAZnewQWU25IUzRGGALIIIhXdxtl0ypACCAMUK7/O7B94YFjZEv88KgwQhKiPRgoBCgYYPgQudkkL0P4u1/OOQmxVNknC5ZHtBTR3rcHADTtdrlpioYQUTSgAUQYQQARXOMknCgihqURxoTheZ5leZbhBJ73+S0rYBmGymBoarIqCRBAwSMSxt4xe2WO48JBf0CVq0uDnS011YmAobGBIrEsrp88e+jYW8e7+reV+rjqRKi21GIIo8VNVmYhsOMZSLLcVl+zNZM6/fzgu2PHXj060NAQ2LUj1tNdOXzu+Xfe+9XB3obG6kB6Q7CrLnlqqM2wVIBh3maWYYos3WfIXa1Vb5zYd/7kvo2Z4tamyJ5Ha48c3/vemQOHd6Q6Wip3ddWmK0tfe6EzGbcoADG2xUjgcNzP1ZR6B7Ymh/e3D7VGjz7Z+Nvx02eP9nxw/sTfLrzwm5/VDD3e/vTh3ie6N22pjz7W3er1GhRFZy86SWipLt3X1/7Kkd4zh9s6yrTRV/Z99NGHTw91b+/pef6Zoef2dG7vahvc0zfw860duxt7+nbqhkHTtANBSFiuKBZLNG8O7hh6uq/22S2Rs0d7xg51NEbN0TNtl870Xjp97MSRoaaK4Jau6vH3XnzjxW77FAGwbeY5prKixCxLhUqCx/dUXzhYd3zfpoH+7rIAO3E09vtX+393erCrJ/ZUM9eRUEf2tvxzuNnyCPkEqCviwcfqjuype3O4+8/n9r8zvPnNU8+9cm5sW8/OQ7ub335592uHtra2Z/oHas4NGB8PKn8ZblVljraPCkJR4DY3VvRvyzzZU9+/tXp7fUlXZ/vOxx5vbGnzmT7DZ3j9oWA4UVTsL4sX1cTMyopSIXfRZe8q5HbTBU7qkQLXIwWuAidVUOgsWP+I01kIsqBpmqbctJtyuahCN3C7qZzb51OvnV+zAUAIZhjCMrkMmo1PQtjVan4OeRAY2deQZZrhcCQUDgeCQVXxqKJQHI6EQuFwKGSalsQxftMMRSKhLHRdXytGls8bDhT5DE3TdY8saZIQDgZMw9A0TfZ4ZI6xvEZJcTDg9+u6LklSPuljQniGSAIvCZwkcHbG5nlZ4CSeE3m7yQtCrinzdpzlkMvQjnVZ/OQBV/Efm2t71q1b5xgbHbkwNnphbHRsdGRs5HyOo6vl6MiF7IS1o7mh0ZHzjqWlpcWF+cXF+eXl5ZXvYSk7vLS4sLy09P1Rx9S1K1NXL0/fvnl3+vbszJ3ZmTv37k7funn98lef37w+df3alS8+/deXn30ydeWr2Znbs9Nrecdx8/q1m9evLc7fn/v26xwX5+9P37n1xeef3roxNXN35vLU1PS92bnFxbmFeZuLi3nO3bfFt2/dmPvm3jdfz97/5t7d6du3bkxNXb385Wef3Jievv/3d7492Tf/+oGFNw4sjDxr8+z+hdcPLJwemPv4j47lpcW19mR3YG5xYX5pcX5peXnl/t2VmSsrd6+uzFxdmb1ucyZbn768MnfPMXnx/cmL71+cGM/z4vuTkxOTF7OcGJ+YnJy49OHEpQ+yvJTlB3lOXnQUfg8Fa8ofhgP9D/i/OHcbQ8jzvGmaehZ+v59lWZh/hP0XK7MsK0mSkIUkSSzL/ojfZllWlmWPx5Mrf5x49U2AMf4Bm/8NXs70wm6qzw0AAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;restaurant result with photo intelligence&apos; title=&apos;&apos; src=&apos;/static/b80c53d64dba6e266a9aa9f243f0589e/ca1dc/02-photo-intelligence-restaurant.png&apos; srcset=&apos;/static/b80c53d64dba6e266a9aa9f243f0589e/e7570/02-photo-intelligence-restaurant.png 170w,
/static/b80c53d64dba6e266a9aa9f243f0589e/f46e7/02-photo-intelligence-restaurant.png 340w,
/static/b80c53d64dba6e266a9aa9f243f0589e/ca1dc/02-photo-intelligence-restaurant.png 680w,
/static/b80c53d64dba6e266a9aa9f243f0589e/02d09/02-photo-intelligence-restaurant.png 1020w,
/static/b80c53d64dba6e266a9aa9f243f0589e/64756/02-photo-intelligence-restaurant.png 1200w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;restaurant result with photo intelligence&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The fitness studio needed different signals. Reusing a warm orange restaurant cue would have looked wrong. In this case, movement, classes, and a bright studio environment mattered more, and the output moved toward white, black, and blue accents.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/d98689926b5a4f38d8a8fa5d62ad8953/64756/03-photo-intelligence-fitness.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 295.29411764705884%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAA7CAIAAAD0ET25AAAACXBIWXMAAAsTAAALEwEAmpwYAAAIWElEQVR42qWXaVQUVxbH++PMAOr4YdDkDDQqAyLdgEAMiSYaMMdxA1eIcUNZRHAMiSAhuBFHR+lpXIbBxAgeRYwxOjFjjFHjMW4RZFFjkCUg0kB3V3Xty6u95lQVjYiY6Jnfeaer3qv773p1675765lUVVEUmdGgKYoSBEHVUCRJ5HlOEHie5yVJVBRZVVWPB7bb7fv37+d5TlVVE8vSLEszDGU0oztwZNAgQWAEgRld00AjhqFomqRpsl/DCxzHsRwHAAcYlgUACAIvCLxh0CfmeaAbaa3vtixNkhjk7kURyAO7cdTFMR4Kh1DEjSEQy3rFNE0+fNjudPY4nT3d3Q4U9TA0KUrS3doLGzLmVJRtOWTPO1G64tvK7Esnd9/8rur4kbKbP3VJIqs9M0URtbU1DQ11DQ31dXW3YdjNMKQoyfdundu6btbR8sITe9fkpU4+WPq3qv+eLD78Sc6eg2eutasy0MQkiTc2Nty501hfX9fc3ITjGEOTiqpeOHs8O3nKhsxEe84raUmxmwpX565f9U7y7PgFS89ca1UVTps2RRFtbS0tLQ+am5s6OzsYhsJxVFWVY1UnDn+ctWPVlN1JIf9YHrZ5WVza3Mm5mXO25qdeuNWuSOCxt4HmThqCXD09jt7eLl5UWxsq6s5N+nbXkveWp02fNf/NCcGps17fnjaleO2C7wwxAAyGIXa7befOHTZbSXd3FwAMRaGAV3vadjV+bUqY99dpKUUHthVOfXPqnLiQbUmRxXnrzt92KBKriVEU2bPHbrOVlJbaXS4nx7Ekiauq+vW5LzLyly5aviYnZXFsVMxfQiKz5s7PXpiYujrv7I0OzWFGMCiKokelyrKM9yloCMYv1TmvNnZfbnh09sf2y/WPrjQ4LtV1XajtdLhRDmgRRjIMSZIYSeIkievh1dcAoFUFKDJQZU5VeVXhVAXovxzHUTRDatN+VtNnMTQsqxmY1P+DZ4plWREEURQFWZZfTCzLMkkxEAzDsJskyX53/ppYFEVWX3cIgrjdbhRFMQyDIAhFUU5fbqIoPlPMcRwEafdDvMAw7NGBYRiCII7jhhBrqUhH0TFOeEGjv2tcMQ6/4bDn97bi7Lhz9frV85d/+OHGLYej665OU1NTa9P9lvv3fr57t721pb2j896N729fOV9z66bA831iRZbqLx+qOmwrO3VmT/W/NxUVlZeXJyUlFWzc+NXh8tIt+fu2byqz276/eCneErB45mRb6S6KIvvEgGHWp71TkP/+mg82f7ijeNHChampqfEJCatSV547euCjzBXpyUlbc7NcXe3zZ4yz2YtgVhJ0t2timiQsL4+wvPSH4PER8TOTx44dazabAwMDrVbr+pUpr04IDnvJf13i1I779QU5WdfPn+pyewAv9IkFQag6/MnBf9krDuz/sqry4GeflZeX7927t7Ky4szpU6ePH7v41ZdnTp4kMQR1OWnETZC4JGsONxlv6IWcrOghKMuySX+XAgCAHQAAgKIoSIemaS3pA1YrPBzH8xzPGxEgaGKeFzheNKJEkiRRFAGvLQojJAVB4DRj0bhqGPSJRUEAnODBaJIgcIKQJElVFZzicJwgCMLwKsUKJA0wDKUoyoi2x2KOF90ewu12QRDk8Xh4nscpzulyu1wuCIYpiqSBiKBEb28PDHsQBBF1NLGqqpKsUKw27f6FRwNRFKV+D7G8xOnTHhyeqA6mgz6JsbB+xcBkNbA8gdVqiYyMnKgTGRk56LrVi2mUzujRowf9ms3mYJ0xY8YYg8b4QEwBAQGBZnNUVFS0TmxsbHh4eOj48dHR0REREVFRUeHh4YGB5kivQUxMTHh4eICOyWw2BwUFxcTEWCyWsLAwi8Uybty4sLCwSZMmRUdHa38UGhoUFGS1WiMiIgybkJAQs45pmM7IkSOHDx8+bNgwHx8fPz+/ESNGGCM+Pj6+vr5+fn6+Oj46vr6+hsp0zEu1jnFepVNdXX1cp3oARtcwM/XnWkmSBrzp50tDRqy6EYIgKY7jJC+CIBgZ82lgGNZiSJK0O8uK4oZRD4JgGNafmWVZfjoq+gPGSKB6DlNUgmT5J3Py84sVlGARnDGm/WJiWZZ7nS6X241hOK/nVP3bU0KexOMFQZDH4qFzjaKwWoEGLOA5Xs8Hmo9kSZJF7+z6po2xEM5DCOlyeXo6HR3tD9scXY9oihAASWGQq/cR5HR0Pmz/pa2lreXBw45fjOWpiXmRt3+Rv+1Ixv6KjRs2LcnOTym1f5ybnV51cN/1bypPlBUUv79ge96SaZMmhJr9g/88cnJMGE1T3qTPgb1HC9dvXpKRtbBgY3p62vycFfMmBgeuTE46tGfV0fLMzw8UVpR+MOutmNAg/0B/n7iJIY/FJE3mFWVOfzve/+VRubmpCZMts6dZVr87K3NJclFu3I7i6Zf/s69y34Y3XgkNHTd6rHnEq1Ghj8sNw9LLM5KS3p2eMCM6c+2y+Ldes1pC586YumxBYm7qGwfKNjxqvVVz5fSRT0uyViWPDRj1hJjnwMyUuNcXWeZlxy3KmhsbO+FPf/QZ9fvfJbwWuzMtofFileOna70PbnLun/NylptMppAgf5Ik+sSiwO/cV/jelvSCXWuK/7ll54cFa1evnDc3MSM9q+yjtKuny7uba+7c+Mb298LE2W9PmzZlxdJFLMtoYr3Yy4OqydOLixe0SjEgCjSVadAWhGVohtG2GfrnK0FRBOBYiiJYljZ2EAO3L4M3KAxDkSRBEFhra3NNzY+1tTUtLQ9wHKUo4mlLk7GdGdQEgbPZShYvXpySklxSslsQwJBmJr3qDW4AAL0yasXROAxp9swvQCOfeNPT0AX8f+E/zGpE6MZ3AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;fitness studio result with photo intelligence&apos; title=&apos;&apos; src=&apos;/static/d98689926b5a4f38d8a8fa5d62ad8953/ca1dc/03-photo-intelligence-fitness.png&apos; srcset=&apos;/static/d98689926b5a4f38d8a8fa5d62ad8953/e7570/03-photo-intelligence-fitness.png 170w,
/static/d98689926b5a4f38d8a8fa5d62ad8953/f46e7/03-photo-intelligence-fitness.png 340w,
/static/d98689926b5a4f38d8a8fa5d62ad8953/ca1dc/03-photo-intelligence-fitness.png 680w,
/static/d98689926b5a4f38d8a8fa5d62ad8953/02d09/03-photo-intelligence-fitness.png 1020w,
/static/d98689926b5a4f38d8a8fa5d62ad8953/64756/03-photo-intelligence-fitness.png 1200w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;fitness studio result with photo intelligence&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;In the workshop case, craft detail photos worked as gallery, proof, and detail evidence. One photo analysis failed and was recorded as &lt;code class=&quot;language-text&quot;&gt;partial&lt;/code&gt;, but generation continued.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/2cdf4d822f8d48f1cb062698a7dededb/64756/04-photo-intelligence-workshop.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 327.6470588235294%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAABCCAIAAADYPGGwAAAACXBIWXMAAAsTAAALEwEAmpwYAAAIPklEQVR42pVX+W9U1xWe/6DNT5BAiUhDlKAALYS0BSWkBKnND21SyVKXCJQUmirCpSxFbAabFGO8FwK44NiEYCNkltYUKEscXBZjGrApxlu8jR3P5lnect/dl1fdN/Z4PHYEufp+eO/M/d4997vnnHvGxyjiDFtmPBgYwghwhhlFGeAUQccCwMKOKR4c5eEHTAhGoC/5MyWQYGcybfRXCjkjlEDGiKCAEZC0+8Y/z3ByWc6w4ES/UoQxeDjYcutRw6FPNhSWZFXV5Nxpv5UAMcEwpWMrE+xAx3KAmYRlxgEwBCfAMb7ouHbxv2dXfTA7e/287HWLNmxe0tF9x1WKEMdHCVSS+ft7rjdc/aLhytXLF+823/7fg/uD/l7XFZYVPXB8x/5juzdsfWv7rp+X/u13m/6yoLX1kuu6BHtkIWg0Eviy+UZHW0vLvbudHW2UQE88YprRnD2rd+xZdeSz3NyP3tq+c2lO7huPOm5oMnFG3cYEW4gBIgCwbSsRj4Vj0RDFyDCClbW7autLLvynqqI6e2fu8s1b37h584K3MvAx4jCpyFATa9wmbuexeA/jnHtflJwl4sOHK9fu2//+lh1vV1Ttyv7zL95bs+J207VRtxmBjAseaRMth8WDo8zwM84YhXo7nJpGuKhs5dbty9b96bX9R3Jrzx48enxvZ9c9V0k65jZknDLXZcpljIweHoGcYQea9Tc+O3mx9Oy1w9cf/OtOe0PTw89D0UHJKU0FiV6faIUYxR4I1+vrZ9MxDBg3wEjMDCfseMKMImSnB4n20JVSobgruatcV3JFTFcp13Vdjl2G9INSLrVdVwlOtbMpMudUKcmcuJJccyWnjqH0Z1ytKLY1VwrqJKQUfCI5CexJNeq5NyMZtpQzmmYczxzfhBwgMO0V6tkZSTZhQsbK40AYOwP9Pf6BPgTBWM6M/zrVymz0ATmWZcRMI24aUdtKYAQogR6SHo2RKYGSs8hIX+ujCw/bL7e1X+rsb+zpuFB/YtvpY5uKdmUdKs9uuvVZ11c1nZ0V/X3HggO1RrRdcK6LgSYLPhzsuNJQcaq24ERNQXPrqZa7NYc/WrF97SubP1y2c/3PGhtK7rWUXrm6qfH65luf5w30NinpRViSHAx11dUVVVVsPVD04Ym60of3T9w4s/rYwTUF27Jy1r7Z1Pjx+X9sKihedqTy18c+eb+/t3kCORTqbGr+9OrlA4dK1h46sPn+3ePnqt47U/FuwZrFa377w5rqHaVlv8wvXlp3ct2n1R981XXbVSpFZoFA973Wc22dF2/dPtl4s7brUf254xvrazZePb2povT3Vy5UnP/nnjN1eZfOl5+rK+jrua+USCUGohQ7NmCUut4QnNmWxRhPvjJGbcvmo69p4empTSKxYEvXvS87muuvnDt/+WwgNKhEMjFHayP1wiNVJMePSgk2GBzYuHvLyj+uWvmHdwvKctq7Wl1XS/JNxTidTP2BvuK/F7+24qdvZ71zsKq4u7fN1buCT0JmvYPd1Wcrc/Zu+/6LL6xeu7JvsNOV/EnJ/uHe6rrK0/8+dbTmUGXtx73+JyMnryKEQDAciBsJRKCDAMaP2W1GYmCCdQ5KziRnSXlTeCx59LpLzZaSS8k09Jk9ATkFgsGgv3d4aGDQ3xcMDNHMIjGJLDgR3Ku7DGNoh4LD4VAgEh6ORUMEg/EakKrN6Xu2bcuyDCG4lEJKqThyBaSMAtu0bcszCr0XnOAZZM4IQhAhqKT0oBTDikF9ozuAUjJml4qhVISmyBjYFkbQVVJXXz0JKgYwRsC2lTYKD1Jxwqfcc3rQC8E4p4ITJTPUxo9RmxJoWwkHmBCYtpX4pqP2pRO8Y9D3G0agp7vDP9Az0N/T3dUOHSvNqSmOCnPmNTFs1HmMHIQAgjZGIFn9x0BSno+rbVumZZmOA7QqSikKFAOEeHbT5Ixpo+AKxXkGmTHiAACADaGjtU2SKcAE25alj0obPTvHmUfFKNZ+QoCRI7TITBCHE0AwRFC77Rk9eP1Z5jlLfbxcSi6Ebg6F5PpG9o5dJi2jdpaxsne5TxxSylgsapqGSl7xaSPzcs8gK6UwxoHA8EgkQgjJ4E9NFl4jQghmVGsghG5bKMWEaEUpxUKIyWTEudaTc0YJxhgyRqnX1mAEKcHeMyYYMUq8toJMEIwSGA4ODfn7AsOD8ViYMRIMDA309wz5++KxiOA0ODwYCn4dDn2tO8OxaB0PkuS3OSPJlKYEEayXlYLpV+0zk0Irz9mElaHntjeSSeuFxJh4Y+Eh9fB2RzK6oQm1kjOMoG0mosBKeP8APPtY5rDJQZKezJzhRCzS29M10N9jGlGhQxKlMLHoM+x4eZvO9/51QIx1zOr0SsMEwbwaZEQjQWAbKT4lKGEk4ol4ImPEE15zlUZGUPfoBDvpZMMwEpPHZLJtxsOhYcuMW2YcQftbkL1+D0RHwiORYCIeMY1YclePJ2MECHbMxEh4uB85lqeQLj0Igmg0OjJpREZGbNskGGAEfKlUcV3iutL9NsNXVlJYVlJYXlpUXlacfC4t3ldUuLe0KL+8OL+sOL+0KL+4ML+sZF95aWEKyZm+Z2dOH8O0Z2dOnzVj2pznZi2cP/eluXOff3HeCy/Nnz9/weKF8+Y8N2vWjGlpkzV8i34wLx0LF7y85NWFr7++LDvr1WMbflK94cfrf7Nk+fI3l/5o0cIFL2dM9j0/+3sZmDN7xtPPzPjV4qdKsr5bkvWdd155avrTz8yZPXPyTF/+X3MnY++e3Ny83Vty8rbk5OXu3l2wJ2/Kab4pZfSSk7mKexCuq6ZU+/91o3te7maFLwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;workshop result with photo intelligence&apos; title=&apos;&apos; src=&apos;/static/2cdf4d822f8d48f1cb062698a7dededb/ca1dc/04-photo-intelligence-workshop.png&apos; srcset=&apos;/static/2cdf4d822f8d48f1cb062698a7dededb/e7570/04-photo-intelligence-workshop.png 170w,
/static/2cdf4d822f8d48f1cb062698a7dededb/f46e7/04-photo-intelligence-workshop.png 340w,
/static/2cdf4d822f8d48f1cb062698a7dededb/ca1dc/04-photo-intelligence-workshop.png 680w,
/static/2cdf4d822f8d48f1cb062698a7dededb/02d09/04-photo-intelligence-workshop.png 1020w,
/static/2cdf4d822f8d48f1cb062698a7dededb/64756/04-photo-intelligence-workshop.png 1200w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;workshop result with photo intelligence&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;That failure policy mattered. Photo intelligence is a quality-improving input, not a hard dependency that should block landing page generation.&lt;/p&gt;
&lt;h2 id=&quot;I-separated-debug-payload-from-generation-payload&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#I-separated-debug-payload-from-generation-payload&quot; aria-label=&quot;I separated debug payload from generation payload permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;I separated debug payload from generation payload&lt;/h2&gt;
&lt;p&gt;The implementation detail I was most careful about was separating the payload operators need from the payload the model needs.&lt;/p&gt;
&lt;p&gt;The debug payload kept a wide trail, including failures. It needed enabled, disabled, skipped, failed, partial, and complete states; model name; photo count; failed count; per-photo errors; a raw-ish summary; and brand color rationale. Later, an operator should be able to answer, &quot;Why did this photo become the hero?&quot;, &quot;Why was this color used?&quot;, or &quot;Why was photo analysis missing?&quot;&lt;/p&gt;
&lt;p&gt;The generation payload was smaller. The final model only received values directly useful for generation: alt text, visible subjects, dominant colors, suggested roles, placement hints, and brand key color. Too much failure noise or internal state can make HTML generation less stable.&lt;/p&gt;
&lt;p&gt;Without this distinction, an AI feature quickly becomes a black box. Even when the result looks better, you cannot explain why. When it fails, you cannot see where.&lt;/p&gt;
&lt;h2 id=&quot;Promotion-criteria&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Promotion-criteria&quot; aria-label=&quot;Promotion criteria permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Promotion criteria&lt;/h2&gt;
&lt;p&gt;The experiment was ambiguous if judged only by automated scores.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variant&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Results&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Published&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Average score&lt;/th&gt;
&lt;th&gt;Verdict&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;photo-intelligence&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;I did not claim that photo intelligence won on the automated metric. The numbers were tied.&lt;/p&gt;
&lt;p&gt;Instead, I used a different promotion standard.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It did not break the existing quality guardrails.&lt;/li&gt;
&lt;li&gt;Human review found the photo and color usage more intentional.&lt;/li&gt;
&lt;li&gt;Improving the runtime data path was more durable than adding more prompt text.&lt;/li&gt;
&lt;li&gt;The analysis result was visible in debug logs and operator screens.&lt;/li&gt;
&lt;li&gt;Failure still had a fallback boundary, so generation could continue.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After code deploy and a smoke test, I promoted it to the production runtime default and kept the previous combined profile as a rollback target.&lt;/p&gt;
&lt;h2 id=&quot;Verification&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Verification&quot; aria-label=&quot;Verification permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Verification&lt;/h2&gt;
&lt;p&gt;I was not verifying that &quot;using photos always makes the page prettier.&quot; The scope was narrower.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Photo analysis is recorded as success, partial, or failed.&lt;/li&gt;
&lt;li&gt;The generation payload receives only the metadata it needs, without internal debug noise.&lt;/li&gt;
&lt;li&gt;Photo analysis failure does not become full generation failure.&lt;/li&gt;
&lt;li&gt;The automated quality guardrail still passes.&lt;/li&gt;
&lt;li&gt;Human review can explain photo roles and color usage more clearly.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Good AI output does not come from one model call. It comes from the whole pipeline: analyzing input, structuring it, filtering it, recording it, showing it to operators, and deciding when it is safe enough to promote.&lt;/p&gt;
&lt;h2 id=&quot;How-I-will-judge-this-next-time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-will-judge-this-next-time&quot; aria-label=&quot;How I will judge this next time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I will judge this next time&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;When multimodal quality is weak, I will first ask how image understanding is represented and passed downstream, not just whether images were included.&lt;/li&gt;
&lt;li&gt;When automated scores tie, I will compare human-visible intent, debuggability, and fallback boundaries.&lt;/li&gt;
&lt;li&gt;I will not leave all photo decisions to the model. The product should define decision units such as hero candidate, detail evidence, alt text, and dominant color.&lt;/li&gt;
&lt;li&gt;AI helper features that can fail should not be hard dependencies. Failure states should be recorded, while core generation continues where possible.&lt;/li&gt;
&lt;li&gt;Public write-ups should not expose real place names, internal profile or run IDs, or operator URLs.&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[사진을 프롬프트가 아니라 생성 메타데이터로 쓰기]]></title><description><![CDATA[Place2Page…]]></description><link>https://sewon.dev/place2page-photo-intelligence-multimodal-metadata-pipeline/</link><guid isPermaLink="false">https://sewon.dev/place2page-photo-intelligence-multimodal-metadata-pipeline/</guid><pubDate>Sun, 24 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Place2Page의 랜딩페이지는 사진을 많이 넣는다고 바로 좋아지지 않았다. 처음에는 프롬프트에 &quot;사진을 잘 활용하라&quot;는 규칙을 더 넣으려 했지만, 실제 결과를 보니 문제는 문구가 아니라 데이터 경로였다. 사진을 먼저 분석해 &lt;code class=&quot;language-text&quot;&gt;photo_intelligence&lt;/code&gt;라는 구조화된 metadata로 넘기자 최종 HTML 모델은 사진을 asset 목록이 아니라 hero 후보, gallery evidence, brand color, alt text의 근거로 쓸 수 있었다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: Hallmark combined prompt 이후에도 최종 HTML 모델은 사진의 역할, 색감, alt text를 내부 추론에 의존했다.&lt;/li&gt;
&lt;li&gt;판단: 프롬프트를 더 길게 쓰는 대신, 사진을 먼저 분석해 generation payload에 명시적인 visual metadata로 넣었다.&lt;/li&gt;
&lt;li&gt;결과: 자동 점수는 기존 variant와 같았지만, 사람 눈으로는 사진 배치와 색감 사용이 더 의도적으로 보였고 debug 화면에서도 원인을 추적할 수 있었다.&lt;/li&gt;
&lt;li&gt;배운 점: 멀티모달 기능은 &quot;이미지를 같이 넣기&quot;가 아니라 &quot;이미지 이해 결과를 제품 파이프라인의 안정적인 입력으로 만드는 일&quot;에 가깝다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;이전-단계의-한계&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9D%B4%EC%A0%84-%EB%8B%A8%EA%B3%84%EC%9D%98-%ED%95%9C%EA%B3%84&quot; aria-label=&quot;이전 단계의 한계 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;이전 단계의 한계&lt;/h2&gt;
&lt;p&gt;앞선 Hallmark combined 실험은 효과가 있었다. structure, anti-slop copy, responsive hardening을 합치니 baseline보다 정보 흐름과 visual rhythm이 좋아졌다. 그래도 사진은 여전히 text prompt 바깥에 있었다.&lt;/p&gt;
&lt;p&gt;예를 들어 음식점 사진 세트가 있을 때 모델은 이런 판단을 해야 한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;어떤 사진이 hero에 적합한가&lt;/li&gt;
&lt;li&gt;어떤 사진이 menu/detail evidence인가&lt;/li&gt;
&lt;li&gt;어떤 사진은 text overlay 배경으로 쓰면 가독성이 깨지는가&lt;/li&gt;
&lt;li&gt;어떤 색을 brand accent로 써도 자연스러운가&lt;/li&gt;
&lt;li&gt;alt text를 어떻게 사실적으로 써야 하는가&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 판단을 최종 HTML 모델에게 한 번에 맡기면 결과는 자주 애매해졌다. 사진은 들어갔지만, 사진을 이해해서 쓴 것 같지는 않은 상태였다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/a03caa42edb43a6057aca9e75d78126a/64756/01-combined-before-photo-intelligence.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 341.764705882353%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAABECAIAAAAOZYKtAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKAklEQVR42o2X2XPb1hWHAa4ALnYQIAASJBaSIMFVC0VRkrVbovbdsSxZXqTYji3bsrzKVpXYqe3GSesmTcaZpp3YbdNxM2ndTNvMpJmmM5npQ/PShz51+tK/os8dAFodu/Y39wHAvT8c3HMu7j0HommSpqlINCLJcjgcpkiKwG0IggA4zjIMSRIAAD7EUVy4lifvTXFX+2mWAhjAofa+rtaWUkJX45JQshLlUkZThEiUM5NSzlJ6e7skWUZRlHAAOI4Bu7lAupnJ1ddnkkY2qY4NtB45WNvXbGUyYrU50dNbGhiuyZGIK3YFwGmbYkUReJYUBYbn6FLOGOwutzWmsjm1v6vY32F193REo1EMw1zL+F6gQoOVVEJmXCim1a5Kqi4t1+nCgUOjQ/tbR6qZSjnPcVwgEEBRNBgMPi0WeFYJs1FFMUwzV18c6GiodTTNjvd1Ntf3D/TVBvp0XVcUxXAgSRIAsCOWeEaLcJIcpkU5LEsjnY2j3eWRwZ7O1ubR3urCdK2p3FAslhIJI5VKPS2uy8YqRT1vKtlkpLmgtxTijZlYZ09va3vHaHfjocHmumJe03UAwDM+W1WkeFSSRF6RhXg0HJVCUTkciSqiHIlKQlwOUeQmz3AYgmIIiqEYhm5eAOcaxTaf7P7Mp4EIArcbju9cOMvLDc13jO0V4/8XiiQYimQoinYbTTEMzTDMi8UEjgcxHPKjsC/gCwa8/iDs9UMQBMOwO5lNMfEM8AAK2tPSlcHshYmWE8PtZyY7Ls0PXls5c+ryJYbnMQzbFKMoiiAI2AVJkrDHe2pu4qO761dOTX3/52fPXpk7ujB5fePyo989FmUJRRDIHZfP53O5nGmaiqKoqmqapiSKsMc7MzW1ODNaX1ZOflBbeefIxWuTS4uDPd1lgiRxAGzLJEnqup5OpyORCEmStAtF+YNYf5s11qqmEqHT81N/evL4X19c+Pb3l9cuzlM0BVwxQRCxWFxR4vG4qmm6phmqqiUSCUAw8wMN65NmMiYsDLY9fvSLjy51fn0t+5e7h3mWRrEtsSyGhRDHh1iOZViWpWkmxLF+lJ5vx/6wzPWXIiwbmi+rH53s+fuJ6hcnaixDYK5lnCDIUARnJJyVWSEiy5FIJCqJUjCINjerb502b47yD6aFfxyl/32977+fv/PVuQYG9WE4CQGA0yQ+VRFeqYpzbVJ7VmBY3iUYQLsn6s6tT52dMp7Mc19PQF+Mgb8tx++8WsEJxnaYIwbjdeR0mTlYYZoNPIhgAMNw+zdC6krm7JHhA0dqKzP1G9N1V+d7Tx+deG35RIhjN+MMcBz245APQF7gRwjSWSIkSQQxvC1BjBRCRSPSmFXbGlKjvQ3n57se36hJIRrBbMvOkiAASeCk/WNsLhJ38ZAEQRGABCgBUArHGALjGSLEkO4YSHoO4XA4LNjwQliUJLuJdhPCovPABlIdNAd1C13XLYdsNmtZlq7rmrY5ZvdIKO4Q24umaXmHYrFYKBQ0TdvdG98CisViiUQil8tlMhn3rfF43DRNy7JSqZTirDtN09LptGN/0+yO2DCMdDqTyViJRELXjXhcTSZT2WwulTINw0gkEpqmp1KmaabdDdg1sGM5m83qurFtOZVKZbNZd5xryn63ZW3danssW1bWtewY15LJpGVlU6mU+0TTdNNMW1Y2nU47A/Qdse1eQ1c1eyZKTFHVuGq7ULE9p7oTjDmzjLnTVbd8DNE0DQDweX0IggIcpygKwXAUAzRNEyRp78QAx0kKA7h9C4C9bnFAEARFUZDf788X8pfWLnXWWhoLJs8Q3WWrWkiQJBHX4qOdlZ76dF4Ry2nVUuTR9ramTFN7Y7MiRxEEgTywd/9Az6++enzp1upYR50api7MDS2OthMAZVn249eXnvz4wr0bCzfHK2+tDt27c/Tq4sTq9FCdmQwgCOT3BcqthbUP3+ieGG4v6emEkkoa1VKyZBlxJXrz1PgnD9c/u3/ql8uVb++03T/ftbZSu7U8XtCVAIJCXq+vrav65afvb5ycGNpfX+vMD/aWhjoa3l2Zuzq7/9WZ7p/8cOn9lY63b06+udC4MW2cWmhZPtirizyCYZDP629pb3p4c/HqTKW7tTQ93jM+2K7E1NWT0/evz4Ro+oClPRprPGrGq7pYjpP7TM7icSVEogCHvD5/z77y4/eurhzdf3i27+TRwWPHhqdrHdMj5bGxysFi+lx787WJ/tXm/Gw5dffsyE9vzWwsDqZELogBCII9k0N9//zs3p/vHnzzzOjy1aV3319fO3to5cQrh2utSxlhQiJmI3QOhm6cmfn09tTnb1T/8/UPZsb7IQiGfP5AtSH/o2unfnZ79cHl4SuH9l08MrJ+5vDJ2ZH+9jJLECUh1CjxqRA7M9Qy2ZI+PmK9vXagu7Pq9frsPYxlqMXjc1/+ZvaTjb63rlz4bO3cB3cu9vc1tbV2Hjs0cnqiZWG46/r5WZZhfEE0iAKvLxgMIgRBQBiGRcTwg3tnvvmw7ePXF9ZuzP32g431W3P7WlLzB6a/t7r45MHGr98998axTjHEOhsWvp1WQSiK6bHo9TMH/nhr6dG983+9f/rR7eO9g9H5mbGlpdfWj089XF/+5uHd925fUiIiimK7kwt7AwxxrK5EK8VMazk1WckP7KukjWghX0qls02WUZ/R26qNtZ5WjmWwvTkG5GRniM8fgD0eCPZCkAeGYa8v4PF6fD4v7PXDXh8EwxAEIwiC7gWC3KMehj0w7PHAXg/s8XicB7Dd4zQPDHs9HuglCQQCYQdRFAVBCAQCzx3q8Xi838HvEAgE/H7/U10+n8+z/SEAgEwmk8vl8vl8oVBQFCUUChUKhewWHMeparxYLOYcDMOwDyoXDMPKTU3VarWpqSmfz8uyLAhCpdJcLpcrzc2NjY0syxqGUW1pKTc1VSqVdDq95S0IwnGQt0zLNOz9SVUjkYjA8+mkZhpxwzkoeJ5XonI6oer2tmmfJ3acXPx+P7EroQIAIAhCudmmfVySbqJEkZs5FkmSfr+dkEFer3c7Nm543NhBO0Hc6nKai+vjpzNA4qXZzABJktw+6yiKwjDMPZ8BAAzDiKIY3osgCJtiN4mLxWIRB2ELjuMwDOM4LhqNRvYiy/IesXuIKorivtXtwzCMZVl39G4kSdr5bIIgQqGQmym43mYYJhwOMw4vFouiSJLkZtkFAMdxsiy/lNid87YYwzCe53Vd53mepukXigkxHKJJOxuiaJpl7SzuZS3b/mHDcAD3o4DneUmyu0VRZFn2BWIM4CyFr+5n3hwPjZWIILpTlAAAWJZ1R+9GFMWtUNmZGl6I4Q0aros75e32giN31VW7l9dOjeFDcE/QLkcIHAfP4bml0e4SyrVGUZTo4FxS27F4QV1F2fWTXUrRdgXFuEXDM8X/A0p/GQqkA41FAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;photo intelligence 이전 combined 결과&apos; title=&apos;&apos; src=&apos;/static/a03caa42edb43a6057aca9e75d78126a/ca1dc/01-combined-before-photo-intelligence.png&apos; srcset=&apos;/static/a03caa42edb43a6057aca9e75d78126a/e7570/01-combined-before-photo-intelligence.png 170w,
/static/a03caa42edb43a6057aca9e75d78126a/f46e7/01-combined-before-photo-intelligence.png 340w,
/static/a03caa42edb43a6057aca9e75d78126a/ca1dc/01-combined-before-photo-intelligence.png 680w,
/static/a03caa42edb43a6057aca9e75d78126a/02d09/01-combined-before-photo-intelligence.png 1020w,
/static/a03caa42edb43a6057aca9e75d78126a/64756/01-combined-before-photo-intelligence.png 1200w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;photo intelligence 이전 combined 결과&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;이 결과도 publish는 가능했다. 하지만 중요한 결정이 모델 내부 추론에 숨어 있었다. 내가 바꿔야 한다고 본 지점은 prompt wording이 아니라 data path였다.&lt;/p&gt;
&lt;h2 id=&quot;질문을-바꿨다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A7%88%EB%AC%B8%EC%9D%84-%EB%B0%94%EA%BF%A8%EB%8B%A4&quot; aria-label=&quot;질문을 바꿨다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;질문을 바꿨다&lt;/h2&gt;
&lt;p&gt;처음 질문은 &quot;사진을 더 잘 쓰라고 prompt를 고칠까?&quot;였다. 중간에 질문을 바꿨다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;사진을 먼저 분석해서 최종 HTML 모델이 쓸 수 있는 구조화된 visual metadata로 넘기면 어떨까?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;새 payload의 핵심은 &lt;code class=&quot;language-text&quot;&gt;photo_intelligence&lt;/code&gt;였다. 실제 payload는 더 길지만, 모델에게 넘긴 판단 단위는 대략 이런 모양이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;analysis_status&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;complete&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;analyzed_photo_count&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;brand_key_color&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;hex&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#FF4500&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;source&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;photo_analysis&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;photos&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;alt_text&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Interior of the restaurant with blue chairs...&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;visible_subjects&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;restaurant bar&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;dining table&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;pendant lights&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;dominant_colors&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;hex&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#005680&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;accent&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;hex&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;#B5845E&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token property&quot;&gt;&quot;role&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;surface&quot;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;suggested_roles&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;hero&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;gallery&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
      &lt;span class=&quot;token property&quot;&gt;&quot;placement_hint&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Use as the opening atmosphere image.&quot;&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 metadata는 모델에게 세 가지를 알려준다. 무엇이 보이는지, 어디에 쓰면 좋은지, 어떤 색과 분위기를 style에 반영할 수 있는지다. 멀티모달 입력을 제품 기능으로 만들려면 이 중간층이 필요했다.&lt;/p&gt;
&lt;h2 id=&quot;결과에서-본-차이&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%B0%EA%B3%BC%EC%97%90%EC%84%9C-%EB%B3%B8-%EC%B0%A8%EC%9D%B4&quot; aria-label=&quot;결과에서 본 차이 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;결과에서 본 차이&lt;/h2&gt;
&lt;p&gt;음식점 결과에서는 interior photo가 hero와 atmosphere의 중심이 됐고, 음식 사진은 menu/detail 영역으로 내려갔다. orange accent도 무작위 장식이 아니라 open-fire cooking과 음식 사진에서 나온 visual cue로 쓸 수 있었다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/b80c53d64dba6e266a9aa9f243f0589e/64756/02-photo-intelligence-restaurant.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 294.1176470588235%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAA7CAIAAAD0ET25AAAACXBIWXMAAAsTAAALEwEAmpwYAAAJR0lEQVR42u1W609b5xn3sgZsn/Pezv343OxzjI1tbGyDIVzscAsQCIGEhARaCKVdLuuitE2z0CptlbRZskVV2kgNkPVD13ajBKXVJm3apn2p1C/7H6becyFXCGkb7tOxHULVqVq1r/vpp1fv7Xfe87zv8zzv64AIcRhqDJQxlAlECGGEMMYsy3IcxwsCx3GEEIwQDZGHwPNlaLwKNymgACAHhFASOU1hvZqIMXK73U6X0+100m43R5DAEgRoyu2m3C5AuVlMewWoc5AnCCLkAADIisfyG9GIJQo8T5CIkakIsWJvNGKVBHSOoQhxcxylKtDQiaozhqkQjkUQOiAAgiwHS+NWKGgamk/iTU0uj1qZDdH6dKIiGYoUqbIHqhosLuJ9Bp+I6RurSxmet8UYY5qi3JQbYowZAiFFEDBUMZUIpjdEG2pi6YqwKGFRoquSRV6LL4kpVsDDiwKE0IEQghC4nAWAcgLKBWiXs3A9g+mAV6wrD1REjBK/xLMuhodFplAaUarKrWCRxAm8LYYQ8QLLY7chApkpLDaVhnRF08aK5rpUR0umsbaiIVnU3ljVP7Szs6uxPmHtqo+lS1R+VczyDE9ohaM9PK5MlW3t2NzdtXlnx8butprGmmQmERjY3XF4+JkDTz1RGTFq4/7yYgVlkf9tBjg1Hhb7vcmIP1OVrKtJpmvKNtXGgn4tGTI31Sa2dbRUl8UCfnNDdVWmLiPJMgDAFiMIJFjAsXA9wIU0dBHOoQXjpv7XJv5PadRZhMsT/sakVWUADlH+YKAkHlc0NS/GCKicWxEREQVWlmnV55Y0vwh7o9xgmdwQ5MvDSry02JSJAJ0WX1jhx5qIAUQO2z0Z6FdRiY/1K0QVoMIBiVCmylbGraqEVRHgyyO+0rKk6PEQSMUNelu1L2gIFA0dAEDdw6WTvpqkL1KkBHxivFhNRb3NVcG26lB93Kgt8WyoSFTWZkpK46ZlJUzyaFM4YnncNHDQNPAZclNNdGNlOB7xxUJGJhVIlwfqUsF00l8VNVIRrTyVqqxNx1MVsbJULKB2VPsDhmSvjBAiGPEMEVjCcwzHMQxDGIIJRhjbQ4RgwpBsb5bEHsUY20cFs2KDwyaPWUIQInkwNhDCEKLciaB8jUCYr9ohyTCMYXh13fD5fIqiiKLI87wgCKIoMgxD06DA6XbRyEXR612FTudPaeB86CSEEFVVdV2TZZnJ/piiKKqqSpIEIDQ0pW9Lw8Ed6aZEybZ0a+em/UFvA8EMQvChWFVVj8cjSRLHcZqm5XoAwvGgOX5s8IXeqn11sZNDu07sfWmofa8qKwDQebGmaYqicNntYhgm9yGe5zHDRi11/NdPjJzY8+5g8bsv1wwfyBztzXh4DsAHKyuKIklSzsicWFVVRfEQlgsZntFTA/94a9cfXqp9e0g/9YuyQ7szIsFg1WZd10VR5LJgWVbXdcMwFEVBmAS88i/70i8907B9c7Q5pQ40Bzb47NQGc2KEUE5FMM4eoZ06WZZlGAZnewQWU25IUzRGGALIIIhXdxtl0ypACCAMUK7/O7B94YFjZEv88KgwQhKiPRgoBCgYYPgQudkkL0P4u1/OOQmxVNknC5ZHtBTR3rcHADTtdrlpioYQUTSgAUQYQQARXOMknCgihqURxoTheZ5leZbhBJ73+S0rYBmGymBoarIqCRBAwSMSxt4xe2WO48JBf0CVq0uDnS011YmAobGBIrEsrp88e+jYW8e7+reV+rjqRKi21GIIo8VNVmYhsOMZSLLcVl+zNZM6/fzgu2PHXj060NAQ2LUj1tNdOXzu+Xfe+9XB3obG6kB6Q7CrLnlqqM2wVIBh3maWYYos3WfIXa1Vb5zYd/7kvo2Z4tamyJ5Ha48c3/vemQOHd6Q6Wip3ddWmK0tfe6EzGbcoADG2xUjgcNzP1ZR6B7Ymh/e3D7VGjz7Z+Nvx02eP9nxw/sTfLrzwm5/VDD3e/vTh3ie6N22pjz7W3er1GhRFZy86SWipLt3X1/7Kkd4zh9s6yrTRV/Z99NGHTw91b+/pef6Zoef2dG7vahvc0zfw860duxt7+nbqhkHTtANBSFiuKBZLNG8O7hh6uq/22S2Rs0d7xg51NEbN0TNtl870Xjp97MSRoaaK4Jau6vH3XnzjxW77FAGwbeY5prKixCxLhUqCx/dUXzhYd3zfpoH+7rIAO3E09vtX+393erCrJ/ZUM9eRUEf2tvxzuNnyCPkEqCviwcfqjuype3O4+8/n9r8zvPnNU8+9cm5sW8/OQ7ub335592uHtra2Z/oHas4NGB8PKn8ZblVljraPCkJR4DY3VvRvyzzZU9+/tXp7fUlXZ/vOxx5vbGnzmT7DZ3j9oWA4UVTsL4sX1cTMyopSIXfRZe8q5HbTBU7qkQLXIwWuAidVUOgsWP+I01kIsqBpmqbctJtyuahCN3C7qZzb51OvnV+zAUAIZhjCMrkMmo1PQtjVan4OeRAY2deQZZrhcCQUDgeCQVXxqKJQHI6EQuFwKGSalsQxftMMRSKhLHRdXytGls8bDhT5DE3TdY8saZIQDgZMw9A0TfZ4ZI6xvEZJcTDg9+u6LklSPuljQniGSAIvCZwkcHbG5nlZ4CSeE3m7yQtCrinzdpzlkMvQjnVZ/OQBV/Efm2t71q1b5xgbHbkwNnphbHRsdGRs5HyOo6vl6MiF7IS1o7mh0ZHzjqWlpcWF+cXF+eXl5ZXvYSk7vLS4sLy09P1Rx9S1K1NXL0/fvnl3+vbszJ3ZmTv37k7funn98lef37w+df3alS8+/deXn30ydeWr2Znbs9Nrecdx8/q1m9evLc7fn/v26xwX5+9P37n1xeef3roxNXN35vLU1PS92bnFxbmFeZuLi3nO3bfFt2/dmPvm3jdfz97/5t7d6du3bkxNXb385Wef3Jievv/3d7492Tf/+oGFNw4sjDxr8+z+hdcPLJwemPv4j47lpcW19mR3YG5xYX5pcX5peXnl/t2VmSsrd6+uzFxdmb1ucyZbn768MnfPMXnx/cmL71+cGM/z4vuTkxOTF7OcGJ+YnJy49OHEpQ+yvJTlB3lOXnQUfg8Fa8ofhgP9D/i/OHcbQ8jzvGmaehZ+v59lWZh/hP0XK7MsK0mSkIUkSSzL/ojfZllWlmWPx5Mrf5x49U2AMf4Bm/8NXs70wm6qzw0AAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;photo intelligence를 적용한 restaurant 결과&apos; title=&apos;&apos; src=&apos;/static/b80c53d64dba6e266a9aa9f243f0589e/ca1dc/02-photo-intelligence-restaurant.png&apos; srcset=&apos;/static/b80c53d64dba6e266a9aa9f243f0589e/e7570/02-photo-intelligence-restaurant.png 170w,
/static/b80c53d64dba6e266a9aa9f243f0589e/f46e7/02-photo-intelligence-restaurant.png 340w,
/static/b80c53d64dba6e266a9aa9f243f0589e/ca1dc/02-photo-intelligence-restaurant.png 680w,
/static/b80c53d64dba6e266a9aa9f243f0589e/02d09/02-photo-intelligence-restaurant.png 1020w,
/static/b80c53d64dba6e266a9aa9f243f0589e/64756/02-photo-intelligence-restaurant.png 1200w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;photo intelligence를 적용한 restaurant 결과&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;fitness studio에서는 다른 신호가 필요했다. 음식점처럼 warm/orange cue를 밀어붙이면 이상하다. 이 케이스에서는 움직임, 수업, 밝은 공간감이 더 중요했고, 결과도 흰색, 검정, 파란색 accent 쪽으로 유도됐다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/d98689926b5a4f38d8a8fa5d62ad8953/64756/03-photo-intelligence-fitness.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 295.29411764705884%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAA7CAIAAAD0ET25AAAACXBIWXMAAAsTAAALEwEAmpwYAAAIWElEQVR42qWXaVQUVxbH++PMAOr4YdDkDDQqAyLdgEAMiSYaMMdxA1eIcUNZRHAMiSAhuBFHR+lpXIbBxAgeRYwxOjFjjFHjMW4RZFFjkCUg0kB3V3Xty6u95lQVjYiY6Jnfeaer3qv773p1675765lUVVEUmdGgKYoSBEHVUCRJ5HlOEHie5yVJVBRZVVWPB7bb7fv37+d5TlVVE8vSLEszDGU0oztwZNAgQWAEgRld00AjhqFomqRpsl/DCxzHsRwHAAcYlgUACAIvCLxh0CfmeaAbaa3vtixNkhjk7kURyAO7cdTFMR4Kh1DEjSEQy3rFNE0+fNjudPY4nT3d3Q4U9TA0KUrS3doLGzLmVJRtOWTPO1G64tvK7Esnd9/8rur4kbKbP3VJIqs9M0URtbU1DQ11DQ31dXW3YdjNMKQoyfdundu6btbR8sITe9fkpU4+WPq3qv+eLD78Sc6eg2eutasy0MQkiTc2Nty501hfX9fc3ITjGEOTiqpeOHs8O3nKhsxEe84raUmxmwpX565f9U7y7PgFS89ca1UVTps2RRFtbS0tLQ+am5s6OzsYhsJxVFWVY1UnDn+ctWPVlN1JIf9YHrZ5WVza3Mm5mXO25qdeuNWuSOCxt4HmThqCXD09jt7eLl5UWxsq6s5N+nbXkveWp02fNf/NCcGps17fnjaleO2C7wwxAAyGIXa7befOHTZbSXd3FwAMRaGAV3vadjV+bUqY99dpKUUHthVOfXPqnLiQbUmRxXnrzt92KBKriVEU2bPHbrOVlJbaXS4nx7Ekiauq+vW5LzLyly5aviYnZXFsVMxfQiKz5s7PXpiYujrv7I0OzWFGMCiKokelyrKM9yloCMYv1TmvNnZfbnh09sf2y/WPrjQ4LtV1XajtdLhRDmgRRjIMSZIYSeIkievh1dcAoFUFKDJQZU5VeVXhVAXovxzHUTRDatN+VtNnMTQsqxmY1P+DZ4plWREEURQFWZZfTCzLMkkxEAzDsJskyX53/ppYFEVWX3cIgrjdbhRFMQyDIAhFUU5fbqIoPlPMcRwEafdDvMAw7NGBYRiCII7jhhBrqUhH0TFOeEGjv2tcMQ6/4bDn97bi7Lhz9frV85d/+OHGLYej665OU1NTa9P9lvv3fr57t721pb2j896N729fOV9z66bA831iRZbqLx+qOmwrO3VmT/W/NxUVlZeXJyUlFWzc+NXh8tIt+fu2byqz276/eCneErB45mRb6S6KIvvEgGHWp71TkP/+mg82f7ijeNHChampqfEJCatSV547euCjzBXpyUlbc7NcXe3zZ4yz2YtgVhJ0t2timiQsL4+wvPSH4PER8TOTx44dazabAwMDrVbr+pUpr04IDnvJf13i1I779QU5WdfPn+pyewAv9IkFQag6/MnBf9krDuz/sqry4GeflZeX7927t7Ky4szpU6ePH7v41ZdnTp4kMQR1OWnETZC4JGsONxlv6IWcrOghKMuySX+XAgCAHQAAgKIoSIemaS3pA1YrPBzH8xzPGxEgaGKeFzheNKJEkiRRFAGvLQojJAVB4DRj0bhqGPSJRUEAnODBaJIgcIKQJElVFZzicJwgCMLwKsUKJA0wDKUoyoi2x2KOF90ewu12QRDk8Xh4nscpzulyu1wuCIYpiqSBiKBEb28PDHsQBBF1NLGqqpKsUKw27f6FRwNRFKV+D7G8xOnTHhyeqA6mgz6JsbB+xcBkNbA8gdVqiYyMnKgTGRk56LrVi2mUzujRowf9ms3mYJ0xY8YYg8b4QEwBAQGBZnNUVFS0TmxsbHh4eOj48dHR0REREVFRUeHh4YGB5kivQUxMTHh4eICOyWw2BwUFxcTEWCyWsLAwi8Uybty4sLCwSZMmRUdHa38UGhoUFGS1WiMiIgybkJAQs45pmM7IkSOHDx8+bNgwHx8fPz+/ESNGGCM+Pj6+vr5+fn6+Oj46vr6+hsp0zEu1jnFepVNdXX1cp3oARtcwM/XnWkmSBrzp50tDRqy6EYIgKY7jJC+CIBgZ82lgGNZiSJK0O8uK4oZRD4JgGNafmWVZfjoq+gPGSKB6DlNUgmT5J3Py84sVlGARnDGm/WJiWZZ7nS6X241hOK/nVP3bU0KexOMFQZDH4qFzjaKwWoEGLOA5Xs8Hmo9kSZJF7+z6po2xEM5DCOlyeXo6HR3tD9scXY9oihAASWGQq/cR5HR0Pmz/pa2lreXBw45fjOWpiXmRt3+Rv+1Ixv6KjRs2LcnOTym1f5ybnV51cN/1bypPlBUUv79ge96SaZMmhJr9g/88cnJMGE1T3qTPgb1HC9dvXpKRtbBgY3p62vycFfMmBgeuTE46tGfV0fLMzw8UVpR+MOutmNAg/0B/n7iJIY/FJE3mFWVOfzve/+VRubmpCZMts6dZVr87K3NJclFu3I7i6Zf/s69y34Y3XgkNHTd6rHnEq1Ghj8sNw9LLM5KS3p2eMCM6c+2y+Ldes1pC586YumxBYm7qGwfKNjxqvVVz5fSRT0uyViWPDRj1hJjnwMyUuNcXWeZlxy3KmhsbO+FPf/QZ9fvfJbwWuzMtofFileOna70PbnLun/NylptMppAgf5Ik+sSiwO/cV/jelvSCXWuK/7ll54cFa1evnDc3MSM9q+yjtKuny7uba+7c+Mb298LE2W9PmzZlxdJFLMtoYr3Yy4OqydOLixe0SjEgCjSVadAWhGVohtG2GfrnK0FRBOBYiiJYljZ2EAO3L4M3KAxDkSRBEFhra3NNzY+1tTUtLQ9wHKUo4mlLk7GdGdQEgbPZShYvXpySklxSslsQwJBmJr3qDW4AAL0yasXROAxp9swvQCOfeNPT0AX8f+E/zGpE6MZ3AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;photo intelligence를 적용한 fitness studio 결과&apos; title=&apos;&apos; src=&apos;/static/d98689926b5a4f38d8a8fa5d62ad8953/ca1dc/03-photo-intelligence-fitness.png&apos; srcset=&apos;/static/d98689926b5a4f38d8a8fa5d62ad8953/e7570/03-photo-intelligence-fitness.png 170w,
/static/d98689926b5a4f38d8a8fa5d62ad8953/f46e7/03-photo-intelligence-fitness.png 340w,
/static/d98689926b5a4f38d8a8fa5d62ad8953/ca1dc/03-photo-intelligence-fitness.png 680w,
/static/d98689926b5a4f38d8a8fa5d62ad8953/02d09/03-photo-intelligence-fitness.png 1020w,
/static/d98689926b5a4f38d8a8fa5d62ad8953/64756/03-photo-intelligence-fitness.png 1200w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;photo intelligence를 적용한 fitness studio 결과&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;workshop 케이스에서는 craft detail 사진이 gallery/proof/detail 역할을 했다. 한 장의 사진 분석 실패는 &lt;code class=&quot;language-text&quot;&gt;partial&lt;/code&gt;로 기록했지만 generation은 계속 진행했다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/2cdf4d822f8d48f1cb062698a7dededb/64756/04-photo-intelligence-workshop.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 327.6470588235294%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAABCCAIAAADYPGGwAAAACXBIWXMAAAsTAAALEwEAmpwYAAAIPklEQVR42pVX+W9U1xWe/6DNT5BAiUhDlKAALYS0BSWkBKnND21SyVKXCJQUmirCpSxFbAabFGO8FwK44NiEYCNkltYUKEscXBZjGrApxlu8jR3P5lnect/dl1fdN/Z4PHYEufp+eO/M/d4997vnnHvGxyjiDFtmPBgYwghwhhlFGeAUQccCwMKOKR4c5eEHTAhGoC/5MyWQYGcybfRXCjkjlEDGiKCAEZC0+8Y/z3ByWc6w4ES/UoQxeDjYcutRw6FPNhSWZFXV5Nxpv5UAMcEwpWMrE+xAx3KAmYRlxgEwBCfAMb7ouHbxv2dXfTA7e/287HWLNmxe0tF9x1WKEMdHCVSS+ft7rjdc/aLhytXLF+823/7fg/uD/l7XFZYVPXB8x/5juzdsfWv7rp+X/u13m/6yoLX1kuu6BHtkIWg0Eviy+UZHW0vLvbudHW2UQE88YprRnD2rd+xZdeSz3NyP3tq+c2lO7huPOm5oMnFG3cYEW4gBIgCwbSsRj4Vj0RDFyDCClbW7autLLvynqqI6e2fu8s1b37h584K3MvAx4jCpyFATa9wmbuexeA/jnHtflJwl4sOHK9fu2//+lh1vV1Ttyv7zL95bs+J207VRtxmBjAseaRMth8WDo8zwM84YhXo7nJpGuKhs5dbty9b96bX9R3Jrzx48enxvZ9c9V0k65jZknDLXZcpljIweHoGcYQea9Tc+O3mx9Oy1w9cf/OtOe0PTw89D0UHJKU0FiV6faIUYxR4I1+vrZ9MxDBg3wEjMDCfseMKMImSnB4n20JVSobgruatcV3JFTFcp13Vdjl2G9INSLrVdVwlOtbMpMudUKcmcuJJccyWnjqH0Z1ytKLY1VwrqJKQUfCI5CexJNeq5NyMZtpQzmmYczxzfhBwgMO0V6tkZSTZhQsbK40AYOwP9Pf6BPgTBWM6M/zrVymz0ATmWZcRMI24aUdtKYAQogR6SHo2RKYGSs8hIX+ujCw/bL7e1X+rsb+zpuFB/YtvpY5uKdmUdKs9uuvVZ11c1nZ0V/X3HggO1RrRdcK6LgSYLPhzsuNJQcaq24ERNQXPrqZa7NYc/WrF97SubP1y2c/3PGhtK7rWUXrm6qfH65luf5w30NinpRViSHAx11dUVVVVsPVD04Ym60of3T9w4s/rYwTUF27Jy1r7Z1Pjx+X9sKihedqTy18c+eb+/t3kCORTqbGr+9OrlA4dK1h46sPn+3ePnqt47U/FuwZrFa377w5rqHaVlv8wvXlp3ct2n1R981XXbVSpFZoFA973Wc22dF2/dPtl4s7brUf254xvrazZePb2povT3Vy5UnP/nnjN1eZfOl5+rK+jrua+USCUGohQ7NmCUut4QnNmWxRhPvjJGbcvmo69p4empTSKxYEvXvS87muuvnDt/+WwgNKhEMjFHayP1wiNVJMePSgk2GBzYuHvLyj+uWvmHdwvKctq7Wl1XS/JNxTidTP2BvuK/F7+24qdvZ71zsKq4u7fN1buCT0JmvYPd1Wcrc/Zu+/6LL6xeu7JvsNOV/EnJ/uHe6rrK0/8+dbTmUGXtx73+JyMnryKEQDAciBsJRKCDAMaP2W1GYmCCdQ5KziRnSXlTeCx59LpLzZaSS8k09Jk9ATkFgsGgv3d4aGDQ3xcMDNHMIjGJLDgR3Ku7DGNoh4LD4VAgEh6ORUMEg/EakKrN6Xu2bcuyDCG4lEJKqThyBaSMAtu0bcszCr0XnOAZZM4IQhAhqKT0oBTDikF9ozuAUjJml4qhVISmyBjYFkbQVVJXXz0JKgYwRsC2lTYKD1Jxwqfcc3rQC8E4p4ITJTPUxo9RmxJoWwkHmBCYtpX4pqP2pRO8Y9D3G0agp7vDP9Az0N/T3dUOHSvNqSmOCnPmNTFs1HmMHIQAgjZGIFn9x0BSno+rbVumZZmOA7QqSikKFAOEeHbT5Ixpo+AKxXkGmTHiAACADaGjtU2SKcAE25alj0obPTvHmUfFKNZ+QoCRI7TITBCHE0AwRFC77Rk9eP1Z5jlLfbxcSi6Ebg6F5PpG9o5dJi2jdpaxsne5TxxSylgsapqGSl7xaSPzcs8gK6UwxoHA8EgkQgjJ4E9NFl4jQghmVGsghG5bKMWEaEUpxUKIyWTEudaTc0YJxhgyRqnX1mAEKcHeMyYYMUq8toJMEIwSGA4ODfn7AsOD8ViYMRIMDA309wz5++KxiOA0ODwYCn4dDn2tO8OxaB0PkuS3OSPJlKYEEayXlYLpV+0zk0Irz9mElaHntjeSSeuFxJh4Y+Eh9fB2RzK6oQm1kjOMoG0mosBKeP8APPtY5rDJQZKezJzhRCzS29M10N9jGlGhQxKlMLHoM+x4eZvO9/51QIx1zOr0SsMEwbwaZEQjQWAbKT4lKGEk4ol4ImPEE15zlUZGUPfoBDvpZMMwEpPHZLJtxsOhYcuMW2YcQftbkL1+D0RHwiORYCIeMY1YclePJ2MECHbMxEh4uB85lqeQLj0Igmg0OjJpREZGbNskGGAEfKlUcV3iutL9NsNXVlJYVlJYXlpUXlacfC4t3ldUuLe0KL+8OL+sOL+0KL+4ML+sZF95aWEKyZm+Z2dOH8O0Z2dOnzVj2pznZi2cP/eluXOff3HeCy/Nnz9/weKF8+Y8N2vWjGlpkzV8i34wLx0LF7y85NWFr7++LDvr1WMbflK94cfrf7Nk+fI3l/5o0cIFL2dM9j0/+3sZmDN7xtPPzPjV4qdKsr5bkvWdd155avrTz8yZPXPyTF/+X3MnY++e3Ny83Vty8rbk5OXu3l2wJ2/Kab4pZfSSk7mKexCuq6ZU+/91o3te7maFLwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;photo intelligence를 적용한 workshop 결과&apos; title=&apos;&apos; src=&apos;/static/2cdf4d822f8d48f1cb062698a7dededb/ca1dc/04-photo-intelligence-workshop.png&apos; srcset=&apos;/static/2cdf4d822f8d48f1cb062698a7dededb/e7570/04-photo-intelligence-workshop.png 170w,
/static/2cdf4d822f8d48f1cb062698a7dededb/f46e7/04-photo-intelligence-workshop.png 340w,
/static/2cdf4d822f8d48f1cb062698a7dededb/ca1dc/04-photo-intelligence-workshop.png 680w,
/static/2cdf4d822f8d48f1cb062698a7dededb/02d09/04-photo-intelligence-workshop.png 1020w,
/static/2cdf4d822f8d48f1cb062698a7dededb/64756/04-photo-intelligence-workshop.png 1200w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;photo intelligence를 적용한 workshop 결과&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;이 실패 허용 정책도 중요했다. Photo intelligence는 품질을 올리는 입력이지, 랜딩페이지 생성을 막는 hard dependency가 아니다.&lt;/p&gt;
&lt;h2 id=&quot;Debug-payload와-generation-payload를-나눴다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Debug-payload%EC%99%80-generation-payload%EB%A5%BC-%EB%82%98%EB%88%B4%EB%8B%A4&quot; aria-label=&quot;Debug payload와 generation payload를 나눴다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Debug payload와 generation payload를 나눴다&lt;/h2&gt;
&lt;p&gt;구현에서 가장 조심한 부분은 운영자가 보는 payload와 모델에게 주는 payload를 분리하는 일이었다.&lt;/p&gt;
&lt;p&gt;Debug payload에는 실패까지 넓게 남겼다. enabled/disabled/skipped/failed/partial/complete 상태, model, photo count, failed count, per-photo error, raw-ish summary, brand color rationale이 필요했다. 운영자는 나중에 &quot;왜 이 사진이 hero가 됐지?&quot;, &quot;왜 이 색을 썼지?&quot;, &quot;왜 사진 분석이 빠졌지?&quot;를 봐야 한다.&lt;/p&gt;
&lt;p&gt;Generation payload는 더 작게 만들었다. 최종 모델에게는 alt text, visible subjects, dominant colors, suggested roles, placement hint, brand key color처럼 생성에 직접 필요한 값만 넘겼다. 실패 noise나 내부 상태를 많이 넘기면 HTML 생성 품질이 오히려 흔들릴 수 있기 때문이다.&lt;/p&gt;
&lt;p&gt;이 구분이 없으면 AI 기능은 금방 블랙박스가 된다. 결과가 좋아 보여도 왜 좋아졌는지 모르고, 실패해도 어디서 실패했는지 모른다.&lt;/p&gt;
&lt;h2 id=&quot;승격-기준&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8A%B9%EA%B2%A9-%EA%B8%B0%EC%A4%80&quot; aria-label=&quot;승격 기준 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;승격 기준&lt;/h2&gt;
&lt;p&gt;실험 결과는 자동 점수만 보면 애매했다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variant&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Results&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Published&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Average score&lt;/th&gt;
&lt;th&gt;Verdict&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;combined&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code class=&quot;language-text&quot;&gt;photo-intelligence&lt;/code&gt;&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;100.0&lt;/td&gt;
&lt;td&gt;4 pass&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;여기서 &quot;photo-intelligence가 자동 평가에서 이겼다&quot;고 말하지 않았다. 숫자는 동률이었다.&lt;/p&gt;
&lt;p&gt;대신 승격 기준을 다르게 봤다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;기존 quality guardrail을 깨지 않았다.&lt;/li&gt;
&lt;li&gt;사람 눈으로 볼 때 사진과 색감 사용이 더 의도적으로 보였다.&lt;/li&gt;
&lt;li&gt;prompt 문구 추가보다 runtime data path 개선이 더 지속 가능했다.&lt;/li&gt;
&lt;li&gt;debug log와 운영 화면에서 분석 결과를 확인할 수 있었다.&lt;/li&gt;
&lt;li&gt;실패해도 generation이 계속되는 fallback boundary가 있었다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;그래서 code deploy와 smoke test 후 production runtime default로 승격했고 이전 combined profile은 rollback target으로 남겼다.&lt;/p&gt;
&lt;h2 id=&quot;검증&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%80%EC%A6%9D&quot; aria-label=&quot;검증 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;검증&lt;/h2&gt;
&lt;p&gt;이 작업에서 검증한 것은 &quot;사진을 쓰니 무조건 예쁘다&quot;가 아니었다. 더 좁게 봤다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;사진 분석이 성공/partial/failed 상태로 남는가&lt;/li&gt;
&lt;li&gt;generation payload가 내부 debug noise 없이 필요한 metadata만 받는가&lt;/li&gt;
&lt;li&gt;사진 분석 실패가 generation 전체 실패로 번지지 않는가&lt;/li&gt;
&lt;li&gt;자동 quality guardrail을 깨지 않는가&lt;/li&gt;
&lt;li&gt;사람 눈으로 봤을 때 사진 역할과 색감 사용이 더 설명 가능한가&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;좋은 AI 결과물은 한 번의 model call에서 나오지 않는다. 입력을 분석하고, 구조화하고, 필터링하고, 기록하고, 운영 화면에 보여주고, 승격 기준까지 정하는 전체 pipeline에서 나온다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;멀티모달 품질 문제가 보이면 먼저 &quot;이미지를 넣었는가&quot;보다 &quot;이미지 이해 결과가 어떤 구조로 전달되는가&quot;를 본다.&lt;/li&gt;
&lt;li&gt;자동 점수가 동률이면 사람 눈으로 보이는 의도성, debug 가능성, fallback boundary를 같이 본다.&lt;/li&gt;
&lt;li&gt;모델에게 모든 사진 판단을 맡기지 않는다. hero 후보, detail evidence, alt text, dominant color처럼 제품이 원하는 판단 단위를 먼저 정의한다.&lt;/li&gt;
&lt;li&gt;실패할 수 있는 AI 보조 기능은 hard dependency로 두지 않는다. 실패 상태는 기록하되, core generation은 가능한 한 계속 진행시킨다.&lt;/li&gt;
&lt;li&gt;공개 글로 남길 때는 실제 장소명, 내부 profile/run id, 운영 URL을 그대로 노출하지 않는다.&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[From moving fast alone to helping the team move with fewer blockers]]></title><description><![CDATA[One thing I learned while building Place2Page is that development speed is not defined only by individual implementation speed. At first, I…]]></description><link>https://sewon.dev/en/place2page-team-collaboration-midpoint-review/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-team-collaboration-midpoint-review/</guid><pubDate>Sat, 23 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c24945dba2d7e0c987432ef2f098cc59/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAABuElEQVR42o2RXWvbMBSG+///wlIoY80udjN2NWhhhcRtmq4bbbOGUNdx6syJZVuSrQ9bH0cqSZxtLRvs5SCOQM973oMOjIVwUaWZSJFYrvlTyvYNj5cMV63/tw4AHCoYJhxXIieiIKKksiCiwDwvmZTae+/crnbqrht45yGVRiUtMMnx5mRCGgvbB3sGnAMA8A6g8/gFm4bVBFeirbiomGwaZVvljfFad1M2NsZb8SK2996mN+vBGzJ+58jCWXBWuwLRm9vk8orfTRwlThvgtFwO4vuPqopewIBjfPupnn62dWa1tlpZXPKHBzydyTAEVoHW0Mo6n2TxmRJom+SP2P8jB9a2/HVs7eyIxQF5PK+jdVP9EKugjoZ1NKE/v+bzEzQdkPCOp5mgX7JJQB5HdN6C6eAGTL+4PowHb9E4FOiEznpJ0EuD7yy5rp8Ok6C3GJ7SWSJwb3l+tAj6q6vath3svG+slptS4EBZI4wSRlkHwiqkWa45NoKDyhVDitWm+R377xtuf+iyjI6i4fv5xfH84jgefVh966fje77ajnQd7Pb1quemzRUrFC8ULxUvjSgMl6B3k58BR9Wnx7pb9NEAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Situation diagram&apos; title=&apos;&apos; src=&apos;/static/c24945dba2d7e0c987432ef2f098cc59/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/c24945dba2d7e0c987432ef2f098cc59/e7570/situation-diagram.png 170w,
/static/c24945dba2d7e0c987432ef2f098cc59/f46e7/situation-diagram.png 340w,
/static/c24945dba2d7e0c987432ef2f098cc59/ca1dc/situation-diagram.png 680w,
/static/c24945dba2d7e0c987432ef2f098cc59/02d09/situation-diagram.png 1020w,
/static/c24945dba2d7e0c987432ef2f098cc59/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Situation diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;One thing I learned while building Place2Page is that development speed is not defined only by individual implementation speed. At first, I thought moving quickly, organizing things myself, and building ahead would help the team. But when I collected feedback, the bottleneck was not the amount of implementation. It was how visible the work was, when design and product judgment were aligned, and whether teammates had to wait for communication.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: The way I handled things quickly did not always translate into team-level speed.&lt;/li&gt;
&lt;li&gt;Judgment: More than ticket count or implementation speed, the team needed to see when work started and what criteria were being used.&lt;/li&gt;
&lt;li&gt;Feedback: There were improvement points around design flow, PO sync, meeting preparation, reply speed, and preparation for support programs.&lt;/li&gt;
&lt;li&gt;Lesson: A good team lead is closer to someone who reduces blockers for teammates than someone who carries a lot alone.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;While working on Place2Page, I had many moments where I thought less about development itself and more about how to work as a team. In a small team, someone often has to move first for work to start moving. I also handled many things that way.&lt;/p&gt;
&lt;p&gt;But moving quickly alone is different from helping the team move well together. If the work I handled first is not visible to teammates, it can become uncertainty rather than speed. Work I carried first out of responsibility can later come back as the cost of realigning direction.&lt;/p&gt;
&lt;p&gt;This post is a midpoint review of my working style, based on feedback I received over about a month.&lt;/p&gt;
&lt;h2 id=&quot;Align-Visual-Outputs-Before-Development&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Align-Visual-Outputs-Before-Development&quot; aria-label=&quot;Align Visual Outputs Before Development permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Align Visual Outputs Before Development&lt;/h2&gt;
&lt;p&gt;In the beginning, I sometimes built the frontend first and got design feedback after there was something to look at.&lt;/p&gt;
&lt;p&gt;It felt efficient to find assets quickly from tools like 21st.dev or lottiefiles.com, customize them, and show the result. But a customer-facing output like a landing page is not done just because the feature works. The flow, visual taste, copy, and demo impression all need to line up.&lt;/p&gt;
&lt;p&gt;For visible outputs, it is better to align the design flow before development than to ask for review after implementation. After development, the flow should feel more like QA.&lt;/p&gt;
&lt;p&gt;Building fast still matters, but the cost of changing direction later is not small. From the next sprint, I want to work from completed planning and design, then use QA after development as the default flow.&lt;/p&gt;
&lt;h2 id=&quot;Make-Work-Visible-to-the-PO&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Make-Work-Visible-to-the-PO&quot; aria-label=&quot;Make Work Visible to the PO permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Make Work Visible to the PO&lt;/h2&gt;
&lt;p&gt;I also received feedback that the PO did not have enough visibility into what I was doing.&lt;/p&gt;
&lt;p&gt;When I see something that needs to be done, I tend to handle it first and share after it is somewhat organized. That has the advantage of speed. But from the team&apos;s point of view, it can be hard to see what I am working on and which judgment made me start it.&lt;/p&gt;
&lt;p&gt;This matters even more when product direction or priority is involved. If I share only after I have already made progress, the PO cannot see the intermediate reasoning. Then the moment to align priority or direction comes too late.&lt;/p&gt;
&lt;p&gt;So I want to move less like &quot;act first, report later&quot; and share briefly before starting.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;I will check this part first.
I will organize this ticket today around the P0 standard.
For this one, I will align the direction with the PO before development.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;For visible outputs, I will align the design flow first. For product direction or priority decisions, I will sync with the PO first.&lt;/p&gt;
&lt;p&gt;In a small team, long reporting is often less important than making the start of work visible to each other. If teammates can see what I am doing, they can decide sooner whether to wait, help, or change direction.&lt;/p&gt;
&lt;h2 id=&quot;Do-Not-Overinterpret-Discord-Feedback-Alone&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Do-Not-Overinterpret-Discord-Feedback-Alone&quot; aria-label=&quot;Do Not Overinterpret Discord Feedback Alone permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Do Not Overinterpret Discord Feedback Alone&lt;/h2&gt;
&lt;p&gt;When feedback comes through text, I sometimes read more tone into it than the sender intended. Especially when I am busy or already deep in a task, short messages can feel more defensive than they are.&lt;/p&gt;
&lt;p&gt;But Discord text naturally loses a lot of context. The other person may not be evaluating me. They may simply be asking for the alignment needed at that moment.&lt;/p&gt;
&lt;p&gt;So when something is ambiguous, I should ask directly instead of interpreting it alone. I am practicing moving quickly from &quot;What does this mean?&quot; to &quot;What standard do I need to check now?&quot;&lt;/p&gt;
&lt;h2 id=&quot;Share-Meeting-Requests-With-Agenda-Items&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Share-Meeting-Requests-With-Agenda-Items&quot; aria-label=&quot;Share Meeting Requests With Agenda Items permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Share Meeting Requests With Agenda Items&lt;/h2&gt;
&lt;p&gt;For U300, I once asked whether there was anything to discuss before a meeting. In my head, there were agenda items: how to run U300, interview results, and software support needed for 300 outreach attempts.&lt;/p&gt;
&lt;p&gt;But if I do not say those first, the other person cannot tell what is different from the existing preparation. I thought I was asking lightly, but for the receiver it could become, &quot;So what should I prepare?&quot;&lt;/p&gt;
&lt;p&gt;Going forward, I will share meeting preparation in this structure:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Agenda items&lt;/li&gt;
&lt;li&gt;Questions I want to check&lt;/li&gt;
&lt;li&gt;Decisions needed&lt;/li&gt;
&lt;li&gt;Areas where I can support&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Meeting preparation is also a small product document. The important thing is to make sure the other person does not have to guess the context in my head.&lt;/p&gt;
&lt;h2 id=&quot;Do-Not-Miss-Communication-While-Focused&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Do-Not-Miss-Communication-While-Focused&quot; aria-label=&quot;Do Not Miss Communication While Focused permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Do Not Miss Communication While Focused&lt;/h2&gt;
&lt;p&gt;When I get deep into a task, I tend to block out almost everything that feels less important. This can help when developing. But it is not always a good habit when working as a team.&lt;/p&gt;
&lt;p&gt;If my reply is late, the other person has to wait, ask again, or decide alone during that time. If I reply quickly, even briefly, I can save their time.&lt;/p&gt;
&lt;p&gt;Recently I have been realizing that checking messages and replying as soon as possible is part of basic collaboration etiquette. Trust is not built only by doing big things. Reducing small blocked moments also affects trust and team speed.&lt;/p&gt;
&lt;p&gt;I have not fixed this well yet, but I am trying to stay aware of it.&lt;/p&gt;
&lt;h2 id=&quot;Do-Not-Carry-Support-Program-Preparation-Alone&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Do-Not-Carry-Support-Program-Preparation-Alone&quot; aria-label=&quot;Do Not Carry Support Program Preparation Alone permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Do Not Carry Support Program Preparation Alone&lt;/h2&gt;
&lt;p&gt;For work like U300 or startup support applications, presentations, slides, copy, business planning, and team strategy are all connected. If I try to carry all of that alone, I hit limits quickly.&lt;/p&gt;
&lt;p&gt;At first, I sometimes thought I could not contribute much unless I was excellent at writing or business plan documents. But active brainstorming with the team produced many more useful ideas.&lt;/p&gt;
&lt;p&gt;The process itself also seems to give the other person more stability. Looking at a blank document alone feels much more uncertain than having someone next to you thinking through it together.&lt;/p&gt;
&lt;p&gt;As a team lead, I should not be someone who does everything alone. I should be someone who helps teammates play their roles, think together, and divide the work. I want to become the kind of lead the team can trust and lean on in that way.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Will-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Will-Judge-This-Next-Time&quot; aria-label=&quot;How I Will Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Will Judge This Next Time&lt;/h2&gt;
&lt;p&gt;Going forward, I will ask &quot;Does the team need to wait or guess because of this?&quot; before asking &quot;Can I finish this quickly?&quot; When individual speed increases team uncertainty, sharing comes first.&lt;/p&gt;
&lt;p&gt;My execution standard is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reduce tickets around goals instead of creating many tickets.&lt;/li&gt;
&lt;li&gt;Align the design flow before developing visible outputs.&lt;/li&gt;
&lt;li&gt;Sync with the PO before work that affects product direction or priority.&lt;/li&gt;
&lt;li&gt;Instead of acting first and reporting later, say &quot;I am going to work on this&quot; before starting.&lt;/li&gt;
&lt;li&gt;Do not interpret Discord feedback alone. Confirm the needed intent.&lt;/li&gt;
&lt;li&gt;Share meeting preparation as separate agenda items and questions.&lt;/li&gt;
&lt;li&gt;Even while focused, try not to miss replies that save teammates&apos; time.&lt;/li&gt;
&lt;li&gt;Delegate more actively for complex work like U300, applications, presentations, and marketing execution.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Looking-Back&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Looking-Back&quot; aria-label=&quot;Looking Back permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Looking Back&lt;/h2&gt;
&lt;p&gt;The strongest lesson from this midpoint review is that developer speed is not only individual working speed.&lt;/p&gt;
&lt;p&gt;Building quickly alone is sometimes necessary. But if the team is not moving with the same criteria, we end up reorganizing, re-explaining, and reworking. In an early product, tickets, design flow, PO sync, meeting agenda, reply speed, and R&amp;#x26;R affect product speed as much as code does.&lt;/p&gt;
&lt;p&gt;These days, I am trying to ask more often: &quot;Is the team less blocked and moving together?&quot; instead of only &quot;Can I handle this quickly?&quot;&lt;/p&gt;</content:encoded></item><item><title><![CDATA[혼자 빠른 개발에서 팀이 덜 막히는 방식으로]]></title><description><![CDATA[Place2Page…]]></description><link>https://sewon.dev/place2page-team-collaboration-midpoint-review/</link><guid isPermaLink="false">https://sewon.dev/place2page-team-collaboration-midpoint-review/</guid><pubDate>Sat, 23 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c24945dba2d7e0c987432ef2f098cc59/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAABuElEQVR42o2RXWvbMBSG+///wlIoY80udjN2NWhhhcRtmq4bbbOGUNdx6syJZVuSrQ9bH0cqSZxtLRvs5SCOQM973oMOjIVwUaWZSJFYrvlTyvYNj5cMV63/tw4AHCoYJhxXIieiIKKksiCiwDwvmZTae+/crnbqrht45yGVRiUtMMnx5mRCGgvbB3sGnAMA8A6g8/gFm4bVBFeirbiomGwaZVvljfFad1M2NsZb8SK2996mN+vBGzJ+58jCWXBWuwLRm9vk8orfTRwlThvgtFwO4vuPqopewIBjfPupnn62dWa1tlpZXPKHBzydyTAEVoHW0Mo6n2TxmRJom+SP2P8jB9a2/HVs7eyIxQF5PK+jdVP9EKugjoZ1NKE/v+bzEzQdkPCOp5mgX7JJQB5HdN6C6eAGTL+4PowHb9E4FOiEznpJ0EuD7yy5rp8Ok6C3GJ7SWSJwb3l+tAj6q6vath3svG+slptS4EBZI4wSRlkHwiqkWa45NoKDyhVDitWm+R377xtuf+iyjI6i4fv5xfH84jgefVh966fje77ajnQd7Pb1quemzRUrFC8ULxUvjSgMl6B3k58BR9Wnx7pb9NEAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/c24945dba2d7e0c987432ef2f098cc59/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/c24945dba2d7e0c987432ef2f098cc59/e7570/situation-diagram.png 170w,
/static/c24945dba2d7e0c987432ef2f098cc59/f46e7/situation-diagram.png 340w,
/static/c24945dba2d7e0c987432ef2f098cc59/ca1dc/situation-diagram.png 680w,
/static/c24945dba2d7e0c987432ef2f098cc59/02d09/situation-diagram.png 1020w,
/static/c24945dba2d7e0c987432ef2f098cc59/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Place2Page를 진행하면서 배운 것은 개발 속도가 개인 작업 속도만으로 결정되지 않는다는 점이었다. 처음에는 내가 빠르게 정리하고 먼저 만들어두는 방식이 팀에 도움이 된다고 생각했다. 하지만 피드백을 모아보니 병목은 구현량이 아니라 일이 보이는 방식, 디자인과 제품 판단을 맞추는 타이밍, 팀원이 기다리지 않아도 되는 커뮤니케이션에 있었다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: 내가 빨리 처리하는 방식이 항상 팀 전체 속도로 이어지지는 않았다.&lt;/li&gt;
&lt;li&gt;판단: 티켓 수나 구현 속도보다, 일이 시작되는 시점과 판단 기준이 팀에 보이는지가 더 중요했다.&lt;/li&gt;
&lt;li&gt;피드백: 디자인 플로우, PO sync, 회의 준비, 답장 속도, 지원사업 준비 방식에서 개선 지점이 보였다.&lt;/li&gt;
&lt;li&gt;배운 점: 좋은 팀장은 혼자 많은 일을 들고 가는 사람이 아니라, 팀원이 덜 막히게 경계를 정리하는 사람에 가깝다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;Place2Page를 진행하면서 개발 자체보다 팀으로 일하는 방식에 대해 생각할 일이 많아졌다. 작은 팀에서는 누군가가 먼저 움직여야 일이 굴러가는 경우가 많고, 나도 그런 방식으로 많은 일을 처리했다.&lt;/p&gt;
&lt;p&gt;하지만 혼자 빠르게 움직이는 것과 팀이 같이 잘 움직이는 것은 달랐다. 내가 먼저 처리한 일이 팀원에게 보이지 않으면, 그 일은 속도가 아니라 불확실성이 될 수 있다. 책임감으로 먼저 들고 간 일이 나중에는 방향을 다시 맞춰야 하는 비용으로 돌아오기도 했다.&lt;/p&gt;
&lt;p&gt;이 글은 약 한 달 동안 받은 피드백을 기준으로, 내가 일하는 방식을 중간 점검한 기록이다.&lt;/p&gt;
&lt;h2 id=&quot;시각-산출물은-개발-전에-흐름을-맞춘다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%9C%EA%B0%81-%EC%82%B0%EC%B6%9C%EB%AC%BC%EC%9D%80-%EA%B0%9C%EB%B0%9C-%EC%A0%84%EC%97%90-%ED%9D%90%EB%A6%84%EC%9D%84-%EB%A7%9E%EC%B6%98%EB%8B%A4&quot; aria-label=&quot;시각 산출물은 개발 전에 흐름을 맞춘다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;시각 산출물은 개발 전에 흐름을 맞춘다&lt;/h2&gt;
&lt;p&gt;초기에는 내가 앞단을 먼저 만들고 나온 결과물을 나중에 디자인 피드백 받는 흐름이 있었다.&lt;/p&gt;
&lt;p&gt;초기에는 21st.dev나 lottiefiles.com에서 빠르게 asset을 찾고 커스터마이즈해서 보여주는 방식이 효율적으로 느껴졌다. 하지만 랜딩페이지처럼 고객이 직접 보는 산출물은 기능만 동작한다고 끝나지 않았다. 플로우, 미감, 카피, 데모에서 보이는 느낌까지 같이 맞아야 했다.&lt;/p&gt;
&lt;p&gt;시각적으로 보이는 것은 개발 후에 검수받는 방식보다 개발 전에 디자인 플로우를 먼저 맞추는 편이 낫다. 개발 이후에는 QA를 받는 흐름으로 가져가는 것이 훨씬 더 자연스럽다.&lt;/p&gt;
&lt;p&gt;빠르게 만드는 것도 중요하지만, 나중에 방향을 다시 맞추는 비용도 무시하기 어렵다. 다음 스프린트부터는 완성된 기획과 디자인 위에서 작업하고, 개발 이후에는 QA로 확인하는 흐름을 기본으로 가져가려고 한다.&lt;/p&gt;
&lt;h2 id=&quot;PO에게-일이-보이게-만들기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#PO%EC%97%90%EA%B2%8C-%EC%9D%BC%EC%9D%B4-%EB%B3%B4%EC%9D%B4%EA%B2%8C-%EB%A7%8C%EB%93%A4%EA%B8%B0&quot; aria-label=&quot;PO에게 일이 보이게 만들기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;PO에게 일이 보이게 만들기&lt;/h2&gt;
&lt;p&gt;PO에게 내가 하는 일의 가시성이 좋지 않다는 피드백도 받았다.&lt;/p&gt;
&lt;p&gt;나는 할 일이 보이면 일단 먼저 처리하고 어느 정도 정리된 뒤에 공유하는 편이었다. 이 방식은 빠르게 움직인다는 점에서는 장점이 있다. 하지만 팀 입장에서는 내가 지금 무엇을 하고 있는지, 어떤 판단으로 일을 시작했는지 잘 보이지 않을 수 있다.&lt;/p&gt;
&lt;p&gt;특히 제품 방향이나 우선순위가 걸린 일은 더 그렇다. 내가 이미 어느 정도 진행한 뒤에 공유하면, PO는 중간 판단 과정을 같이 보기 어렵다. 그러면 우선순위나 방향을 맞추는 타이밍이 늦어진다.&lt;/p&gt;
&lt;p&gt;그래서 앞으로는 선조치 후보고처럼 움직이기보다 일을 시작하기 전에 짧게라도 공유한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;이 부분 먼저 확인해볼게요.
이 티켓은 오늘 P0 기준으로 정리해볼게요.
이건 개발 전에 PO랑 방향만 한번 맞추고 들어갈게요.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;시각적으로 보이는 것은 디자인 플로우를 먼저 맞추고, 그 외 제품 방향이나 우선순위가 걸린 일은 PO와 sync를 맞추는 식으로 가져가려고 한다.&lt;/p&gt;
&lt;p&gt;작은 팀에서는 보고를 길게 하는 것보다 일이 시작되는 순간을 서로 알 수 있게 만드는 것이 더 중요할 때가 있다. 내가 무엇을 하고 있는지 보이면 팀원도 기다릴지, 도와줄지, 방향을 바꿀지 더 빨리 판단할 수 있다.&lt;/p&gt;
&lt;h2 id=&quot;Discord-피드백을-혼자-꼬아듣지-않기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Discord-%ED%94%BC%EB%93%9C%EB%B0%B1%EC%9D%84-%ED%98%BC%EC%9E%90-%EA%BC%AC%EC%95%84%EB%93%A3%EC%A7%80-%EC%95%8A%EA%B8%B0&quot; aria-label=&quot;Discord 피드백을 혼자 꼬아듣지 않기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Discord 피드백을 혼자 꼬아듣지 않기&lt;/h2&gt;
&lt;p&gt;텍스트로 피드백을 받으면 가끔 말의 의도보다 뉘앙스를 더 크게 받아들일 때가 있다. 특히 바쁘거나 이미 몰입해 있는 상태에서는 짧은 문장도 필요 이상으로 방어적으로 읽힐 때가 있다.&lt;/p&gt;
&lt;p&gt;하지만 Discord 텍스트는 원래 맥락이 많이 잘린다. 상대가 나를 평가하려는 것이 아니라, 그냥 지금 필요한 정렬을 요청하는 경우가 많다.&lt;/p&gt;
&lt;p&gt;그래서 애매하면 혼자 해석하지 말고 바로 확인한다. &quot;이 말이 무슨 뜻이지?&quot;에서 오래 머무르기보다, &quot;그럼 지금 내가 확인해야 할 기준이 뭐지?&quot;로 빨리 넘어가는 연습을 하고 있다.&lt;/p&gt;
&lt;h2 id=&quot;회의-준비-요청은-안건까지-같이-공유하기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%9A%8C%EC%9D%98-%EC%A4%80%EB%B9%84-%EC%9A%94%EC%B2%AD%EC%9D%80-%EC%95%88%EA%B1%B4%EA%B9%8C%EC%A7%80-%EA%B0%99%EC%9D%B4-%EA%B3%B5%EC%9C%A0%ED%95%98%EA%B8%B0&quot; aria-label=&quot;회의 준비 요청은 안건까지 같이 공유하기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;회의 준비 요청은 안건까지 같이 공유하기&lt;/h2&gt;
&lt;p&gt;U300 관련해서 회의 전에 논의할 것이 있는지 물어본 적이 있었다. 내 머릿속에는 U300 진행 방식, 인터뷰 결과, 300개 아웃리치에 필요한 소프트웨어 지원 같은 안건이 있었다.&lt;/p&gt;
&lt;p&gt;그런데 그걸 먼저 말하지 않으면 상대 입장에서는 기존 준비와 무엇이 달라지는지 알기 어렵다. 나는 가볍게 물어본다고 생각했지만, 받는 사람 입장에서는 &quot;그래서 뭘 준비해야 하지?&quot;가 될 수 있었다.&lt;/p&gt;
&lt;p&gt;앞으로는 회의 전에 아래처럼 나눠 공유한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;논의할 안건&lt;/li&gt;
&lt;li&gt;확인하고 싶은 질문&lt;/li&gt;
&lt;li&gt;결정이 필요한 항목&lt;/li&gt;
&lt;li&gt;내가 지원할 수 있는 부분&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;회의 준비도 결국 작은 제품 문서처럼 써야 하는 것 같다. 상대가 내 머릿속 맥락을 추측하지 않아도 되게 만드는 게 중요하다.&lt;/p&gt;
&lt;h2 id=&quot;몰입하더라도-연락을-놓치지-않기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AA%B0%EC%9E%85%ED%95%98%EB%8D%94%EB%9D%BC%EB%8F%84-%EC%97%B0%EB%9D%BD%EC%9D%84-%EB%86%93%EC%B9%98%EC%A7%80-%EC%95%8A%EA%B8%B0&quot; aria-label=&quot;몰입하더라도 연락을 놓치지 않기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;몰입하더라도 연락을 놓치지 않기&lt;/h2&gt;
&lt;p&gt;나는 어떤 일에 몰입하면 덜 중요하다고 느끼는 것들을 거의 다 차단하는 버릇이 있다. 개발할 때는 이게 도움이 될 때도 있다. 하지만 팀으로 일할 때는 항상 좋은 습관은 아니었다.&lt;/p&gt;
&lt;p&gt;내가 답장을 늦게 하면 상대는 그 시간 동안 기다리거나, 다시 물어보거나, 혼자 판단해야 한다. 반대로 짧게라도 빨리 답하면 상대의 시간을 아낄 수 있다.&lt;/p&gt;
&lt;p&gt;요즘은 연락을 잘 보고 가능한 빨리 답하는 것도 기본적인 협업 에티켓이라는 것을 느끼고 있다. 큰 일을 해주는 것만 신뢰를 만드는 것이 아니라, 작게 막히는 시간을 줄여주는 것도 신뢰와 협업 속도에 영향을 준다.&lt;/p&gt;
&lt;p&gt;아직 잘 고쳐진 것은 아니지만, 의식적으로 보려고 한다.&lt;/p&gt;
&lt;h2 id=&quot;지원사업-준비를-혼자-끌고-가지-않기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A7%80%EC%9B%90%EC%82%AC%EC%97%85-%EC%A4%80%EB%B9%84%EB%A5%BC-%ED%98%BC%EC%9E%90-%EB%81%8C%EA%B3%A0-%EA%B0%80%EC%A7%80-%EC%95%8A%EA%B8%B0&quot; aria-label=&quot;지원사업 준비를 혼자 끌고 가지 않기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;지원사업 준비를 혼자 끌고 가지 않기&lt;/h2&gt;
&lt;p&gt;U300이나 모두의 창업 지원서처럼 발표, 장표, 카피, 사업계획, 팀 전략이 같이 걸린 일은 혼자 다 끌고 가면 빠르게 한계가 온다.&lt;/p&gt;
&lt;p&gt;처음에는 내가 글을 엄청 잘 쓰거나 사업계획서를 잘 쓰는 사람이 아니면 크게 기여하기 어렵다고 생각한 적도 있다. 그런데 같이 브레인스토밍에 적극적으로 참여하는 것만으로도 좋은 아이디어가 훨씬 많이 나왔다.&lt;/p&gt;
&lt;p&gt;그리고 그 과정 자체가 상대에게 안정감을 주는 것 같다. 혼자 빈 문서를 보고 있을 때보다, 옆에서 같이 생각해주는 사람이 있으면 막막함이 줄어든다.&lt;/p&gt;
&lt;p&gt;팀장이라면 모든 것을 혼자 잘하는 사람보다 팀원이 자기 역할을 할 수 있게 같이 생각하고 일을 나눌 수 있는 사람이어야 한다고 느꼈다. 나도 그런 방향으로 더 믿고 의지할 수 있는 팀장이 되고 싶다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;앞으로는 &quot;내가 빨리 끝낼 수 있는가&quot;보다 &quot;팀이 이 일을 기다리거나 추측하지 않아도 되는가&quot;를 먼저 본다. 개인 속도가 팀의 불확실성을 키우는 순간에는 공유가 먼저다.&lt;/p&gt;
&lt;p&gt;실행 기준은 이렇게 가져간다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;티켓은 많이 만들기보다 목표 기준으로 줄인다.&lt;/li&gt;
&lt;li&gt;시각 산출물은 개발 전에 디자인 플로우를 먼저 맞춘다.&lt;/li&gt;
&lt;li&gt;제품 방향이나 우선순위가 걸린 일은 PO와 먼저 sync를 맞춘다.&lt;/li&gt;
&lt;li&gt;선조치 후보고보다, 일을 시작하기 전에 &quot;나 이거 할게&quot; 한마디라도 공유한다.&lt;/li&gt;
&lt;li&gt;Discord 피드백은 혼자 해석하지 말고 필요한 의도를 확인한다.&lt;/li&gt;
&lt;li&gt;회의 준비 요청은 안건과 질문을 분리해서 전달한다.&lt;/li&gt;
&lt;li&gt;몰입 중이어도 팀원의 시간을 아끼는 답장은 놓치지 않으려고 한다.&lt;/li&gt;
&lt;li&gt;U300, 지원서, 발표, 마케팅 실행처럼 복합적인 일은 팀원에게 더 적극적으로 맡긴다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;돌아보면&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8F%8C%EC%95%84%EB%B3%B4%EB%A9%B4&quot; aria-label=&quot;돌아보면 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;돌아보면&lt;/h2&gt;
&lt;p&gt;이번 중간점검에서 많이 느낀 것은 개발자의 속도가 개인 작업 속도만은 아니라는 점이다.&lt;/p&gt;
&lt;p&gt;혼자 빠르게 만드는 것도 필요하다. 하지만 팀이 같은 기준으로 움직이지 않으면 다시 정리하고, 다시 설명하고, 다시 고치게 된다. 초기 제품에서는 코드만큼이나 티켓, 디자인 플로우, PO sync, 회의 안건, 답장 속도, R&amp;#x26;R이 제품 속도에 영향을 준다.&lt;/p&gt;
&lt;p&gt;요즘은 &quot;내가 빨리 처리할 수 있는가&quot;보다 &quot;팀이 덜 막히고 같이 움직이고 있는가&quot;를 더 자주 보려고 한다.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Tracing Event loop is closed through the OpenAI client lifecycle]]></title><description><![CDATA[Sentry kept collecting  events where our code was almost absent from the stack. At first it looked like library cleanup noise. But following…]]></description><link>https://sewon.dev/en/place2page-openai-async-client-event-loop-closed/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-openai-async-client-event-loop-closed/</guid><pubDate>Fri, 22 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c469430483eaa6bf0f492c6a47413e62/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB5klEQVR42oWSzWsTQRjG965HQQVvnkS8evFf8uRNCpaCqIhg8eMkirYgidJaiyD1CzFgG5qGJMWYmKZxN9nZr0k2m5nZj9mZdyTdxFCr+PAeXmb4Pc/MvKMJAchhpsMMRE2H2Tg0LIpcpiPSs2nXogaiDo6EAHVEGgD0feb1R3hAvQE96Gl/yBxMXEy8PsEDShkHmMAAkxrD2crU6y/2mWTKRRzLZOyS6TeslIhVGilQgqs0USlXIJXiXKUcOFcAMAoAYwiGh449dvUNv/jULz5hZmO3HG4X+pUtghFhje+4XGHNZvBT9zbe2283gs0tniSpELNkGROql2inmDLfNtP2D9Leo0koUtdlRi+xbRWGgJDo7IPnKoBDyX9eD6SQYtJLqZR696kwd/3uwo3F+Vv3r87fvnzl2na5NoUB9BDXR2Yr8lqx14ycRmjvRV4sUyHGLnMLd46fvnDm3KWTZy8eO3Ve0048XnoxS36uF29+e3Ov83Gx/eGB8fmh+eWR+9XjJNutVuvLyyv53Hou9zqfX3+29LK9r89gnNBeNETR0Ax9FA+tJLCSAJTqhoMCbu0QoxqhamTuJlZN2kiSbKravwabvWc9QCvdnbVueVUvrRqltV75lVOpjcwDGLTp54Cjpf6nXzJrj3lsMUVhAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Situation diagram&apos; title=&apos;&apos; src=&apos;/static/c469430483eaa6bf0f492c6a47413e62/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/c469430483eaa6bf0f492c6a47413e62/e7570/situation-diagram.png 170w,
/static/c469430483eaa6bf0f492c6a47413e62/f46e7/situation-diagram.png 340w,
/static/c469430483eaa6bf0f492c6a47413e62/ca1dc/situation-diagram.png 680w,
/static/c469430483eaa6bf0f492c6a47413e62/02d09/situation-diagram.png 1020w,
/static/c469430483eaa6bf0f492c6a47413e62/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Situation diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Sentry kept collecting &lt;code class=&quot;language-text&quot;&gt;RuntimeError: Event loop is closed&lt;/code&gt; events where our code was almost absent from the stack. At first it looked like library cleanup noise. But following the coroutine name and the &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; boundary showed a lifecycle issue: a raw &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt; client was not being closed inside the event loop that created it. The fix was not a broad async rewrite. It was a small change that guaranteed async close before returning from the coroutine path that created the client.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: &lt;code class=&quot;language-text&quot;&gt;RuntimeError: Event loop is closed&lt;/code&gt; kept accumulating in Sentry as recurring noise.&lt;/li&gt;
&lt;li&gt;Symptom: 5 events in the last 24 hours, 36 total occurrences, and the issue status was regressed.&lt;/li&gt;
&lt;li&gt;Judgment: I did not discard the system-only stack. I traced the cleanup resource and the event loop lifecycle boundary.&lt;/li&gt;
&lt;li&gt;Cause: An OpenAI async client created inside an event loop opened by &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; was not closed before the coroutine ended.&lt;/li&gt;
&lt;li&gt;Fix: In the meta prompt and final HTML generation paths that create raw &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt; clients, I guaranteed async close with &lt;code class=&quot;language-text&quot;&gt;finally&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Lesson: A system-only stack is still evidence. &quot;Our code is not in the stack&quot; can mean the lifecycle boundary is the thing to inspect.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;Place2Page receives a map URL, fetches place data, and generates landing page HTML with AI. The generation pipeline roughly looks like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;place URL
  -&gt; Google/Naver place fetch
  -&gt; meta prompt generation
  -&gt; final freeform HTML generation
  -&gt; save landing/debug log
  -&gt; send progress through SSE&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I had been working through Sentry issues by priority. Clear P1 issues like DB pool timeout came first. After that, one recurring issue kept showing up:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;RuntimeError: Event loop is closed&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;At first glance, it did not look like a high-impact user failure. Sentry reported 0 users impacted. But the issue was &lt;code class=&quot;language-text&quot;&gt;regressed&lt;/code&gt;, had 5 events in the last 24 hours, and 36 total occurrences.&lt;/p&gt;
&lt;p&gt;This kind of error is easy to ignore. It did not directly fail a request handler, and the stack was almost entirely inside libraries. But recurring production noise lowers operational sensitivity. It makes real incidents harder to see.&lt;/p&gt;
&lt;h2 id=&quot;Problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Problem&quot; aria-label=&quot;Problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;The latest Sentry event message looked like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Task exception was never retrieved
future: &amp;lt;Task finished name=&apos;Task-117508&apos;
  coro=&amp;lt;AsyncClient.aclose() done, defined at /app/.venv/lib/python3.11/site-packages/httpx/_client.py:1978&gt;
  exception=RuntimeError(&apos;Event loop is closed&apos;)&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The exception itself was simple.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;RuntimeError: Event loop is closed&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;But the stack consisted entirely of system frames.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;httpx/_client.py:1985 in aclose
httpx/_transports/default.py:406 in aclose
httpcore/_async/connection_pool.py:353 in aclose
httpcore/_async/http11.py:258 in aclose
anyio/streams/tls.py:241 in aclose
anyio/_backends/_asyncio.py:1352 in aclose
asyncio/selector_events.py:864 in close
asyncio/base_events.py:520 in _check_closed&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Our code files were not visible. That made it hard to see &quot;where&quot; the close was happening.&lt;/p&gt;
&lt;p&gt;There were two useful clues.&lt;/p&gt;
&lt;p&gt;First, the coroutine name was &lt;code class=&quot;language-text&quot;&gt;AsyncClient.aclose()&lt;/code&gt;. The OpenAI SDK uses an HTTP client internally. The Sentry stack showed cleanup for &lt;code class=&quot;language-text&quot;&gt;httpx.AsyncClient&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Second, the message said &lt;code class=&quot;language-text&quot;&gt;Task exception was never retrieved&lt;/code&gt;. This looked less like an exception raised directly from a request handler, and more like a cleanup task running later and finding that the event loop had already closed.&lt;/p&gt;
&lt;h2 id=&quot;Initial-Hypothesis&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Initial-Hypothesis&quot; aria-label=&quot;Initial Hypothesis permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Initial Hypothesis&lt;/h2&gt;
&lt;p&gt;I framed the hypothesis like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;An OpenAI async client is being created inside an event loop, not explicitly closed in that loop, and later HTTPX cleanup runs after the event loop has closed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To test that, I needed to find who creates and closes the event loop.&lt;/p&gt;
&lt;p&gt;In the Place2Page generation background path, a sync function runs an async generation coroutine.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;rendered_html&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; generation_meta &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    generate_freeform_landing_html_with_meta&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The Python documentation says &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; runs the coroutine, finalizes async generators and the executor, then closes the event loop it created. It is intended as a main entry point.&lt;/p&gt;
&lt;p&gt;In this structure, any async resource created inside &lt;code class=&quot;language-text&quot;&gt;generate_freeform_landing_html_with_meta()&lt;/code&gt; should be closed before the coroutine returns.&lt;/p&gt;
&lt;p&gt;Searching the code showed a path that creates a raw OpenAI async client.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;_openai_raw_client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; AsyncOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That client was used in two places:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;_generate_freeform_meta_prompt_with_openai()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;_request_freeform_html_with_openai()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both functions created the client and called &lt;code class=&quot;language-text&quot;&gt;client.responses.create(...)&lt;/code&gt;, but neither closed it explicitly.&lt;/p&gt;
&lt;h2 id=&quot;Grounding-the-Rule-in-Official-Docs&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Grounding-the-Rule-in-Official-Docs&quot; aria-label=&quot;Grounding the Rule in Official Docs permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Grounding the Rule in Official Docs&lt;/h2&gt;
&lt;p&gt;I did not want to stop at &quot;closing it sounds right,&quot; so I checked the official docs.&lt;/p&gt;
&lt;p&gt;HTTPX&apos;s async docs recommend managing &lt;code class=&quot;language-text&quot;&gt;AsyncClient&lt;/code&gt; with &lt;code class=&quot;language-text&quot;&gt;async with&lt;/code&gt;, or explicitly calling &lt;code class=&quot;language-text&quot;&gt;await client.aclose()&lt;/code&gt; when using a manual lifecycle. They also warn that manual streaming mode puts close responsibility on the developer.&lt;/p&gt;
&lt;p&gt;Python&apos;s &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; docs explain that the function creates a new event loop and closes it at the end. That means an async HTTP client created inside &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; should be closed while that loop is still alive.&lt;/p&gt;
&lt;p&gt;This issue was where those two rules met:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;HTTPX async clients need async close.
asyncio.run() closes the event loop at the end.
Therefore, a client created inside asyncio.run() must be closed before the coroutine returns.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;Checking-the-Local-SDK-Surface&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Checking-the-Local-SDK-Surface&quot; aria-label=&quot;Checking the Local SDK Surface permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Checking the Local SDK Surface&lt;/h2&gt;
&lt;p&gt;There was one more thing to confirm. Sentry showed &lt;code class=&quot;language-text&quot;&gt;httpx.AsyncClient.aclose()&lt;/code&gt;, but our code used OpenAI SDK&apos;s &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt;. I checked which close API the installed SDK exposed locally.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api
uv run python - &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;PY&apos;
from openai import AsyncOpenAI
import inspect

client = AsyncOpenAI(api_key=&quot;test-key&quot;)
print(&quot;AsyncOpenAI has close:&quot;, hasattr(client, &quot;close&quot;))
print(&quot;AsyncOpenAI.close is coroutine:&quot;, inspect.iscoroutinefunction(getattr(client, &quot;close&quot;, None)))
print(&quot;AsyncOpenAI has aclose:&quot;, hasattr(client, &quot;aclose&quot;))
print(&quot;AsyncOpenAI.aclose is coroutine:&quot;, inspect.iscoroutinefunction(getattr(client, &quot;aclose&quot;, None)))
print(&quot;AsyncOpenAI supports async context manager:&quot;, hasattr(client, &quot;__aenter__&quot;) and hasattr(client, &quot;__aexit__&quot;))
PY&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The result was:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI has close: True
AsyncOpenAI.close is coroutine: True
AsyncOpenAI has aclose: False
AsyncOpenAI.aclose is coroutine: False
AsyncOpenAI supports async context manager: True&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So in the SDK version installed in the project, &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt; had async &lt;code class=&quot;language-text&quot;&gt;close()&lt;/code&gt; and did not have &lt;code class=&quot;language-text&quot;&gt;aclose()&lt;/code&gt;. The helper needed to use &lt;code class=&quot;language-text&quot;&gt;aclose&lt;/code&gt; if it existed, otherwise use &lt;code class=&quot;language-text&quot;&gt;close&lt;/code&gt; and await the result if it was awaitable.&lt;/p&gt;
&lt;h2 id=&quot;RED-Tests&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#RED-Tests&quot; aria-label=&quot;RED Tests permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;RED Tests&lt;/h2&gt;
&lt;p&gt;I added tests before changing the implementation.&lt;/p&gt;
&lt;p&gt;The goals were simple:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The raw client must be closed after a successful OpenAI final HTML request.&lt;/li&gt;
&lt;li&gt;The raw client must be closed after a successful OpenAI meta prompt request.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The tests did not use the network. They used a fake client with &lt;code class=&quot;language-text&quot;&gt;responses.create()&lt;/code&gt; and async &lt;code class=&quot;language-text&quot;&gt;close()&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;_ClosableOpenAIRawClient&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        self&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;responses &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _OpenAIResponses&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;response&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        self&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;close_calls &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        self&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;close_calls &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The final HTML stream was represented by an async iterator.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;_AsyncEventStream&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; events&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        self&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_events &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;iter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;events&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;__aiter__&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; self

    &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;__anext__&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_events&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt; StopIteration &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; exc&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;raise&lt;/span&gt; StopAsyncIteration &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; exc&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The first test checked that &lt;code class=&quot;language-text&quot;&gt;close_calls == 1&lt;/code&gt; after the final HTML request completed.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;test_request_freeform_html_with_openai_closes_raw_client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _ClosableOpenAIRawClient&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_AsyncEventStream&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;generation_service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;settings&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;openai_api_key&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;test-key&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;generation_service&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;_openai_raw_client&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;lambda&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        generation_service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_request_freeform_html_with_openai&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;assert&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; html
    &lt;span class=&quot;token keyword&quot;&gt;assert&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;close_calls &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The second test checked the same condition after meta prompt generation.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;test_generate_freeform_meta_prompt_with_openai_closes_raw_client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _ClosableOpenAIRawClient&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        SimpleNamespace&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;output_text&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Use the venue data to choose a focused style.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;generation_service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;settings&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;openai_api_key&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;test-key&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;generation_service&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;_openai_raw_client&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;lambda&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        generation_service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_generate_freeform_meta_prompt_with_openai&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;assert&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Use the venue data to choose a focused style.&quot;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;assert&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;close_calls &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Before the implementation change, both failed.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;assert 0 == 1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That failure was the key evidence. Sentry showed cleanup happening too late, and the tests showed that our generation path was not closing the client.&lt;/p&gt;
&lt;h2 id=&quot;Fix&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Fix&quot; aria-label=&quot;Fix permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Fix&lt;/h2&gt;
&lt;p&gt;The fix was intentionally small.&lt;/p&gt;
&lt;p&gt;First, I added a helper for closing the OpenAI async client.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;_close_openai_async_client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Any&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; context&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    close &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;getattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;aclose&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;callable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;close&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        close &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;getattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;close&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;callable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;close&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; close&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; inspect&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;isawaitable&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; result
    &lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt; Exception&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        logger&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;warning&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;token string&quot;&gt;&quot;Failed to close OpenAI async client (context=%s)&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            exc_info&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then I wrapped both functions that create raw clients with &lt;code class=&quot;language-text&quot;&gt;try/finally&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _openai_raw_client&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    stream &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;responses&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;create&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;**&lt;/span&gt;request_payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; output_text
&lt;span class=&quot;token keyword&quot;&gt;finally&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; _close_openai_async_client&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; context&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;freeform_html&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The meta prompt path used the same pattern.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _openai_raw_client&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    response &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;responses&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;create&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;**&lt;/span&gt;request_payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; normalized
&lt;span class=&quot;token keyword&quot;&gt;finally&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; _close_openai_async_client&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; context&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;meta_prompt&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;With this shape, OpenAI/httpx cleanup does not spill past the event loop that &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; is about to close. The client close finishes inside the same loop that made the request.&lt;/p&gt;
&lt;h2 id=&quot;Why-I-Did-Not-Make-a-Larger-Structural-Change&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-I-Did-Not-Make-a-Larger-Structural-Change&quot; aria-label=&quot;Why I Did Not Make a Larger Structural Change permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why I Did Not Make a Larger Structural Change&lt;/h2&gt;
&lt;p&gt;There were larger options.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make the whole generation background worker async-first.&lt;/li&gt;
&lt;li&gt;Manage the OpenAI client as an app lifespan singleton.&lt;/li&gt;
&lt;li&gt;Remove &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; and redesign the event loop boundary.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Those may be cleaner long term. But the direct cause of this Sentry issue was that the per-generation raw async client was not being closed. A larger rewrite would also touch DB session lifecycle, SSE stream behavior, and provider fallback paths.&lt;/p&gt;
&lt;p&gt;So I limited this fix to &quot;the code that creates the client closes the client.&quot;&lt;/p&gt;
&lt;p&gt;That choice had clear advantages.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It fixed the path directly connected to the production error.&lt;/li&gt;
&lt;li&gt;It preserved fallback and quality gate behavior.&lt;/li&gt;
&lt;li&gt;The tests pinned the close boundary directly.&lt;/li&gt;
&lt;li&gt;Even if the async worker structure changes later, the lifecycle rule remains useful.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Verification&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Verification&quot; aria-label=&quot;Verification permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Verification&lt;/h2&gt;
&lt;p&gt;The two tests that failed first passed after the fix.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api
uv run pytest &lt;span class=&quot;token parameter variable&quot;&gt;-q&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  tests/test_generation_service.py::test_request_freeform_html_with_openai_closes_raw_client &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  tests/test_generation_service.py::test_generate_freeform_meta_prompt_with_openai_closes_raw_client&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;2 passed in 0.30s&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I also ran the full generation service test file.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api
uv run pytest &lt;span class=&quot;token parameter variable&quot;&gt;-q&lt;/span&gt; tests/test_generation_service.py&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;72 passed in 0.47s&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Lint passed too.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api
uv run ruff check services/generation_service.py tests/test_generation_service.py&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;All checks passed!&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Finally, when checking this Sentry hotfix batch together, 185 targeted API tests passed.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;185 passed, 1 warning in 4.44s&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I kept the evidence files in the repository.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;outputs/sentry-event-loop-closed-20260522/
  README.md
  red-openai-client-close-tests.txt
  green-openai-client-close-tests.txt
  openai-async-client-surface.txt
  test-generation-service.txt
  ruff-generation-service.txt
  git-diff-check.txt
  fix.diff&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;Lessons&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Lessons&quot; aria-label=&quot;Lessons permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Lessons&lt;/h2&gt;
&lt;p&gt;The most important lesson was that &quot;our code is not in the stack&quot; does not mean &quot;this is not our problem.&quot;&lt;/p&gt;
&lt;p&gt;The Sentry stack showed only &lt;code class=&quot;language-text&quot;&gt;httpx&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;httpcore&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;anyio&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;asyncio&lt;/code&gt;. But that stack showed where cleanup finally failed, not who created the client.&lt;/p&gt;
&lt;p&gt;Reading the stack from bottom to top was not enough. I had to turn it into lifecycle questions.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Where was this async resource created?&lt;/li&gt;
&lt;li&gt;Which event loop is it tied to?&lt;/li&gt;
&lt;li&gt;Who is responsible for closing it?&lt;/li&gt;
&lt;li&gt;Does close happen before or after loop shutdown?&lt;/li&gt;
&lt;li&gt;Can cleanup run outside the request context?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This time, those questions led to &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; and the raw &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt; client.&lt;/p&gt;
&lt;p&gt;Another lesson was to inspect the SDK wrapper surface directly. Sentry showed &lt;code class=&quot;language-text&quot;&gt;httpx.AsyncClient.aclose()&lt;/code&gt;, but the object our code had to close was &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt;. Local introspection showed that this SDK exposed async &lt;code class=&quot;language-text&quot;&gt;close()&lt;/code&gt; and not &lt;code class=&quot;language-text&quot;&gt;aclose()&lt;/code&gt;. The last small gap between docs and the installed version is often best checked locally.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Will-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Will-Judge-This-Next-Time&quot; aria-label=&quot;How I Will Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Will Judge This Next Time&lt;/h2&gt;
&lt;p&gt;For a similar &lt;code class=&quot;language-text&quot;&gt;Event loop is closed&lt;/code&gt; issue, I will inspect resource lifecycle before focusing on the final library frame. Cleanup stacks often show what resource closed too late, not the original cause.&lt;/p&gt;
&lt;p&gt;My order will be:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Check the coroutine name in the Sentry message.&lt;/li&gt;
&lt;li&gt;Even for a system-only stack, identify the resource being cleaned up.&lt;/li&gt;
&lt;li&gt;Look for &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt;, background tasks, and thread boundaries.&lt;/li&gt;
&lt;li&gt;Add a test that requires the resource to close before the loop ends.&lt;/li&gt;
&lt;li&gt;Treat singleton or app lifespan migration as a separate design after the direct fix.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;Event loop is closed&lt;/code&gt; usually fails at the end. But the last code to fail is not necessarily the cause. The cause is often between the place that created the resource and the place that promised to close it.&lt;/p&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.python-httpx.org/async/&quot;&gt;HTTPX Async Support&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3.10/library/asyncio-task.html#asyncio.run&quot;&gt;Python docs: asyncio.run&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Event loop is closed를 OpenAI client lifecycle로 추적하기]]></title><description><![CDATA[Sentry에는 우리 코드가 거의 보이지 않는 가 반복해서 쌓이고 있었다. 처음에는 library cleanup noise처럼 보였지만, coroutine 이름과  경계를 따라가 보니 raw  client가 생성된 event loop…]]></description><link>https://sewon.dev/place2page-openai-async-client-event-loop-closed/</link><guid isPermaLink="false">https://sewon.dev/place2page-openai-async-client-event-loop-closed/</guid><pubDate>Fri, 22 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c469430483eaa6bf0f492c6a47413e62/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB5klEQVR42oWSzWsTQRjG965HQQVvnkS8evFf8uRNCpaCqIhg8eMkirYgidJaiyD1CzFgG5qGJMWYmKZxN9nZr0k2m5nZj9mZdyTdxFCr+PAeXmb4Pc/MvKMJAchhpsMMRE2H2Tg0LIpcpiPSs2nXogaiDo6EAHVEGgD0feb1R3hAvQE96Gl/yBxMXEy8PsEDShkHmMAAkxrD2crU6y/2mWTKRRzLZOyS6TeslIhVGilQgqs0USlXIJXiXKUcOFcAMAoAYwiGh449dvUNv/jULz5hZmO3HG4X+pUtghFhje+4XGHNZvBT9zbe2283gs0tniSpELNkGROql2inmDLfNtP2D9Leo0koUtdlRi+xbRWGgJDo7IPnKoBDyX9eD6SQYtJLqZR696kwd/3uwo3F+Vv3r87fvnzl2na5NoUB9BDXR2Yr8lqx14ycRmjvRV4sUyHGLnMLd46fvnDm3KWTZy8eO3Ve0048XnoxS36uF29+e3Ov83Gx/eGB8fmh+eWR+9XjJNutVuvLyyv53Hou9zqfX3+29LK9r89gnNBeNETR0Ax9FA+tJLCSAJTqhoMCbu0QoxqhamTuJlZN2kiSbKravwabvWc9QCvdnbVueVUvrRqltV75lVOpjcwDGLTp54Cjpf6nXzJrj3lsMUVhAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/c469430483eaa6bf0f492c6a47413e62/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/c469430483eaa6bf0f492c6a47413e62/e7570/situation-diagram.png 170w,
/static/c469430483eaa6bf0f492c6a47413e62/f46e7/situation-diagram.png 340w,
/static/c469430483eaa6bf0f492c6a47413e62/ca1dc/situation-diagram.png 680w,
/static/c469430483eaa6bf0f492c6a47413e62/02d09/situation-diagram.png 1020w,
/static/c469430483eaa6bf0f492c6a47413e62/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Sentry에는 우리 코드가 거의 보이지 않는 &lt;code class=&quot;language-text&quot;&gt;RuntimeError: Event loop is closed&lt;/code&gt;가 반복해서 쌓이고 있었다. 처음에는 library cleanup noise처럼 보였지만, coroutine 이름과 &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; 경계를 따라가 보니 raw &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt; client가 생성된 event loop 안에서 닫히지 않는 lifecycle 문제였다. 해결은 큰 async 구조 개편이 아니라 client를 만든 경로에서 coroutine 반환 전에 async close를 보장하는 작은 fix였다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: Sentry에 &lt;code class=&quot;language-text&quot;&gt;RuntimeError: Event loop is closed&lt;/code&gt;가 recurring noise로 쌓이고 있었다.&lt;/li&gt;
&lt;li&gt;증상: 최근 24시간 5건, 전체 36건, 상태는 regressed였다.&lt;/li&gt;
&lt;li&gt;판단: system-only stack을 버리지 않고, cleanup 대상 resource와 event loop lifecycle 경계를 추적했다.&lt;/li&gt;
&lt;li&gt;원인: &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt;으로 열린 event loop 안에서 만든 OpenAI async client가 coroutine 종료 전에 닫히지 않았다.&lt;/li&gt;
&lt;li&gt;해결: raw &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt; client를 만든 meta prompt와 final HTML generation 경로에서 &lt;code class=&quot;language-text&quot;&gt;finally&lt;/code&gt;로 async close를 보장했다.&lt;/li&gt;
&lt;li&gt;배운 점: system-only stack도 버릴 정보가 아니다. &quot;우리 코드가 안 보이는 스택&quot;은 lifecycle 경계를 봐야 한다는 신호일 수 있다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;Place2Page는 지도 URL을 받아 장소 데이터를 가져오고 AI로 랜딩페이지 HTML을 만든다. generation pipeline은 대략 이렇게 흐른다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;place URL
  -&gt; Google/Naver place fetch
  -&gt; meta prompt generation
  -&gt; final freeform HTML generation
  -&gt; landing/debug log 저장
  -&gt; SSE로 진행상황 전달&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;최근에는 Sentry 이슈를 우선순위대로 보고 있었다. DB pool timeout 같은 명확한 P1은 먼저 처리했고, 그 다음으로 반복적으로 눈에 걸리는 이슈가 있었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;RuntimeError: Event loop is closed&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;처음 보기에는 사용자 영향이 큰 실패처럼 보이지 않았다. Sentry상 users impacted는 0이었다. 하지만 이슈 상태는 &lt;code class=&quot;language-text&quot;&gt;regressed&lt;/code&gt;였고, 최근 24시간에만 5건이 다시 발생했다. 전체 occurrence도 36건이었다.&lt;/p&gt;
&lt;p&gt;이런 종류의 에러는 그냥 무시하기 쉽다. request handler가 직접 실패한 것도 아니고, stack도 거의 전부 library 내부였다. 하지만 production 로그에 계속 남는 noise는 운영 감도를 떨어뜨린다. 진짜 장애가 생겼을 때 신호를 흐리게 만든다.&lt;/p&gt;
&lt;h2 id=&quot;문제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%A0%9C&quot; aria-label=&quot;문제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문제&lt;/h2&gt;
&lt;p&gt;Sentry 최신 이벤트 메시지는 이랬다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Task exception was never retrieved
future: &amp;lt;Task finished name=&apos;Task-117508&apos;
  coro=&amp;lt;AsyncClient.aclose() done, defined at /app/.venv/lib/python3.11/site-packages/httpx/_client.py:1978&gt;
  exception=RuntimeError(&apos;Event loop is closed&apos;)&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;에러 자체는 단순했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;RuntimeError: Event loop is closed&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;하지만 stack은 전부 system frame이었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;httpx/_client.py:1985 in aclose
httpx/_transports/default.py:406 in aclose
httpcore/_async/connection_pool.py:353 in aclose
httpcore/_async/http11.py:258 in aclose
anyio/streams/tls.py:241 in aclose
anyio/_backends/_asyncio.py:1352 in aclose
asyncio/selector_events.py:864 in close
asyncio/base_events.py:520 in _check_closed&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;우리 코드 파일이 보이지 않았다. 그래서 처음에는 &quot;어디서 닫히는지&quot;가 잘 안 보였다.&lt;/p&gt;
&lt;p&gt;여기서 중요한 단서는 두 가지였다.&lt;/p&gt;
&lt;p&gt;첫째, coroutine 이름이 &lt;code class=&quot;language-text&quot;&gt;AsyncClient.aclose()&lt;/code&gt;였다. OpenAI SDK는 내부적으로 HTTP client를 사용한다. Sentry stack에는 &lt;code class=&quot;language-text&quot;&gt;httpx.AsyncClient&lt;/code&gt; cleanup이 보였다.&lt;/p&gt;
&lt;p&gt;둘째, 메시지가 &lt;code class=&quot;language-text&quot;&gt;Task exception was never retrieved&lt;/code&gt;였다. request handler에서 직접 raise된 exception이라기보다, 나중에 cleanup task가 실행되면서 이미 닫힌 event loop를 만난 형태에 가까웠다.&lt;/p&gt;
&lt;h2 id=&quot;처음-생각한-가설&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C-%EC%83%9D%EA%B0%81%ED%95%9C-%EA%B0%80%EC%84%A4&quot; aria-label=&quot;처음 생각한 가설 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음 생각한 가설&lt;/h2&gt;
&lt;p&gt;가설은 이렇게 잡았다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;OpenAI async client가 생성된 event loop 안에서 명시적으로 닫히지 않고, event loop가 닫힌 뒤에 httpx cleanup이 실행되고 있다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;이 가설을 보려면 event loop를 누가 만들고 닫는지 확인해야 했다.&lt;/p&gt;
&lt;p&gt;Place2Page의 generation background path에는 sync function 안에서 async generation coroutine을 실행하는 구간이 있다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;rendered_html&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; generation_meta &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
    generate_freeform_landing_html_with_meta&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Python 공식 문서에서 &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt;은 coroutine을 실행하고, async generator와 executor를 정리한 뒤, 새로 만든 event loop를 끝에서 닫는다. main entry point로 한 번 쓰는 용도에 가깝다.&lt;/p&gt;
&lt;p&gt;그러면 이 구조에서는 &lt;code class=&quot;language-text&quot;&gt;generate_freeform_landing_html_with_meta()&lt;/code&gt; 안에서 만든 async resource가 coroutine이 끝나기 전에 닫혀야 한다.&lt;/p&gt;
&lt;p&gt;그런데 코드 검색을 해보니 raw OpenAI async client를 만드는 경로가 있었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;_openai_raw_client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; AsyncOpenAI&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그리고 이 client가 쓰이는 곳은 두 군데였다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;_generate_freeform_meta_prompt_with_openai()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;_request_freeform_html_with_openai()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;둘 다 client를 만들고 &lt;code class=&quot;language-text&quot;&gt;client.responses.create(...)&lt;/code&gt;를 호출했지만 명시적으로 닫지는 않았다.&lt;/p&gt;
&lt;h2 id=&quot;공식-문서로-기준-잡기&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B3%B5%EC%8B%9D-%EB%AC%B8%EC%84%9C%EB%A1%9C-%EA%B8%B0%EC%A4%80-%EC%9E%A1%EA%B8%B0&quot; aria-label=&quot;공식 문서로 기준 잡기 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;공식 문서로 기준 잡기&lt;/h2&gt;
&lt;p&gt;감으로 &quot;닫으면 되겠지&quot;라고 끝내지 않으려고 공식 문서를 같이 봤다.&lt;/p&gt;
&lt;p&gt;HTTPX의 async 문서는 &lt;code class=&quot;language-text&quot;&gt;AsyncClient&lt;/code&gt;를 &lt;code class=&quot;language-text&quot;&gt;async with&lt;/code&gt;로 context-managed 하거나 manual lifecycle을 쓸 때는 &lt;code class=&quot;language-text&quot;&gt;await client.aclose()&lt;/code&gt;로 명시적으로 닫으라고 설명한다. 특히 manual streaming mode에서는 response close를 개발자가 책임져야 한다고 경고한다.&lt;/p&gt;
&lt;p&gt;Python &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; 문서는 이 함수가 새 event loop를 만들고 끝에서 닫는다고 설명한다. 즉, &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; 안에서 만든 async HTTP client는 그 loop가 살아 있을 때 닫아야 한다.&lt;/p&gt;
&lt;p&gt;이번 이슈의 구조는 두 문서가 만나는 지점이었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;HTTPX async client는 async close가 필요하다.
asyncio.run()은 끝에서 event loop를 닫는다.
따라서 asyncio.run() 안에서 만든 client는 coroutine 반환 전에 닫혀야 한다.&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;로컬-SDK-표면-확인&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%A1%9C%EC%BB%AC-SDK-%ED%91%9C%EB%A9%B4-%ED%99%95%EC%9D%B8&quot; aria-label=&quot;로컬 SDK 표면 확인 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;로컬 SDK 표면 확인&lt;/h2&gt;
&lt;p&gt;한 가지 더 확인해야 했다. Sentry stack은 &lt;code class=&quot;language-text&quot;&gt;httpx.AsyncClient.aclose()&lt;/code&gt;였지만, 우리 코드가 직접 쓰는 객체는 OpenAI SDK의 &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt;다. 이 객체가 어떤 close API를 제공하는지 로컬에서 확인했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api
uv run python - &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&apos;PY&apos;
from openai import AsyncOpenAI
import inspect

client = AsyncOpenAI(api_key=&quot;test-key&quot;)
print(&quot;AsyncOpenAI has close:&quot;, hasattr(client, &quot;close&quot;))
print(&quot;AsyncOpenAI.close is coroutine:&quot;, inspect.iscoroutinefunction(getattr(client, &quot;close&quot;, None)))
print(&quot;AsyncOpenAI has aclose:&quot;, hasattr(client, &quot;aclose&quot;))
print(&quot;AsyncOpenAI.aclose is coroutine:&quot;, inspect.iscoroutinefunction(getattr(client, &quot;aclose&quot;, None)))
print(&quot;AsyncOpenAI supports async context manager:&quot;, hasattr(client, &quot;__aenter__&quot;) and hasattr(client, &quot;__aexit__&quot;))
PY&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;결과는 이랬다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI has close: True
AsyncOpenAI.close is coroutine: True
AsyncOpenAI has aclose: False
AsyncOpenAI.aclose is coroutine: False
AsyncOpenAI supports async context manager: True&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;즉, 우리 SDK 버전에서는 &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt;에 &lt;code class=&quot;language-text&quot;&gt;aclose()&lt;/code&gt;가 없고 async &lt;code class=&quot;language-text&quot;&gt;close()&lt;/code&gt;가 있었다. 그래서 helper는 &lt;code class=&quot;language-text&quot;&gt;aclose&lt;/code&gt;가 있으면 쓰고, 없으면 &lt;code class=&quot;language-text&quot;&gt;close&lt;/code&gt;를 찾아서 awaitable이면 await하는 형태가 맞았다.&lt;/p&gt;
&lt;h2 id=&quot;RED-테스트&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#RED-%ED%85%8C%EC%8A%A4%ED%8A%B8&quot; aria-label=&quot;RED 테스트 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;RED 테스트&lt;/h2&gt;
&lt;p&gt;수정 전에 테스트를 먼저 추가했다.&lt;/p&gt;
&lt;p&gt;목표는 단순했다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;OpenAI final HTML 요청이 성공해도 raw client가 닫혀야 한다.&lt;/li&gt;
&lt;li&gt;OpenAI meta prompt 요청이 성공해도 raw client가 닫혀야 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;테스트에서는 실제 네트워크를 쓰지 않았다. 대신 &lt;code class=&quot;language-text&quot;&gt;responses.create()&lt;/code&gt;와 async &lt;code class=&quot;language-text&quot;&gt;close()&lt;/code&gt;를 가진 fake client를 만들었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;_ClosableOpenAIRawClient&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        self&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;responses &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _OpenAIResponses&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;response&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        self&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;close_calls &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;0&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        self&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;close_calls &lt;span class=&quot;token operator&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;final HTML stream은 async iterator로 흉내냈다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;token class-name&quot;&gt;_AsyncEventStream&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;__init__&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; events&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;list&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;object&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        self&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_events &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;iter&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;events&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;__aiter__&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; self

    &lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;__anext__&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;next&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;self&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_events&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt; StopIteration &lt;span class=&quot;token keyword&quot;&gt;as&lt;/span&gt; exc&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;raise&lt;/span&gt; StopAsyncIteration &lt;span class=&quot;token keyword&quot;&gt;from&lt;/span&gt; exc&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;첫 번째 테스트는 final HTML 요청이 끝난 뒤 &lt;code class=&quot;language-text&quot;&gt;close_calls == 1&lt;/code&gt;인지 확인했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;test_request_freeform_html_with_openai_closes_raw_client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _ClosableOpenAIRawClient&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;_AsyncEventStream&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;generation_service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;settings&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;openai_api_key&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;test-key&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;generation_service&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;_openai_raw_client&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;lambda&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        generation_service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_request_freeform_html_with_openai&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;assert&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; html
    &lt;span class=&quot;token keyword&quot;&gt;assert&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;close_calls &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;두 번째 테스트는 meta prompt 생성이 끝난 뒤 같은 조건을 확인했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;test_generate_freeform_meta_prompt_with_openai_closes_raw_client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _ClosableOpenAIRawClient&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        SimpleNamespace&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;output_text&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;Use the venue data to choose a focused style.&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;generation_service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;settings&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;openai_api_key&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;test-key&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;generation_service&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;_openai_raw_client&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;lambda&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
        generation_service&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;_generate_freeform_meta_prompt_with_openai&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;token keyword&quot;&gt;assert&lt;/span&gt; result &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;Use the venue data to choose a focused style.&quot;&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;assert&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;close_calls &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token number&quot;&gt;1&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;수정 전 결과는 둘 다 실패였다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;assert 0 == 1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 실패가 핵심 증거였다. Sentry는 cleanup이 늦게 실행되는 모습을 보여줬고, 테스트는 우리 generation 경로가 client를 닫지 않는다는 사실을 보여줬다.&lt;/p&gt;
&lt;h2 id=&quot;해결한-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%B4%EA%B2%B0%ED%95%9C-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;해결한 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;해결한 방식&lt;/h2&gt;
&lt;p&gt;수정은 작게 잡았다.&lt;/p&gt;
&lt;p&gt;먼저 OpenAI async client close helper를 만들었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;async&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;_close_openai_async_client&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Any&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; context&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    close &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;getattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;aclose&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;callable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;close&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        close &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;getattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;close&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;None&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;not&lt;/span&gt; &lt;span class=&quot;token builtin&quot;&gt;callable&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;close&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        result &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; close&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; inspect&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;isawaitable&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;result&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
            &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; result
    &lt;span class=&quot;token keyword&quot;&gt;except&lt;/span&gt; Exception&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
        logger&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;warning&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
            &lt;span class=&quot;token string&quot;&gt;&quot;Failed to close OpenAI async client (context=%s)&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            context&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
            exc_info&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
        &lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그 다음 raw client를 만드는 두 함수에 &lt;code class=&quot;language-text&quot;&gt;try/finally&lt;/code&gt;를 붙였다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _openai_raw_client&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    stream &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;responses&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;create&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;**&lt;/span&gt;request_payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; output_text
&lt;span class=&quot;token keyword&quot;&gt;finally&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; _close_openai_async_client&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; context&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;freeform_html&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;meta prompt도 같은 패턴이다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;client &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; _openai_raw_client&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;try&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    response &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; client&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;responses&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;create&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;**&lt;/span&gt;request_payload&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; normalized
&lt;span class=&quot;token keyword&quot;&gt;finally&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;await&lt;/span&gt; _close_openai_async_client&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;client&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; context&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;meta_prompt&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이렇게 하면 OpenAI/httpx cleanup이 &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt;이 닫는 event loop 밖으로 밀리지 않는다. 요청을 만든 loop 안에서 client close까지 끝난다.&lt;/p&gt;
&lt;h2 id=&quot;왜-더-큰-구조-변경을-하지-않았나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EB%8D%94-%ED%81%B0-%EA%B5%AC%EC%A1%B0-%EB%B3%80%EA%B2%BD%EC%9D%84-%ED%95%98%EC%A7%80-%EC%95%8A%EC%95%98%EB%82%98&quot; aria-label=&quot;왜 더 큰 구조 변경을 하지 않았나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 더 큰 구조 변경을 하지 않았나&lt;/h2&gt;
&lt;p&gt;사실 더 큰 선택지도 있었다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;generation background worker를 전부 async-first 구조로 바꾸기&lt;/li&gt;
&lt;li&gt;OpenAI client를 app lifespan singleton으로 관리하기&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt; 자체를 없애고 event loop boundary를 재설계하기&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;장기적으로는 이런 방향이 더 깔끔할 수 있다. 하지만 이번 Sentry 이슈의 직접 원인은 per-generation raw async client가 닫히지 않는 것이었다. 당장 큰 구조 변경을 하면 DB session lifecycle 수정, SSE stream, provider fallback 같은 다른 표면까지 같이 흔들 수 있었다.&lt;/p&gt;
&lt;p&gt;그래서 이번에는 &quot;client를 만든 곳에서 닫는다&quot;로 범위를 제한했다.&lt;/p&gt;
&lt;p&gt;이 선택의 장점은 명확하다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;production error와 직접 연결된 경로만 고친다.&lt;/li&gt;
&lt;li&gt;실패해도 fallback/quality gate 흐름은 그대로 유지된다.&lt;/li&gt;
&lt;li&gt;테스트가 close boundary를 직접 고정한다.&lt;/li&gt;
&lt;li&gt;나중에 async worker 구조를 바꾸더라도 lifecycle 규칙은 남는다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;검증&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%80%EC%A6%9D&quot; aria-label=&quot;검증 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;검증&lt;/h2&gt;
&lt;p&gt;처음 실패했던 두 테스트는 수정 후 통과했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api
uv run pytest &lt;span class=&quot;token parameter variable&quot;&gt;-q&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  tests/test_generation_service.py::test_request_freeform_html_with_openai_closes_raw_client &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  tests/test_generation_service.py::test_generate_freeform_meta_prompt_with_openai_closes_raw_client&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;2 passed in 0.30s&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;generation service 전체 테스트도 돌렸다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api
uv run pytest &lt;span class=&quot;token parameter variable&quot;&gt;-q&lt;/span&gt; tests/test_generation_service.py&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;72 passed in 0.47s&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;lint도 통과했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api
uv run ruff check services/generation_service.py tests/test_generation_service.py&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;All checks passed!&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;최종으로 이번 Sentry hotfix 묶음까지 같이 확인했을 때는 targeted API 테스트 185개가 통과했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;185 passed, 1 warning in 4.44s&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;증거 파일은 repo에 같이 남겼다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;outputs/sentry-event-loop-closed-20260522/
  README.md
  red-openai-client-close-tests.txt
  green-openai-client-close-tests.txt
  openai-async-client-surface.txt
  test-generation-service.txt
  ruff-generation-service.txt
  git-diff-check.txt
  fix.diff&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;이번 이슈에서 제일 중요한 배움은 stack에 우리 코드가 없다고 해서 우리 문제가 아닌 것은 아니라는 점이었다.&lt;/p&gt;
&lt;p&gt;Sentry stack은 &lt;code class=&quot;language-text&quot;&gt;httpx&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;httpcore&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;anyio&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;asyncio&lt;/code&gt;만 보여줬다. 하지만 그 stack은 &quot;누가 client를 만들었는가&quot;가 아니라 &quot;늦게 닫히다 어디서 터졌는가&quot;를 보여주는 스택이었다.&lt;/p&gt;
&lt;p&gt;이럴 때는 stack을 아래에서 위로만 읽으면 막힌다. 대신 lifecycle 질문으로 바꿔야 한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;이 async resource는 어디서 생성됐나?&lt;/li&gt;
&lt;li&gt;어떤 event loop에 묶여 있나?&lt;/li&gt;
&lt;li&gt;누가 닫아야 하나?&lt;/li&gt;
&lt;li&gt;닫히는 시점이 loop 종료 전인가 후인가?&lt;/li&gt;
&lt;li&gt;cleanup task가 request context 밖에서 실행될 가능성이 있나?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이번에는 이 질문들이 &lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt;과 raw &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt; client로 이어졌다.&lt;/p&gt;
&lt;p&gt;또 하나의 배움은 SDK wrapper의 surface를 직접 확인해야 한다는 점이다. Sentry에는 &lt;code class=&quot;language-text&quot;&gt;httpx.AsyncClient.aclose()&lt;/code&gt;가 보였지만 우리가 닫아야 하는 객체는 &lt;code class=&quot;language-text&quot;&gt;AsyncOpenAI&lt;/code&gt;였다. 로컬 확인 결과 이 SDK는 async &lt;code class=&quot;language-text&quot;&gt;close()&lt;/code&gt;를 제공하고 &lt;code class=&quot;language-text&quot;&gt;aclose()&lt;/code&gt;는 없었다. 문서와 실제 설치 버전 사이의 마지막 1cm는 로컬 introspection으로 확인하는 것이 안전했다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;비슷한 &lt;code class=&quot;language-text&quot;&gt;Event loop is closed&lt;/code&gt; 계열 이슈가 나오면 마지막에 터진 library frame보다 resource lifecycle을 먼저 본다. cleanup stack은 원인을 보여주기보다, 어떤 resource가 늦게 닫혔는지를 보여주는 경우가 많다.&lt;/p&gt;
&lt;p&gt;순서는 이렇게 잡는다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Sentry에서 message의 coroutine 이름을 본다.&lt;/li&gt;
&lt;li&gt;system-only stack이라도 cleanup 대상 resource를 찾는다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;asyncio.run()&lt;/code&gt;, background task, thread boundary가 있는지 본다.&lt;/li&gt;
&lt;li&gt;해당 resource가 loop 종료 전에 명시 close되는지 테스트로 고정한다.&lt;/li&gt;
&lt;li&gt;singleton이나 app lifespan 전환은 direct fix 이후 별도 설계로 분리한다.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;Event loop is closed&lt;/code&gt;는 대개 마지막에 터진다. 하지만 마지막에 터졌다고 마지막 코드가 원인은 아니다. 원인은 보통 그 resource를 만든 곳, 그리고 닫기로 약속한 곳 사이에 있다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.python-httpx.org/async/&quot;&gt;HTTPX Async Support&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.python.org/3.10/library/asyncio-task.html#asyncio.run&quot;&gt;Python docs: asyncio.run&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Treating DB pool timeout as a lifecycle problem, not just pool size]]></title><description><![CDATA[When SQLAlchemy  timeout appeared as a P1 issue in Sentry, the easiest fix would have been to increase the pool size. But grouping routes…]]></description><link>https://sewon.dev/en/place2page-sentry-db-pool-session-lifecycle/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-sentry-db-pool-session-lifecycle/</guid><pubDate>Fri, 22 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/997fd6e293f8b90bdf085c84df7b093f/708e8/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 58.82352941176471%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAACOUlEQVR42n2TzWsTQRTA+39471U8aaUXK+jBi1RQ9ODBgx8Ignj3XxBPgpeKF0GvSvEgiNaClWpLFZtNsslu0s3HZpPsdr9nZn+yE9M2UnzwdubNvPfb9+bNzAmpiBJJliviRGpNs8mYpJI4lQhZHNjlXhQL0ryME4SxQBUcyNw4SDEaIxw3wtwLqFo+zb2AZjvQo9n28cax9rGdgL1eiO1EeOOMdj/G6kTkYkIsCpibTApUnlNIoVVJOVlTBaookEppWxYTW8dICWqiZWy5Xu5MgFlGahh42zuMd36i2m0NmFYiVEFWZnEEJiybwdY27vctkt3KYclTB+m6ZN0ueaeLGo9RaQoyxxlmrHzq8XTVZqPmgxKoJEEOh6SOQ+I4iF5vFnicqPIT+axuuNxf2eXus02evOsgBh7/Ew1UWUbStBjuVvArBqLbRcQxSMEoFLz+6vH8g8Ov1j4UChkn2sc3qoyNKplt/5NheaitFolpkpkmhevO/DWOE/wgZNrA8iyV4xAZBvtlAo3GLLDvejRNi5bV0mrZbb2mAUoQuBU85wcqD3WjRKEQUiBFrlXk+Szw3sPHnF5aZvHCVRYvXmP+1BI3bj3QDkk4xLM/4tnvCQd16qM+L2qfeWmu88r5xpvRNm+D3yQiPwTevP2Ik2cvcebcMgvnr3BifoHL1+8cXNZCpqh8X9uRyFgbVFnzqnwZ1lj362yGNnl5J6fATrdPtdbAbNjUGxZ106LT6f8t4si7mpkf3+U/HWV/196KgKYAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Situation diagram&apos; title=&apos;&apos; src=&apos;/static/997fd6e293f8b90bdf085c84df7b093f/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/997fd6e293f8b90bdf085c84df7b093f/e7570/situation-diagram.png 170w,
/static/997fd6e293f8b90bdf085c84df7b093f/f46e7/situation-diagram.png 340w,
/static/997fd6e293f8b90bdf085c84df7b093f/ca1dc/situation-diagram.png 680w,
/static/997fd6e293f8b90bdf085c84df7b093f/02d09/situation-diagram.png 1020w,
/static/997fd6e293f8b90bdf085c84df7b093f/708e8/situation-diagram.png 1218w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Situation diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;When SQLAlchemy &lt;code class=&quot;language-text&quot;&gt;QueuePool&lt;/code&gt; timeout appeared as a P1 issue in Sentry, the easiest fix would have been to increase the pool size. But grouping routes and timestamps showed that database capacity alone did not explain the issue. The first bottleneck was a DB session that stayed alive during external I/O. The remaining timeouts came from an operator screen fanning out detail requests and pressuring the same pool.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: In production, detail lookup requests and an SSE stream hit &lt;code class=&quot;language-text&quot;&gt;QueuePool&lt;/code&gt; timeout around the same time.&lt;/li&gt;
&lt;li&gt;First judgment: Before increasing pool size, I checked whether sessions were holding connections for too long.&lt;/li&gt;
&lt;li&gt;Follow-up judgment: After releasing sessions earlier, the remaining timeout came from detail prefetch fan-out overlapping with stream polling.&lt;/li&gt;
&lt;li&gt;Fix: Close sessions around external I/O windows and limit detail request concurrency.&lt;/li&gt;
&lt;li&gt;Lesson: Pool timeout can mean &quot;connections are held too long&quot; or &quot;too many are borrowed at once,&quot; not only &quot;the database is too small.&quot;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;Place2Page has an operator screen for comparing generation results and inspecting detail records. While running several prompt experiments, Sentry grouped issues with this shape:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;TimeoutError: QueuePool limit of size 5 overflow 10 reached,
connection timed out, timeout 30.00&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Two route families were affected.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;admin detail endpoint
generation stream endpoint&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The first endpoint is used by operators to view generation details. The second is the SSE endpoint that sends generation progress. Even if the issue seemed to start from an internal operator flow, it was not safe to dismiss. If the shared pool dries up, it can affect the actual generation stream too.&lt;/p&gt;
&lt;h2 id=&quot;Why-I-Did-Not-Increase-Pool-Size-First&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-I-Did-Not-Increase-Pool-Size-First&quot; aria-label=&quot;Why I Did Not Increase Pool Size First permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why I Did Not Increase Pool Size First&lt;/h2&gt;
&lt;p&gt;A connection pool reuses DB connections instead of creating a new connection for every request. A pool timeout means all borrowable connections were checked out and not returned within the timeout.&lt;/p&gt;
&lt;p&gt;Increasing the numbers can make the symptom quieter for a while. But if code holds connections during non-DB work, or if one screen fires too many DB-backed requests at once, tuning pool size only delays the problem.&lt;/p&gt;
&lt;p&gt;The SQLAlchemy error guide describes this error as a protection mechanism around the pool. I also checked FastAPI&apos;s &lt;code class=&quot;language-text&quot;&gt;yield&lt;/code&gt; dependencies. Request-scoped dependency cleanup runs after the response lifecycle, and &lt;code class=&quot;language-text&quot;&gt;StreamingResponse&lt;/code&gt; can keep the response open for a long time.&lt;/p&gt;
&lt;p&gt;The local FastAPI &lt;code class=&quot;language-text&quot;&gt;Depends&lt;/code&gt; signature at the time did not have the newer &lt;code class=&quot;language-text&quot;&gt;scope=&quot;function&quot;&lt;/code&gt; option shown in current docs.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Depends(dependency=None, *, use_cache=True)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So I did not rely on a dependency option. I chose an explicit &lt;code class=&quot;language-text&quot;&gt;session.close()&lt;/code&gt; at a safe boundary.&lt;/p&gt;
&lt;h2 id=&quot;Evidence-1-StreamingResponse-Held-the-Session-Too-Long&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Evidence-1-StreamingResponse-Held-the-Session-Too-Long&quot; aria-label=&quot;Evidence 1 StreamingResponse Held the Session Too Long permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Evidence 1: StreamingResponse Held the Session Too Long&lt;/h2&gt;
&lt;p&gt;The existing SSE route checked access before starting the stream.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;ensure_access&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;session&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; StreamingResponse&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event_generator&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; media_type&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;text/event-stream&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The issue was that &lt;code class=&quot;language-text&quot;&gt;session&lt;/code&gt; came from a request-scoped dependency. Returning &lt;code class=&quot;language-text&quot;&gt;StreamingResponse&lt;/code&gt; does not immediately close it.&lt;/p&gt;
&lt;p&gt;I first pinned this behavior with a test.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;test_stream_generation_releases_access_session_before_streaming&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    session &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Mock&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    request &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Mock&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    user &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; SimpleNamespace&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;user-1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; is_admin&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    ensure_access &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Mock&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;projects&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ensure_access&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ensure_access&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    response &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;projects&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;stream_generation&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;proj-1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; request&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; session&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    ensure_access&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;assert_called_once_with&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;session&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;proj-1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    session&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;close&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;assert_called_once&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;assert&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;media_type &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;text/event-stream&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Before the fix, &lt;code class=&quot;language-text&quot;&gt;session.close()&lt;/code&gt; was not called and the test failed. After the fix, the route closed the session right after the access check. The stream itself already used separate short &lt;code class=&quot;language-text&quot;&gt;SessionLocal()&lt;/code&gt; contexts when it needed database access.&lt;/p&gt;
&lt;h2 id=&quot;Evidence-2-AI-Generation-Was-Inside-the-DB-Session&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Evidence-2-AI-Generation-Was-Inside-the-DB-Session&quot; aria-label=&quot;Evidence 2 AI Generation Was Inside the DB Session permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Evidence 2: AI Generation Was Inside the DB Session&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;run_generation()&lt;/code&gt; had a similar shape. The original structure ran the whole generation process inside one DB session context.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;with SessionLocal() as session:
  read project
  read prompt/runtime settings
  fetch place data
  generate AI HTML
  save landing/debug log&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;place data fetch&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;AI HTML generation&lt;/code&gt; are external I/O, not database work. If the session stays alive during that time, it can keep occupying a connection.&lt;/p&gt;
&lt;p&gt;I wrote a test that required the session to be closed before external fetch and AI generation. That test failed before the change and passed after the DB windows were separated from external I/O windows.&lt;/p&gt;
&lt;p&gt;The final structure became:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;DB setup window
  read project/runtime/profile
  close session

external window
  fetch place data

DB persist window
  save place snapshot
  close session

external window
  AI generation

DB persist window
  save landing/debug log
  close session&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The code became a little longer. In return, the time holding a connection narrowed to actual DB work.&lt;/p&gt;
&lt;h2 id=&quot;Evidence-3-The-Remaining-Timeout-Was-Fan-out&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Evidence-3-The-Remaining-Timeout-Was-Fan-out&quot; aria-label=&quot;Evidence 3 The Remaining Timeout Was Fan out permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Evidence 3: The Remaining Timeout Was Fan-out&lt;/h2&gt;
&lt;p&gt;After the first fix, some issues in the same Sentry family still remained. Looking again, the session release guard for the stream endpoint was already in place, and writes for existing users were already limited.&lt;/p&gt;
&lt;p&gt;The remaining evidence pointed to detail preview prefetch in an operator screen. When a detail-heavy tab opened, the page fetched up to 50 records at once. Each request performed an authorization lookup and a detail query. That fan-out overlapped with stream polling reads.&lt;/p&gt;
&lt;p&gt;In a public-safe pattern, the Sentry log looked like this:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;18:08:35  GET admin detail endpoint      200     30096ms
18:08:35  GET admin detail endpoint      200     30097ms
18:08:35  GET admin detail endpoint      200     30451ms
18:08:35  GET admin detail endpoint      failed  TimeoutError
18:08:35  GET generation stream endpoint failed  TimeoutError&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;If this had been a single slow query, I would expect one endpoint to appear long. Instead, a batch of detail requests from the same screen completed or failed around the 30-second pool timeout value. So I changed the frontend detail prefetch to use bounded workers and limited concurrent requests.&lt;/p&gt;
&lt;h2 id=&quot;Verification&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Verification&quot; aria-label=&quot;Verification permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Verification&lt;/h2&gt;
&lt;p&gt;The two RED tests passed after the fix.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;test_stream_generation_releases_access_session_before_streaming
test_run_generation_releases_db_session_around_external_generation_calls&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;I also ran the related test range.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api &lt;span class=&quot;token operator&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; uv run pytest &lt;span class=&quot;token parameter variable&quot;&gt;-q&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  tests/test_generation_service.py &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  tests/test_routers_admin_debug.py &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  tests/test_routers_projects.py &lt;span class=&quot;token punctuation&quot;&gt;\&lt;/span&gt;
  tests/test_projects_stream_state.py&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The result was &lt;code class=&quot;language-text&quot;&gt;183 passed, 1 warning&lt;/code&gt;. &lt;code class=&quot;language-text&quot;&gt;ruff check&lt;/code&gt; also passed for the related router and test files.&lt;/p&gt;
&lt;p&gt;For the follow-up fan-out fix, I added a test to pin that detail prefetch does not exceed the configured concurrency.&lt;/p&gt;
&lt;p&gt;The important part of this verification is not to overstate it as &quot;pool timeout disappeared completely.&quot; What I verified was that the session release boundary and fan-out limit behave as intended.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Will-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Will-Judge-This-Next-Time&quot; aria-label=&quot;How I Will Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Will Judge This Next Time&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;When I see pool timeout, I will not increase pool size first. I will separate lifecycle issues from fan-out pressure.&lt;/li&gt;
&lt;li&gt;If Sentry shows multiple 30-second-range requests in the same second, I will suspect concurrency before a single slow query.&lt;/li&gt;
&lt;li&gt;For &lt;code class=&quot;language-text&quot;&gt;StreamingResponse&lt;/code&gt;, background tasks, AI/provider calls, and external fetches, I will inspect DB session lifetime separately.&lt;/li&gt;
&lt;li&gt;Even operator screens can pressure the production pool if they over-prefetch DB-backed detail endpoints.&lt;/li&gt;
&lt;li&gt;After reducing lifecycle length and limiting fan-out, if normal traffic still needs more capacity, then I will tune pool size, worker count, and database max connections.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.sqlalchemy.org/en/20/errors.html#queuepool-limit-of-size-x-overflow-y-reached-connection-timed-out-timeout-z&quot;&gt;SQLAlchemy 2.0 Errors: QueuePool limit of size x overflow y reached&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/&quot;&gt;FastAPI: Dependencies with yield&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[DB pool timeout을 pool size가 아니라 lifecycle 문제로 보기]]></title><description><![CDATA[Sentry에 SQLAlchemy  timeout이 P1으로 올라왔을 때 가장 쉬운 해결은 pool size를 키우는 것이었다. 하지만 route와 timestamp를 묶어보니 문제는 DB capacity…]]></description><link>https://sewon.dev/place2page-sentry-db-pool-session-lifecycle/</link><guid isPermaLink="false">https://sewon.dev/place2page-sentry-db-pool-session-lifecycle/</guid><pubDate>Fri, 22 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/997fd6e293f8b90bdf085c84df7b093f/708e8/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 58.82352941176471%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAACOUlEQVR42n2TzWsTQRTA+39471U8aaUXK+jBi1RQ9ODBgx8Ignj3XxBPgpeKF0GvSvEgiNaClWpLFZtNsslu0s3HZpPsdr9nZn+yE9M2UnzwdubNvPfb9+bNzAmpiBJJliviRGpNs8mYpJI4lQhZHNjlXhQL0ryME4SxQBUcyNw4SDEaIxw3wtwLqFo+zb2AZjvQo9n28cax9rGdgL1eiO1EeOOMdj/G6kTkYkIsCpibTApUnlNIoVVJOVlTBaookEppWxYTW8dICWqiZWy5Xu5MgFlGahh42zuMd36i2m0NmFYiVEFWZnEEJiybwdY27vctkt3KYclTB+m6ZN0ueaeLGo9RaQoyxxlmrHzq8XTVZqPmgxKoJEEOh6SOQ+I4iF5vFnicqPIT+axuuNxf2eXus02evOsgBh7/Ew1UWUbStBjuVvArBqLbRcQxSMEoFLz+6vH8g8Ov1j4UChkn2sc3qoyNKplt/5NheaitFolpkpkmhevO/DWOE/wgZNrA8iyV4xAZBvtlAo3GLLDvejRNi5bV0mrZbb2mAUoQuBU85wcqD3WjRKEQUiBFrlXk+Szw3sPHnF5aZvHCVRYvXmP+1BI3bj3QDkk4xLM/4tnvCQd16qM+L2qfeWmu88r5xpvRNm+D3yQiPwTevP2Ik2cvcebcMgvnr3BifoHL1+8cXNZCpqh8X9uRyFgbVFnzqnwZ1lj362yGNnl5J6fATrdPtdbAbNjUGxZ106LT6f8t4si7mpkf3+U/HWV/196KgKYAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/997fd6e293f8b90bdf085c84df7b093f/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/997fd6e293f8b90bdf085c84df7b093f/e7570/situation-diagram.png 170w,
/static/997fd6e293f8b90bdf085c84df7b093f/f46e7/situation-diagram.png 340w,
/static/997fd6e293f8b90bdf085c84df7b093f/ca1dc/situation-diagram.png 680w,
/static/997fd6e293f8b90bdf085c84df7b093f/02d09/situation-diagram.png 1020w,
/static/997fd6e293f8b90bdf085c84df7b093f/708e8/situation-diagram.png 1218w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Sentry에 SQLAlchemy &lt;code class=&quot;language-text&quot;&gt;QueuePool&lt;/code&gt; timeout이 P1으로 올라왔을 때 가장 쉬운 해결은 pool size를 키우는 것이었다. 하지만 route와 timestamp를 묶어보니 문제는 DB capacity 하나로 설명되지 않았다. 첫 번째 병목은 외부 I/O 동안 너무 오래 살아 있는 DB session이었고, 후속으로 남은 timeout은 detail 요청을 한꺼번에 fan-out하면서 같은 pool을 압박한 케이스였다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: detail 조회 요청과 SSE stream이 같은 시각에 &lt;code class=&quot;language-text&quot;&gt;QueuePool&lt;/code&gt; timeout을 맞았다.&lt;/li&gt;
&lt;li&gt;첫 판단: pool size를 키우기 전에 connection을 오래 잡는 session lifecycle을 확인했다.&lt;/li&gt;
&lt;li&gt;후속 판단: session release 이후에도 남은 timeout은 detail prefetch fan-out이 stream polling과 겹친 문제였다.&lt;/li&gt;
&lt;li&gt;해결: 외부 I/O 구간에서는 session을 닫고, detail 요청은 bounded concurrency로 제한했다.&lt;/li&gt;
&lt;li&gt;배운 점: pool timeout은 &quot;DB가 작다&quot;보다 &quot;오래 잡고 있거나, 동시에 너무 많이 빌리고 있다&quot;는 신호일 수 있다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;Place2Page에는 생성 결과를 비교하고 세부 기록을 보는 화면이 있다. 프롬프트 실험을 여러 개 돌리던 시점에 Sentry에는 다음 계열 이슈가 묶여 올라왔다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;TimeoutError: QueuePool limit of size 5 overflow 10 reached,
connection timed out, timeout 30.00&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;영향을 받은 route 계열은 두 종류였다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;detail endpoint
generation stream endpoint&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;전자는 생성 세부 기록을 보는 endpoint이고, 후자는 생성 진행상황을 보내는 SSE endpoint다. 관리성 화면에서 시작된 문제처럼 보여도 가볍게 볼 수 없었다. 같은 pool을 말리면 실제 generation stream에도 영향을 줄 수 있기 때문이다.&lt;/p&gt;
&lt;h2 id=&quot;왜-pool-size부터-키우지-않았나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-pool-size%EB%B6%80%ED%84%B0-%ED%82%A4%EC%9A%B0%EC%A7%80-%EC%95%8A%EC%95%98%EB%82%98&quot; aria-label=&quot;왜 pool size부터 키우지 않았나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 pool size부터 키우지 않았나&lt;/h2&gt;
&lt;p&gt;Connection pool은 DB connection을 매 요청마다 새로 만들지 않기 위해 재사용하는 장치다. pool timeout은 동시에 빌릴 수 있는 connection이 모두 나갔고, 정해진 시간 안에 반납되지 않았다는 뜻이다.&lt;/p&gt;
&lt;p&gt;그래서 숫자만 키우면 당장은 조용해질 수 있다. 하지만 connection을 너무 오래 들고 있거나 한 화면이 한꺼번에 너무 많은 DB-backed 요청을 날리는 구조라면 pool size 조정은 증상을 늦추는 일에 가깝다.&lt;/p&gt;
&lt;p&gt;SQLAlchemy error guide도 이 오류를 pool의 보호 장치로 설명한다. FastAPI의 &lt;code class=&quot;language-text&quot;&gt;yield&lt;/code&gt; dependency도 같이 봤다. request-scoped dependency cleanup은 response lifecycle 뒤에 실행되는데 &lt;code class=&quot;language-text&quot;&gt;StreamingResponse&lt;/code&gt;는 응답이 오래 열려 있을 수 있다.&lt;/p&gt;
&lt;p&gt;당시 로컬 FastAPI &lt;code class=&quot;language-text&quot;&gt;Depends&lt;/code&gt; signature에는 최신 문서에서 보이는 &lt;code class=&quot;language-text&quot;&gt;scope=&quot;function&quot;&lt;/code&gt; 옵션이 없었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Depends(dependency=None, *, use_cache=True)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그래서 dependency 옵션에 기대지 않고, 안전한 경계에서 &lt;code class=&quot;language-text&quot;&gt;session.close()&lt;/code&gt;를 명시적으로 호출하는 방향으로 잡았다.&lt;/p&gt;
&lt;h2 id=&quot;증거-1-StreamingResponse가-session을-오래-잡았다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A6%9D%EA%B1%B0-1-StreamingResponse%EA%B0%80-session%EC%9D%84-%EC%98%A4%EB%9E%98-%EC%9E%A1%EC%95%98%EB%8B%A4&quot; aria-label=&quot;증거 1 StreamingResponse가 session을 오래 잡았다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;증거 1: StreamingResponse가 session을 오래 잡았다&lt;/h2&gt;
&lt;p&gt;기존 SSE route는 stream 시작 전에 권한 확인을 했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;ensure_access&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;session&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; project_id&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt; StreamingResponse&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;event_generator&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; media_type&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;text/event-stream&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;문제는 &lt;code class=&quot;language-text&quot;&gt;session&lt;/code&gt;이 request-scoped dependency에서 왔다는 점이다. &lt;code class=&quot;language-text&quot;&gt;StreamingResponse&lt;/code&gt;를 반환했다고 바로 닫히지는 않는다.&lt;/p&gt;
&lt;p&gt;이걸 테스트로 먼저 고정했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;test_stream_generation_releases_access_session_before_streaming&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    session &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Mock&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    request &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Mock&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    user &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; SimpleNamespace&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;user-1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; is_admin&lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token boolean&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    ensure_access &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; Mock&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    monkeypatch&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token builtin&quot;&gt;setattr&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;projects&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;ensure_access&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; ensure_access&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    response &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; asyncio&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;run&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;projects&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;stream_generation&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;proj-1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; request&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; session&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;

    ensure_access&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;assert_called_once_with&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;session&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;proj-1&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; user&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    session&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;close&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;assert_called_once&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;token keyword&quot;&gt;assert&lt;/span&gt; response&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;media_type &lt;span class=&quot;token operator&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;text/event-stream&quot;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;처음에는 &lt;code class=&quot;language-text&quot;&gt;session.close()&lt;/code&gt;가 호출되지 않아 실패했다. 수정 후에는 access check 직후 session을 닫았다. stream 안에서 DB가 필요할 때는 이미 별도의 짧은 &lt;code class=&quot;language-text&quot;&gt;SessionLocal()&lt;/code&gt; context를 쓰고 있었기 때문이다.&lt;/p&gt;
&lt;h2 id=&quot;증거-2-AI-generation이-DB-session-안에-있었다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A6%9D%EA%B1%B0-2-AI-generation%EC%9D%B4-DB-session-%EC%95%88%EC%97%90-%EC%9E%88%EC%97%88%EB%8B%A4&quot; aria-label=&quot;증거 2 AI generation이 DB session 안에 있었다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;증거 2: AI generation이 DB session 안에 있었다&lt;/h2&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;run_generation()&lt;/code&gt;도 비슷했다. 처음 구조는 생성 전체를 하나의 DB session context 안에서 실행했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;with SessionLocal() as session:
  project 조회
  prompt/runtime 설정 조회
  place data fetch
  AI HTML generation
  landing/debug log 저장&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;place data fetch&lt;/code&gt;와 &lt;code class=&quot;language-text&quot;&gt;AI HTML generation&lt;/code&gt;은 DB 작업이 아니라 외부 I/O다. 이 시간 동안 session이 살아 있으면 connection을 계속 점유할 수 있다.&lt;/p&gt;
&lt;p&gt;그래서 외부 fetch와 AI generation에 들어가기 전에 session이 닫혀 있어야 한다는 테스트를 만들었다. 이 테스트도 처음에는 실패했고, 수정 후에는 DB 작업 구간과 외부 I/O 구간이 분리됐다.&lt;/p&gt;
&lt;p&gt;최종 구조는 이렇게 바뀌었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;DB setup window
  read project/runtime/profile
  close session

external window
  fetch place data

DB persist window
  save place snapshot
  close session

external window
  AI generation

DB persist window
  save landing/debug log
  close session&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;코드는 조금 길어졌다. 대신 connection을 점유하는 구간이 실제 DB 작업으로 좁아졌다.&lt;/p&gt;
&lt;h2 id=&quot;증거-3-남은-timeout은-fan-out이었다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%A6%9D%EA%B1%B0-3-%EB%82%A8%EC%9D%80-timeout%EC%9D%80-fan-out%EC%9D%B4%EC%97%88%EB%8B%A4&quot; aria-label=&quot;증거 3 남은 timeout은 fan out이었다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;증거 3: 남은 timeout은 fan-out이었다&lt;/h2&gt;
&lt;p&gt;처음 fix 뒤에도 같은 계열의 Sentry 이슈가 일부 남아 있었다. 다시 보니 stream endpoint의 session release guard는 이미 들어가 있었고, 기존 유저 write도 과도하게 반복되지 않도록 제한되어 있었다.&lt;/p&gt;
&lt;p&gt;남은 증거는 detail preview prefetch였다. 특정 탭이 열릴 때 현재 페이지의 detail record를 최대 50개까지 동시에 가져오고 있었다. 각 요청은 권한 확인을 위한 DB lookup과 detail query를 실행한다. 이 fan-out이 stream polling read와 같은 시간대에 겹쳤다.&lt;/p&gt;
&lt;p&gt;Sentry log를 공개 가능한 형태로 패턴화하면 이런 모양이었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;18:08:35  GET detail endpoint            200     30096ms
18:08:35  GET detail endpoint            200     30097ms
18:08:35  GET detail endpoint            200     30451ms
18:08:35  GET detail endpoint            failed  TimeoutError
18:08:35  GET generation stream endpoint failed  TimeoutError&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;단일 slow query였다면 특정 endpoint 하나가 길게 찍혔을 가능성이 높다. 여기서는 같은 화면에서 생긴 detail request 묶음이 pool timeout 값인 30초 주변에 한꺼번에 완료되거나 실패했다. 그래서 frontend detail prefetch를 bounded worker 방식으로 바꾸고, 동시 요청 수를 제한했다.&lt;/p&gt;
&lt;h2 id=&quot;검증&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%80%EC%A6%9D&quot; aria-label=&quot;검증 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;검증&lt;/h2&gt;
&lt;p&gt;처음 만든 RED 테스트 두 개는 수정 후 GREEN이 됐다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;test_stream_generation_releases_access_session_before_streaming
test_run_generation_releases_db_session_around_external_generation_calls&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;관련 범위도 같이 돌렸다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token builtin class-name&quot;&gt;cd&lt;/span&gt; apps/api
uv run pytest &lt;span class=&quot;token parameter variable&quot;&gt;-q&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;&amp;lt;&lt;/span&gt;generation service, detail route, project route, stream state tests&lt;span class=&quot;token operator&quot;&gt;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;결과는 &lt;code class=&quot;language-text&quot;&gt;183 passed, 1 warning&lt;/code&gt;이었다. 관련 router와 test 파일에 대한 &lt;code class=&quot;language-text&quot;&gt;ruff check&lt;/code&gt;도 통과했다.&lt;/p&gt;
&lt;p&gt;후속 fan-out fix는 detail prefetch가 지정된 concurrency를 넘지 않는지 테스트로 고정했다.&lt;/p&gt;
&lt;p&gt;이 검증에서 중요한 점은 &quot;pool timeout이 완전히 사라졌다&quot;는 식으로 과장하지 않는 것이다. 확인한 것은 session release boundary와 fan-out limit이 의도대로 작동한다는 점이다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;pool timeout을 보면 pool size부터 키우지 않는다. 먼저 connection을 오래 잡는 lifecycle과 동시에 몰리는 fan-out을 분리해서 본다.&lt;/li&gt;
&lt;li&gt;Sentry에서 같은 초에 30초대 요청이 여러 개 몰려 있으면 slow query보다 concurrency 문제를 먼저 의심한다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;StreamingResponse&lt;/code&gt;, background task, AI/provider 호출, 외부 fetch는 DB session 수명을 별도로 확인한다.&lt;/li&gt;
&lt;li&gt;관리성 화면이라도 DB-backed detail endpoint를 과하게 prefetch하면 DB pool을 압박할 수 있다고 본다.&lt;/li&gt;
&lt;li&gt;lifecycle을 줄이고 fan-out을 제한한 뒤에도 정상 트래픽에서 부족하면 그때 pool size, worker 수, DB max connection을 조정한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.sqlalchemy.org/en/20/errors.html#queuepool-limit-of-size-x-overflow-y-reached-connection-timed-out-timeout-z&quot;&gt;SQLAlchemy 2.0 Errors: QueuePool limit of size x overflow y reached&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/&quot;&gt;FastAPI: Dependencies with yield&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Choosing a Garment Classifier by Routing Cost, Not Accuracy Alone]]></title><description><![CDATA[The ThatzFit garment classifier was not a feature for showing off model performance. It was a routing gate before virtual try-on. At first…]]></description><link>https://sewon.dev/en/mobilenetv2-fashion-classifier-decision/</link><guid isPermaLink="false">https://sewon.dev/en/mobilenetv2-fashion-classifier-decision/</guid><pubDate>Thu, 21 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/586f31226193826104a1fa4f11dfafbf/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB7ElEQVR42oWSz2sTQRTH41n04kHwJIIgoge1Fg+tFETqxR946l8lGGO1YqCoFL146KFQUDA9WdJoY+2vJN1kk2x+7G53s5PdnZ2d9+bJpsG0OeiXYXhz+Hzfe18mJWIs60xrsAOd6Ubf6PpGx292fd3oNzu+6wkiUnRco1cKUdluYDu+5fjmYd92/KPTMr22xXgkh0SiEacGVUop1WORy0TA5ZgxEcUAPBZhLCSAUkqEdsQaKOPEiVQKAHyfS4moCIFAJniEsFIv5lp7Lc/J6+W8Xi6Z7YBZ2tbybmHJbW0Px07spTyaaeent/Ojp4AkyVx7+7tZoXFJonC0819YEfkMTEvafVhaZyu/IiKqaHpm4d3bxU/pzJvnL7Pp1+9fLHx4lsl2utYIxkECiOpj3s2uORs6321zIvq8vHr5xr3bM0+vTNw/d/HW6fNXz1y4durspfWNzROdoxgjgV4IbgBEBIhEtPpl7ebUw7sP5mZm5yanH09OPboz/eT6xOzW770hLKWMYyxqrKgxCUikJKCExILzSK8b1XqzUNkvaKXkruxv1spRLIawUgoAQwGhAAkQhDzkAgAHISbr9OLwVTWX1r7O177NN3KLTt4DPoT/oSRIRAHygHVLXkcLrCq3a+GhRDgBq/Fv+H/9ARuIhm5PLWhpAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;situation diagram&apos; title=&apos;&apos; src=&apos;/static/586f31226193826104a1fa4f11dfafbf/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/586f31226193826104a1fa4f11dfafbf/e7570/situation-diagram.png 170w,
/static/586f31226193826104a1fa4f11dfafbf/f46e7/situation-diagram.png 340w,
/static/586f31226193826104a1fa4f11dfafbf/ca1dc/situation-diagram.png 680w,
/static/586f31226193826104a1fa4f11dfafbf/02d09/situation-diagram.png 1020w,
/static/586f31226193826104a1fa4f11dfafbf/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;situation diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The ThatzFit garment classifier was not a feature for showing off model performance. It was a routing gate before virtual try-on. At first, choosing DenseNet201 because it had the highest test accuracy looked natural. But the real product bottleneck was not classification. It was the virtual try-on step after classification. The decision changed from &quot;pick the most accurate model&quot; to &quot;pick the lightest model that avoids serious routing failures.&quot;&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: I needed a fast routing model that sends garment images into the right virtual try-on flow, such as tops or bottoms.&lt;/li&gt;
&lt;li&gt;Decision: I treated roughly 90% accuracy as the threshold, then weighted downstream cost and inference time more heavily.&lt;/li&gt;
&lt;li&gt;Result: DenseNet201 had higher test accuracy, but MobileNetV2 had the better balance of validation accuracy, inference time, and experiment iteration cost.&lt;/li&gt;
&lt;li&gt;Lesson: Model selection is not a leaderboard decision. It has to include what happens in the product when the model is wrong.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;ThatzFit needed a classifier that could route a user-uploaded garment image into the right virtual try-on flow. For example, a pants image should go to the bottoms flow, while a shirt or outerwear image should go to the tops flow.&lt;/p&gt;
&lt;p&gt;I started with a simple CNN baseline, then compared several transfer-learning models pretrained on ImageNet. The final candidate had to be more than accurate. It also had to make a quick decision inside the service.&lt;/p&gt;
&lt;h2 id=&quot;Problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Problem&quot; aria-label=&quot;Problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;Garment classification is not the core user-visible task. Most of the waiting time happens in the virtual try-on model. The classifier still needs to be accurate enough, but making it too heavy slows down the entire fitting flow.&lt;/p&gt;
&lt;p&gt;The experiment had two criteria.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Accuracy should be high enough for practical use.&lt;/li&gt;
&lt;li&gt;If accuracy is similar, choose the model with shorter inference time.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Data&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Data&quot; aria-label=&quot;Data permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Data&lt;/h2&gt;
&lt;p&gt;The dataset contained 4,500 garment images. I used 4,050 images, or 90%, for training and 450 images, or 10%, for testing.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/a7ba62674a856f33cdafe8fca7ab938c/46d55/dataset-overview.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAACjElEQVR42q3T20vTYRjAca+66a6ki7yotBNkF11VN/0BCpaYZ6eiGbhCxZlz4QEz8UBWiqdCLDE1O16YhGCeYwSRG0qpm879fvvBpj/nqrnptvzGNguCoIJeeHgf3sOH5+XhDfH5fLjdbjweD1tbW/i++XBuOFkwGBBEAUEUMUsiy4KAKEmYBDOiKDI3N48oCmy6XWy63T8jZHt7G9PSMvFRCmoqbtFRfY+byhuMPRygLaMS3bMRhjKr+fhoCP/wOl347wSC4PiRe71eQvwLC3MG9u06SOqFLK7FFRAbGUN3cRPK/VEM13TRHhrNWMFdPuVdZza/AnmgH6mtFpdhhq/6CTwrFjyyxOaaNQiaFpeJCD1JTspVyhQaFGeT6S+/h+p4POO3+3hwOIkpdSvTCTl8UOQjNlaykBuPPNTHckMujvfDyFNPsetHg6BhwUj4nhNkJyspTVOTejqJ/vJ2Co9eZKyhl87weCbVLegVSnTZKqT2eoyqTOxvniO0FvFZN8aa9iXrMxOEbGw4WTKaOPQnsLgFfZoSXZYKqa0OY2F6EGxW/Qp6vB4WjUv/D/zrJ/8L6K8wYm8kl5KVlClKSD2z05RjwaZ0RiQwqW5Fr7iCLrsIqb0OoypjByz6TYXzBsJ2HyE9LoeSRBUJp+Lo1bSQdyCG0fpuOsJimShsQp94GZ0iH6m5msW8FOzDTxCb8vkyPcK69gWOmfEgKAoWos7FUl5cRaOmAXVaEYMtj6k7r0Lb9Yr+6ELe3elBr6liurQOc8995mpLsE6+xthVy6r+LRbtILZZbRD0fzubzYYsy9jtdlZXV3E6nYHc5XIF9sxmMxaLyJoss263s2Kz4XA4sFqtgdl/xrHu4DtFU9D8gKSIXwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;garment classification dataset overview&apos; title=&apos;&apos; src=&apos;/static/a7ba62674a856f33cdafe8fca7ab938c/ca1dc/dataset-overview.png&apos; srcset=&apos;/static/a7ba62674a856f33cdafe8fca7ab938c/e7570/dataset-overview.png 170w,
/static/a7ba62674a856f33cdafe8fca7ab938c/f46e7/dataset-overview.png 340w,
/static/a7ba62674a856f33cdafe8fca7ab938c/ca1dc/dataset-overview.png 680w,
/static/a7ba62674a856f33cdafe8fca7ab938c/02d09/dataset-overview.png 1020w,
/static/a7ba62674a856f33cdafe8fca7ab938c/46d55/dataset-overview.png 1035w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;garment classification dataset overview&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;There were eight classes.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LongPants&lt;/li&gt;
&lt;li&gt;Sleeveless&lt;/li&gt;
&lt;li&gt;Outerwear&lt;/li&gt;
&lt;li&gt;Accessories&lt;/li&gt;
&lt;li&gt;ShortPants&lt;/li&gt;
&lt;li&gt;ShortSleeve&lt;/li&gt;
&lt;li&gt;Shoes&lt;/li&gt;
&lt;li&gt;LongSleeve&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/2f8002a8b1aecf9cdb3ce2836ca7e048/13ce4/dataset-examples.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 46.470588235294116%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAACY0lEQVR42h2RW1MSAQBG91/1Vg/9jab3HqyZNHvLmew202UqncoRVFDRSZAIE0RcDAQXW1aW5bIsN+OS4aIgOGZeOo1+M+cHnPMJLuciqqoxbx9HliIsLvn5thKk1z2k1TJpNBp0Oh3UZJJMJkNWy2Doefb2TEzTJKfn0HWder1OpVJBsNgchKMSw0MPef3iMXcGhxh49JTDTpv9/RaGYXBwcIDNPs1nlxvRv0Is/J3mnsnv300URUHT0shygmg0huD1LpGQExTSCuV8hmxOJ5XSOD4+5u/JCeL3CIqaQo1HSEZFDrtHHP85oWjoGNk0vV6PbrdLo75Do1ZB2BDXKBcKTI68wjs3RdM8QJK2cDgcxCJhnn2awuLxM9t/i4nbN4nGt/B4vERWPMjrAXZKWZq7deLr82ysTiMkFYVa9SculwsxGMQ0W1SrVWRZvmoTEEOEopskA27CbgdaOouqqshSjFw6xX5rj06njZaU0LY3ERx2G6u+ZeYmrCwtOlmYm8ftnMfzxUNwdY0vX704XW607RjlfAqr1crs7CxnZ2dI0ia1ao1svsTMzAzW0bcIRj5PsVAg6FsmKf9g/MNHbFYLuZyOpmlkshn0vIGaiFEpZBFFkVAoxNnpKaVikXK5ws9anbicYtUfQGg2m/za3eX1yBgT9jmWfT5Cosjg4APGLRYUOYGSULi4+Mf5+QV+3wobkShRaZ1YPIxRql/hdntwLjgRLh9qt9vYXQE+jNmulKamJrl2/QZ99/t5/uQ5796OcLmj3hG2STuuz4u8GR3m5fthCsVdSjtN+u8PcLfvHv8BXw5RQe0yh5cAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;garment image dataset examples&apos; title=&apos;&apos; src=&apos;/static/2f8002a8b1aecf9cdb3ce2836ca7e048/ca1dc/dataset-examples.png&apos; srcset=&apos;/static/2f8002a8b1aecf9cdb3ce2836ca7e048/e7570/dataset-examples.png 170w,
/static/2f8002a8b1aecf9cdb3ce2836ca7e048/f46e7/dataset-examples.png 340w,
/static/2f8002a8b1aecf9cdb3ce2836ca7e048/ca1dc/dataset-examples.png 680w,
/static/2f8002a8b1aecf9cdb3ce2836ca7e048/02d09/dataset-examples.png 1020w,
/static/2f8002a8b1aecf9cdb3ce2836ca7e048/9d567/dataset-examples.png 1360w,
/static/2f8002a8b1aecf9cdb3ce2836ca7e048/13ce4/dataset-examples.png 2006w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;garment image dataset examples&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;During training, I used image augmentation such as rotation, zoom, shift, and horizontal flip to reduce overfitting.&lt;/p&gt;
&lt;h2 id=&quot;Criteria&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Criteria&quot; aria-label=&quot;Criteria permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Criteria&lt;/h2&gt;
&lt;p&gt;I split the metrics into two types.&lt;/p&gt;
&lt;p&gt;The first was a threshold-based metric. I treated accuracy around 90% as potentially usable in practice. This was the minimum line for a routing model that should not make major garment-flow mistakes.&lt;/p&gt;
&lt;p&gt;The second was an optimization metric. Lower inference time was better. In ThatzFit&apos;s full flow, VITON-based virtual try-on is much heavier than image classification, so the classification step should finish as quickly as possible.&lt;/p&gt;
&lt;p&gt;The final selection rule was:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Among models near or above 90% accuracy, choose the one with the shortest inference time.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;Baseline&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Baseline&quot; aria-label=&quot;Baseline permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Baseline&lt;/h2&gt;
&lt;p&gt;I first trained a simple CNN baseline. It used two &lt;code class=&quot;language-text&quot;&gt;Conv2D&lt;/code&gt; layers with &lt;code class=&quot;language-text&quot;&gt;MaxPooling&lt;/code&gt;, then a &lt;code class=&quot;language-text&quot;&gt;Dense&lt;/code&gt; layer for the eight classes.&lt;/p&gt;
&lt;p&gt;After 10 epochs, the result was:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Training Accuracy&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Validation Accuracy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CNN baseline&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;97.85%&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;65.85%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The gap between training accuracy and validation accuracy was large. The baseline was quick to build, but it was not good enough for a service model.&lt;/p&gt;
&lt;h2 id=&quot;Model-comparison&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Model-comparison&quot; aria-label=&quot;Model comparison permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Model comparison&lt;/h2&gt;
&lt;p&gt;For the transfer-learning models, I used ImageNet pretrained weights and trained a new classification head. I compared 13 pretrained models in total. The table below shows the stronger candidates.&lt;/p&gt;
&lt;p&gt;Inference time was measured as the total time needed to predict the same 450-image test set once. &lt;code class=&quot;language-text&quot;&gt;Per Image Time&lt;/code&gt; is that total divided by the number of test images. These numbers are useful for relative comparison between models. Actual API latency would depend on server hardware, batch size, and preprocessing.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Val Accuracy&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Test Accuracy&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Training Time&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Inference Time&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Per Image Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DenseNet201&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8988&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.9067&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;111.38s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.3523s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.007450s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Xception&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8815&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.9000&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;62.02s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.5610s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.007913s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MobileNetV2&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.9062&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8956&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;48.22s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.3096s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.007355s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ResNet50V2&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8963&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8933&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;41.77s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.3293s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.007399s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DenseNet121&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8741&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8822&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;86.92s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.3616s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.007470s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;DenseNet201 had the highest test accuracy. It also had longer inference and training time. MobileNetV2 was slightly below 90% test accuracy, but its validation accuracy was above 90% and it had the shortest inference time.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/f84203a42cbd2ed28e56a4c5a543f482/f2aa7/model-comparison-chart.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 52.352941176470594%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsTAAALEwEAmpwYAAABeElEQVR42n2SWa7sIAxEeyMhhMGAGTJ2739n9WRHPdyf91EyYiidsnlkTgjk4YKFDRaLVDfDzAbTNP1fxqiMMZjnWeuDC6OVgp4jyDs465C8R3AOIUaklFREpGJmlXcO5BZEHzCb+WsYQgDHgKNlrJzARFhzRk2EUgq2bcO6rui9q47jULFAlIxChOg9lmX5GubgMTLh1Rk9EzgSzlaU7G2w77sav81fzyfG6ArTSkLwQdvwiDGipYBnZzVplHDUglEyWmu4rgvneaqhSNav1wujd2yc0bhqfLcssLPFw/ub7uoFO2eMnNASYXBG5YIxxodM4ouhEAvdaFWjS+9jCBpbDWuKuFq5+xYJGycIeW3tE7HWin3fcJwneq36JlNQMp30dygRlYLSyUCEsJaMWhnbdlMJpcSVKoMYrcE7j8XOSjX9fhshkcYKVY5R+1dLQu/jMxChfNcmrcj3XTWbpr//MEYHY6bPxn1o/lx8n+naWl3bn/1fw38mgiKwp9ve3AAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;transfer-learning model performance comparison&apos; title=&apos;&apos; src=&apos;/static/f84203a42cbd2ed28e56a4c5a543f482/ca1dc/model-comparison-chart.png&apos; srcset=&apos;/static/f84203a42cbd2ed28e56a4c5a543f482/e7570/model-comparison-chart.png 170w,
/static/f84203a42cbd2ed28e56a4c5a543f482/f46e7/model-comparison-chart.png 340w,
/static/f84203a42cbd2ed28e56a4c5a543f482/ca1dc/model-comparison-chart.png 680w,
/static/f84203a42cbd2ed28e56a4c5a543f482/f2aa7/model-comparison-chart.png 782w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;transfer-learning model performance comparison&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/acde966a28b070e7d9c9af53998a4c8e/e19bc/model-performance-chart.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 53.529411764705884%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsTAAALEwEAmpwYAAACyklEQVR42h3R62/aBhTGYf7VaZX2YZNWTduXLUm1aNK6KukubZVGVdJtanNp02wkWxRKICRcWjUlCbijgG1s7hdjmxgM+AK/Cc7n55z3SG/gUtFRKzX0joCceEchm8fsGbiej+N4jEYjfNdBbZtITZOJ52A7Y0zLRDdMbHvIcGgzm1gsRmD1ROHkLIWUXSH62fe8Wv2dRjLBxHbwpw7TKUycIcfXFf5K1+aL2mGIZqbGdDphBlzfpwMcRU4J3I+ohGNJxMwK4VtLPFt+iPgyiHwZRVIfzw+MBybhbIWfDz7guSLZhQV2bq+T2NnEt4ZEctsslqrshyIENuMK8TcXSB82iC89IPjoGVLolKqQ5FB4gmB4MBnzVmqxcSRQV/d58+hHju7uknz+FFOoEEwt80BROAxHCRhmD03T6HTa6FqXQX+AaRgYuo7aaNKzh/MvLauP1u3S0TponQ7WjUXfsjC6Os1Wi7HrkkqlCHiex9j18H1/jma41+vhug6uM8SbTHE9D89z587zJ9gDex4+s/ZwyHjUn4eexxMEXr5v8Db9H/XSPhcrT/l3fZtq8h2GfMWWsME/zSGjG510qc1OTKKrxcn+ucbr+3u8//sFo5LGWeY3njdbBF9HZy3PSklQvL5H+NNFtn5Yo7h3SDcbYzG5zJOyzWRgcJJrsLqXoVnbJrb0Ba++3uT08S8MrsrsJr5hQVY4CJ8S+OlYIhQ5p3B5l9An3/HHnV/JvQjSvo6weH6HNfkGp9chJFS4t3tJrbxFdOFzdr9cJ/xwhZu0wvbZV3xbFNk/PiGQrxtUanW0do7qhYCSE9HLVXrtGplqBtUaw3RCy+yTU1roukRduEK9lmjJIlZbR6ymKQ4GnCWSBColCVEUyRdkpIpKtV4jL4oUihJyXqZRVlHLZRRZQpFFPuYliiWFSqOKpCh8LBbI50S6jQYHB0H+B3YI/P5K+m8kAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;accuracy and inference time by model&apos; title=&apos;&apos; src=&apos;/static/acde966a28b070e7d9c9af53998a4c8e/ca1dc/model-performance-chart.png&apos; srcset=&apos;/static/acde966a28b070e7d9c9af53998a4c8e/e7570/model-performance-chart.png 170w,
/static/acde966a28b070e7d9c9af53998a4c8e/f46e7/model-performance-chart.png 340w,
/static/acde966a28b070e7d9c9af53998a4c8e/ca1dc/model-performance-chart.png 680w,
/static/acde966a28b070e7d9c9af53998a4c8e/02d09/model-performance-chart.png 1020w,
/static/acde966a28b070e7d9c9af53998a4c8e/e19bc/model-performance-chart.png 1346w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;accuracy and inference time by model&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;Why-I-chose-MobileNetV2&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-I-chose-MobileNetV2&quot; aria-label=&quot;Why I chose MobileNetV2 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why I chose MobileNetV2&lt;/h2&gt;
&lt;p&gt;I chose MobileNetV2 for three reasons.&lt;/p&gt;
&lt;p&gt;First, the accuracy was high enough. MobileNetV2 reached 90.62% validation accuracy and 89.56% test accuracy. It was very close to the 90% target, and the practical difference from the other candidates was small.&lt;/p&gt;
&lt;p&gt;Second, inference time was the shortest. Total inference time on 450 images was 3.3096 seconds, or 0.007355 seconds per image. Since this classifier is only a routing step before virtual try-on, saving time here fits the user experience better.&lt;/p&gt;
&lt;p&gt;Third, training time was also short. At 48.22 seconds, it was lighter to iterate on than models with similar performance. That mattered for experiment speed and operating cost.&lt;/p&gt;
&lt;h2 id=&quot;Additional-evaluation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Additional-evaluation&quot; aria-label=&quot;Additional evaluation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Additional evaluation&lt;/h2&gt;
&lt;p&gt;After training MobileNetV2 for seven more epochs, I checked class-level precision, recall, and F1 score.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Class&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Precision&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Recall&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;F1-Score&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Accessories&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.93&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.93&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.93&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LongPants&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.94&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.94&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.94&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LongSleeve&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.77&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.84&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Outerwear&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.95&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.79&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.86&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shoes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.98&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.97&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.98&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ShortPants&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.92&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.94&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.93&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ShortSleeve&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.90&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.90&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.90&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sleeveless&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.89&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.94&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.91&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;The final metrics were:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Accuracy&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;90.89%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weighted Precision&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;91%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weighted Recall&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;91%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weighted F1-Score&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;91%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;Visualization-results&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Visualization-results&quot; aria-label=&quot;Visualization results permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Visualization results&lt;/h2&gt;
&lt;p&gt;Over seven epochs, training accuracy reached 98.51% and validation accuracy reached 91.60%.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 507px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/ec23737dfba72be77bba01f5d2606987/f03ec/mobilenet-accuracy-curve.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 77.64705882352942%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAAsTAAALEwEAmpwYAAABz0lEQVR42p1U2Y4aMRDk/7+HJwa+gwfEIVjBJgO2x/ddUXt2NpBMlGRLKrntnimX3Wovcs7QWsFoBW00rLXQWkMp1UbOObbbbePxePzMEY3WjUpKEDabDRYUfL8zfGMS977H9XrFMAxwzjVxIs2FEG0MwTd67zBoA6kNei7hU0W3WmHBhUD/fkV1A87nM3a7XXNCDn5FqYCLBdwmCJswuJHKxZZfkaDWBpwxoGbEGJFSQgihxRN8yuAm4KEDlEtIpSKT+rRRKW3sug4LckLHmYONuYkIExFz+S1fP5ifBY0xEGIYP6jjrvQz0wGDjS9OJpFXuYpS8k9Buny67E9X1uIuJFKZE5lHeXWoIUiwJFTzAOvfkZ0ATI/qJOAVYB6vpHzQI6NB0Y+2bdetqSh6vMMg4ZwFt/HDVQWibT+glqcj0qUFIKiRXqIEOzqkKj8fmZsIFzP+FzNV5m2hVx51to5z+ENRSFAOA2wsrar/UoS/FMU2QTquTwVfwYsgYwx3xsBswlcxCbbWo0BKBetcazvvfWs7eoWmmEjx1JZEyk8xkbBer0eH9Cjs93vcbjccDoc2p5jWLpdLI63TS3Q6nVpMeXpEaE75t7c3LJdL/AAPidYXepCUGwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;MobileNetV2 training and validation accuracy&apos; title=&apos;&apos; src=&apos;/static/ec23737dfba72be77bba01f5d2606987/f03ec/mobilenet-accuracy-curve.png&apos; srcset=&apos;/static/ec23737dfba72be77bba01f5d2606987/e7570/mobilenet-accuracy-curve.png 170w,
/static/ec23737dfba72be77bba01f5d2606987/f46e7/mobilenet-accuracy-curve.png 340w,
/static/ec23737dfba72be77bba01f5d2606987/f03ec/mobilenet-accuracy-curve.png 507w&apos; sizes=&apos;(max-width: 507px) 100vw, 507px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;MobileNetV2 training and validation accuracy&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Both training loss and validation loss decreased steadily. There was some overfitting, but this dataset was close to the target shopping-mall image domain, so I did not treat it as a blocker at the time.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 484px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/a152e9d8e3e1697a6302b92c00eb5c8c/6ad3c/mobilenet-loss-curve.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 78.82352941176471%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAAsTAAALEwEAmpwYAAABrElEQVR42pVU2Y7bMAz0//9iHrpAgxaI5UP3rSlGchMHyO5mDRCmSGo09FCeAKCUgpzzp5ZSwuVygRACrbW+PudLedRNBNz2HbvSCMHD+9emtYa19ilmjMXfVeH39Q/EPGNdN0xSSuz7DmEiWsOPHnYGv2Odb/j18YHr9YqJVJ012GyEjaUXvovL9lutqLV2n11MPMUaA58KVht/BHgG5uOcw8R2t23rAaEDSn2b391aqwegHaIYY3pChQwd8lHe3ub6xJCidIYlIuWCxeY3ECqQXBcEdkYzM5AMnDFDFH7M5lVPimVGDqoXNDc2gBusONkCMJcD6Y2Wa4TTEhMVYsuDdoO3CmIRqAStY5T+557tC1Fo5yKfG2aTYVO9R1/A3CMPwJMorT1v5Vq61AfepXKI9EpjoJ4ZKqVAa6dr0gf2WOc6gBcTsbnY5zWX+nnLMcYhyjf3rnVwQPkC6TNWm6BDQcwN/vg0HZDFZMjLTnBaCOH+fphHihE5jbjzAdI43HYNIQ2EtLiJdQDyL8JZ5O+HPg+gzzfZ02eeDHgQfe9dP0TJHSWnLsiyLPgHs5DoL5p+WX8AAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;MobileNetV2 training and validation loss&apos; title=&apos;&apos; src=&apos;/static/a152e9d8e3e1697a6302b92c00eb5c8c/6ad3c/mobilenet-loss-curve.png&apos; srcset=&apos;/static/a152e9d8e3e1697a6302b92c00eb5c8c/e7570/mobilenet-loss-curve.png 170w,
/static/a152e9d8e3e1697a6302b92c00eb5c8c/f46e7/mobilenet-loss-curve.png 340w,
/static/a152e9d8e3e1697a6302b92c00eb5c8c/6ad3c/mobilenet-loss-curve.png 484w&apos; sizes=&apos;(max-width: 484px) 100vw, 484px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;MobileNetV2 training and validation loss&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The confusion matrix showed some confusion between LongSleeve and Outerwear. In ThatzFit&apos;s business logic, however, both can route to a tops virtual try-on flow. From the model&apos;s point of view, that is a misclassification. From the product routing point of view, it is not necessarily a critical failure.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/4eb37a7f0db1cc587942db1fe5481b6b/2561a/mobilenet-confusion-matrix.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 47.05882352941176%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAACUklEQVR42k2S60uTYRjG771tc++7g/OAC8+KFaiUWk47kYkGHtK5V5NSnNswD9M0bTKlrFyCiK0PlUJU9K36A/rSl/6a2DRCDQlB6Rd7C+rDj5uH++a57ut6Htnf3yfN0c8t+PWdjZev8PfdJhKJMTERJRicZCgQIRSeJhS8Qzg8TWA4wujYHLOzSwZzcw+ZjMRIJDaRvb09vm1v8ywe597ICPFolBcrK7Q3X0NEQTE5EclGJAuRnP9InzMNFCXdz6C+vhlJb5dMpqiuvoSIlaEbg2yur7E2P8PzmSARvRsRD4qSj00rQbWXoGklaPZSMp3lZLkqyHWfQrUU0XJVR3Z2dkilUpw+04RILlZrnqHmb7zCl+VHfJyd5nm4j+X+Thw2FyIWVLUAu6MMp1aGSyvH7ajALB6aLncjBwcHpFJb1NY0I5KHXSvFphaTpZ4gx1SFt8jLm/E+NsZuEl9Y5MmDxxQVnDREzZY8LLZCrLZCw3pDYxtyeHhoXHiurhWLko+qlmCxFnLMko+YPZjMHmPY7S5lI5Hg/dvXxGMLLEejeGvPI2LDmuExcr1wseOf5bqzLZiU4zgcZWhaqVFdznKcjjJUrRhVK8KkuBGxs7oY4/OHd6wvxrg/Pkp3SzsiZhq8rcju7i7JZJLKSq9hQ1HSL+dEkWwyTAWYJZ2p6y9uA0WxIiIEutr4tLHK0/m79LfrxGNLfzJMf52pqUU62m+h94bp6BxA10P4fQF69RDXuwbx9QTw6yF8/mH03hC+niHaOgaoqmklvrwKh0mOfnzlN49QV8GDGR4rAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;MobileNetV2 confusion matrix&apos; title=&apos;&apos; src=&apos;/static/4eb37a7f0db1cc587942db1fe5481b6b/ca1dc/mobilenet-confusion-matrix.png&apos; srcset=&apos;/static/4eb37a7f0db1cc587942db1fe5481b6b/e7570/mobilenet-confusion-matrix.png 170w,
/static/4eb37a7f0db1cc587942db1fe5481b6b/f46e7/mobilenet-confusion-matrix.png 340w,
/static/4eb37a7f0db1cc587942db1fe5481b6b/ca1dc/mobilenet-confusion-matrix.png 680w,
/static/4eb37a7f0db1cc587942db1fe5481b6b/02d09/mobilenet-confusion-matrix.png 1020w,
/static/4eb37a7f0db1cc587942db1fe5481b6b/2561a/mobilenet-confusion-matrix.png 1180w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;MobileNetV2 confusion matrix&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;Deployment-shape&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Deployment-shape&quot; aria-label=&quot;Deployment shape permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Deployment shape&lt;/h2&gt;
&lt;p&gt;I saved both the full model and the weights file so the server could load them.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;model&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;save&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mobilenet_v2_fashion_classifier.h5&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
model&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;save_weights&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mobilenet_v2_fashion_classifier.weights.h5&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This is simple for an early deployment. For real operation, model file versioning, fixed image preprocessing, fixed class label mapping, and reproducible inference environments would need to be managed together.&lt;/p&gt;
&lt;h2 id=&quot;What-I-learned&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-I-learned&quot; aria-label=&quot;What I learned permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What I learned&lt;/h2&gt;
&lt;p&gt;The important lesson from this experiment is that &quot;highest accuracy&quot; is not always &quot;best choice.&quot; DenseNet201 had higher test accuracy, but ThatzFit&apos;s bottleneck is virtual try-on, not garment classification. The classifier needs to be accurate enough and fast.&lt;/p&gt;
&lt;p&gt;Another lesson is that misclassification cost cannot be judged from model metrics alone. LongSleeve and Outerwear confusion is a loss in the classification report, but if both route into the same tops fitting flow, the product impact is smaller. Model evaluation should be read together with downstream product behavior.&lt;/p&gt;
&lt;h2 id=&quot;How-I-will-judge-this-next-time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-will-judge-this-next-time&quot; aria-label=&quot;How I will judge this next time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I will judge this next time&lt;/h2&gt;
&lt;p&gt;For models used in downstream routing, I will not choose by top accuracy alone. First, I will identify which mistakes become actual user failures, then separate critical failures from acceptable confusion.&lt;/p&gt;
&lt;p&gt;MobileNetV2 was the best-balanced choice between accuracy and inference time. The final test accuracy reached 90.89%, and weighted precision, recall, and F1 score were all around 91%. The next step is not just improving model metrics. It is measuring how often routing failures happen on real service inputs. If critical misclassifications accumulate in operation data, I would revisit class grouping and fallback policy before tuning augmentation or hyperparameters.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[의류 분류 모델을 정확도보다 라우팅 비용으로 선택하기]]></title><description><![CDATA[ThatzFit의 의류 분류기는 모델 성능을 보여주는 기능이 아니라 가상 피팅으로 들어가기 전 routing gate였다. 처음에는 test accuracy가 가장 높은 DenseNet20…]]></description><link>https://sewon.dev/mobilenetv2-fashion-classifier-decision/</link><guid isPermaLink="false">https://sewon.dev/mobilenetv2-fashion-classifier-decision/</guid><pubDate>Thu, 21 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/586f31226193826104a1fa4f11dfafbf/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB7ElEQVR42oWSz2sTQRTH41n04kHwJIIgoge1Fg+tFETqxR946l8lGGO1YqCoFL146KFQUDA9WdJoY+2vJN1kk2x+7G53s5PdnZ2d9+bJpsG0OeiXYXhz+Hzfe18mJWIs60xrsAOd6Ubf6PpGx292fd3oNzu+6wkiUnRco1cKUdluYDu+5fjmYd92/KPTMr22xXgkh0SiEacGVUop1WORy0TA5ZgxEcUAPBZhLCSAUkqEdsQaKOPEiVQKAHyfS4moCIFAJniEsFIv5lp7Lc/J6+W8Xi6Z7YBZ2tbybmHJbW0Px07spTyaaeent/Ojp4AkyVx7+7tZoXFJonC0819YEfkMTEvafVhaZyu/IiKqaHpm4d3bxU/pzJvnL7Pp1+9fLHx4lsl2utYIxkECiOpj3s2uORs6321zIvq8vHr5xr3bM0+vTNw/d/HW6fNXz1y4durspfWNzROdoxgjgV4IbgBEBIhEtPpl7ebUw7sP5mZm5yanH09OPboz/eT6xOzW770hLKWMYyxqrKgxCUikJKCExILzSK8b1XqzUNkvaKXkruxv1spRLIawUgoAQwGhAAkQhDzkAgAHISbr9OLwVTWX1r7O177NN3KLTt4DPoT/oSRIRAHygHVLXkcLrCq3a+GhRDgBq/Fv+H/9ARuIhm5PLWhpAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/586f31226193826104a1fa4f11dfafbf/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/586f31226193826104a1fa4f11dfafbf/e7570/situation-diagram.png 170w,
/static/586f31226193826104a1fa4f11dfafbf/f46e7/situation-diagram.png 340w,
/static/586f31226193826104a1fa4f11dfafbf/ca1dc/situation-diagram.png 680w,
/static/586f31226193826104a1fa4f11dfafbf/02d09/situation-diagram.png 1020w,
/static/586f31226193826104a1fa4f11dfafbf/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;ThatzFit의 의류 분류기는 모델 성능을 보여주는 기능이 아니라 가상 피팅으로 들어가기 전 routing gate였다. 처음에는 test accuracy가 가장 높은 DenseNet201을 고르는 것이 자연스러워 보였지만, 실제 제품 병목은 분류가 아니라 뒤의 virtual try-on이었다. 그래서 최종 판단은 &quot;가장 높은 정확도&quot;가 아니라 &quot;치명적 라우팅 실패를 줄이면서 가장 가볍게 지나가는 모델&quot;로 바뀌었다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: 의류 이미지를 상의/하의 등 적절한 가상 피팅 흐름으로 보내는 빠른 routing model이 필요했다.&lt;/li&gt;
&lt;li&gt;판단: 90% 안팎의 정확도를 threshold로 두고, 그 이후에는 downstream 비용과 추론 시간을 더 크게 봤다.&lt;/li&gt;
&lt;li&gt;결과: DenseNet201은 test accuracy가 더 높았지만 MobileNetV2가 validation accuracy, inference time, 학습 반복 비용의 균형이 좋았다.&lt;/li&gt;
&lt;li&gt;배운 점: 모델 선택은 leaderboard가 아니라 제품에서 그 모델이 틀렸을 때 어떤 일이 벌어지는지까지 포함한 의사결정이다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;ThatzFit에는 사용자가 올린 의류 이미지를 적절한 가상 피팅 흐름으로 보내기 위한 분류기가 필요했다. 예를 들어 바지 이미지는 하의 피팅 쪽으로, 셔츠나 아우터 이미지는 상의 피팅 쪽으로 보내야 한다.&lt;/p&gt;
&lt;p&gt;처음에는 간단한 CNN baseline을 만들고, 이후 ImageNet으로 사전 학습된 여러 전이 학습 모델을 비교했다. 최종 후보는 성능만 가장 높은 모델이 아니라 서비스 안에서 빠르게 판단할 수 있는 모델이어야 했다.&lt;/p&gt;
&lt;h2 id=&quot;문제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%A0%9C&quot; aria-label=&quot;문제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문제&lt;/h2&gt;
&lt;p&gt;의류 분류는 그 자체로 최종 사용자 경험의 핵심 작업은 아니다. 사용자가 실제로 기다리는 시간의 대부분은 가상 피팅 모델에서 발생한다. 그래서 분류기는 충분히 정확해야 하지만, 너무 무겁게 만들면 전체 피팅 흐름을 더 느리게 만든다.&lt;/p&gt;
&lt;p&gt;이번 실험의 기준은 두 가지였다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;정확도는 실무에서 쓸 수 있을 만큼 높아야 한다.&lt;/li&gt;
&lt;li&gt;정확도가 비슷하다면 추론 시간이 짧은 모델을 선택해야 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;데이터&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8D%B0%EC%9D%B4%ED%84%B0&quot; aria-label=&quot;데이터 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;데이터&lt;/h2&gt;
&lt;p&gt;데이터셋은 총 4,500장의 의류 이미지로 구성했다. 90%인 4,050장은 학습에 사용하고, 10%인 450장은 테스트에 사용했다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/a7ba62674a856f33cdafe8fca7ab938c/46d55/dataset-overview.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAACjElEQVR42q3T20vTYRjAca+66a6ki7yotBNkF11VN/0BCpaYZ6eiGbhCxZlz4QEz8UBWiqdCLDE1O16YhGCeYwSRG0qpm879fvvBpj/nqrnptvzGNguCoIJeeHgf3sOH5+XhDfH5fLjdbjweD1tbW/i++XBuOFkwGBBEAUEUMUsiy4KAKEmYBDOiKDI3N48oCmy6XWy63T8jZHt7G9PSMvFRCmoqbtFRfY+byhuMPRygLaMS3bMRhjKr+fhoCP/wOl347wSC4PiRe71eQvwLC3MG9u06SOqFLK7FFRAbGUN3cRPK/VEM13TRHhrNWMFdPuVdZza/AnmgH6mtFpdhhq/6CTwrFjyyxOaaNQiaFpeJCD1JTspVyhQaFGeT6S+/h+p4POO3+3hwOIkpdSvTCTl8UOQjNlaykBuPPNTHckMujvfDyFNPsetHg6BhwUj4nhNkJyspTVOTejqJ/vJ2Co9eZKyhl87weCbVLegVSnTZKqT2eoyqTOxvniO0FvFZN8aa9iXrMxOEbGw4WTKaOPQnsLgFfZoSXZYKqa0OY2F6EGxW/Qp6vB4WjUv/D/zrJ/8L6K8wYm8kl5KVlClKSD2z05RjwaZ0RiQwqW5Fr7iCLrsIqb0OoypjByz6TYXzBsJ2HyE9LoeSRBUJp+Lo1bSQdyCG0fpuOsJimShsQp94GZ0iH6m5msW8FOzDTxCb8vkyPcK69gWOmfEgKAoWos7FUl5cRaOmAXVaEYMtj6k7r0Lb9Yr+6ELe3elBr6liurQOc8995mpLsE6+xthVy6r+LRbtILZZbRD0fzubzYYsy9jtdlZXV3E6nYHc5XIF9sxmMxaLyJoss263s2Kz4XA4sFqtgdl/xrHu4DtFU9D8gKSIXwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;의류 분류 데이터셋 개요&apos; title=&apos;&apos; src=&apos;/static/a7ba62674a856f33cdafe8fca7ab938c/ca1dc/dataset-overview.png&apos; srcset=&apos;/static/a7ba62674a856f33cdafe8fca7ab938c/e7570/dataset-overview.png 170w,
/static/a7ba62674a856f33cdafe8fca7ab938c/f46e7/dataset-overview.png 340w,
/static/a7ba62674a856f33cdafe8fca7ab938c/ca1dc/dataset-overview.png 680w,
/static/a7ba62674a856f33cdafe8fca7ab938c/02d09/dataset-overview.png 1020w,
/static/a7ba62674a856f33cdafe8fca7ab938c/46d55/dataset-overview.png 1035w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;의류 분류 데이터셋 개요&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;분류 클래스는 8개였다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LongPants&lt;/li&gt;
&lt;li&gt;Sleeveless&lt;/li&gt;
&lt;li&gt;Outerwear&lt;/li&gt;
&lt;li&gt;Accessories&lt;/li&gt;
&lt;li&gt;ShortPants&lt;/li&gt;
&lt;li&gt;ShortSleeve&lt;/li&gt;
&lt;li&gt;Shoes&lt;/li&gt;
&lt;li&gt;LongSleeve&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/2f8002a8b1aecf9cdb3ce2836ca7e048/13ce4/dataset-examples.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 46.470588235294116%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAACY0lEQVR42h2RW1MSAQBG91/1Vg/9jab3HqyZNHvLmew202UqncoRVFDRSZAIE0RcDAQXW1aW5bIsN+OS4aIgOGZeOo1+M+cHnPMJLuciqqoxbx9HliIsLvn5thKk1z2k1TJpNBp0Oh3UZJJMJkNWy2Doefb2TEzTJKfn0HWder1OpVJBsNgchKMSw0MPef3iMXcGhxh49JTDTpv9/RaGYXBwcIDNPs1nlxvRv0Is/J3mnsnv300URUHT0shygmg0huD1LpGQExTSCuV8hmxOJ5XSOD4+5u/JCeL3CIqaQo1HSEZFDrtHHP85oWjoGNk0vV6PbrdLo75Do1ZB2BDXKBcKTI68wjs3RdM8QJK2cDgcxCJhnn2awuLxM9t/i4nbN4nGt/B4vERWPMjrAXZKWZq7deLr82ysTiMkFYVa9SculwsxGMQ0W1SrVWRZvmoTEEOEopskA27CbgdaOouqqshSjFw6xX5rj06njZaU0LY3ERx2G6u+ZeYmrCwtOlmYm8ftnMfzxUNwdY0vX704XW607RjlfAqr1crs7CxnZ2dI0ia1ao1svsTMzAzW0bcIRj5PsVAg6FsmKf9g/MNHbFYLuZyOpmlkshn0vIGaiFEpZBFFkVAoxNnpKaVikXK5ws9anbicYtUfQGg2m/za3eX1yBgT9jmWfT5Cosjg4APGLRYUOYGSULi4+Mf5+QV+3wobkShRaZ1YPIxRql/hdntwLjgRLh9qt9vYXQE+jNmulKamJrl2/QZ99/t5/uQ5796OcLmj3hG2STuuz4u8GR3m5fthCsVdSjtN+u8PcLfvHv8BXw5RQe0yh5cAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;의류 이미지 데이터 예시&apos; title=&apos;&apos; src=&apos;/static/2f8002a8b1aecf9cdb3ce2836ca7e048/ca1dc/dataset-examples.png&apos; srcset=&apos;/static/2f8002a8b1aecf9cdb3ce2836ca7e048/e7570/dataset-examples.png 170w,
/static/2f8002a8b1aecf9cdb3ce2836ca7e048/f46e7/dataset-examples.png 340w,
/static/2f8002a8b1aecf9cdb3ce2836ca7e048/ca1dc/dataset-examples.png 680w,
/static/2f8002a8b1aecf9cdb3ce2836ca7e048/02d09/dataset-examples.png 1020w,
/static/2f8002a8b1aecf9cdb3ce2836ca7e048/9d567/dataset-examples.png 1360w,
/static/2f8002a8b1aecf9cdb3ce2836ca7e048/13ce4/dataset-examples.png 2006w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;의류 이미지 데이터 예시&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;학습 과정에서는 과적합을 줄이기 위해 회전, 확대/축소, 이동, 좌우 반전 같은 이미지 증강을 적용했다.&lt;/p&gt;
&lt;h2 id=&quot;기준&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B8%B0%EC%A4%80&quot; aria-label=&quot;기준 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;기준&lt;/h2&gt;
&lt;p&gt;이번 의사결정에서는 지표를 두 종류로 나눴다.&lt;/p&gt;
&lt;p&gt;첫 번째는 임계값 기준 지표(threshold-based metric)다. 정확도는 90% 안팎이면 실무 적용 가능성이 있다고 봤다. 이 기준은 모델이 의류 라우팅을 크게 틀리지 않을 정도의 신뢰도를 보장하기 위한 최소선이다.&lt;/p&gt;
&lt;p&gt;두 번째는 최적화 기준 지표(optimization metric)다. 추론 시간은 낮을수록 좋다. ThatzFit의 전체 흐름에서는 이미지 분류보다 VITON 기반 가상 피팅이 훨씬 무겁기 때문에, 분류 단계는 가능한 한 빠르게 끝나야 한다.&lt;/p&gt;
&lt;p&gt;그래서 최종 선택 기준은 이렇게 잡았다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;정확도가 90%에 가깝거나 넘는 모델 중에서, 추론 시간이 가장 짧은 모델을 선택한다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;Baseline&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Baseline&quot; aria-label=&quot;Baseline permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Baseline&lt;/h2&gt;
&lt;p&gt;먼저 간단한 CNN baseline을 학습했다. 이 모델은 2개의 &lt;code class=&quot;language-text&quot;&gt;Conv2D&lt;/code&gt; 레이어와 &lt;code class=&quot;language-text&quot;&gt;MaxPooling&lt;/code&gt; 레이어를 사용했고, 마지막에 &lt;code class=&quot;language-text&quot;&gt;Dense&lt;/code&gt; 레이어로 8개 클래스를 분류했다.&lt;/p&gt;
&lt;p&gt;10 epoch 학습 결과는 다음과 같았다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Training Accuracy&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Validation Accuracy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CNN baseline&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;97.85%&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;65.85%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;학습 정확도와 검증 정확도 차이가 컸다. baseline은 빠르게 만들 수 있었지만, 실제 서비스에 넣을 모델로는 부족했다.&lt;/p&gt;
&lt;h2 id=&quot;모델-비교&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AA%A8%EB%8D%B8-%EB%B9%84%EA%B5%90&quot; aria-label=&quot;모델 비교 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;모델 비교&lt;/h2&gt;
&lt;p&gt;전이 학습 모델은 ImageNet pretrained weight를 사용하고, 분류 head만 새로 붙여 학습했다. 실제로는 13개 pretrained 모델을 비교했고, 아래는 성능이 준수했던 모델들이다.&lt;/p&gt;
&lt;p&gt;추론 시간은 같은 테스트셋 450장을 한 번 예측하는 데 걸린 전체 시간으로 기록했다. &lt;code class=&quot;language-text&quot;&gt;Per Image Time&lt;/code&gt;은 이 전체 시간을 테스트 이미지 수로 나눈 값이다. 따라서 아래 수치는 모델 간 상대 비교용이며, 실제 API 응답 시간은 서버 장비, 배치 크기, 이미지 전처리 방식에 따라 달라질 수 있다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;모델&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Val Accuracy&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Test Accuracy&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Training Time&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Inference Time&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Per Image Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DenseNet201&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8988&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.9067&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;111.38s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.3523s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.007450s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Xception&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8815&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.9000&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;62.02s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.5610s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.007913s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MobileNetV2&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.9062&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8956&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;48.22s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.3096s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.007355s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ResNet50V2&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8963&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8933&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;41.77s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.3293s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.007399s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DenseNet121&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8741&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.8822&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;86.92s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.3616s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.007470s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;DenseNet201은 test accuracy가 가장 높았다. 하지만 추론 시간과 학습 시간이 더 길었다. MobileNetV2는 test accuracy가 90%에 아주 살짝 못 미쳤지만, validation accuracy는 90%를 넘었고 추론 시간이 가장 짧았다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/f84203a42cbd2ed28e56a4c5a543f482/f2aa7/model-comparison-chart.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 52.352941176470594%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAKCAYAAAC0VX7mAAAACXBIWXMAAAsTAAALEwEAmpwYAAABeElEQVR42n2SWa7sIAxEeyMhhMGAGTJ2739n9WRHPdyf91EyYiidsnlkTgjk4YKFDRaLVDfDzAbTNP1fxqiMMZjnWeuDC6OVgp4jyDs465C8R3AOIUaklFREpGJmlXcO5BZEHzCb+WsYQgDHgKNlrJzARFhzRk2EUgq2bcO6rui9q47jULFAlIxChOg9lmX5GubgMTLh1Rk9EzgSzlaU7G2w77sav81fzyfG6ArTSkLwQdvwiDGipYBnZzVplHDUglEyWmu4rgvneaqhSNav1wujd2yc0bhqfLcssLPFw/ub7uoFO2eMnNASYXBG5YIxxodM4ouhEAvdaFWjS+9jCBpbDWuKuFq5+xYJGycIeW3tE7HWin3fcJwneq36JlNQMp30dygRlYLSyUCEsJaMWhnbdlMJpcSVKoMYrcE7j8XOSjX9fhshkcYKVY5R+1dLQu/jMxChfNcmrcj3XTWbpr//MEYHY6bPxn1o/lx8n+naWl3bn/1fw38mgiKwp9ve3AAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;전이 학습 모델 성능 비교&apos; title=&apos;&apos; src=&apos;/static/f84203a42cbd2ed28e56a4c5a543f482/ca1dc/model-comparison-chart.png&apos; srcset=&apos;/static/f84203a42cbd2ed28e56a4c5a543f482/e7570/model-comparison-chart.png 170w,
/static/f84203a42cbd2ed28e56a4c5a543f482/f46e7/model-comparison-chart.png 340w,
/static/f84203a42cbd2ed28e56a4c5a543f482/ca1dc/model-comparison-chart.png 680w,
/static/f84203a42cbd2ed28e56a4c5a543f482/f2aa7/model-comparison-chart.png 782w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;전이 학습 모델 성능 비교&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/acde966a28b070e7d9c9af53998a4c8e/e19bc/model-performance-chart.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 53.529411764705884%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAYAAAB/Ca1DAAAACXBIWXMAAAsTAAALEwEAmpwYAAACyklEQVR42h3R62/aBhTGYf7VaZX2YZNWTduXLUm1aNK6KukubZVGVdJtanNp02wkWxRKICRcWjUlCbijgG1s7hdjmxgM+AK/Cc7n55z3SG/gUtFRKzX0joCceEchm8fsGbiej+N4jEYjfNdBbZtITZOJ52A7Y0zLRDdMbHvIcGgzm1gsRmD1ROHkLIWUXSH62fe8Wv2dRjLBxHbwpw7TKUycIcfXFf5K1+aL2mGIZqbGdDphBlzfpwMcRU4J3I+ohGNJxMwK4VtLPFt+iPgyiHwZRVIfzw+MBybhbIWfDz7guSLZhQV2bq+T2NnEt4ZEctsslqrshyIENuMK8TcXSB82iC89IPjoGVLolKqQ5FB4gmB4MBnzVmqxcSRQV/d58+hHju7uknz+FFOoEEwt80BROAxHCRhmD03T6HTa6FqXQX+AaRgYuo7aaNKzh/MvLauP1u3S0TponQ7WjUXfsjC6Os1Wi7HrkkqlCHiex9j18H1/jma41+vhug6uM8SbTHE9D89z587zJ9gDex4+s/ZwyHjUn4eexxMEXr5v8Db9H/XSPhcrT/l3fZtq8h2GfMWWsME/zSGjG510qc1OTKKrxcn+ucbr+3u8//sFo5LGWeY3njdbBF9HZy3PSklQvL5H+NNFtn5Yo7h3SDcbYzG5zJOyzWRgcJJrsLqXoVnbJrb0Ba++3uT08S8MrsrsJr5hQVY4CJ8S+OlYIhQ5p3B5l9An3/HHnV/JvQjSvo6weH6HNfkGp9chJFS4t3tJrbxFdOFzdr9cJ/xwhZu0wvbZV3xbFNk/PiGQrxtUanW0do7qhYCSE9HLVXrtGplqBtUaw3RCy+yTU1roukRduEK9lmjJIlZbR6ymKQ4GnCWSBColCVEUyRdkpIpKtV4jL4oUihJyXqZRVlHLZRRZQpFFPuYliiWFSqOKpCh8LBbI50S6jQYHB0H+B3YI/P5K+m8kAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;모델별 정확도와 추론 시간 비교&apos; title=&apos;&apos; src=&apos;/static/acde966a28b070e7d9c9af53998a4c8e/ca1dc/model-performance-chart.png&apos; srcset=&apos;/static/acde966a28b070e7d9c9af53998a4c8e/e7570/model-performance-chart.png 170w,
/static/acde966a28b070e7d9c9af53998a4c8e/f46e7/model-performance-chart.png 340w,
/static/acde966a28b070e7d9c9af53998a4c8e/ca1dc/model-performance-chart.png 680w,
/static/acde966a28b070e7d9c9af53998a4c8e/02d09/model-performance-chart.png 1020w,
/static/acde966a28b070e7d9c9af53998a4c8e/e19bc/model-performance-chart.png 1346w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;모델별 정확도와 추론 시간 비교&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;MobileNetV2-선택-이유&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#MobileNetV2-%EC%84%A0%ED%83%9D-%EC%9D%B4%EC%9C%A0&quot; aria-label=&quot;MobileNetV2 선택 이유 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;MobileNetV2 선택 이유&lt;/h2&gt;
&lt;p&gt;MobileNetV2를 선택한 이유는 세 가지였다.&lt;/p&gt;
&lt;p&gt;첫째, 정확도가 충분히 높았다. MobileNetV2는 validation accuracy 90.62%, test accuracy 89.56%를 기록했다. 목표로 잡은 90% 기준에 거의 도달했고, 다른 모델들과 비교했을 때 실무적으로 큰 차이가 없었다.&lt;/p&gt;
&lt;p&gt;둘째, 추론 시간이 가장 짧았다. 전체 추론 시간(inference time)은 450장 기준 3.3096초, 이미지당 시간은 0.007355초였다. 이 분류기는 가상 피팅 전에 지나가는 라우팅 단계이므로 이 지점에서 시간을 아끼는 것이 전체 사용자 경험에 더 맞다.&lt;/p&gt;
&lt;p&gt;셋째, 학습 시간도 짧았다. 48.22초로 성능이 비슷한 모델들보다 가볍게 학습할 수 있었다. 실험 반복 속도와 운영 비용을 생각하면 이 점도 중요했다.&lt;/p&gt;
&lt;h2 id=&quot;추가-평가&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B6%94%EA%B0%80-%ED%8F%89%EA%B0%80&quot; aria-label=&quot;추가 평가 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;추가 평가&lt;/h2&gt;
&lt;p&gt;MobileNetV2를 7 epoch 추가 학습한 뒤 class별 precision, recall, F1-score를 확인했다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Class&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Precision&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Recall&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;F1-Score&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Accessories&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.93&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.93&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.93&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LongPants&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.94&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.94&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.94&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;LongSleeve&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.77&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.84&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.80&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Outerwear&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.95&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.79&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.86&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shoes&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.98&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.97&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.98&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ShortPants&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.92&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.94&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.93&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ShortSleeve&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.90&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.90&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.90&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sleeveless&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.89&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.94&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.91&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;최종 지표는 다음과 같았다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Result&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Accuracy&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;90.89%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weighted Precision&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;91%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weighted Recall&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;91%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Weighted F1-Score&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;91%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;시각화-결과&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%8B%9C%EA%B0%81%ED%99%94-%EA%B2%B0%EA%B3%BC&quot; aria-label=&quot;시각화 결과 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;시각화 결과&lt;/h2&gt;
&lt;p&gt;7 epoch 동안 학습 정확도는 98.51%, 검증 정확도는 91.60%에 도달했다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 507px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/ec23737dfba72be77bba01f5d2606987/f03ec/mobilenet-accuracy-curve.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 77.64705882352942%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAAsTAAALEwEAmpwYAAABz0lEQVR42p1U2Y4aMRDk/7+HJwa+gwfEIVjBJgO2x/ddUXt2NpBMlGRLKrntnimX3Wovcs7QWsFoBW00rLXQWkMp1UbOObbbbePxePzMEY3WjUpKEDabDRYUfL8zfGMS977H9XrFMAxwzjVxIs2FEG0MwTd67zBoA6kNei7hU0W3WmHBhUD/fkV1A87nM3a7XXNCDn5FqYCLBdwmCJswuJHKxZZfkaDWBpwxoGbEGJFSQgihxRN8yuAm4KEDlEtIpSKT+rRRKW3sug4LckLHmYONuYkIExFz+S1fP5ifBY0xEGIYP6jjrvQz0wGDjS9OJpFXuYpS8k9Buny67E9X1uIuJFKZE5lHeXWoIUiwJFTzAOvfkZ0ATI/qJOAVYB6vpHzQI6NB0Y+2bdetqSh6vMMg4ZwFt/HDVQWibT+glqcj0qUFIKiRXqIEOzqkKj8fmZsIFzP+FzNV5m2hVx51to5z+ENRSFAOA2wsrar/UoS/FMU2QTquTwVfwYsgYwx3xsBswlcxCbbWo0BKBetcazvvfWs7eoWmmEjx1JZEyk8xkbBer0eH9Cjs93vcbjccDoc2p5jWLpdLI63TS3Q6nVpMeXpEaE75t7c3LJdL/AAPidYXepCUGwAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;MobileNetV2 학습 정확도와 검증 정확도&apos; title=&apos;&apos; src=&apos;/static/ec23737dfba72be77bba01f5d2606987/f03ec/mobilenet-accuracy-curve.png&apos; srcset=&apos;/static/ec23737dfba72be77bba01f5d2606987/e7570/mobilenet-accuracy-curve.png 170w,
/static/ec23737dfba72be77bba01f5d2606987/f46e7/mobilenet-accuracy-curve.png 340w,
/static/ec23737dfba72be77bba01f5d2606987/f03ec/mobilenet-accuracy-curve.png 507w&apos; sizes=&apos;(max-width: 507px) 100vw, 507px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;MobileNetV2 학습 정확도와 검증 정확도&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;손실 함수는 학습 손실과 검증 손실 모두 안정적으로 감소했다. 다만 약간의 과적합은 보였다. 이 데이터는 실제 서비스에서 들어올 쇼핑몰 도메인 이미지와 가까운 target data라서, 당시에는 이 정도 과적합을 치명적 문제로 보지는 않았다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 484px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/a152e9d8e3e1697a6302b92c00eb5c8c/6ad3c/mobilenet-loss-curve.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 78.82352941176471%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAAsTAAALEwEAmpwYAAABrElEQVR42pVU2Y7bMAz0//9iHrpAgxaI5UP3rSlGchMHyO5mDRCmSGo09FCeAKCUgpzzp5ZSwuVygRACrbW+PudLedRNBNz2HbvSCMHD+9emtYa19ilmjMXfVeH39Q/EPGNdN0xSSuz7DmEiWsOPHnYGv2Odb/j18YHr9YqJVJ012GyEjaUXvovL9lutqLV2n11MPMUaA58KVht/BHgG5uOcw8R2t23rAaEDSn2b391aqwegHaIYY3pChQwd8lHe3ub6xJCidIYlIuWCxeY3ECqQXBcEdkYzM5AMnDFDFH7M5lVPimVGDqoXNDc2gBusONkCMJcD6Y2Wa4TTEhMVYsuDdoO3CmIRqAStY5T+557tC1Fo5yKfG2aTYVO9R1/A3CMPwJMorT1v5Vq61AfepXKI9EpjoJ4ZKqVAa6dr0gf2WOc6gBcTsbnY5zWX+nnLMcYhyjf3rnVwQPkC6TNWm6BDQcwN/vg0HZDFZMjLTnBaCOH+fphHihE5jbjzAdI43HYNIQ2EtLiJdQDyL8JZ5O+HPg+gzzfZ02eeDHgQfe9dP0TJHSWnLsiyLPgHs5DoL5p+WX8AAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;MobileNetV2 학습 손실과 검증 손실&apos; title=&apos;&apos; src=&apos;/static/a152e9d8e3e1697a6302b92c00eb5c8c/6ad3c/mobilenet-loss-curve.png&apos; srcset=&apos;/static/a152e9d8e3e1697a6302b92c00eb5c8c/e7570/mobilenet-loss-curve.png 170w,
/static/a152e9d8e3e1697a6302b92c00eb5c8c/f46e7/mobilenet-loss-curve.png 340w,
/static/a152e9d8e3e1697a6302b92c00eb5c8c/6ad3c/mobilenet-loss-curve.png 484w&apos; sizes=&apos;(max-width: 484px) 100vw, 484px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;MobileNetV2 학습 손실과 검증 손실&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;혼동 행렬에서는 LongSleeve와 Outerwear 사이에 약간의 혼동이 있었다. 하지만 ThatzFit의 비즈니스 로직에서는 둘 다 상의 가상 피팅 흐름으로 보내질 수 있다. 즉, 모델 관점에서는 오분류지만 서비스 라우팅 관점에서는 치명적인 실패가 아니다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/4eb37a7f0db1cc587942db1fe5481b6b/2561a/mobilenet-confusion-matrix.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 47.05882352941176%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAJCAYAAAAywQxIAAAACXBIWXMAAAsTAAALEwEAmpwYAAACUklEQVR42k2S60uTYRjG771tc++7g/OAC8+KFaiUWk47kYkGHtK5V5NSnNswD9M0bTKlrFyCiK0PlUJU9K36A/rSl/6a2DRCDQlB6Rd7C+rDj5uH++a57ut6Htnf3yfN0c8t+PWdjZev8PfdJhKJMTERJRicZCgQIRSeJhS8Qzg8TWA4wujYHLOzSwZzcw+ZjMRIJDaRvb09vm1v8ywe597ICPFolBcrK7Q3X0NEQTE5EclGJAuRnP9InzMNFCXdz6C+vhlJb5dMpqiuvoSIlaEbg2yur7E2P8PzmSARvRsRD4qSj00rQbWXoGklaPZSMp3lZLkqyHWfQrUU0XJVR3Z2dkilUpw+04RILlZrnqHmb7zCl+VHfJyd5nm4j+X+Thw2FyIWVLUAu6MMp1aGSyvH7ajALB6aLncjBwcHpFJb1NY0I5KHXSvFphaTpZ4gx1SFt8jLm/E+NsZuEl9Y5MmDxxQVnDREzZY8LLZCrLZCw3pDYxtyeHhoXHiurhWLko+qlmCxFnLMko+YPZjMHmPY7S5lI5Hg/dvXxGMLLEejeGvPI2LDmuExcr1wseOf5bqzLZiU4zgcZWhaqVFdznKcjjJUrRhVK8KkuBGxs7oY4/OHd6wvxrg/Pkp3SzsiZhq8rcju7i7JZJLKSq9hQ1HSL+dEkWwyTAWYJZ2p6y9uA0WxIiIEutr4tLHK0/m79LfrxGNLfzJMf52pqUU62m+h94bp6BxA10P4fQF69RDXuwbx9QTw6yF8/mH03hC+niHaOgaoqmklvrwKh0mOfnzlN49QV8GDGR4rAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;MobileNetV2 혼동 행렬&apos; title=&apos;&apos; src=&apos;/static/4eb37a7f0db1cc587942db1fe5481b6b/ca1dc/mobilenet-confusion-matrix.png&apos; srcset=&apos;/static/4eb37a7f0db1cc587942db1fe5481b6b/e7570/mobilenet-confusion-matrix.png 170w,
/static/4eb37a7f0db1cc587942db1fe5481b6b/f46e7/mobilenet-confusion-matrix.png 340w,
/static/4eb37a7f0db1cc587942db1fe5481b6b/ca1dc/mobilenet-confusion-matrix.png 680w,
/static/4eb37a7f0db1cc587942db1fe5481b6b/02d09/mobilenet-confusion-matrix.png 1020w,
/static/4eb37a7f0db1cc587942db1fe5481b6b/2561a/mobilenet-confusion-matrix.png 1180w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;MobileNetV2 혼동 행렬&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;배포-형태&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%ED%8F%AC-%ED%98%95%ED%83%9C&quot; aria-label=&quot;배포 형태 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배포 형태&lt;/h2&gt;
&lt;p&gt;모델은 서버에서 로드할 수 있도록 전체 모델과 weight 파일을 각각 저장했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;python&quot;&gt;&lt;pre class=&quot;language-python&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;model&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;save&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mobilenet_v2_fashion_classifier.h5&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;
model&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;save_weights&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&quot;mobilenet_v2_fashion_classifier.weights.h5&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 방식은 배포 초기에 단순하다. 다만 실제 운영으로 가려면 모델 파일 버전 관리, 입력 이미지 전처리 고정, 클래스 라벨 매핑(class label mapping) 고정, 추론 환경(inference environment) 재현성이 같이 관리되어야 한다.&lt;/p&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;이 실험에서 중요한 점은 “가장 높은 정확도”가 항상 “가장 좋은 선택”은 아니라는 것이다. DenseNet201은 test accuracy가 더 높았지만 ThatzFit의 병목은 의류 분류가 아니라 가상 피팅이다. 분류기는 충분히 정확하고 빨라야 한다.&lt;/p&gt;
&lt;p&gt;또 하나의 포인트는 오분류의 비용을 모델 지표만으로 판단하면 안 된다는 점이다. LongSleeve와 Outerwear 혼동은 분류 리포트(classification report)에서는 손실이지만, 둘 다 상의 피팅으로 이어진다면 제품 영향(product impact)은 작다. 모델 평가는 항상 이후 제품 동작(downstream behavior)과 같이 봐야 한다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;의류 분류처럼 downstream routing에 쓰이는 모델은 최고 정확도만으로 고르지 않는다. 먼저 어떤 오분류가 실제 사용자 실패로 이어지는지 보고, 치명적인 실패와 허용 가능한 혼동을 나눈다.&lt;/p&gt;
&lt;p&gt;MobileNetV2는 정확도와 추론 시간 사이에서 가장 균형 잡힌 선택이었다. 최종 테스트 정확도는 90.89%까지 확인했고, weighted precision, recall, F1-score도 모두 91% 수준이었다. 다음 단계는 모델 성능을 더 올리는 것보다, 실제 서비스 입력에서 라우팅 실패가 얼마나 발생하는지 보는 것이다. 운영 데이터에서 치명적인 오분류가 쌓이면 데이터 증강이나 하이퍼파라미터 튜닝보다 먼저 클래스 묶음(class grouping)과 fallback 정책을 다시 본다.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Treat PostgreSQL Docker Env Vars as Initialization Input, Not Live Config]]></title><description><![CDATA[The new environment variables were visible inside the PostgreSQL container, but Spring Boot kept failing with the old password. At first, I…]]></description><link>https://sewon.dev/en/postgresql-docker-volume-initialization/</link><guid isPermaLink="false">https://sewon.dev/en/postgresql-docker-volume-initialization/</guid><pubDate>Thu, 21 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c083822477d0e552addaec4cd4e98aae/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB0UlEQVR42nVRS2sTYRTtwh/gRhA3FqSruhOsS3f1F7lzLwqCuBT8EypaKNHGTm2SNklTE9PUkEzm/chMZr6Z7/2QyYyVhPZw+eB+3MM599wNysTUTCcmMJzMDaDl5m4IHT+fmEC3gD9HpgsdH1keXKRUrWJDCOkFiesnQZiG8zSMsiiB8zgLQuCFIAU4yxnIaAYZJkJKdVUFWV0DWb2Cy3Kq7FdRkWlkIXuAnN/Mv5SMFHOMcdelsxm3bYmxugEFOeh8vPj0arr/Ljl+z8IZJ5hbRtw9mzRa3klb2FYpLOSylq7/k1lsQPucBUMxv5AUFd+EENOEoxHWdYnQzcpSEi9Etgctjzq+Kk0uVxIAqH9LQ0606E89utTScSPTkaAVOWh39B/a7Ogn7PVk4HNCGCYEpbHRxVmAKcWETBL/zXDv9eDL22ntQ9RcMFiRFYIK5gpCmWWSsSpbNF7Yezz/pZRQSnEpfAY8BlyaejTlUqyfqvRoWE77bNDt9VvH31snp+1u/7Rz3h+MuBDXpH11eEaLTZ6/eHn3wc72zrP7D5/e23pyZ/PRrdtb24934yQpgpBiJe015eFovP9Nq2uNg8NGXWvWDo4+f63VD5uM8TXlv1T3lqSrowReAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Situation diagram&apos; title=&apos;&apos; src=&apos;/static/c083822477d0e552addaec4cd4e98aae/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/c083822477d0e552addaec4cd4e98aae/e7570/situation-diagram.png 170w,
/static/c083822477d0e552addaec4cd4e98aae/f46e7/situation-diagram.png 340w,
/static/c083822477d0e552addaec4cd4e98aae/ca1dc/situation-diagram.png 680w,
/static/c083822477d0e552addaec4cd4e98aae/02d09/situation-diagram.png 1020w,
/static/c083822477d0e552addaec4cd4e98aae/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Situation diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The new environment variables were visible inside the PostgreSQL container, but Spring Boot kept failing with the old password. At first, I suspected &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;, Docker Compose, and networking. The key log line was &lt;code class=&quot;language-text&quot;&gt;Skipping initialization&lt;/code&gt;. The issue was that &lt;code class=&quot;language-text&quot;&gt;POSTGRES_*&lt;/code&gt; values are not live settings that rewrite database state on every start. They are initialization inputs used only when the data directory is empty.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: I changed PostgreSQL environment variables in Docker Compose, but the Spring Boot server still failed database authentication.&lt;/li&gt;
&lt;li&gt;Judgment: The important state was not the container env. It was the PostgreSQL data directory and the named volume.&lt;/li&gt;
&lt;li&gt;Cause: An existing named volume was reused, so PostgreSQL skipped database initialization.&lt;/li&gt;
&lt;li&gt;Fix: In development, I removed the volume with &lt;code class=&quot;language-text&quot;&gt;docker compose down -v&lt;/code&gt; and recreated the stack. In production, user/password changes must be done explicitly with SQL.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;I was running &lt;code class=&quot;language-text&quot;&gt;nginx&lt;/code&gt;, PostgreSQL, and a Spring Boot server together with Docker Compose. The PostgreSQL container received &lt;code class=&quot;language-text&quot;&gt;POSTGRES_USER&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;POSTGRES_PASSWORD&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;POSTGRES_DB&lt;/code&gt; as environment variables, and the Spring Boot server read the same &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt; values.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;3.8&quot;&lt;/span&gt;

&lt;span class=&quot;token key atrule&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;nginx&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;proxy
    &lt;span class=&quot;token key atrule&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ./nginx
      &lt;span class=&quot;token key atrule&quot;&gt;dockerfile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Dockerfile
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;proxy&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1.0.0&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;compose
    &lt;span class=&quot;token key atrule&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;80:80&quot;&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;network

  &lt;span class=&quot;token key atrule&quot;&gt;postgresdb&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;db
    &lt;span class=&quot;token key atrule&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ./postgresDB
      &lt;span class=&quot;token key atrule&quot;&gt;dockerfile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Dockerfile
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;db&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1.0.0&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;compose
    &lt;span class=&quot;token key atrule&quot;&gt;environment&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;POSTGRES_USER&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; $&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;DB_USERNAME&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; $&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;DB_PASSWORD&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;POSTGRES_DB&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; $&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;DB_NAME&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;5432:5432&quot;&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; postgres_data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;/var/lib/postgresql/data
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;network

  &lt;span class=&quot;token key atrule&quot;&gt;web-application-server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;was
    &lt;span class=&quot;token key atrule&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ./web&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;application&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;server
      &lt;span class=&quot;token key atrule&quot;&gt;dockerfile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Dockerfile
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;was&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1.0.0&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;compose
    &lt;span class=&quot;token key atrule&quot;&gt;env_file&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; .env
    &lt;span class=&quot;token key atrule&quot;&gt;depends_on&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; postgresdb
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;network

&lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;postgres_data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;

&lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;app-network&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;driver&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; bridge&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;On the surface, nothing looked wrong. When I checked &lt;code class=&quot;language-text&quot;&gt;env&lt;/code&gt; inside the PostgreSQL container, the environment variables were present. So my first suspicion was the Spring Boot configuration or the Docker network.&lt;/p&gt;
&lt;h2 id=&quot;Problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Problem&quot; aria-label=&quot;Problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;The Spring Boot server kept failing PostgreSQL authentication.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;app-was | org.hibernate.exception.GenericJDBCException:
app-was |   unable to obtain isolated JDBC connection
app-was |   [FATAL: password authentication failed for user &quot;app_user&quot;]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;When I entered the PostgreSQL container and checked the actual users and databases, they had not been initialized with the values I expected. The container had the environment variables, but the database state did not reflect them.&lt;/p&gt;
&lt;p&gt;At first this looked strange. If the environment variables were present, I expected PostgreSQL to have created the user and database from those values.&lt;/p&gt;
&lt;h2 id=&quot;The-Clue&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Clue&quot; aria-label=&quot;The Clue permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Clue&lt;/h2&gt;
&lt;p&gt;The key message was in the logs.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;app-db | PostgreSQL Database directory appears to contain a database; Skipping initialization&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;PostgreSQL was not ignoring the environment variables. It was not running the initialization process again.&lt;/p&gt;
&lt;h2 id=&quot;Why-This-Happened&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-This-Happened&quot; aria-label=&quot;Why This Happened permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why This Happened&lt;/h2&gt;
&lt;p&gt;In the official PostgreSQL Docker image, Docker-specific environment variables such as &lt;code class=&quot;language-text&quot;&gt;POSTGRES_USER&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;POSTGRES_PASSWORD&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;POSTGRES_DB&lt;/code&gt; are used to create the initial database when the data directory is empty.&lt;/p&gt;
&lt;p&gt;When the container starts with an empty data directory, &lt;code class=&quot;language-text&quot;&gt;initdb&lt;/code&gt; runs. That is when the default user and database are created. Scripts under &lt;code class=&quot;language-text&quot;&gt;/docker-entrypoint-initdb.d/&lt;/code&gt;, such as &lt;code class=&quot;language-text&quot;&gt;.sql&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.sql.gz&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;.sh&lt;/code&gt; files, also run during this initialization step.&lt;/p&gt;
&lt;p&gt;If the data directory already contains PostgreSQL data, initialization is skipped. In that case, changing &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt; or &lt;code class=&quot;language-text&quot;&gt;docker-compose.yml&lt;/code&gt; later does not automatically change the existing database user or password.&lt;/p&gt;
&lt;p&gt;The official image documentation states the same behavior: these Docker-specific environment variables affect a container started with an empty data directory, while an existing database is left as-is on startup.&lt;/p&gt;
&lt;h2 id=&quot;Cause&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Cause&quot; aria-label=&quot;Cause permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Cause&lt;/h2&gt;
&lt;p&gt;During debugging, I ran &lt;code class=&quot;language-text&quot;&gt;docker compose up&lt;/code&gt; multiple times. The named volume created on the first run, &lt;code class=&quot;language-text&quot;&gt;postgres_data&lt;/code&gt;, kept being reused.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; postgres_data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;/var/lib/postgresql/data&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Removing the container does not automatically remove a named volume. So even when a new container started, PostgreSQL saw a data directory that already contained an initialized database.&lt;/p&gt;
&lt;p&gt;The sequence was:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;/var/lib/postgresql/data&lt;/code&gt; already contains data.&lt;/li&gt;
&lt;li&gt;PostgreSQL treats it as an initialized database.&lt;/li&gt;
&lt;li&gt;Initialization based on &lt;code class=&quot;language-text&quot;&gt;POSTGRES_USER&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;POSTGRES_PASSWORD&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;POSTGRES_DB&lt;/code&gt; is skipped.&lt;/li&gt;
&lt;li&gt;The old user/password remain, so they no longer match the Spring Boot connection settings.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;Fix&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Fix&quot; aria-label=&quot;Fix permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Fix&lt;/h2&gt;
&lt;p&gt;This was a development environment, and I did not need to preserve the existing data. I brought the Compose stack down with the volume, then started it again.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose down &lt;span class=&quot;token parameter variable&quot;&gt;-v&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose up &lt;span class=&quot;token parameter variable&quot;&gt;--build&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The &lt;code class=&quot;language-text&quot;&gt;-v&lt;/code&gt; option also removes named volumes created by Compose. After that, a new volume was created, the PostgreSQL data directory was empty, and environment-variable-based initialization ran again.&lt;/p&gt;
&lt;p&gt;After this, Spring Boot JPA connected to PostgreSQL normally.&lt;/p&gt;
&lt;h2 id=&quot;Production-Caution&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Production-Caution&quot; aria-label=&quot;Production Caution permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Production Caution&lt;/h2&gt;
&lt;p&gt;In development, &lt;code class=&quot;language-text&quot;&gt;docker compose down -v&lt;/code&gt; is a fast fix. In production or shared development databases, it is dangerous because it deletes the data stored in the volume.&lt;/p&gt;
&lt;p&gt;If a production user or password has to change, do not remove the volume. Change it explicitly with SQL.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sql&quot;&gt;&lt;pre class=&quot;language-sql&quot;&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;ALTER&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;USER&lt;/span&gt; app_user &lt;span class=&quot;token keyword&quot;&gt;WITH&lt;/span&gt; PASSWORD &lt;span class=&quot;token string&quot;&gt;&apos;new-password&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Or create the required user and grant privileges.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sql&quot;&gt;&lt;pre class=&quot;language-sql&quot;&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;USER&lt;/span&gt; app_user &lt;span class=&quot;token keyword&quot;&gt;WITH&lt;/span&gt; PASSWORD &lt;span class=&quot;token string&quot;&gt;&apos;new-password&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;GRANT&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;ALL&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;PRIVILEGES&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;ON&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;DATABASE&lt;/span&gt; app_db &lt;span class=&quot;token keyword&quot;&gt;TO&lt;/span&gt; app_user&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;Lesson&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Lesson&quot; aria-label=&quot;Lesson permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Lesson&lt;/h2&gt;
&lt;p&gt;PostgreSQL Docker container environment variables are not settings that are reapplied every time the container starts. They are inputs used to create the database at first initialization.&lt;/p&gt;
&lt;p&gt;So when debugging a database through Docker Compose, the container is not enough. The volume state has to be checked too. &lt;code class=&quot;language-text&quot;&gt;docker compose down&lt;/code&gt; alone does not reset data. If the named volume remains, PostgreSQL keeps using the existing database.&lt;/p&gt;
&lt;p&gt;The rule I keep now is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Container environment variables are the values passed into the current container.&lt;/li&gt;
&lt;li&gt;PostgreSQL users and passwords are database state stored in the data directory.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;POSTGRES_*&lt;/code&gt; environment variables are applied only when an empty data directory is initialized.&lt;/li&gt;
&lt;li&gt;To fully recreate a development database, remove the volume too.&lt;/li&gt;
&lt;li&gt;For production databases, use SQL migrations or privilege changes instead of deleting volumes.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;How-I-Would-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Would-Judge-This-Next-Time&quot; aria-label=&quot;How I Would Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Would Judge This Next Time&lt;/h2&gt;
&lt;p&gt;If changing a DB container env does not change state, I first ask whether that env is runtime config or initialization input. For services like PostgreSQL, where the data directory is the source of truth, I check the volume before the container.&lt;/p&gt;
&lt;p&gt;In development, &lt;code class=&quot;language-text&quot;&gt;down -v&lt;/code&gt; can be a quick reset. In production, the same command is data deletion. Production changes belong in SQL migrations or explicit permission changes.&lt;/p&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://hub.docker.com/_/postgres&quot;&gt;Postgres Docker Official Image&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/guides/pre-seeding/&quot;&gt;Docker Docs: Pre-seeding database containers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[PostgreSQL Docker env를 설정값이 아니라 초기화 입력으로 보기]]></title><description><![CDATA[PostgreSQL 컨테이너 안에는 새 env가 보이는데 Spring Boot는 계속 이전 비밀번호로 실패했다. 처음에는 , Docker Compose, 네트워크 설정을 의심했지만 핵심 로그는 이었다.  값은 매번 DB…]]></description><link>https://sewon.dev/postgresql-docker-volume-initialization/</link><guid isPermaLink="false">https://sewon.dev/postgresql-docker-volume-initialization/</guid><pubDate>Thu, 21 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c083822477d0e552addaec4cd4e98aae/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB0UlEQVR42nVRS2sTYRTtwh/gRhA3FqSruhOsS3f1F7lzLwqCuBT8EypaKNHGTm2SNklTE9PUkEzm/chMZr6Z7/2QyYyVhPZw+eB+3MM599wNysTUTCcmMJzMDaDl5m4IHT+fmEC3gD9HpgsdH1keXKRUrWJDCOkFiesnQZiG8zSMsiiB8zgLQuCFIAU4yxnIaAYZJkJKdVUFWV0DWb2Cy3Kq7FdRkWlkIXuAnN/Mv5SMFHOMcdelsxm3bYmxugEFOeh8vPj0arr/Ljl+z8IZJ5hbRtw9mzRa3klb2FYpLOSylq7/k1lsQPucBUMxv5AUFd+EENOEoxHWdYnQzcpSEi9Etgctjzq+Kk0uVxIAqH9LQ0606E89utTScSPTkaAVOWh39B/a7Ogn7PVk4HNCGCYEpbHRxVmAKcWETBL/zXDv9eDL22ntQ9RcMFiRFYIK5gpCmWWSsSpbNF7Yezz/pZRQSnEpfAY8BlyaejTlUqyfqvRoWE77bNDt9VvH31snp+1u/7Rz3h+MuBDXpH11eEaLTZ6/eHn3wc72zrP7D5/e23pyZ/PRrdtb24934yQpgpBiJe015eFovP9Nq2uNg8NGXWvWDo4+f63VD5uM8TXlv1T3lqSrowReAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/c083822477d0e552addaec4cd4e98aae/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/c083822477d0e552addaec4cd4e98aae/e7570/situation-diagram.png 170w,
/static/c083822477d0e552addaec4cd4e98aae/f46e7/situation-diagram.png 340w,
/static/c083822477d0e552addaec4cd4e98aae/ca1dc/situation-diagram.png 680w,
/static/c083822477d0e552addaec4cd4e98aae/02d09/situation-diagram.png 1020w,
/static/c083822477d0e552addaec4cd4e98aae/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;PostgreSQL 컨테이너 안에는 새 env가 보이는데 Spring Boot는 계속 이전 비밀번호로 실패했다. 처음에는 &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;, Docker Compose, 네트워크 설정을 의심했지만 핵심 로그는 &lt;code class=&quot;language-text&quot;&gt;Skipping initialization&lt;/code&gt;이었다. &lt;code class=&quot;language-text&quot;&gt;POSTGRES_*&lt;/code&gt; 값은 매번 DB 상태를 바꾸는 설정값이 아니라 빈 data directory를 처음 만들 때만 쓰이는 초기화 입력이라는 점을 놓친 문제였다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: Docker Compose에서 PostgreSQL 환경 변수를 바꿨는데 Spring Boot 서버의 DB 인증이 계속 실패했다.&lt;/li&gt;
&lt;li&gt;판단: 컨테이너 env가 아니라 PostgreSQL data directory와 named volume 상태를 봐야 했다.&lt;/li&gt;
&lt;li&gt;원인: 기존 named volume이 재사용되면서 PostgreSQL이 데이터베이스 초기화를 건너뛰었다.&lt;/li&gt;
&lt;li&gt;해결: 개발 환경에서는 &lt;code class=&quot;language-text&quot;&gt;docker compose down -v&lt;/code&gt;로 volume까지 삭제한 뒤 다시 올렸고, 운영 환경에서는 SQL로 사용자/비밀번호를 변경해야 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;Docker Compose로 &lt;code class=&quot;language-text&quot;&gt;nginx&lt;/code&gt;, PostgreSQL, Spring Boot 서버를 한 번에 올리고 있었다. PostgreSQL 컨테이너에는 &lt;code class=&quot;language-text&quot;&gt;POSTGRES_USER&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;POSTGRES_PASSWORD&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;POSTGRES_DB&lt;/code&gt;를 환경 변수로 넘겼고 Spring Boot 서버도 같은 &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt; 값을 읽도록 구성했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;version&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;3.8&quot;&lt;/span&gt;

&lt;span class=&quot;token key atrule&quot;&gt;services&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;nginx&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;proxy
    &lt;span class=&quot;token key atrule&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ./nginx
      &lt;span class=&quot;token key atrule&quot;&gt;dockerfile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Dockerfile
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;proxy&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1.0.0&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;compose
    &lt;span class=&quot;token key atrule&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;80:80&quot;&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;network

  &lt;span class=&quot;token key atrule&quot;&gt;postgresdb&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;db
    &lt;span class=&quot;token key atrule&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ./postgresDB
      &lt;span class=&quot;token key atrule&quot;&gt;dockerfile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Dockerfile
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;db&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1.0.0&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;compose
    &lt;span class=&quot;token key atrule&quot;&gt;environment&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;POSTGRES_USER&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; $&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;DB_USERNAME&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; $&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;DB_PASSWORD&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;POSTGRES_DB&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; $&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;DB_NAME&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;ports&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;5432:5432&quot;&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; postgres_data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;/var/lib/postgresql/data
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;network

  &lt;span class=&quot;token key atrule&quot;&gt;web-application-server&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;container_name&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;was
    &lt;span class=&quot;token key atrule&quot;&gt;build&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token key atrule&quot;&gt;context&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; ./web&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;application&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;server
      &lt;span class=&quot;token key atrule&quot;&gt;dockerfile&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; Dockerfile
    &lt;span class=&quot;token key atrule&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;was&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;1.0.0&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;compose
    &lt;span class=&quot;token key atrule&quot;&gt;env_file&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; .env
    &lt;span class=&quot;token key atrule&quot;&gt;depends_on&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; postgresdb
    &lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
      &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; app&lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt;network

&lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;postgres_data&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;

&lt;span class=&quot;token key atrule&quot;&gt;networks&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token key atrule&quot;&gt;app-network&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
    &lt;span class=&quot;token key atrule&quot;&gt;driver&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; bridge&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;겉으로 보기에는 문제가 없어 보였다. PostgreSQL 컨테이너 안에서 &lt;code class=&quot;language-text&quot;&gt;env&lt;/code&gt;를 확인하면 환경 변수도 들어와 있었다. 그래서 처음에는 Spring Boot 쪽 설정이나 네트워크 문제를 의심했다.&lt;/p&gt;
&lt;h2 id=&quot;문제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%A0%9C&quot; aria-label=&quot;문제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문제&lt;/h2&gt;
&lt;p&gt;Spring Boot 서버는 계속 PostgreSQL 인증에 실패했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;app-was | org.hibernate.exception.GenericJDBCException:
app-was |   unable to obtain isolated JDBC connection
app-was |   [FATAL: password authentication failed for user &quot;app_user&quot;]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;PostgreSQL 컨테이너에 직접 들어가 사용자 정보와 데이터베이스를 확인해보니 기대했던 값으로 초기화되어 있지 않았다. 컨테이너에는 환경 변수가 들어와 있는데, 실제 데이터베이스는 그 값을 반영하지 않은 상태였다.&lt;/p&gt;
&lt;p&gt;처음에는 이상하게 보였다. 환경 변수가 있으니 PostgreSQL도 그 값으로 생성됐어야 한다고 생각했기 때문이다.&lt;/p&gt;
&lt;h2 id=&quot;확인한-단서&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%95%EC%9D%B8%ED%95%9C-%EB%8B%A8%EC%84%9C&quot; aria-label=&quot;확인한 단서 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;확인한 단서&lt;/h2&gt;
&lt;p&gt;로그를 자세히 보니 핵심 메시지가 있었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;app-db | PostgreSQL Database directory appears to contain a database; Skipping initialization&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;즉, PostgreSQL 컨테이너는 환경 변수를 무시한 것이 아니라 초기화 과정을 아예 다시 실행하지 않은 것이다.&lt;/p&gt;
&lt;h2 id=&quot;왜-이런-일이-생겼나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EC%9D%B4%EB%9F%B0-%EC%9D%BC%EC%9D%B4-%EC%83%9D%EA%B2%BC%EB%82%98&quot; aria-label=&quot;왜 이런 일이 생겼나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 이런 일이 생겼나&lt;/h2&gt;
&lt;p&gt;PostgreSQL Docker 공식 이미지에서 &lt;code class=&quot;language-text&quot;&gt;POSTGRES_USER&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;POSTGRES_PASSWORD&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;POSTGRES_DB&lt;/code&gt; 같은 Docker 전용 환경 변수는 데이터 디렉터리가 비어 있을 때 초기 데이터베이스를 만들기 위해 사용된다.&lt;/p&gt;
&lt;p&gt;처음 컨테이너가 시작될 때 데이터 디렉터리가 비어 있으면 &lt;code class=&quot;language-text&quot;&gt;initdb&lt;/code&gt;가 실행되고, 이때 기본 사용자와 데이터베이스가 만들어진다. 추가로 &lt;code class=&quot;language-text&quot;&gt;/docker-entrypoint-initdb.d/&lt;/code&gt; 아래의 &lt;code class=&quot;language-text&quot;&gt;.sql&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.sql.gz&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;.sh&lt;/code&gt; 스크립트도 이 초기화 단계에서 실행된다.&lt;/p&gt;
&lt;p&gt;반대로 데이터 디렉터리에 이미 PostgreSQL 데이터가 있으면 초기화는 건너뛴다. 이 경우 나중에 &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;나 &lt;code class=&quot;language-text&quot;&gt;docker-compose.yml&lt;/code&gt;의 환경 변수를 바꿔도 기존 데이터베이스 사용자나 비밀번호가 자동으로 바뀌지 않는다.&lt;/p&gt;
&lt;p&gt;공식 이미지 문서도 같은 점을 명시한다. Docker 전용 환경 변수는 빈 데이터 디렉터리로 컨테이너를 시작할 때만 영향을 주고, 이미 존재하는 데이터베이스는 시작 시 그대로 둔다.&lt;/p&gt;
&lt;h2 id=&quot;원인&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9B%90%EC%9D%B8&quot; aria-label=&quot;원인 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;원인&lt;/h2&gt;
&lt;p&gt;디버깅 과정에서 &lt;code class=&quot;language-text&quot;&gt;docker compose up&lt;/code&gt;을 여러 번 반복했다. 그 사이 처음 만들어진 named volume인 &lt;code class=&quot;language-text&quot;&gt;postgres_data&lt;/code&gt;가 계속 재사용되고 있었다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;yaml&quot;&gt;&lt;pre class=&quot;language-yaml&quot;&gt;&lt;code class=&quot;language-yaml&quot;&gt;&lt;span class=&quot;token key atrule&quot;&gt;volumes&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;-&lt;/span&gt; postgres_data&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt;/var/lib/postgresql/data&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;컨테이너를 지웠더라도 named volume은 자동으로 지워지지 않는다. 그래서 새 컨테이너를 띄워도 PostgreSQL 입장에서는 이미 데이터가 있는 디렉터리를 다시 마운트한 상태였다.&lt;/p&gt;
&lt;p&gt;결과적으로 PostgreSQL은 다음처럼 판단했다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;/var/lib/postgresql/data&lt;/code&gt;에 기존 데이터가 있다.&lt;/li&gt;
&lt;li&gt;이미 초기화된 데이터베이스라고 본다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;POSTGRES_USER&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;POSTGRES_PASSWORD&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;POSTGRES_DB&lt;/code&gt; 기반 초기화를 생략한다.&lt;/li&gt;
&lt;li&gt;기존 사용자/비밀번호가 남아 있으므로 Spring Boot의 접속 정보와 맞지 않는다.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;해결&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%B4%EA%B2%B0&quot; aria-label=&quot;해결 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;해결&lt;/h2&gt;
&lt;p&gt;개발 환경이라 기존 데이터를 보존할 필요가 없었다. 그래서 Compose를 내리면서 volume까지 삭제한 뒤 다시 올렸다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;bash&quot;&gt;&lt;pre class=&quot;language-bash&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose down &lt;span class=&quot;token parameter variable&quot;&gt;-v&lt;/span&gt;
&lt;span class=&quot;token function&quot;&gt;docker&lt;/span&gt; compose up &lt;span class=&quot;token parameter variable&quot;&gt;--build&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;-v&lt;/code&gt; 옵션은 Compose가 만든 named volume도 함께 제거한다. 이후 새 volume이 만들어지면서 PostgreSQL 데이터 디렉터리가 비어 있는 상태가 되었고, 환경 변수 기반 초기화가 다시 실행됐다.&lt;/p&gt;
&lt;p&gt;그 뒤 Spring Boot JPA도 정상적으로 PostgreSQL에 접속했다.&lt;/p&gt;
&lt;h2 id=&quot;운영할-때-주의할-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%B4%EC%98%81%ED%95%A0-%EB%95%8C-%EC%A3%BC%EC%9D%98%ED%95%A0-%EC%A0%90&quot; aria-label=&quot;운영할 때 주의할 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;운영할 때 주의할 점&lt;/h2&gt;
&lt;p&gt;개발 환경에서는 &lt;code class=&quot;language-text&quot;&gt;docker compose down -v&lt;/code&gt;가 빠른 해결책이지만, 운영이나 공유 개발 DB에서는 매우 위험하다. volume 안의 데이터가 삭제되기 때문이다.&lt;/p&gt;
&lt;p&gt;운영 환경에서 사용자나 비밀번호를 바꿔야 한다면 volume을 지우는 방식이 아니라 SQL로 명시적으로 변경해야 한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sql&quot;&gt;&lt;pre class=&quot;language-sql&quot;&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;ALTER&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;USER&lt;/span&gt; app_user &lt;span class=&quot;token keyword&quot;&gt;WITH&lt;/span&gt; PASSWORD &lt;span class=&quot;token string&quot;&gt;&apos;new-password&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;또는 필요한 사용자를 새로 만들고 권한을 부여해야 한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;sql&quot;&gt;&lt;pre class=&quot;language-sql&quot;&gt;&lt;code class=&quot;language-sql&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;CREATE&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;USER&lt;/span&gt; app_user &lt;span class=&quot;token keyword&quot;&gt;WITH&lt;/span&gt; PASSWORD &lt;span class=&quot;token string&quot;&gt;&apos;new-password&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;token keyword&quot;&gt;GRANT&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;ALL&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;PRIVILEGES&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;ON&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;DATABASE&lt;/span&gt; app_db &lt;span class=&quot;token keyword&quot;&gt;TO&lt;/span&gt; app_user&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;PostgreSQL Docker 컨테이너의 환경 변수는 매번 적용되는 설정값이 아니다. 첫 초기화 시점에만 데이터베이스를 생성하기 위한 입력값이다.&lt;/p&gt;
&lt;p&gt;그래서 Docker Compose로 DB를 디버깅할 때는 컨테이너만 보는 것이 아니라 volume 상태까지 같이 봐야 한다. &lt;code class=&quot;language-text&quot;&gt;docker compose down&lt;/code&gt;만으로는 데이터가 초기화되지 않고, named volume이 남아 있으면 PostgreSQL도 기존 데이터베이스를 계속 사용한다.&lt;/p&gt;
&lt;p&gt;정리하면 다음 기준을 기억하면 된다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;컨테이너 환경 변수는 현재 컨테이너에 들어온 값이다.&lt;/li&gt;
&lt;li&gt;PostgreSQL 사용자와 비밀번호는 데이터 디렉터리에 저장된 DB 상태다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;POSTGRES_*&lt;/code&gt; 환경 변수는 빈 데이터 디렉터리를 처음 초기화할 때만 반영된다.&lt;/li&gt;
&lt;li&gt;개발 중 DB를 완전히 새로 만들려면 volume까지 삭제해야 한다.&lt;/li&gt;
&lt;li&gt;운영 DB에서는 volume 삭제가 아니라 SQL 마이그레이션/권한 변경으로 처리해야 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;DB 컨테이너의 env를 바꿨는데 상태가 바뀌지 않으면 먼저 그 env가 runtime 설정인지 initialization input인지 구분한다. 특히 PostgreSQL처럼 data directory가 상태의 source of truth인 서비스는 컨테이너보다 volume을 먼저 본다.&lt;/p&gt;
&lt;p&gt;개발에서는 &lt;code class=&quot;language-text&quot;&gt;down -v&lt;/code&gt;가 빠른 해결일 수 있지만 운영에서는 같은 명령이 데이터 삭제다. 운영 변경은 SQL migration이나 권한 변경으로 다룬다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://hub.docker.com/_/postgres&quot;&gt;Postgres Docker Official Image&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/guides/pre-seeding/&quot;&gt;Docker Docs: Pre-seeding database containers&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Validate the Judge Before Evaluating RAG Retrieval]]></title><description><![CDATA[In a RAG retrieval experiment, the first question was whether a proposed query brought back better search results than the baseline. I built…]]></description><link>https://sewon.dev/en/rag-retrieval-llm-as-a-judge-bias/</link><guid isPermaLink="false">https://sewon.dev/en/rag-retrieval-llm-as-a-judge-bias/</guid><pubDate>Thu, 21 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/35db3a6ac411e325b7f69885fc86af1b/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB3klEQVR42o1ST4vTQBytH0APHhU8eNCboDc/gB/Jk3hSWESpLKjsoqygZwUPXhZZkZV12VPrYtq0TUz/JE3STJImM8lMZn6/kaQVV6jgYxgew7x5vPebViVh7OYTj3ohG7t5EBWzgE596gVs7OVuwLyAKYV6E1oAGBIaEkoSOg/zKGELkkcxJQmLYhrFNM05ACLq1arx+6lWzdeoyeoUAIsKuMRCAACubtQMFJU8VUUmS0CsxcFSde2sa6cjX3ABWqM559uf8+19v31ATZ83Bhobx/ek+8Taf+UdZYrXYpIpc1YOXTZZyIIrBBjO+ZsT/vY4e31cjvxSVaLkUrAFT+yf1D+JnT71JUJLbwZqDc2umlia5ctofOAO3onEUnAmcxyA0cmNTuqYvGQSpBzN+d63Yu+QvDwqhgFXFS+FQpHJbAoIqNcRanESoNOTjlmFE1xNZTgXL76WO1+SZ4d8EPB1wUoBZX+NSmstqsocWUZ/cGr0vv/odU6N5TLTiApASVn7VJWczqhlLXt97jhASJOsaduyJ9dv3bl87fbFKzcvXLpx7vzVDx8/NU5qbSGEsO20bxKjR80BhOEfMYmTR093t9o7Dx8/v/+gfffeltEfNtOGMw1u+GT/avu/8AurJ5gZjyaSWQAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Situation diagram&apos; title=&apos;&apos; src=&apos;/static/35db3a6ac411e325b7f69885fc86af1b/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/35db3a6ac411e325b7f69885fc86af1b/e7570/situation-diagram.png 170w,
/static/35db3a6ac411e325b7f69885fc86af1b/f46e7/situation-diagram.png 340w,
/static/35db3a6ac411e325b7f69885fc86af1b/ca1dc/situation-diagram.png 680w,
/static/35db3a6ac411e325b7f69885fc86af1b/02d09/situation-diagram.png 1020w,
/static/35db3a6ac411e325b7f69885fc86af1b/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Situation diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;In a RAG retrieval experiment, the first question was whether a proposed query brought back better search results than the baseline. I built an evaluation pipeline that compared the two result sets with an LLM-as-a-Judge. Then a swap test showed that the judge changed its decision based on answer order in about 81% of cases. The conclusion changed from &quot;which query won&quot; to &quot;the evaluator has to be validated first.&quot;&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: In a real-time financial information RAG system, manually judging retrieval results for every case was not practical.&lt;/li&gt;
&lt;li&gt;Approach: Compare baseline-query and proposed-query results with an LLM judge, then evaluate the same pair in both A/B and B/A order.&lt;/li&gt;
&lt;li&gt;Result: The initial results made the proposed query look stronger, but the swap test exposed about 81% position bias.&lt;/li&gt;
&lt;li&gt;Lesson: LLM-as-a-Judge is an evaluation automation tool, not a source of truth. Retrieval quality evaluation also needs judge stability checks.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;During an undergraduate research program, I built a pipeline to evaluate retrieval quality for real-time financial information RAG. The goal was to compare which result set was more useful: one retrieved by a baseline query, or one retrieved by a proposed query.&lt;/p&gt;
&lt;p&gt;In RAG, retrieval quality is not just about bringing back more documents. The result has to contain evidence that can answer the question, reflect current financial context, and avoid irrelevant documents. When there is no pre-labeled gold document set, recall and precision alone are not enough.&lt;/p&gt;
&lt;p&gt;So I used an LLM as a judge. In this post, &quot;judge&quot; does not mean a fine-tuned model. It means a comparison evaluator controlled by a prompt that defines criteria and output format.&lt;/p&gt;
&lt;h2 id=&quot;The-First-Evaluation-Pipeline&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-First-Evaluation-Pipeline&quot; aria-label=&quot;The First Evaluation Pipeline permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The First Evaluation Pipeline&lt;/h2&gt;
&lt;p&gt;The first pipeline was simple.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/static/retrieval-evaluation-pipeline-e4b15e344f9c999b4e99d64ad7a324bc.svg&quot; alt=&quot;RAG retrieval evaluation pipeline&quot;&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Generate a baseline query and a proposed query from the same input.&lt;/li&gt;
&lt;li&gt;Retrieve search results for each query.&lt;/li&gt;
&lt;li&gt;Ask the LLM judge to compare the two result sets.&lt;/li&gt;
&lt;li&gt;Evaluate the same pair once as A/B and once as B/A.&lt;/li&gt;
&lt;li&gt;Count a winner only when both evaluations point to the same real answer.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;My initial expectation was that the proposed query would perform better because it included role assignment, step-by-step reasoning, and financial context in query generation.&lt;/p&gt;
&lt;p&gt;The first judge results seemed to support that expectation.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Decision&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Count&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Ratio&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Proposed win&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;38&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;59.4%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Baseline win&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;25&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;39.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tie&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;From those numbers alone, it is tempting to say that the proposed query was better. But there was a more important question to answer first.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Is this judge fair?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;The-Swap-Test-Changed-the-Conclusion&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Swap-Test-Changed-the-Conclusion&quot; aria-label=&quot;The Swap Test Changed the Conclusion permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Swap Test Changed the Conclusion&lt;/h2&gt;
&lt;p&gt;When an LLM judge compares two answers, its decision can change depending on which answer is shown first, even if the content is the same. So I evaluated each pair twice.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;First pass: A vs B
Second pass: B vs A
If both passes choose the same real answer: consistent
If the winner changes after swapping order: position-biased&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the final presentation material, about 81% of cases showed position bias.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/static/judge-bias-summary-8df1a7b8c9c4b7c7823bf537157fdb21.svg&quot; alt=&quot;Initial LLM judge decisions and swap test results&quot;&gt;&lt;/p&gt;
&lt;p&gt;That result changed the center of the experiment. I could no longer separate whether the proposed query was better from whether the judge preferred the answer shown first. While trying to automate evaluation, I first found evidence that the evaluator itself was unstable.&lt;/p&gt;
&lt;h2 id=&quot;Why-This-Happened&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-This-Happened&quot; aria-label=&quot;Why This Happened permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why This Happened&lt;/h2&gt;
&lt;p&gt;Position bias becomes easier to see when both results look similarly plausible. When the quality gap between A and B is large, the judge tends to be more stable. But when both look good enough, the judge can be influenced by signals other than actual retrieval quality.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The answer presented first&lt;/li&gt;
&lt;li&gt;A longer or more structured answer&lt;/li&gt;
&lt;li&gt;Sentences that look more current&lt;/li&gt;
&lt;li&gt;More confident wording&lt;/li&gt;
&lt;li&gt;Small wording differences in the judge prompt&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This changed how I looked at LLM-as-a-Judge. It is not a full replacement for human evaluation. It is a cheap and fast evaluation system that helps narrow candidates. If it is a system, its failure modes also need to be tested.&lt;/p&gt;
&lt;h2 id=&quot;What-I-Changed&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-I-Changed&quot; aria-label=&quot;What I Changed permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What I Changed&lt;/h2&gt;
&lt;p&gt;I made the evaluation pipeline more conservative.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;A/B result&lt;/th&gt;
&lt;th&gt;B/A result&lt;/th&gt;
&lt;th&gt;Final decision&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A wins&lt;/td&gt;
&lt;td&gt;A wins&lt;/td&gt;
&lt;td&gt;A wins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B wins&lt;/td&gt;
&lt;td&gt;B wins&lt;/td&gt;
&lt;td&gt;B wins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A wins&lt;/td&gt;
&lt;td&gt;B wins&lt;/td&gt;
&lt;td&gt;Review needed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tie&lt;/td&gt;
&lt;td&gt;Any&lt;/td&gt;
&lt;td&gt;Review needed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Any&lt;/td&gt;
&lt;td&gt;Tie&lt;/td&gt;
&lt;td&gt;Review needed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;This approach does not produce many wins. Instead, it separates cases where the judge was unstable from cases where a decision survived the order swap. The goal of automation changed from &quot;reach conclusions quickly&quot; to &quot;filter out conclusions that are not trustworthy.&quot;&lt;/p&gt;
&lt;h2 id=&quot;Verification&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Verification&quot; aria-label=&quot;Verification permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Verification&lt;/h2&gt;
&lt;p&gt;The verification did not only look at query performance. It also checked judge consistency.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Sent baseline and proposed retrieval results to the judge under the same criteria.&lt;/li&gt;
&lt;li&gt;Evaluated each pair in both A/B and B/A order.&lt;/li&gt;
&lt;li&gt;Checked whether the winner stayed the same in terms of the real answer, not the display slot.&lt;/li&gt;
&lt;li&gt;Marked conflicting cases as review-needed instead of forcing a winner.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This makes the number &quot;proposed query won by X%&quot; less impressive. But the remaining wins have at least passed one position-bias check.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Would-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Would-Judge-This-Next-Time&quot; aria-label=&quot;How I Would Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Would Judge This Next Time&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;When using LLM-as-a-Judge, validate judge stability before looking only at the evaluated target.&lt;/li&gt;
&lt;li&gt;Treat A/B and B/A swap tests as the default for pairwise comparison.&lt;/li&gt;
&lt;li&gt;Do not claim that one query strategy is better from a single judge pass.&lt;/li&gt;
&lt;li&gt;When two results are both reasonably good, keep the case as review-needed instead of forcing a tie or winner.&lt;/li&gt;
&lt;li&gt;The goal of evaluation automation is not to create more conclusions. It is to filter out conclusions that should not be trusted.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://ai.google.dev/gemini-api/docs/model-tuning/tutorial&quot;&gt;Gemini API Fine-tuning documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://ai.google.dev/gemini-api/docs/changelog&quot;&gt;Gemini API release notes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/2406.07791&quot;&gt;Judging the Judges: A Systematic Study of Position Bias in LLM-as-a-Judge&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[RAG Retrieval을 평가하기 전에 Judge부터 검증하기]]></title><description><![CDATA[RAG retrieval 실험에서 처음 확인하고 싶었던 것은 proposed query가 baseline보다 좋은 검색 결과를 가져오는지였다. 그래서 LLM-as-a-Judge로 두 결과를 비교하는 평가 파이프라인을 만들었다. 그런데 swap test…]]></description><link>https://sewon.dev/rag-retrieval-llm-as-a-judge-bias/</link><guid isPermaLink="false">https://sewon.dev/rag-retrieval-llm-as-a-judge-bias/</guid><pubDate>Thu, 21 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/35db3a6ac411e325b7f69885fc86af1b/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB3klEQVR42o1ST4vTQBytH0APHhU8eNCboDc/gB/Jk3hSWESpLKjsoqygZwUPXhZZkZV12VPrYtq0TUz/JE3STJImM8lMZn6/kaQVV6jgYxgew7x5vPebViVh7OYTj3ohG7t5EBWzgE596gVs7OVuwLyAKYV6E1oAGBIaEkoSOg/zKGELkkcxJQmLYhrFNM05ACLq1arx+6lWzdeoyeoUAIsKuMRCAACubtQMFJU8VUUmS0CsxcFSde2sa6cjX3ABWqM559uf8+19v31ATZ83Bhobx/ek+8Taf+UdZYrXYpIpc1YOXTZZyIIrBBjO+ZsT/vY4e31cjvxSVaLkUrAFT+yf1D+JnT71JUJLbwZqDc2umlia5ctofOAO3onEUnAmcxyA0cmNTuqYvGQSpBzN+d63Yu+QvDwqhgFXFS+FQpHJbAoIqNcRanESoNOTjlmFE1xNZTgXL76WO1+SZ4d8EPB1wUoBZX+NSmstqsocWUZ/cGr0vv/odU6N5TLTiApASVn7VJWczqhlLXt97jhASJOsaduyJ9dv3bl87fbFKzcvXLpx7vzVDx8/NU5qbSGEsO20bxKjR80BhOEfMYmTR093t9o7Dx8/v/+gfffeltEfNtOGMw1u+GT/avu/8AurJ5gZjyaSWQAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/35db3a6ac411e325b7f69885fc86af1b/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/35db3a6ac411e325b7f69885fc86af1b/e7570/situation-diagram.png 170w,
/static/35db3a6ac411e325b7f69885fc86af1b/f46e7/situation-diagram.png 340w,
/static/35db3a6ac411e325b7f69885fc86af1b/ca1dc/situation-diagram.png 680w,
/static/35db3a6ac411e325b7f69885fc86af1b/02d09/situation-diagram.png 1020w,
/static/35db3a6ac411e325b7f69885fc86af1b/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;RAG retrieval 실험에서 처음 확인하고 싶었던 것은 proposed query가 baseline보다 좋은 검색 결과를 가져오는지였다. 그래서 LLM-as-a-Judge로 두 결과를 비교하는 평가 파이프라인을 만들었다. 그런데 swap test를 해보니 약 81%의 케이스에서 judge가 답변 순서에 흔들렸고, 결론은 &quot;어떤 query가 이겼다&quot;가 아니라 &quot;평가자부터 검증해야 한다&quot;로 바뀌었다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: 실시간 금융 정보 RAG에서 retrieval 결과를 사람이 매번 판정하기 어려웠다.&lt;/li&gt;
&lt;li&gt;판단: baseline query와 proposed query의 검색 결과를 LLM judge로 비교하되, 같은 쌍을 A/B와 B/A 순서로 모두 평가했다.&lt;/li&gt;
&lt;li&gt;결과: 초기 결과만 보면 proposed query가 우세했지만, swap test에서 약 81% 위치 편향이 드러났다.&lt;/li&gt;
&lt;li&gt;배운 점: LLM-as-a-Judge는 평가 자동화 도구이지 정답 기계가 아니다. retrieval 품질을 평가하려면 judge의 안정성도 같이 검증해야 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;학부 연구생 프로그램에서 실시간 금융 정보 RAG의 검색 품질을 평가하는 파이프라인을 만들었다. 목표는 baseline query와 proposed query가 가져온 검색 결과 중 어느 쪽이 더 유용한지 비교하는 것이었다.&lt;/p&gt;
&lt;p&gt;RAG에서 retrieval은 단순히 문서를 많이 가져오는 문제가 아니다. 질문에 답하는 데 필요한 근거가 있는지, 최신 금융 맥락을 반영하는지, 불필요한 문서가 섞이지 않았는지를 봐야 한다. 정답 문서가 미리 라벨링되어 있지 않다면 recall이나 precision만으로 판단하기 어렵다.&lt;/p&gt;
&lt;p&gt;그래서 LLM을 judge로 세웠다. 여기서 말하는 judge는 fine-tuned model이 아니라 평가 기준과 출력 형식을 prompt로 준 비교 평가자다.&lt;/p&gt;
&lt;h2 id=&quot;처음-만든-평가-파이프라인&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C-%EB%A7%8C%EB%93%A0-%ED%8F%89%EA%B0%80-%ED%8C%8C%EC%9D%B4%ED%94%84%EB%9D%BC%EC%9D%B8&quot; aria-label=&quot;처음 만든 평가 파이프라인 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음 만든 평가 파이프라인&lt;/h2&gt;
&lt;p&gt;파이프라인은 단순했다.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/static/retrieval-evaluation-pipeline-e4b15e344f9c999b4e99d64ad7a324bc.svg&quot; alt=&quot;RAG retrieval 평가 파이프라인&quot;&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;같은 입력에서 baseline query와 proposed query를 만든다.&lt;/li&gt;
&lt;li&gt;각 query로 검색 결과를 가져온다.&lt;/li&gt;
&lt;li&gt;LLM judge가 두 결과를 비교한다.&lt;/li&gt;
&lt;li&gt;같은 쌍을 A/B, B/A 순서로 한 번씩 평가한다.&lt;/li&gt;
&lt;li&gt;두 평가가 같은 실제 승자를 가리킬 때만 승패로 인정한다.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;처음 기대는 proposed query가 더 좋을 것이라는 쪽이었다. 역할 부여, 단계적 사고, 금융 맥락을 query 생성에 넣었기 때문이다.&lt;/p&gt;
&lt;p&gt;초기 judge 결과만 보면 이 기대는 맞는 것처럼 보였다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Decision&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Count&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Ratio&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Proposed win&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;38&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;59.4%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Baseline win&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;25&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;39.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tie&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1.6%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;이 숫자만 보면 &quot;proposed query가 더 낫다&quot;고 말하고 싶어진다. 하지만 그 전에 더 중요한 질문이 있었다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;이 judge는 공정한가?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;Swap-test에서-결론이-바뀌었다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Swap-test%EC%97%90%EC%84%9C-%EA%B2%B0%EB%A1%A0%EC%9D%B4-%EB%B0%94%EB%80%8C%EC%97%88%EB%8B%A4&quot; aria-label=&quot;Swap test에서 결론이 바뀌었다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Swap test에서 결론이 바뀌었다&lt;/h2&gt;
&lt;p&gt;LLM judge가 두 결과를 비교할 때, 같은 내용이라도 어느 쪽을 먼저 보여주느냐에 따라 판단이 달라질 수 있다. 그래서 같은 쌍을 두 번 평가했다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;1차: A vs B
2차: B vs A
두 번 모두 같은 실제 답변을 고르면 consistent
순서를 바꿨더니 승자가 바뀌면 position-biased&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;최종 발표자료 기준으로 약 81%의 케이스에서 위치 편향이 발생했다.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/static/judge-bias-summary-8df1a7b8c9c4b7c7823bf537157fdb21.svg&quot; alt=&quot;LLM judge의 초기 판정과 swap test 결과&quot;&gt;&lt;/p&gt;
&lt;p&gt;이 결과가 실험의 중심을 바꿨다. proposed query가 좋아진 것인지, judge가 앞에 놓인 답변을 더 자주 고른 것인지 분리할 수 없었다. 평가 자동화를 하려다 평가자 자체가 불안정하다는 증거를 먼저 본 셈이다.&lt;/p&gt;
&lt;h2 id=&quot;왜-이런-일이-생겼나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EC%9D%B4%EB%9F%B0-%EC%9D%BC%EC%9D%B4-%EC%83%9D%EA%B2%BC%EB%82%98&quot; aria-label=&quot;왜 이런 일이 생겼나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 이런 일이 생겼나&lt;/h2&gt;
&lt;p&gt;위치 편향은 두 결과가 비슷하게 그럴듯할 때 더 잘 드러난다. A와 B의 품질 차이가 크면 judge도 비교적 안정적으로 판단한다. 하지만 둘 다 충분히 좋아 보이면 judge는 실제 retrieval 품질보다 다른 신호에 흔들릴 수 있다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;먼저 제시된 답변&lt;/li&gt;
&lt;li&gt;더 길고 구조화된 답변&lt;/li&gt;
&lt;li&gt;더 최근 정보처럼 보이는 문장&lt;/li&gt;
&lt;li&gt;더 자신감 있는 표현&lt;/li&gt;
&lt;li&gt;judge prompt의 작은 표현 차이&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 지점에서 LLM-as-a-Judge를 보는 관점이 바뀌었다. 사람 평가를 완전히 대체하는 도구가 아니라, 싸고 빠르게 후보를 줄여주는 평가 시스템으로 봐야 했다. 시스템이라면 그 시스템의 failure mode도 같이 검증해야 한다.&lt;/p&gt;
&lt;h2 id=&quot;해결한-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%B4%EA%B2%B0%ED%95%9C-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;해결한 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;해결한 방식&lt;/h2&gt;
&lt;p&gt;평가 파이프라인을 더 보수적으로 바꿨다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;A/B result&lt;/th&gt;
&lt;th&gt;B/A result&lt;/th&gt;
&lt;th&gt;Final decision&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;A wins&lt;/td&gt;
&lt;td&gt;A wins&lt;/td&gt;
&lt;td&gt;A wins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;B wins&lt;/td&gt;
&lt;td&gt;B wins&lt;/td&gt;
&lt;td&gt;B wins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A wins&lt;/td&gt;
&lt;td&gt;B wins&lt;/td&gt;
&lt;td&gt;Review needed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Tie&lt;/td&gt;
&lt;td&gt;Any&lt;/td&gt;
&lt;td&gt;Review needed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Any&lt;/td&gt;
&lt;td&gt;Tie&lt;/td&gt;
&lt;td&gt;Review needed&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;이 방식은 승패를 많이 만들어내지 않는다. 대신 judge가 흔들린 케이스를 결과에서 분리한다. 자동화의 목적을 &quot;빨리 결론 내기&quot;가 아니라 &quot;믿기 어려운 결론 걸러내기&quot;로 바꾼 것이다.&lt;/p&gt;
&lt;h2 id=&quot;검증&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B2%80%EC%A6%9D&quot; aria-label=&quot;검증 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;검증&lt;/h2&gt;
&lt;p&gt;검증은 query 성능만 보지 않고 judge 일관성을 같이 봤다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;baseline/proposed 검색 결과를 같은 기준으로 judge에 넣었다.&lt;/li&gt;
&lt;li&gt;같은 쌍을 A/B와 B/A 순서로 모두 평가했다.&lt;/li&gt;
&lt;li&gt;실제 답변 기준으로 승자가 유지되는지 확인했다.&lt;/li&gt;
&lt;li&gt;충돌하는 케이스는 억지로 승패 처리하지 않고 review-needed로 분리했다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이렇게 하면 &quot;proposed query가 몇 % 이겼다&quot;는 숫자는 덜 화려해진다. 대신 남은 승패는 judge 위치 편향을 한 번 통과한 결과가 된다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;LLM-as-a-Judge를 쓰면 평가 대상만 보지 않고 judge의 안정성도 먼저 본다.&lt;/li&gt;
&lt;li&gt;pairwise comparison에서는 A/B와 B/A swap test를 기본값으로 넣는다.&lt;/li&gt;
&lt;li&gt;한 번의 judge 결과만으로 query strategy의 우열을 말하지 않는다.&lt;/li&gt;
&lt;li&gt;두 결과가 비슷하게 좋은 케이스는 tie보다 review-needed로 남겨 사람 검토 후보로 분리한다.&lt;/li&gt;
&lt;li&gt;평가 자동화의 목표는 결론을 많이 만드는 것이 아니라, 믿을 수 없는 결론을 걸러내는 것이다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://ai.google.dev/gemini-api/docs/model-tuning/tutorial&quot;&gt;Gemini API Fine-tuning documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://ai.google.dev/gemini-api/docs/changelog&quot;&gt;Gemini API release notes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://arxiv.org/abs/2406.07791&quot;&gt;Judging the Judges: A Systematic Study of Position Bias in LLM-as-a-Judge&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[When Pants-Only Virtual Try-On Also Changes the Shoes]]></title><description><![CDATA[Sometimes the user wants to apply only pants, but the virtual try-on result also changes surrounding items such as shoes or a top. At first…]]></description><link>https://sewon.dev/en/thatzfit-garment-masking-gemini-experiment/</link><guid isPermaLink="false">https://sewon.dev/en/thatzfit-garment-masking-gemini-experiment/</guid><pubDate>Thu, 21 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Sometimes the user wants to apply only pants, but the virtual try-on result also changes surrounding items such as shoes or a top. At first, that looks like a generation model failure. In this ThatzFit experiment, the input scope mattered before model quality.&lt;/p&gt;
&lt;p&gt;The original garment image included a hoodie, shoes, background, and part of a person, so the provider had to infer the difference between &quot;the garment to apply&quot; and &quot;the outfit to reference.&quot; If that distinction is left to the provider, a pants-only request can be interpreted as a full outfit reference. When I used a human parser to keep only the pants region, the target garment identity became clearer.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: The user wanted to apply only pants, but the original garment image mixed the target pants with a top, shoes, body parts, and background.&lt;/li&gt;
&lt;li&gt;Decision: Before changing the provider, I tested whether input preprocessing could make the &quot;garment to apply&quot; boundary explicit.&lt;/li&gt;
&lt;li&gt;Result: The masked input improved the garment identity score from &lt;code class=&quot;language-text&quot;&gt;2.0 -&gt; 4.0&lt;/code&gt; and the overall score from &lt;code class=&quot;language-text&quot;&gt;2.8 -&gt; 3.7&lt;/code&gt;, but edge and detail quality were still unstable.&lt;/li&gt;
&lt;li&gt;Lesson: Segmentation does not automatically improve generation quality. It reduces the room for a downstream model to misunderstand what should be applied.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;ThatzFit virtual try-on sends a model image and a garment image to an external generation provider. User-uploaded garment images are not always clean product shots. If the task is to apply only pants, but the source image also includes a top, shoes, body parts, and background, the provider has to infer where the target garment ends.&lt;/p&gt;
&lt;p&gt;The question in this experiment was not &quot;Is the external generation model bad?&quot; It was, &quot;Can we make the target garment boundary clearer before the provider sees the input?&quot;&lt;/p&gt;
&lt;h2 id=&quot;Problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Problem&quot; aria-label=&quot;Problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;The test input was a pants image, but the original image also contained a black hoodie, shoes, part of a person, and background. The user intent was pants only. If that image is sent directly to the provider, &quot;pants&quot; and &quot;the outfit around the pants&quot; are mixed in one image.&lt;/p&gt;
&lt;p&gt;That ambiguity matters. The provider might apply only the pants, or it might use the hoodie and shoes as part of the outfit reference. When a pants-only request also changes shoes or a top, the issue is not just generic image quality. It is a target garment scope failure.&lt;/p&gt;
&lt;p&gt;I wanted to answer two questions.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Can a local human parser find the pants region quickly and reliably enough on ThatzFit-style input images?&lt;/li&gt;
&lt;li&gt;If I send only the masked pants to the provider, does the item to apply become clearer than when I send the full original image?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Initial-hypothesis&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Initial-hypothesis&quot; aria-label=&quot;Initial hypothesis permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Initial hypothesis&lt;/h2&gt;
&lt;p&gt;The hypothesis was simple. If the garment candidate is reduced to a transparent PNG containing only the pants before generation, the provider may be less likely to treat the hoodie or shoes as part of the target garment.&lt;/p&gt;
&lt;p&gt;There was also a risk in the opposite direction. If the mask boundary is rough or thin details disappear, the generation model may understand the pants shape less accurately. For that reason, I kept this as a separate worktree and Jupyter notebook experiment, not a backend default change.&lt;/p&gt;
&lt;h2 id=&quot;Evidence-checked&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Evidence-checked&quot; aria-label=&quot;Evidence checked permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Evidence checked&lt;/h2&gt;
&lt;p&gt;I ran the experiment in a separate worktree so I would not disturb the existing backend worktree.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Environment: macOS arm64, Python 3.12.3, torch 2.12.0, MPS available&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For this experiment, I used &lt;a href=&quot;https://huggingface.co/fashn-ai/fashn-human-parser&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;fashn-ai/fashn-human-parser&lt;/code&gt;&lt;/a&gt; from Hugging Face. It is a SegFormer-based human parsing model published for fashion and virtual try-on use cases, and it returns semantic classes such as &lt;code class=&quot;language-text&quot;&gt;top&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;dress&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;skirt&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;pants&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;feet&lt;/code&gt;. The point of this post is not to benchmark that model itself. It is to test whether its segmentation output can narrow the target garment scope before the provider sees the input.&lt;/p&gt;
&lt;p&gt;First, I measured standalone human parser runtime. On warm cached runs, MPS was much faster than CPU.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;device&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;cached load&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;first inference&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;warm avg&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CPU&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.87s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1.23s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1.02s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MPS&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.93s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.45s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.26s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;On the first cold run, CPU model loading reached 114 seconds, which included weight download and cache effects. For service-style judgment, cached numbers are the more relevant ones. The package default also did not automatically select MPS on macOS, so the device had to be specified.&lt;/p&gt;
&lt;p&gt;The class distribution for the test image was:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;class&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;area&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;pants&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;45.84%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;background&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;45.17%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;top&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;5.35%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;feet&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.59%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/48fca9e8f30e8fcd8cbbb99c0abed39f/b67f0/parser_panel_mps.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 55.88235294117647%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACgklEQVR42mN48+K5g7OjqIiwuIS4iKjImVOn1ixdyKxsZbnwkdOG6/Yb71vOPcnAyhUTHhpZ2qEclq8dk6sUmRda3NjX1cnw////a5cvGmpp6Kup6quq3Lp6ef26tQwMDFqp6UHnT/scOuC6dhUDE2NkaOiUSRN9igqsczLNszJS6mv7O0Ga/x3Yu1tNQU5DSVFaRHjfju2bNm5gYGDQKy4OOHvOe/9+z507mQUEIoKD+vv7HXOyzTMyDFNTwsrLejo7QDZv2bBOQVJcVUGOm511w6oVmzdtYmBgMK6vDzh92nv/fu+9eznk5cMDA3r7+2yyMk3T03QS4v2Ki7shmjesXikvIaamKMfCyLB4zuzNYJtNW1v9T53y2rfP5+BBHk3NMH//3gn91lmZpmmpWvFx7gX5XR1gzWuWLZGXFNNUVmRlYpg2ccIGsJ/N2ttBmvfu9T18mF9fP8zPt7u/3zIzwyw9TScx3ik3p7O9neH//7/rVi1XkJLQUlVmZWLo6WjfuH4dAwODSXOz/+nTXnv2+B05ImBoGOrj093Xa5WVYZ6Rpp+UaJuV2d7WxvDv18/jhw8qykprqyrzcLJv27xp4waQs/WLioIvXvQ+edJ9zx42MTFQgE3od87NMcvO1EtP8ysp7unoYHjz/Mmrp48tTY0ZGBhY2dl27dyxbOkSBgYGXi0tu/XrPWbMsE5KYmBg8PHxbq2v88lIk/PzlbWz8w4JbqipYXj7+tWXD+/37NpRUlFe19R4+Mihffv2+vr4hEZElPT0dLe1NdbUxCckdHZ0bFi3Zv6SRU1dXQ11tX19fStXrmT4/ffv79+///z5+////3///v1HBn///scLAM/bPwyxncxmAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;human parser result panel&apos; title=&apos;&apos; src=&apos;/static/48fca9e8f30e8fcd8cbbb99c0abed39f/ca1dc/parser_panel_mps.png&apos; srcset=&apos;/static/48fca9e8f30e8fcd8cbbb99c0abed39f/e7570/parser_panel_mps.png 170w,
/static/48fca9e8f30e8fcd8cbbb99c0abed39f/f46e7/parser_panel_mps.png 340w,
/static/48fca9e8f30e8fcd8cbbb99c0abed39f/ca1dc/parser_panel_mps.png 680w,
/static/48fca9e8f30e8fcd8cbbb99c0abed39f/02d09/parser_panel_mps.png 1020w,
/static/48fca9e8f30e8fcd8cbbb99c0abed39f/9d567/parser_panel_mps.png 1360w,
/static/48fca9e8f30e8fcd8cbbb99c0abed39f/b67f0/parser_panel_mps.png 2406w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;human parser result panel&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Choosing the largest class naively could select &lt;code class=&quot;language-text&quot;&gt;background&lt;/code&gt;, so the experiment selected the largest area only among garment class candidates such as &lt;code class=&quot;language-text&quot;&gt;top&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;dress&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;skirt&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;pants&lt;/code&gt;. In this sample, &lt;code class=&quot;language-text&quot;&gt;pants&lt;/code&gt; was selected, and the pants silhouette was good enough for the experiment. It was not garment matting quality, though. Thin accessories like a keychain, the hand and pocket area, and the boundary around the foot and hem were still imperfect.&lt;/p&gt;
&lt;h2 id=&quot;What-I-changed&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-I-changed&quot; aria-label=&quot;What I changed permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What I changed&lt;/h2&gt;
&lt;p&gt;In the notebook, I created two variants for the same model image.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;baseline_original&lt;/code&gt;: pass the original garment image, including the hoodie, shoes, and body parts, directly to the provider&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;masked_largest_garment&lt;/code&gt;: pass only the &lt;code class=&quot;language-text&quot;&gt;pants&lt;/code&gt; region selected by the human parser as a transparent PNG&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Provider runtime was about 14.8 seconds for the baseline and about 25.2 seconds for the masked variant. This was a single-run result and includes external provider latency variance. Local preprocessing itself was about 0.26 seconds on warm MPS, and the segmentation step recorded in the notebook was about 0.72 seconds.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/57478edd571fee567f1e34ccf23e1904/9c796/comparison_panel.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 32.35294117647059%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAIAAABM9SnKAAAACXBIWXMAAAsTAAALEwEAmpwYAAABaklEQVR42iXO7S8CAQDH8eaF5xfWDJsX/gg2liFJZNo41VJrM/9FNt7ZeI2ZN4Y3vPKazUOjROUqeTarVasuuc7duQe6+1n6vv9sXw2AUrGQTycApJIJk9HQ29P9/voCYGtjfWnBw5RKv2Ul4D2J3Pj5byFPFcjA5UP09qP4qQHA0XTq7RWqKosiMTnR1d52T5IADAP9na3a58fHcllx2qfdTpsgiolkIpdKP8Wi2Vy2gg8P9rc3N/4XPswjwy3NjT7vuaoopuGhjlYtGQ5LkjQyqLOYR1mOowrUyqJnbXWZ+fqq4Pj15V3gAgBTxU0NJ8dHqqrqdX21NZrzs1MATisx73bJskzT9Lh+0O2wC6JYwexngaeLAKRvbtY2U19Xe+X3AXA5bEaDPpPJALAR01ZiShQliqIs5rE5t4vl2AqupiiKUv6JRSM7e7u5fBZAOpMWBAGALMvBYDAUCkmSxDAMGbqJx6I8z/8BpkQF31GvZWkAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;original input and masked input comparison&apos; title=&apos;&apos; src=&apos;/static/57478edd571fee567f1e34ccf23e1904/ca1dc/comparison_panel.png&apos; srcset=&apos;/static/57478edd571fee567f1e34ccf23e1904/e7570/comparison_panel.png 170w,
/static/57478edd571fee567f1e34ccf23e1904/f46e7/comparison_panel.png 340w,
/static/57478edd571fee567f1e34ccf23e1904/ca1dc/comparison_panel.png 680w,
/static/57478edd571fee567f1e34ccf23e1904/02d09/comparison_panel.png 1020w,
/static/57478edd571fee567f1e34ccf23e1904/9d567/comparison_panel.png 1360w,
/static/57478edd571fee567f1e34ccf23e1904/9c796/comparison_panel.png 1708w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;original input and masked input comparison&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;I recorded the manual evaluation below. Scores use a 1-5 scale. The table keeps only the numbers, and the judgment notes are separated below.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variant&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Garment identity&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Body realism&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Edge quality&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Artifact control&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Overall&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Original input&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;2.0&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4.0&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4.0&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;2.0&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;2.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Masked input&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4.0&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.5&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.5&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.5&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;Evaluation notes&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;baseline_original&lt;/code&gt;: The provider interpreted the original image as a &lt;code class=&quot;language-text&quot;&gt;hoodie + pants&lt;/code&gt; outfit. The pants looked natural, but the expected &lt;code class=&quot;language-text&quot;&gt;pants only&lt;/code&gt; target failed.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;masked_largest_garment&lt;/code&gt;: The white T-shirt and shoes were better preserved, and the output moved toward applying only the pants. However, the foot and hem were distorted, and a checkerboard background remained.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;What-I-learned&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-I-learned&quot; aria-label=&quot;What I learned permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What I learned&lt;/h2&gt;
&lt;p&gt;Masking helped in this experiment. The point was not that it automatically improved image quality. It reduced the garment scope that the provider had to interpret. Passing the original image let the provider pull surrounding outfit information into the result. Passing only the pants made the contract much clearer: apply the pants, preserve the rest.&lt;/p&gt;
&lt;p&gt;It is still too early to make this a production default. The human parser is good enough for semantic segmentation, but it is not a pixel-level matting tool. Also, the provider returned a rasterized checkerboard background rather than true alpha, so post-processing needs to be evaluated together.&lt;/p&gt;
&lt;h2 id=&quot;How-I-will-judge-this-next-time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-will-judge-this-next-time&quot; aria-label=&quot;How I will judge this next time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I will judge this next time&lt;/h2&gt;
&lt;p&gt;When I see a similar virtual try-on issue, I will not immediately change providers. First, I will check whether the target garment and reference outfit are mixed inside the input image. If the user wanted pants only but shoes or a top changed as well, target garment scope should be checked before model choice.&lt;/p&gt;
&lt;p&gt;The next step is not to attach this directly to the backend. It is to repeat the same comparison across 3-5 representative garments. If the masked variant keeps winning, I would add it as an experimental feature behind a feature flag.&lt;/p&gt;
&lt;p&gt;The candidate flow is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Skip if the provider is not supported.&lt;/li&gt;
&lt;li&gt;Skip if &lt;code class=&quot;language-text&quot;&gt;VIRTUAL_FITTING_GARMENT_MASKING_ENABLED&lt;/code&gt; is off.&lt;/li&gt;
&lt;li&gt;Run the singleton parser through &lt;code class=&quot;language-text&quot;&gt;asyncio.to_thread&lt;/code&gt; or a bounded executor.&lt;/li&gt;
&lt;li&gt;Keep only the largest area among allowed garment classes.&lt;/li&gt;
&lt;li&gt;Fall back to original bytes if the garment area is too small.&lt;/li&gt;
&lt;li&gt;Record &lt;code class=&quot;language-text&quot;&gt;garment_segmentation&lt;/code&gt; in the performance step.&lt;/li&gt;
&lt;li&gt;Pass masked PNG bytes into the direct-bytes runner.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The conclusion of this experiment is that it is worth continuing. Masking was useful for controlling target garment scope, but before it becomes a production feature, it needs repeated validation across multiple inputs, including whether shoes and tops are preserved, plus a comparison with remove-background post-processing.&lt;/p&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://huggingface.co/fashn-ai/fashn-human-parser&quot;&gt;fashn-ai/fashn-human-parser&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[바지만 입히려는데 신발까지 따라오는 문제를 입력 범위로 보기]]></title><description><![CDATA[가상 피팅에서 사용자가 바지만 입히고 싶은데 결과에 신발이나 상의까지 같이 따라오는 경우가 있다. 겉으로 보면 생성 모델이 틀린 것처럼 보인다. 하지만 이번 ThatzFit…]]></description><link>https://sewon.dev/thatzfit-garment-masking-gemini-experiment/</link><guid isPermaLink="false">https://sewon.dev/thatzfit-garment-masking-gemini-experiment/</guid><pubDate>Thu, 21 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;가상 피팅에서 사용자가 바지만 입히고 싶은데 결과에 신발이나 상의까지 같이 따라오는 경우가 있다. 겉으로 보면 생성 모델이 틀린 것처럼 보인다. 하지만 이번 ThatzFit 실험에서 더 먼저 봐야 했던 문제는 모델 성능이 아니라 입력 범위였다.&lt;/p&gt;
&lt;p&gt;원본 의류 이미지에 후드, 신발, 배경, 인물 일부가 같이 들어오자 provider는 &quot;입힐 옷&quot;과 &quot;참고할 착장&quot;을 구분해야 했다. 이 구분을 provider에게 맡기면 바지만 입혀야 하는 요청도 전체 착장 변환처럼 해석될 수 있다. human parser로 바지 영역만 남겼을 때 target garment identity가 더 선명해졌다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: 사용자는 바지만 입히고 싶은데 원본 의류 이미지에 상의, 신발, 배경이 섞이면 provider가 target garment와 참고 착장을 혼동할 수 있었다.&lt;/li&gt;
&lt;li&gt;판단: provider를 바꾸기 전에 &quot;입힐 의류 범위&quot;를 먼저 좁혀야 했다.&lt;/li&gt;
&lt;li&gt;결과: masked input은 garment identity 점수를 &lt;code class=&quot;language-text&quot;&gt;2.0 -&gt; 4.0&lt;/code&gt;, overall 점수를 &lt;code class=&quot;language-text&quot;&gt;2.8 -&gt; 3.7&lt;/code&gt;로 올렸지만 edge/detail 품질은 아직 불안했다.&lt;/li&gt;
&lt;li&gt;배운 점: segmentation은 생성 품질을 자동으로 올리는 장치가 아니라, downstream 모델이 &quot;어디까지 입혀야 하는지&quot; 오해할 여지를 줄이는 장치다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;ThatzFit의 가상 피팅은 모델 이미지와 의류 이미지를 외부 생성 모델(provider)에 넘겨 결과를 만든다. 사용자가 올리는 의류 이미지는 항상 깔끔한 상품 컷이 아니다. 바지만 입히고 싶은데 원본 이미지 안에 상의, 신발, 사람 몸, 배경이 같이 있으면 provider는 어디까지를 목표 의류(target garment)로 봐야 하는지 추론해야 한다.&lt;/p&gt;
&lt;p&gt;이번 실험의 질문은 &quot;외부 생성 모델이 나쁜가?&quot;가 아니었다. &quot;provider가 보기 전에 우리가 target garment 범위를 더 명확히 줄 수 있는가?&quot;였다.&lt;/p&gt;
&lt;h2 id=&quot;문제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%A0%9C&quot; aria-label=&quot;문제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문제&lt;/h2&gt;
&lt;p&gt;테스트 입력은 바지 이미지였지만 원본에는 검은 후드, 신발, 인물 일부, 배경이 같이 있었다. 사용자의 의도는 바지만 입히는 것이다. 하지만 이 이미지를 그대로 provider에 넘기면 &quot;바지&quot;와 &quot;바지를 입은 사람의 착장&quot;이 한 장에 섞인다.&lt;/p&gt;
&lt;p&gt;그 결과 provider는 바지만 target garment로 볼 수도 있고, 후드나 신발까지 포함한 착장을 함께 참고할 수도 있다. 사용자는 바지만 바꾸고 싶은데 결과가 신발이나 상의까지 건드리면, 문제는 단순한 생성 품질이 아니라 target garment scope의 실패에 가깝다.&lt;/p&gt;
&lt;p&gt;그래서 확인하고 싶었던 질문은 두 가지였다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;로컬 human parser가 ThatzFit의 실제 입력 이미지에서 바지 영역을 충분히 빠르고 안정적으로 잡는가?&lt;/li&gt;
&lt;li&gt;마스킹된 바지만 provider에 넘기면 &quot;입힐 대상&quot;이 바지로 더 분명해지는가?&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;처음-생각한-가설&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C-%EC%83%9D%EA%B0%81%ED%95%9C-%EA%B0%80%EC%84%A4&quot; aria-label=&quot;처음 생각한 가설 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음 생각한 가설&lt;/h2&gt;
&lt;p&gt;가설은 단순했다. 생성 모델이 보기 전에 의류 후보를 바지만 남긴 투명 PNG로 줄이면, provider가 후드나 신발까지 target garment처럼 해석하는 오해를 줄일 수 있다.&lt;/p&gt;
&lt;p&gt;다만 반대 가능성도 있었다. 마스크 경계가 거칠거나 얇은 디테일이 날아가면 생성 모델이 오히려 바지의 형태를 덜 잘 이해할 수 있다. 그래서 이번 실험은 backend default 변경이 아니라 별도 worktree와 Jupyter notebook에서만 진행했다.&lt;/p&gt;
&lt;h2 id=&quot;확인한-증거&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%95%EC%9D%B8%ED%95%9C-%EC%A6%9D%EA%B1%B0&quot; aria-label=&quot;확인한 증거 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;확인한 증거&lt;/h2&gt;
&lt;p&gt;실험은 기존 backend 작업트리를 건드리지 않기 위해 별도 worktree에서 진행했다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;환경: macOS arm64, Python 3.12.3, torch 2.12.0, MPS 사용 가능&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이번 실험에서는 Hugging Face의 &lt;a href=&quot;https://huggingface.co/fashn-ai/fashn-human-parser&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;fashn-ai/fashn-human-parser&lt;/code&gt;&lt;/a&gt;를 사용했다. fashion/virtual try-on 용도로 공개된 SegFormer 기반 human parsing 모델이고, &lt;code class=&quot;language-text&quot;&gt;top&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;dress&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;skirt&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;pants&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;feet&lt;/code&gt; 같은 semantic class를 반환한다. 이 글의 초점은 모델 자체 성능 비교가 아니라, segmentation 결과로 provider에 넘기는 target garment 범위를 좁힐 수 있는지였다.&lt;/p&gt;
&lt;p&gt;먼저 human parser의 단독 실행 시간을 측정했다. 캐시가 된 반복 실행(warm run) 기준으로 MPS가 CPU보다 훨씬 빨랐다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;device&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;cached load&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;first inference&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;warm avg&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;CPU&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.87s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1.23s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;1.02s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MPS&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.93s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.45s&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;0.26s&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;첫 실행(cold run)에서 CPU 모델 로드가 114초까지 나왔는데, 이는 weight 다운로드와 캐시 영향이다. 실제 서비스형 실행 판단에는 캐시 이후 수치를 보는 것이 맞다. 또 패키지 기본값은 macOS에서 MPS를 자동 선택하지 않으므로 device를 명시해야 한다.&lt;/p&gt;
&lt;p&gt;테스트 이미지의 class 분포는 다음과 같았다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;class&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;area&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;pants&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;45.84%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;background&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;45.17%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;top&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;5.35%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;feet&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.59%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/48fca9e8f30e8fcd8cbbb99c0abed39f/b67f0/parser_panel_mps.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 55.88235294117647%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAALCAIAAADwazoUAAAACXBIWXMAAAsTAAALEwEAmpwYAAACgklEQVR42mN48+K5g7OjqIiwuIS4iKjImVOn1ixdyKxsZbnwkdOG6/Yb71vOPcnAyhUTHhpZ2qEclq8dk6sUmRda3NjX1cnw////a5cvGmpp6Kup6quq3Lp6ef26tQwMDFqp6UHnT/scOuC6dhUDE2NkaOiUSRN9igqsczLNszJS6mv7O0Ga/x3Yu1tNQU5DSVFaRHjfju2bNm5gYGDQKy4OOHvOe/9+z507mQUEIoKD+vv7HXOyzTMyDFNTwsrLejo7QDZv2bBOQVJcVUGOm511w6oVmzdtYmBgMK6vDzh92nv/fu+9eznk5cMDA3r7+2yyMk3T03QS4v2Ki7shmjesXikvIaamKMfCyLB4zuzNYJtNW1v9T53y2rfP5+BBHk3NMH//3gn91lmZpmmpWvFx7gX5XR1gzWuWLZGXFNNUVmRlYpg2ccIGsJ/N2ttBmvfu9T18mF9fP8zPt7u/3zIzwyw9TScx3ik3p7O9neH//7/rVi1XkJLQUlVmZWLo6WjfuH4dAwODSXOz/+nTXnv2+B05ImBoGOrj093Xa5WVYZ6Rpp+UaJuV2d7WxvDv18/jhw8qykprqyrzcLJv27xp4waQs/WLioIvXvQ+edJ9zx42MTFQgE3od87NMcvO1EtP8ysp7unoYHjz/Mmrp48tTY0ZGBhY2dl27dyxbOkSBgYGXi0tu/XrPWbMsE5KYmBg8PHxbq2v88lIk/PzlbWz8w4JbqipYXj7+tWXD+/37NpRUlFe19R4+Mihffv2+vr4hEZElPT0dLe1NdbUxCckdHZ0bFi3Zv6SRU1dXQ11tX19fStXrmT4/ffv79+///z5+////3///v1HBn///scLAM/bPwyxncxmAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;human parser 결과 패널&apos; title=&apos;&apos; src=&apos;/static/48fca9e8f30e8fcd8cbbb99c0abed39f/ca1dc/parser_panel_mps.png&apos; srcset=&apos;/static/48fca9e8f30e8fcd8cbbb99c0abed39f/e7570/parser_panel_mps.png 170w,
/static/48fca9e8f30e8fcd8cbbb99c0abed39f/f46e7/parser_panel_mps.png 340w,
/static/48fca9e8f30e8fcd8cbbb99c0abed39f/ca1dc/parser_panel_mps.png 680w,
/static/48fca9e8f30e8fcd8cbbb99c0abed39f/02d09/parser_panel_mps.png 1020w,
/static/48fca9e8f30e8fcd8cbbb99c0abed39f/9d567/parser_panel_mps.png 1360w,
/static/48fca9e8f30e8fcd8cbbb99c0abed39f/b67f0/parser_panel_mps.png 2406w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;human parser 결과 패널&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;단순히 가장 큰 클래스(class)를 고르면 배경(background)을 선택할 수 있으므로, 실험에서는 &lt;code class=&quot;language-text&quot;&gt;top&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;dress&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;skirt&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;pants&lt;/code&gt;처럼 의류 클래스(garment class) 후보 안에서 가장 큰 영역을 선택했다. 이 샘플에서는 &lt;code class=&quot;language-text&quot;&gt;pants&lt;/code&gt;가 선택됐고, 바지 실루엣은 충분히 잡혔다. 대신 키링 같은 얇은 액세서리, 손과 포켓 주변, 발과 밑단 경계는 의류 매팅(garment matting) 수준으로 정밀하지 않았다.&lt;/p&gt;
&lt;h2 id=&quot;해결한-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%B4%EA%B2%B0%ED%95%9C-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;해결한 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;해결한 방식&lt;/h2&gt;
&lt;p&gt;노트북에서는 같은 모델 이미지에 대해 두 가지 변형(variant)을 만들었다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;baseline_original&lt;/code&gt;: 후드, 신발, 인물 일부가 포함된 원본 의류 이미지를 그대로 provider에 전달&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;masked_largest_garment&lt;/code&gt;: human parser가 선택한 &lt;code class=&quot;language-text&quot;&gt;pants&lt;/code&gt; 영역만 투명 PNG로 만들어 provider에 전달&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Provider 실행 시간은 baseline이 약 14.8초, masked variant가 약 25.2초였다. 이 차이는 단일 실행 결과라 외부 모델 지연(provider latency) 변동까지 포함한다. 로컬 전처리 자체는 MPS warm 기준 약 0.26초였고, 노트북에서 기록된 segmentation 구간은 약 0.72초였다.&lt;/p&gt;
&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/57478edd571fee567f1e34ccf23e1904/9c796/comparison_panel.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 32.35294117647059%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAGCAIAAABM9SnKAAAACXBIWXMAAAsTAAALEwEAmpwYAAABaklEQVR42iXO7S8CAQDH8eaF5xfWDJsX/gg2liFJZNo41VJrM/9FNt7ZeI2ZN4Y3vPKazUOjROUqeTarVasuuc7duQe6+1n6vv9sXw2AUrGQTycApJIJk9HQ29P9/voCYGtjfWnBw5RKv2Ul4D2J3Pj5byFPFcjA5UP09qP4qQHA0XTq7RWqKosiMTnR1d52T5IADAP9na3a58fHcllx2qfdTpsgiolkIpdKP8Wi2Vy2gg8P9rc3N/4XPswjwy3NjT7vuaoopuGhjlYtGQ5LkjQyqLOYR1mOowrUyqJnbXWZ+fqq4Pj15V3gAgBTxU0NJ8dHqqrqdX21NZrzs1MATisx73bJskzT9Lh+0O2wC6JYwexngaeLAKRvbtY2U19Xe+X3AXA5bEaDPpPJALAR01ZiShQliqIs5rE5t4vl2AqupiiKUv6JRSM7e7u5fBZAOpMWBAGALMvBYDAUCkmSxDAMGbqJx6I8z/8BpkQF31GvZWkAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;원본 입력과 마스킹 입력 비교&apos; title=&apos;&apos; src=&apos;/static/57478edd571fee567f1e34ccf23e1904/ca1dc/comparison_panel.png&apos; srcset=&apos;/static/57478edd571fee567f1e34ccf23e1904/e7570/comparison_panel.png 170w,
/static/57478edd571fee567f1e34ccf23e1904/f46e7/comparison_panel.png 340w,
/static/57478edd571fee567f1e34ccf23e1904/ca1dc/comparison_panel.png 680w,
/static/57478edd571fee567f1e34ccf23e1904/02d09/comparison_panel.png 1020w,
/static/57478edd571fee567f1e34ccf23e1904/9d567/comparison_panel.png 1360w,
/static/57478edd571fee567f1e34ccf23e1904/9c796/comparison_panel.png 1708w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;원본 입력과 마스킹 입력 비교&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;수동 평가는 아래처럼 기록했다. 점수는 1-5 기준이다. 표에는 숫자만 남기고, 판단 메모는 아래에 분리했다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Variant&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Garment identity&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Body realism&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Edge quality&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Artifact control&lt;/th&gt;
&lt;th align=&quot;right&quot;&gt;Overall&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Original input&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;2.0&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4.0&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4.0&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;2.0&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;2.8&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Masked input&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;4.0&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.5&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.5&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.5&lt;/td&gt;
&lt;td align=&quot;right&quot;&gt;3.7&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;&lt;strong&gt;평가 메모&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;baseline_original&lt;/code&gt;: provider가 원본을 &lt;code class=&quot;language-text&quot;&gt;hoodie + pants&lt;/code&gt; 착장으로 해석했다. 바지는 자연스럽지만 사용자가 기대한 &lt;code class=&quot;language-text&quot;&gt;pants only&lt;/code&gt; 범위에는 실패했다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;masked_largest_garment&lt;/code&gt;: 흰 티와 신발은 더 잘 보존되고 바지만 입히는 방향으로 개선됐다. 다만 발과 밑단이 변형되고 checkerboard 배경이 남았다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;이 실험에서 마스킹은 효과가 있었다. 핵심은 이미지 품질을 자동으로 올리는 것이 아니라 provider가 해석할 garment 범위를 줄여주는 데 있었다. 원본을 그대로 넣으면 provider가 후드나 신발까지 착장 정보로 끌고 들어올 수 있다. 바지만 남긴 입력은 &quot;입힐 대상은 바지&quot;라는 계약을 훨씬 분명하게 만들었다.&lt;/p&gt;
&lt;p&gt;하지만 바로 기본 기능으로 넣기에는 이르다. human parser는 의미론적 분할(semantic segmentation)에는 충분하지만 픽셀 단위 매팅(matting) 도구는 아니다. 또한 provider 결과가 실제 alpha가 아니라 checkerboard 배경을 rasterize해서 반환한 점은 후처리까지 같이 봐야 한다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;비슷한 가상 피팅 이슈를 다시 보면 바로 provider를 바꾸지 않는다. 먼저 입력 이미지 안에서 목표 의류와 참고 착장이 섞여 있는지 본다. 사용자가 바지만 원했는데 신발이나 상의까지 결과에 영향을 준다면, 모델 교체보다 target garment scope를 좁히는 전처리가 먼저다.&lt;/p&gt;
&lt;p&gt;다음 단계는 backend에 바로 붙이는 것이 아니라, 대표 의류 3-5개로 같은 비교를 반복하는 것이다. masked variant가 계속 이기면 feature flag 뒤에 숨긴 실험 기능으로 넣는다.&lt;/p&gt;
&lt;p&gt;후보 flow는 이렇다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;provider가 지원 대상이 아니면 skip한다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;VIRTUAL_FITTING_GARMENT_MASKING_ENABLED&lt;/code&gt;가 꺼져 있으면 skip한다.&lt;/li&gt;
&lt;li&gt;singleton parser를 &lt;code class=&quot;language-text&quot;&gt;asyncio.to_thread&lt;/code&gt;나 bounded executor로 실행한다.&lt;/li&gt;
&lt;li&gt;허용된 garment class 중 가장 큰 영역만 남긴다.&lt;/li&gt;
&lt;li&gt;garment area가 기준보다 작으면 원본 bytes로 fallback한다.&lt;/li&gt;
&lt;li&gt;performance step에 &lt;code class=&quot;language-text&quot;&gt;garment_segmentation&lt;/code&gt;을 남긴다.&lt;/li&gt;
&lt;li&gt;masked PNG bytes를 direct-bytes runner에 전달한다.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;이번 실험의 결론은 “계속 실험할 가치가 있다”이다. 마스킹은 목표 의류 범위(target garment scope)를 통제하는 데 유효했다. 다만 운영 기능(production feature)으로 만들려면 여러 입력에서 반복 검증하고, 신발/상의 보존 여부와 removebg 후처리 결과까지 같이 비교해야 한다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://huggingface.co/fashn-ai/fashn-human-parser&quot;&gt;fashn-ai/fashn-human-parser&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Next.js client env is a build artifact, not runtime env]]></title><description><![CDATA[The production container had the environment variable, but the Mixpanel Session Replay setting in the browser did not change. At first I…]]></description><link>https://sewon.dev/en/place2page-next-public-env-docker-build-artifact/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-next-public-env-docker-build-artifact/</guid><pubDate>Tue, 19 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/47528cfb9eac7c864056e791d44b088f/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB4UlEQVR42o2SS2sUQRSF8xPcCIIIboLgSnGhuMvOf6MgRgiCL0RI0IWIIG4ElwFFZILMmIckThrBQOKQMTrd05OZ7pmuru7qV3V1dVXdknkYJWD0cBe1+e6te86d4qW0uknHzcz9xEXUw7kzoPtuanWTjJYKlFJK/0VTUgLCiR8kAxQHJMMRHeDUw6nnp1FMM8pYwSUoCUoBjB8SFMAI1v8QAIAGfahgRA9hRQn3TRHaZcFaqGy6DKWCZRAikYbAStFm2Mz9SORembQo6hVEgprA3Dac2qOo/rxrfr/9Lry5OFj8Qtq7dGMlaBj5NxQ+cVYfW7VPQeu1u7VgVV+6BlV8AoOkWmAtiFLCZ9pjOhXAMohDyIiiGe1ETif3Y1kgnthF6PJYHnzb7vYrH+rvV42l6tryylq1tvxxvS6FGPbluXJdTeLh+qrUY6MO3NZaP3vx6vjpC9PnZk6euXxi+tKxU+fPXryCf5hxcw/tNKhpAecZ2es036R4d+z5b3i9/vna7L25Ows3bj28Pvfg6uzd+/NPqYdYr0d7Du/3tZBQxhx/BU4OTz4qqGEyOhFsI7AMYhthexO3NuN2KOivqADkSOKPmmQ8Oq+Q07e9rYq7XenvVJztJb/hlen/HMlR+glQCpBtbi9OzgAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Situation diagram&apos; title=&apos;&apos; src=&apos;/static/47528cfb9eac7c864056e791d44b088f/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/47528cfb9eac7c864056e791d44b088f/e7570/situation-diagram.png 170w,
/static/47528cfb9eac7c864056e791d44b088f/f46e7/situation-diagram.png 340w,
/static/47528cfb9eac7c864056e791d44b088f/ca1dc/situation-diagram.png 680w,
/static/47528cfb9eac7c864056e791d44b088f/02d09/situation-diagram.png 1020w,
/static/47528cfb9eac7c864056e791d44b088f/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Situation diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;The production container had the environment variable, but the Mixpanel Session Replay setting in the browser did not change. At first I suspected a missing runtime environment variable. The actual boundary was earlier: &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt;, not container startup. I debugged the path by treating &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; values as build artifacts inlined into the client bundle, then checking the GitHub Actions build args, Dockerfile &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;/&lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt;, and the browser bundle in that order.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: The env value existed in the production container, but the Mixpanel Session Replay behavior in the browser did not change.&lt;/li&gt;
&lt;li&gt;Judgment: This was a build pipeline problem, not just a container runtime env problem.&lt;/li&gt;
&lt;li&gt;Cause: &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; values are embedded into the Next.js client bundle at build time, so changing only runtime env does not change already-built JavaScript.&lt;/li&gt;
&lt;li&gt;Lesson: Frontend env debugging does not end with &lt;code class=&quot;language-text&quot;&gt;printenv&lt;/code&gt; inside the server. The real question is which value was used to build the bundle that users receive.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;While wiring Mixpanel Session Replay into Place2Page, one production flag caused confusion.&lt;/p&gt;
&lt;p&gt;The intended behavior was simple. When a specific &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; flag was enabled in production, the browser-side Mixpanel Replay setting should change. I added the GitHub Actions variable, and when I entered the production container and ran &lt;code class=&quot;language-text&quot;&gt;printenv&lt;/code&gt;, the value was there.&lt;/p&gt;
&lt;p&gt;But the browser behavior did not change.&lt;/p&gt;
&lt;p&gt;That looked strange at first. If the environment variable existed in the container, why did the frontend not know about it?&lt;/p&gt;
&lt;h2 id=&quot;Problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Problem&quot; aria-label=&quot;Problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;For a backend server, &quot;read runtime env&quot; is usually a natural model. The environment variable exists when the container starts, and server code can read that value while handling a request.&lt;/p&gt;
&lt;p&gt;Next.js client code is different.&lt;/p&gt;
&lt;p&gt;Code that runs in the browser does not directly read &lt;code class=&quot;language-text&quot;&gt;process.env&lt;/code&gt; from inside the container. It downloads and executes the JavaScript bundle produced by &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The Next.js documentation explains that &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; environment variables are inlined into the client JavaScript bundle at build time. So although the name can sound like public runtime env, in practice it becomes part of the build artifact.&lt;/p&gt;
&lt;p&gt;That means &lt;code class=&quot;language-text&quot;&gt;printenv NEXT_PUBLIC_SOMETHING=true&lt;/code&gt; can be visible in the production container while the already-built JS bundle still contains &lt;code class=&quot;language-text&quot;&gt;false&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;Initial-Hypothesis&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Initial-Hypothesis&quot; aria-label=&quot;Initial Hypothesis permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Initial Hypothesis&lt;/h2&gt;
&lt;p&gt;My first assumption was that the production env configuration was wrong, so I checked the env values on the server.&lt;/p&gt;
&lt;p&gt;But checking only the container runtime env was not enough. The important question was different:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Was this value present when &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt; ran?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;For Next.js client env issues, the check order has to change.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Does GitHub Actions pass the value into the Docker build as a build arg?&lt;/li&gt;
&lt;li&gt;Does the Dockerfile receive that value as an &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;Is it exposed as &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt; in the stage where &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt; runs?&lt;/li&gt;
&lt;li&gt;Was the production bundle actually built with that value?&lt;/li&gt;
&lt;li&gt;Is the deployed browser code receiving the new bundle?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Runtime &lt;code class=&quot;language-text&quot;&gt;printenv&lt;/code&gt; answers only part of that chain.&lt;/p&gt;
&lt;h2 id=&quot;Evidence&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Evidence&quot; aria-label=&quot;Evidence permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Evidence&lt;/h2&gt;
&lt;p&gt;The order of evidence mattered in this issue. Following the repository path made it clear why runtime env alone was not enough.&lt;/p&gt;
&lt;p&gt;The GitHub Actions web image build step passed client env through &lt;code class=&quot;language-text&quot;&gt;build-args&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_MIXPANEL_TOKEN=...
NEXT_PUBLIC_MIXPANEL_RECORD_SESSIONS_PERCENT=...
NEXT_PUBLIC_UNMASKED_SESSION_REPLAY=...
APP_ENV=production&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The Dockerfile accepted those values as &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt; and exposed them again as &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt; before &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt;.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;dockerfile&quot;&gt;&lt;pre class=&quot;language-dockerfile&quot;&gt;&lt;code class=&quot;language-dockerfile&quot;&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;ARG&lt;/span&gt; NEXT_PUBLIC_MIXPANEL_TOKEN&lt;/span&gt;
&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;ARG&lt;/span&gt; NEXT_PUBLIC_MIXPANEL_RECORD_SESSIONS_PERCENT=100&lt;/span&gt;
&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;ARG&lt;/span&gt; NEXT_PUBLIC_UNMASKED_SESSION_REPLAY=false&lt;/span&gt;

&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;ENV&lt;/span&gt; NEXT_PUBLIC_MIXPANEL_TOKEN=&lt;span class=&quot;token variable&quot;&gt;$NEXT_PUBLIC_MIXPANEL_TOKEN&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;\&lt;/span&gt;
    NEXT_PUBLIC_MIXPANEL_RECORD_SESSIONS_PERCENT=&lt;span class=&quot;token variable&quot;&gt;$NEXT_PUBLIC_MIXPANEL_RECORD_SESSIONS_PERCENT&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;\&lt;/span&gt;
    NEXT_PUBLIC_UNMASKED_SESSION_REPLAY=&lt;span class=&quot;token variable&quot;&gt;$NEXT_PUBLIC_UNMASKED_SESSION_REPLAY&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;RUN&lt;/span&gt; npm run build&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The client code then read this value from &lt;code class=&quot;language-text&quot;&gt;process.env.NEXT_PUBLIC_UNMASKED_SESSION_REPLAY&lt;/code&gt; to build the Mixpanel Replay masking configuration.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;UNMASKED_SESSION_REPLAY&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;resolveUnmaskedSessionReplay&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;NEXT_PUBLIC_UNMASKED_SESSION_REPLAY&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So if the value existed only in the production container runtime and not when &lt;code class=&quot;language-text&quot;&gt;npm run build&lt;/code&gt; ran, the browser bundle could still be built with the old value.&lt;/p&gt;
&lt;p&gt;The commit history pointed to the same conclusion. &lt;code class=&quot;language-text&quot;&gt;98c38da2 fix(ci): wire NEXT_PUBLIC_MIXPANEL_TOKEN into web image build&lt;/code&gt; changed both the GitHub Actions build arg and the Dockerfile. &lt;code class=&quot;language-text&quot;&gt;fc262431 fix: wire mixpanel replay unmask flag&lt;/code&gt; also touched the workflow, Dockerfile, Mixpanel wrapper, tests, and docs. The fix point was not one production &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt; value. It was the whole build pipeline.&lt;/p&gt;
&lt;h2 id=&quot;The-Docker-Boundary-That-Mattered&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#The-Docker-Boundary-That-Mattered&quot; aria-label=&quot;The Docker Boundary That Mattered permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;The Docker Boundary That Mattered&lt;/h2&gt;
&lt;p&gt;This issue made me revisit the difference between Docker &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In Docker&apos;s documentation, &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt; is a value that can be passed at build time, while &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt; is an environment variable available to later instructions in the build stage and at container runtime. They look similar, but their lifetimes are different.&lt;/p&gt;
&lt;p&gt;Next.js client env is needed when &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt; runs. That means GitHub Actions has to pass the value with &lt;code class=&quot;language-text&quot;&gt;--build-arg&lt;/code&gt;, the Dockerfile has to receive it as &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;, and the build stage has to expose it with &lt;code class=&quot;language-text&quot;&gt;ENV NEXT_PUBLIC_...=$NEXT_PUBLIC_...&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;By contrast, adding a value to production &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt; after the image has already been built can matter for server runtime, but it is too late for the client bundle.&lt;/p&gt;
&lt;p&gt;This is the confusing part.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The Docker container can have the env value.&lt;/li&gt;
&lt;li&gt;Next.js server code can read that env value.&lt;/li&gt;
&lt;li&gt;Browser code still receives already-built JavaScript.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All three can be true at the same time.&lt;/p&gt;
&lt;h2 id=&quot;Fix-Approach&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Fix-Approach&quot; aria-label=&quot;Fix Approach permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Fix Approach&lt;/h2&gt;
&lt;p&gt;I set the debugging order like this.&lt;/p&gt;
&lt;p&gt;First, I checked the web image build step in the GitHub Actions workflow and confirmed whether the affected &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; value was passed as a build arg.&lt;/p&gt;
&lt;p&gt;Next, I checked the Dockerfile. I confirmed that the build stage declared the value as an &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt; and exposed it as &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt; before &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt; ran.&lt;/p&gt;
&lt;p&gt;Finally, I checked the production container and the real browser behavior. I did not stop at container env. I also checked whether the Session Replay-related browser events matched the intended behavior.&lt;/p&gt;
&lt;p&gt;The fix was not &quot;add the value to production env.&quot; It was &quot;inject the client env at image build time.&quot;&lt;/p&gt;
&lt;h2 id=&quot;Lessons&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Lessons&quot; aria-label=&quot;Lessons permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Lessons&lt;/h2&gt;
&lt;p&gt;This issue stays confusing unless Docker is part of the mental model.&lt;/p&gt;
&lt;p&gt;At first I thought seeing the env value inside the container was enough. But the frontend bundle is not created when the container starts. It is created when the image is built.&lt;/p&gt;
&lt;p&gt;In Next.js, &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; is closer to a public build-time constant than public runtime config. &lt;code class=&quot;language-text&quot;&gt;PUBLIC&lt;/code&gt; does not mean the value can be changed at any time. It mostly means the value will be exposed to the browser.&lt;/p&gt;
&lt;p&gt;So in a Next.js + Docker setup, &lt;code class=&quot;language-text&quot;&gt;printenv&lt;/code&gt; inside the server is not enough for client env debugging.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Will-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Will-Judge-This-Next-Time&quot; aria-label=&quot;How I Will Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Will Judge This Next Time&lt;/h2&gt;
&lt;p&gt;When another Next.js client env issue appears, I will not treat production container &lt;code class=&quot;language-text&quot;&gt;printenv&lt;/code&gt; as final evidence. I will first check whether the value existed when the client bundle was built.&lt;/p&gt;
&lt;p&gt;My production client env checklist is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Was it passed as a build arg from GitHub Actions?&lt;/li&gt;
&lt;li&gt;Does the Dockerfile build stage declare the &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;Is it exposed as &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt; before &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt;?&lt;/li&gt;
&lt;li&gt;Is the value safe to expose publicly?&lt;/li&gt;
&lt;li&gt;After deploy, was the actual browser bundle behavior verified?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The last point matters most. Client env can look correct in code and in the container. But users execute the browser bundle, so the final question is which value that bundle was built with.&lt;/p&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://nextjs.org/docs/app/guides/environment-variables&quot;&gt;Next.js Environment Variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/build/building/variables/&quot;&gt;Docker Build variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/reference/builder/#arg&quot;&gt;Dockerfile reference: ARG&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Next.js client env는 runtime env가 아니라 build artifact다]]></title><description><![CDATA[production 컨테이너에 env가 보이는데도 브라우저의 Mixpanel Session Replay 설정은 바뀌지 않았다. 처음에는 런타임 환경 변수 누락을 의심했지만, 실제 경계는 컨테이너 시작 시점이 아니라  시점이었다.  값은 runtime…]]></description><link>https://sewon.dev/place2page-next-public-env-docker-build-artifact/</link><guid isPermaLink="false">https://sewon.dev/place2page-next-public-env-docker-build-artifact/</guid><pubDate>Tue, 19 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/47528cfb9eac7c864056e791d44b088f/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB4UlEQVR42o2SS2sUQRSF8xPcCIIIboLgSnGhuMvOf6MgRgiCL0RI0IWIIG4ElwFFZILMmIckThrBQOKQMTrd05OZ7pmuru7qV3V1dVXdknkYJWD0cBe1+e6te86d4qW0uknHzcz9xEXUw7kzoPtuanWTjJYKlFJK/0VTUgLCiR8kAxQHJMMRHeDUw6nnp1FMM8pYwSUoCUoBjB8SFMAI1v8QAIAGfahgRA9hRQn3TRHaZcFaqGy6DKWCZRAikYbAStFm2Mz9SORembQo6hVEgprA3Dac2qOo/rxrfr/9Lry5OFj8Qtq7dGMlaBj5NxQ+cVYfW7VPQeu1u7VgVV+6BlV8AoOkWmAtiFLCZ9pjOhXAMohDyIiiGe1ETif3Y1kgnthF6PJYHnzb7vYrH+rvV42l6tryylq1tvxxvS6FGPbluXJdTeLh+qrUY6MO3NZaP3vx6vjpC9PnZk6euXxi+tKxU+fPXryCf5hxcw/tNKhpAecZ2es036R4d+z5b3i9/vna7L25Ows3bj28Pvfg6uzd+/NPqYdYr0d7Du/3tZBQxhx/BU4OTz4qqGEyOhFsI7AMYhthexO3NuN2KOivqADkSOKPmmQ8Oq+Q07e9rYq7XenvVJztJb/hlen/HMlR+glQCpBtbi9OzgAAAABJRU5ErkJggg==&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/47528cfb9eac7c864056e791d44b088f/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/47528cfb9eac7c864056e791d44b088f/e7570/situation-diagram.png 170w,
/static/47528cfb9eac7c864056e791d44b088f/f46e7/situation-diagram.png 340w,
/static/47528cfb9eac7c864056e791d44b088f/ca1dc/situation-diagram.png 680w,
/static/47528cfb9eac7c864056e791d44b088f/02d09/situation-diagram.png 1020w,
/static/47528cfb9eac7c864056e791d44b088f/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;production 컨테이너에 env가 보이는데도 브라우저의 Mixpanel Session Replay 설정은 바뀌지 않았다. 처음에는 런타임 환경 변수 누락을 의심했지만, 실제 경계는 컨테이너 시작 시점이 아니라 &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt; 시점이었다. &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; 값은 runtime config가 아니라 client bundle에 inline되는 build artifact라는 점을 기준으로 GitHub Actions build arg, Dockerfile &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;/&lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt;, 실제 browser bundle을 순서대로 확인했다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: production 컨테이너에는 env가 보이는데, 브라우저에서 실행되는 Mixpanel Session Replay 설정은 바뀌지 않았다.&lt;/li&gt;
&lt;li&gt;판단: 컨테이너 runtime env가 아니라 image build pipeline을 먼저 봐야 하는 문제였다.&lt;/li&gt;
&lt;li&gt;원인: &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; 값은 Next.js client bundle에 build time에 박히므로, runtime env만 바꿔서는 이미 빌드된 JS가 바뀌지 않는다.&lt;/li&gt;
&lt;li&gt;배운 점: 프론트엔드 env 문제는 서버에 들어가 &lt;code class=&quot;language-text&quot;&gt;printenv&lt;/code&gt;를 보는 것으로 끝나지 않는다. 최종 사용자가 받는 bundle이 어떤 값으로 만들어졌는지 확인해야 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;Place2Page에 Mixpanel Session Replay 설정을 붙이면서 production flag 하나가 문제를 만들었다.&lt;/p&gt;
&lt;p&gt;원하는 동작은 단순했다. production에서 특정 &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; flag를 켜면 브라우저의 Mixpanel Replay 설정이 달라져야 했다. GitHub Actions variable도 넣었고, production 컨테이너에 들어가서 &lt;code class=&quot;language-text&quot;&gt;printenv&lt;/code&gt;를 보면 값도 있었다.&lt;/p&gt;
&lt;p&gt;그런데 브라우저 동작은 바뀌지 않았다.&lt;/p&gt;
&lt;p&gt;처음에는 이상했다. 컨테이너에 환경 변수가 있는데 왜 프론트엔드는 모를까?&lt;/p&gt;
&lt;h2 id=&quot;문제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%A0%9C&quot; aria-label=&quot;문제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문제&lt;/h2&gt;
&lt;p&gt;백엔드 서버라면 runtime env를 읽는다는 말이 자연스럽다. 컨테이너가 시작될 때 환경 변수가 있고, 서버 코드가 요청 시점에 그 값을 읽으면 된다.&lt;/p&gt;
&lt;p&gt;하지만 Next.js client code는 다르다.&lt;/p&gt;
&lt;p&gt;브라우저에서 실행되는 코드는 컨테이너 안에서 직접 &lt;code class=&quot;language-text&quot;&gt;process.env&lt;/code&gt;를 읽지 않는다. &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt; 시점에 만들어진 JavaScript bundle을 내려받아 실행한다.&lt;/p&gt;
&lt;p&gt;Next.js 공식 문서도 &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; 환경 변수는 build time에 client JavaScript bundle 안으로 inline 된다고 설명한다. 즉, &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt;은 이름만 보면 runtime public env처럼 느껴지지만, 실제로는 build artifact의 일부가 된다.&lt;/p&gt;
&lt;p&gt;그래서 production 컨테이너에서 &lt;code class=&quot;language-text&quot;&gt;printenv NEXT_PUBLIC_SOMETHING=true&lt;/code&gt;가 보여도, 이미 그 전에 만들어진 JS bundle 안에는 &lt;code class=&quot;language-text&quot;&gt;false&lt;/code&gt;가 들어가 있을 수 있다.&lt;/p&gt;
&lt;h2 id=&quot;처음-생각한-가설&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C-%EC%83%9D%EA%B0%81%ED%95%9C-%EA%B0%80%EC%84%A4&quot; aria-label=&quot;처음 생각한 가설 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음 생각한 가설&lt;/h2&gt;
&lt;p&gt;처음에는 production env 설정이 잘못됐다고 생각했다. 그래서 서버에 들어가 env를 확인했다.&lt;/p&gt;
&lt;p&gt;하지만 컨테이너 runtime env만 확인해서는 부족했다. 중요한 질문은 따로 있었다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;이 값이 &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt;가 실행되는 시점에 들어갔는가?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Next.js client env 문제를 보면 확인 순서를 바꿔야 한다.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;GitHub Actions가 Docker build에 build arg를 넘기는가?&lt;/li&gt;
&lt;li&gt;Dockerfile이 그 &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;를 받는가?&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt;가 실행되는 stage에서 &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt;로 노출되는가?&lt;/li&gt;
&lt;li&gt;실제 production bundle이 그 값으로 만들어졌는가?&lt;/li&gt;
&lt;li&gt;배포된 브라우저 코드가 새 bundle을 받고 있는가?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;runtime container의 &lt;code class=&quot;language-text&quot;&gt;printenv&lt;/code&gt;는 이 중 일부만 답한다.&lt;/p&gt;
&lt;h2 id=&quot;확인한-증거&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%95%EC%9D%B8%ED%95%9C-%EC%A6%9D%EA%B1%B0&quot; aria-label=&quot;확인한 증거 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;확인한 증거&lt;/h2&gt;
&lt;p&gt;이 문제는 확인 순서가 중요했다. repo에서 단서를 따라가면 왜 runtime env만으로는 부족한지 보인다.&lt;/p&gt;
&lt;p&gt;GitHub Actions의 web image build step은 &lt;code class=&quot;language-text&quot;&gt;build-args&lt;/code&gt;로 client env를 넘긴다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_MIXPANEL_TOKEN=...
NEXT_PUBLIC_MIXPANEL_RECORD_SESSIONS_PERCENT=...
NEXT_PUBLIC_UNMASKED_SESSION_REPLAY=...
APP_ENV=production&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Dockerfile에서는 이 값들을 &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;로 받고, &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt; 전에 &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt;로 다시 노출한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;dockerfile&quot;&gt;&lt;pre class=&quot;language-dockerfile&quot;&gt;&lt;code class=&quot;language-dockerfile&quot;&gt;&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;ARG&lt;/span&gt; NEXT_PUBLIC_MIXPANEL_TOKEN&lt;/span&gt;
&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;ARG&lt;/span&gt; NEXT_PUBLIC_MIXPANEL_RECORD_SESSIONS_PERCENT=100&lt;/span&gt;
&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;ARG&lt;/span&gt; NEXT_PUBLIC_UNMASKED_SESSION_REPLAY=false&lt;/span&gt;

&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;ENV&lt;/span&gt; NEXT_PUBLIC_MIXPANEL_TOKEN=&lt;span class=&quot;token variable&quot;&gt;$NEXT_PUBLIC_MIXPANEL_TOKEN&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;\&lt;/span&gt;
    NEXT_PUBLIC_MIXPANEL_RECORD_SESSIONS_PERCENT=&lt;span class=&quot;token variable&quot;&gt;$NEXT_PUBLIC_MIXPANEL_RECORD_SESSIONS_PERCENT&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;\&lt;/span&gt;
    NEXT_PUBLIC_UNMASKED_SESSION_REPLAY=&lt;span class=&quot;token variable&quot;&gt;$NEXT_PUBLIC_UNMASKED_SESSION_REPLAY&lt;/span&gt;&lt;/span&gt;

&lt;span class=&quot;token instruction&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;RUN&lt;/span&gt; npm run build&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그리고 client code는 이 값을 &lt;code class=&quot;language-text&quot;&gt;process.env.NEXT_PUBLIC_UNMASKED_SESSION_REPLAY&lt;/code&gt;에서 읽어 Mixpanel Replay masking 설정을 만든다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;ts&quot;&gt;&lt;pre class=&quot;language-ts&quot;&gt;&lt;code class=&quot;language-ts&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; &lt;span class=&quot;token constant&quot;&gt;UNMASKED_SESSION_REPLAY&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;resolveUnmaskedSessionReplay&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;
  process&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;env&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token constant&quot;&gt;NEXT_PUBLIC_UNMASKED_SESSION_REPLAY&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;따라서 값이 production container runtime에만 있고 &lt;code class=&quot;language-text&quot;&gt;npm run build&lt;/code&gt; 시점에 없다면, 브라우저 bundle은 예전 값으로 만들어질 수 있다.&lt;/p&gt;
&lt;p&gt;커밋 기록도 같은 결론을 가리킨다. &lt;code class=&quot;language-text&quot;&gt;98c38da2 fix(ci): wire NEXT_PUBLIC_MIXPANEL_TOKEN into web image build&lt;/code&gt;는 GitHub Actions build arg와 Dockerfile을 같이 바꿨고, &lt;code class=&quot;language-text&quot;&gt;fc262431 fix: wire mixpanel replay unmask flag&lt;/code&gt;도 workflow, Dockerfile, Mixpanel wrapper, 테스트, 문서를 같이 바꿨다. 즉 수정 지점은 production &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt; 하나가 아니라 build pipeline 전체였다.&lt;/p&gt;
&lt;h2 id=&quot;Docker를-다시-보게-된-부분&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Docker%EB%A5%BC-%EB%8B%A4%EC%8B%9C-%EB%B3%B4%EA%B2%8C-%EB%90%9C-%EB%B6%80%EB%B6%84&quot; aria-label=&quot;Docker를 다시 보게 된 부분 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Docker를 다시 보게 된 부분&lt;/h2&gt;
&lt;p&gt;이 문제를 보면서 Docker의 &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;와 &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt; 차이를 다시 봤다.&lt;/p&gt;
&lt;p&gt;Docker 공식 문서 기준으로 &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;는 build time에 넘길 수 있는 값이고, &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt;는 build stage의 이후 instruction과 container runtime에서 사용할 수 있는 환경 변수다. 둘은 비슷해 보이지만 수명이 다르다.&lt;/p&gt;
&lt;p&gt;Next.js client env는 &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt;가 실행될 때 필요하다. 그러면 GitHub Actions에서 &lt;code class=&quot;language-text&quot;&gt;--build-arg&lt;/code&gt;로 값을 넘기고, Dockerfile에서 &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;로 받고, build stage에서 &lt;code class=&quot;language-text&quot;&gt;ENV NEXT_PUBLIC_...=$NEXT_PUBLIC_...&lt;/code&gt; 형태로 노출해야 한다.&lt;/p&gt;
&lt;p&gt;반대로 이미 이미지가 만들어진 뒤 production &lt;code class=&quot;language-text&quot;&gt;.env&lt;/code&gt;에 값을 넣는 것은 서버 runtime에는 의미가 있어도, client bundle에는 늦다.&lt;/p&gt;
&lt;p&gt;이 지점이 헷갈리기 쉽다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Docker container에는 env가 있다.&lt;/li&gt;
&lt;li&gt;Next.js server code는 그 env를 읽을 수 있다.&lt;/li&gt;
&lt;li&gt;하지만 browser code는 이미 빌드된 JS만 받는다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;세 문장이 동시에 참일 수 있다.&lt;/p&gt;
&lt;h2 id=&quot;해결한-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%B4%EA%B2%B0%ED%95%9C-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;해결한 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;해결한 방식&lt;/h2&gt;
&lt;p&gt;디버깅 순서는 이렇게 잡았다.&lt;/p&gt;
&lt;p&gt;먼저 GitHub Actions workflow에서 web image build step을 봤다. 문제가 된 &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt; 값이 build args로 넘어가는지 확인했다.&lt;/p&gt;
&lt;p&gt;다음으로 Dockerfile을 봤다. build stage에서 해당 값을 &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;로 선언하고, &lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt;가 실행되는 시점에 &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt;로 노출되는지 확인했다.&lt;/p&gt;
&lt;p&gt;마지막으로 production container와 실제 브라우저 동작을 확인했다. container env만 보고 끝내지 않고, 브라우저에서 Session Replay 관련 event가 의도대로 나오는지까지 확인했다.&lt;/p&gt;
&lt;p&gt;결국 수정은 &quot;production env에 값을 추가한다&quot;가 아니라 &quot;이미지 build 시점에 client env를 넣는다&quot;였다.&lt;/p&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;이번 문제는 Docker를 제대로 이해하지 못하면 계속 헷갈릴 수밖에 없었다.&lt;/p&gt;
&lt;p&gt;나는 처음에 컨테이너 안에 env가 보이면 충분하다고 생각했다. 하지만 프론트엔드 번들은 컨테이너가 시작될 때 만들어지는 것이 아니라, 이미지가 빌드될 때 만들어진다.&lt;/p&gt;
&lt;p&gt;Next.js의 &lt;code class=&quot;language-text&quot;&gt;NEXT_PUBLIC_&lt;/code&gt;은 public runtime config가 아니라 public build-time constant에 가깝다. 이름에 &lt;code class=&quot;language-text&quot;&gt;PUBLIC&lt;/code&gt;이 붙었다고 해서 언제든 바꿀 수 있는 값이라는 뜻은 아니다. 브라우저에 공개될 값이라는 뜻에 가깝다.&lt;/p&gt;
&lt;p&gt;그래서 Next.js + Docker 조합에서 client env 문제가 생기면, 서버 안에 들어가 &lt;code class=&quot;language-text&quot;&gt;printenv&lt;/code&gt;만 보는 것으로는 부족하다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;Next.js client env 문제가 다시 나오면 production container의 &lt;code class=&quot;language-text&quot;&gt;printenv&lt;/code&gt;를 최종 증거로 보지 않는다. 먼저 이 값이 client bundle이 만들어지는 시점에 있었는지 확인한다.&lt;/p&gt;
&lt;p&gt;앞으로 Next.js client env를 production에 넣을 때는 체크리스트를 이렇게 가져간다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;GitHub Actions에서 build arg로 넘겼는가?&lt;/li&gt;
&lt;li&gt;Dockerfile build stage에 &lt;code class=&quot;language-text&quot;&gt;ARG&lt;/code&gt;가 있는가?&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;next build&lt;/code&gt; 전에 &lt;code class=&quot;language-text&quot;&gt;ENV&lt;/code&gt;로 노출되는가?&lt;/li&gt;
&lt;li&gt;값이 secret인지 public이어도 되는 값인지 확인했는가?&lt;/li&gt;
&lt;li&gt;배포 후 실제 브라우저 bundle 동작으로 확인했는가?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;특히 마지막이 중요하다. client env 문제는 코드와 컨테이너만 보면 맞아 보일 수 있다. 하지만 최종 사용자는 브라우저 bundle을 실행한다. 결국 그 bundle이 어떤 값으로 만들어졌는지를 확인해야 한다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://nextjs.org/docs/app/guides/environment-variables&quot;&gt;Next.js Environment Variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/build/building/variables/&quot;&gt;Docker Build variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/reference/builder/#arg&quot;&gt;Dockerfile reference: ARG&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Treating AI Copy Quality as a Grounding Problem, Not a Forbidden-Words List]]></title><description><![CDATA[Place2Page's AI copy was not grammatically wrong, but repeated patterns became obvious across multiple places. At first, it seemed like…]]></description><link>https://sewon.dev/en/place2page-copy-quality-grounding-rules/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-copy-quality-grounding-rules/</guid><pubDate>Fri, 15 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/ec219aaf42fbb7c7c51dbd85cfa4e484/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB+ElEQVR42o2SzWsTQRjGI+JZPfWiIKLgwYMnL4J49k/oxbugSFuVVKpF0qDiJxb0oOihraQ9iC14qBrEJtpQsaGUkERrNml2N9lsttmPye7svO9MmbUSChJ85zk8l98zvM9MjIb4q2prBqmqXk1z1SbZbHi6QRTVdVwq+k4MkBum295yW23XMJ2m6Rmm9I2WazsEETnnyDlEYogMAAA5j+CdEM4Fx12xnAmJSZs3Kykl907Lv7cKC3Zh2VUEl0fC2KmT0kdSXGStMgLjLKSeYevffLuKwASES9r6ZPHDa/XrlLEy7fz45JRl+B+YKVkt/VhNP/ELC0h99LvEyKs/39palrYNDIJAoCfApOS3Zda2LJN4OzvLDAjBqjJzgwUecAHIAYA5ClCCwMHzQlWltTpTNdQaXNN5y+zB/SZqplMqbXz+ouZWOmtrUCqCUunBAPD85dStiUeJe5PJ+8/GEg+vjd2Jj9+9cv32zNy8TKCh6FLRDaSIL/ygBwcBPXd+cODo6SMnzx4+cebAoVN79x/bd/B4bM/A4IXLTUHSVjnjKBlXydiVJU9Z9XWInia6GfHB0xeXRsZHRpND8cRQPDE8OnH1RvLi8M3U7Px6V39Vzb6p52Y2l1P691lrddEphQj/sbMQyDFEYH8lPcCuwmS9/xIg9vme28XrfvbmgFHEAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/ec219aaf42fbb7c7c51dbd85cfa4e484/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/ec219aaf42fbb7c7c51dbd85cfa4e484/e7570/situation-diagram.png 170w,
/static/ec219aaf42fbb7c7c51dbd85cfa4e484/f46e7/situation-diagram.png 340w,
/static/ec219aaf42fbb7c7c51dbd85cfa4e484/ca1dc/situation-diagram.png 680w,
/static/ec219aaf42fbb7c7c51dbd85cfa4e484/02d09/situation-diagram.png 1020w,
/static/ec219aaf42fbb7c7c51dbd85cfa4e484/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Place2Page&apos;s AI copy was not grammatically wrong, but repeated patterns became obvious across multiple places. At first, it seemed like blocking words such as &lt;code class=&quot;language-text&quot;&gt;premium&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;special experience&lt;/code&gt; would solve it. The real issue was not the words themselves. It was unsupported claims. So I changed the final HTML contract from &quot;write more impressively&quot; to &quot;write usefully from the provided place data.&quot;&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: AI-generated landing page copy leaned on generic phrases such as &quot;premium&quot; and &quot;special experience&quot; instead of the actual place information.&lt;/li&gt;
&lt;li&gt;Decision: A grounding contract was more important than a forbidden-words list.&lt;/li&gt;
&lt;li&gt;Fix: Add copy quality constraints to the generation contract just before final HTML generation, and prioritize real business facts such as menu items, location, opening hours, and reservation links.&lt;/li&gt;
&lt;li&gt;Lesson: Good AI copy is less about more polished language and more about making fewer unsupported claims.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;Place2Page builds landing pages from place data. For a restaurant, the input may include menus, opening hours, photos, and reviews. For a salon, it may include reservation links and service information. From that data, the page title, intro copy, CTA, and visit information are generated.&lt;/p&gt;
&lt;p&gt;The first outputs looked plausible. They had design, sections, and calls to action. But after reviewing several results, the same sentence patterns kept appearing.&lt;/p&gt;
&lt;p&gt;Phrases like &quot;premium experience,&quot; &quot;unforgettable journey,&quot; and &quot;crafted with care&quot; showed up often. In Korean output, phrases like &quot;특별한 경험&quot;, &quot;최고의 가치&quot;, &quot;프리미엄 공간&quot;, and &quot;잊지 못할 순간&quot; repeated too.&lt;/p&gt;
&lt;p&gt;One or two examples may look acceptable. Across many places, the repetition quickly starts to read like AI-generated copy.&lt;/p&gt;
&lt;h2 id=&quot;Problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Problem&quot; aria-label=&quot;Problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;At first, this looked like a forbidden-words problem.&lt;/p&gt;
&lt;p&gt;When certain words appear too often, it is natural to think blocking those words will help. Rules that avoid terms like &quot;premium,&quot; &quot;journey,&quot; and &quot;crafted&quot; do have some effect.&lt;/p&gt;
&lt;p&gt;But a larger issue became clear.&lt;/p&gt;
&lt;p&gt;The weak sentences were awkward not because of one specific word, but because they were not grounded in the actual place data. Instead of using information about the restaurant, menu, location, or reservation availability, the model leaned on pleasant but generic marketing language.&lt;/p&gt;
&lt;p&gt;If menu data exists, &quot;we offer a special experience&quot; is weak. Showing real menu names, prices, reservation links, and location information is more trustworthy.&lt;/p&gt;
&lt;h2 id=&quot;Initial-Hypothesis&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Initial-Hypothesis&quot; aria-label=&quot;Initial Hypothesis permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Initial Hypothesis&lt;/h2&gt;
&lt;p&gt;At first, I thought changing the meta prompt would be enough. If the meta prompt said &quot;be more specific&quot; and &quot;do not exaggerate,&quot; final HTML should improve.&lt;/p&gt;
&lt;p&gt;In practice, the final HTML stage inflated the language again. Even when the meta prompt stayed restrained, the last generation model pulled in familiar marketing copy while writing the landing page.&lt;/p&gt;
&lt;p&gt;That pointed to the contract right before final HTML output. The last generation step needed a stronger rule: write only from the facts present in the input.&lt;/p&gt;
&lt;h2 id=&quot;Evidence&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Evidence&quot; aria-label=&quot;Evidence permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Evidence&lt;/h2&gt;
&lt;p&gt;When I later summarized this in the runbook, the record was fairly clear.&lt;/p&gt;
&lt;p&gt;The problem notes mentioned repeated use of phrases in the &quot;premium,&quot; &quot;experience,&quot; and &quot;special moment&quot; family. Korean output also used phrases such as &quot;특별한 경험&quot;, &quot;최고의 가치&quot;, and &quot;프리미엄 공간&quot; without data support.&lt;/p&gt;
&lt;p&gt;The first suspect was the meta prompt. But comparing the active generation rules showed that the meaningful production change happened in the final HTML contract. The important change was not a more emotional style instruction. It was adding a grounding constraint to the last generation step.&lt;/p&gt;
&lt;p&gt;The final HTML prompt points in the same direction. When business facts are available, the visible copy should use concrete cues such as website, price level, opening hours, reservation links, menu items, and photos. The core instruction was not &quot;write more emotionally.&quot; It was &quot;make the facts in the input visible.&quot;&lt;/p&gt;
&lt;p&gt;The evidence came down to three signals.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Signal&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Repeated generic copy records&lt;/td&gt;
&lt;td&gt;The issue was an unsupported sentence pattern, not one bad word.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Changed operating rule&lt;/td&gt;
&lt;td&gt;The fix belonged in the final HTML prompt contract.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Business-facts rule&lt;/td&gt;
&lt;td&gt;Better copy meant staying closer to data, not sounding grander.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;Implementation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Implementation&quot; aria-label=&quot;Implementation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Implementation&lt;/h2&gt;
&lt;p&gt;The core fix was grounding, not a forbidden-words list.&lt;/p&gt;
&lt;p&gt;The rules were roughly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use the provided JSON data first: business name, category, location, opening hours, reviews, services, menu items, reservation URL, website, photos, and price level.&lt;/li&gt;
&lt;li&gt;Do not invent awards, origin stories, premium positioning, or emotional claims that are not present in the data.&lt;/li&gt;
&lt;li&gt;If information is unknown, do not fill it in with plausible-sounding copy. Write within what is known.&lt;/li&gt;
&lt;li&gt;Before returning headings and paragraphs, ask whether the sentence could be attached to almost any business.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Some avoid-list language still existed. But the goal was not &quot;do not use this word.&quot; The goal was closer to &quot;do not write unsupported sentences.&quot;&lt;/p&gt;
&lt;h2 id=&quot;What-Changed&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#What-Changed&quot; aria-label=&quot;What Changed permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;What Changed&lt;/h2&gt;
&lt;p&gt;After this rule, the copy direction changes.&lt;/p&gt;
&lt;p&gt;Before, it was easy to get a sentence like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A special space that delivers an unforgettable premium experience.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It sounds plausible, but it can be attached to almost any place.&lt;/p&gt;
&lt;p&gt;With stronger grounding, the direction becomes closer to this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A pasta restaurant near Hongik University Station where reservations are available. Check signature menu items and opening hours before planning your visit.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The second sentence may look more ordinary. On an actual landing page, it is better. Users need concrete visit information and credible cues before abstract emotional language.&lt;/p&gt;
&lt;h2 id=&quot;Lesson&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Lesson&quot; aria-label=&quot;Lesson permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Lesson&lt;/h2&gt;
&lt;p&gt;&quot;Improving AI copy quality&quot; can sound like making sentences more impressive. In a real product, it was closer to the opposite.&lt;/p&gt;
&lt;p&gt;Less invented copy mattered more than more polished copy. The important parts were not saying things absent from the data, avoiding the same phrasing across every place, and putting actionable information first.&lt;/p&gt;
&lt;p&gt;This was closer to product writing than prompt engineering. Instead of telling the model, &quot;make it sound good,&quot; the better instruction was, &quot;make it useful using only what you know.&quot;&lt;/p&gt;
&lt;h2 id=&quot;How-I-Would-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Would-Judge-This-Next-Time&quot; aria-label=&quot;How I Would Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Would Judge This Next Time&lt;/h2&gt;
&lt;p&gt;When reviewing AI-generated copy, I will not look only at words. Before deciding which expressions to ban, I will ask why the sentence was possible. If the sentence is not grounded in input data, the fix belongs in the grounding contract more than in the writing style.&lt;/p&gt;
&lt;p&gt;For each sentence, I would ask:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is this grounded in the provided data?&lt;/li&gt;
&lt;li&gt;Could this sentence be attached to any other place?&lt;/li&gt;
&lt;li&gt;Can it be shorter and more specific?&lt;/li&gt;
&lt;li&gt;Can a user take action based on this sentence?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Forbidden words can be useful. But a forbidden-words list does not create good copy by itself. The real issue is grounding.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[AI 카피 품질을 금지어가 아니라 근거 문제로 보기]]></title><description><![CDATA[Place2Page의 AI 카피는 문법적으로 틀리지 않았지만, 여러 장소를 보면 반복 패턴이 바로 보였다. 처음에는 ,  같은 단어를 금지하면 해결될 것 같았지만 실제 문제는 단어가 아니라 근거 없는 주장에 있었다. 그래서 final HTML…]]></description><link>https://sewon.dev/place2page-copy-quality-grounding-rules/</link><guid isPermaLink="false">https://sewon.dev/place2page-copy-quality-grounding-rules/</guid><pubDate>Fri, 15 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/ec219aaf42fbb7c7c51dbd85cfa4e484/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB+ElEQVR42o2SzWsTQRjGI+JZPfWiIKLgwYMnL4J49k/oxbugSFuVVKpF0qDiJxb0oOihraQ9iC14qBrEJtpQsaGUkERrNml2N9lsttmPye7svO9MmbUSChJ85zk8l98zvM9MjIb4q2prBqmqXk1z1SbZbHi6QRTVdVwq+k4MkBum295yW23XMJ2m6Rmm9I2WazsEETnnyDlEYogMAAA5j+CdEM4Fx12xnAmJSZs3Kykl907Lv7cKC3Zh2VUEl0fC2KmT0kdSXGStMgLjLKSeYevffLuKwASES9r6ZPHDa/XrlLEy7fz45JRl+B+YKVkt/VhNP/ELC0h99LvEyKs/39palrYNDIJAoCfApOS3Zda2LJN4OzvLDAjBqjJzgwUecAHIAYA5ClCCwMHzQlWltTpTNdQaXNN5y+zB/SZqplMqbXz+ouZWOmtrUCqCUunBAPD85dStiUeJe5PJ+8/GEg+vjd2Jj9+9cv32zNy8TKCh6FLRDaSIL/ygBwcBPXd+cODo6SMnzx4+cebAoVN79x/bd/B4bM/A4IXLTUHSVjnjKBlXydiVJU9Z9XWInia6GfHB0xeXRsZHRpND8cRQPDE8OnH1RvLi8M3U7Px6V39Vzb6p52Y2l1P691lrddEphQj/sbMQyDFEYH8lPcCuwmS9/xIg9vme28XrfvbmgFHEAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/ec219aaf42fbb7c7c51dbd85cfa4e484/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/ec219aaf42fbb7c7c51dbd85cfa4e484/e7570/situation-diagram.png 170w,
/static/ec219aaf42fbb7c7c51dbd85cfa4e484/f46e7/situation-diagram.png 340w,
/static/ec219aaf42fbb7c7c51dbd85cfa4e484/ca1dc/situation-diagram.png 680w,
/static/ec219aaf42fbb7c7c51dbd85cfa4e484/02d09/situation-diagram.png 1020w,
/static/ec219aaf42fbb7c7c51dbd85cfa4e484/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Place2Page의 AI 카피는 문법적으로 틀리지 않았지만, 여러 장소를 보면 반복 패턴이 바로 보였다. 처음에는 &lt;code class=&quot;language-text&quot;&gt;premium&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;special experience&lt;/code&gt; 같은 단어를 금지하면 해결될 것 같았지만 실제 문제는 단어가 아니라 근거 없는 주장에 있었다. 그래서 final HTML contract를 &quot;더 멋지게 쓰기&quot;가 아니라 &quot;제공된 장소 데이터 안에서 쓸모 있게 쓰기&quot;로 바꿨다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: AI가 만든 랜딩페이지 카피가 실제 장소 정보보다 &quot;premium&quot;, &quot;special experience&quot; 같은 범용 문구에 기대고 있었다.&lt;/li&gt;
&lt;li&gt;판단: 금지어 목록보다, 문장이 입력 데이터에 근거하는지 확인하는 contract가 더 중요했다.&lt;/li&gt;
&lt;li&gt;해결: final HTML 직전의 생성 규칙에 copy quality constraint를 넣고, 메뉴, 위치, 영업시간, 예약 링크처럼 실제 business facts를 우선 쓰게 했다.&lt;/li&gt;
&lt;li&gt;배운 점: 좋은 AI 카피는 더 화려한 문장이 아니라 덜 지어낸 문장에 가깝다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;Place2Page는 장소 데이터를 바탕으로 랜딩페이지를 만든다. 음식점이면 메뉴와 영업시간, 사진, 리뷰가 들어오고 미용실이면 예약 링크와 서비스 정보가 들어온다. 이 데이터를 바탕으로 페이지의 제목, 소개 문구, CTA, 방문 정보가 만들어진다.&lt;/p&gt;
&lt;p&gt;처음 생성 결과를 보면 그럴듯했다. 디자인도 있고, 섹션도 있고, CTA도 있었다. 그런데 여러 결과를 반복해서 보다 보니 비슷한 문장 패턴이 보였다.&lt;/p&gt;
&lt;p&gt;&quot;premium experience&quot;, &quot;unforgettable journey&quot;, &quot;crafted with care&quot; 같은 문장이 자주 나왔다. 한국어로도 &quot;특별한 경험&quot;, &quot;최고의 가치&quot;, &quot;프리미엄 공간&quot;, &quot;잊지 못할 순간&quot; 같은 표현이 반복됐다.&lt;/p&gt;
&lt;p&gt;한두 번 보면 괜찮아 보이지만, 여러 장소에 같은 말이 반복되면 곧 AI가 쓴 문장처럼 느껴진다.&lt;/p&gt;
&lt;h2 id=&quot;문제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%A0%9C&quot; aria-label=&quot;문제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문제&lt;/h2&gt;
&lt;p&gt;처음에는 금지어 문제처럼 보였다.&lt;/p&gt;
&lt;p&gt;특정 단어가 너무 자주 나오니까 그 단어들을 막으면 된다고 생각하기 쉽다. 실제로 &quot;premium&quot;, &quot;journey&quot;, &quot;crafted&quot; 같은 표현을 피하라는 규칙은 어느 정도 효과가 있다.&lt;/p&gt;
&lt;p&gt;하지만 곧 더 큰 문제가 보였다.&lt;/p&gt;
&lt;p&gt;문제가 되는 문장은 특정 단어 때문이 아니라 실제 장소 데이터에 근거하지 않기 때문에 어색했다. 어떤 식당인지, 어떤 메뉴가 있는지, 어디에 있는지, 예약이 가능한지 같은 정보보다 분위기 좋은 말이 먼저 나왔다.&lt;/p&gt;
&lt;p&gt;예를 들어 메뉴 데이터가 있는데도 &quot;특별한 경험을 선사합니다&quot;라고 쓰면 약하다. 차라리 실제 메뉴 이름과 가격, 예약 링크, 위치 정보를 짧게 보여주는 편이 더 믿을 만하다.&lt;/p&gt;
&lt;h2 id=&quot;처음-생각한-가설&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C-%EC%83%9D%EA%B0%81%ED%95%9C-%EA%B0%80%EC%84%A4&quot; aria-label=&quot;처음 생각한 가설 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음 생각한 가설&lt;/h2&gt;
&lt;p&gt;처음에는 meta prompt를 고치면 충분할 것 같았다. meta prompt 단계에서 &quot;더 구체적으로 써라&quot;, &quot;과장하지 마라&quot;라고 지시하면 final HTML도 나아질 거라고 봤다.&lt;/p&gt;
&lt;p&gt;그런데 실제로는 final HTML 단계에서 다시 문장이 부풀었다. meta prompt가 아무리 담백해도, 마지막 생성 모델이 랜딩페이지 카피를 만들면서 익숙한 마케팅 문구를 끌어왔다.&lt;/p&gt;
&lt;p&gt;그래서 최종 HTML 출력 직전의 contract에 copy quality 규칙을 넣어야 한다고 봤다. 원문 기획 단계보다 마지막 생성 단계에서 &quot;입력 데이터 안에서만 쓴다&quot;는 규칙이 더 강하게 필요했다.&lt;/p&gt;
&lt;h2 id=&quot;확인한-증거&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%95%EC%9D%B8%ED%95%9C-%EC%A6%9D%EA%B1%B0&quot; aria-label=&quot;확인한 증거 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;확인한 증거&lt;/h2&gt;
&lt;p&gt;나중에 runbook을 정리하면서 이 문제를 다시 확인해보니 기록은 꽤 명확했다.&lt;/p&gt;
&lt;p&gt;문제 상황에는 &quot;premium&quot;, &quot;experience&quot;, &quot;special moment&quot; 계열 표현이 반복된다고 남아 있었다. 한국어 출력에서도 &quot;특별한 경험&quot;, &quot;최고의 가치&quot;, &quot;프리미엄 공간&quot; 같은 표현이 데이터 근거 없이 등장했다.&lt;/p&gt;
&lt;p&gt;처음 의심한 방향은 meta prompt였다. 하지만 현재 생성 규칙을 비교해보니 의미 있게 바뀐 부분은 final HTML 직전의 copy quality contract였다. 파일에 남은 기본 문구보다, 실제 선택된 마지막 생성 규칙에 grounding constraint가 들어간 것이 핵심 차이였다.&lt;/p&gt;
&lt;p&gt;final HTML prompt도 같은 방향을 가리킨다. business facts가 있을 때는 웹사이트, 가격대, 영업시간, 예약 링크, 메뉴, 사진 같은 실제 단서를 visible copy에 사용하라는 요구가 있었다. 즉, &quot;더 감성적으로 써라&quot;가 아니라 &quot;입력 데이터에 있는 사실을 보이게 써라&quot;가 핵심이었다.&lt;/p&gt;
&lt;p&gt;정리하면 증거는 세 가지였다.&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;단서&lt;/th&gt;
&lt;th&gt;의미&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;반복된 generic copy 기록&lt;/td&gt;
&lt;td&gt;문제는 특정 단어 하나가 아니라 근거 없는 문장 패턴이었다.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;운영 규칙의 변경 지점&lt;/td&gt;
&lt;td&gt;final HTML 직전 prompt contract에서 잡아야 했다.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;business facts 사용 규칙&lt;/td&gt;
&lt;td&gt;좋은 문장은 더 화려한 문장이 아니라 데이터에 더 가까운 문장이었다.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;해결한-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%B4%EA%B2%B0%ED%95%9C-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;해결한 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;해결한 방식&lt;/h2&gt;
&lt;p&gt;핵심은 금지어 목록이 아니라 grounding 규칙이었다.&lt;/p&gt;
&lt;p&gt;규칙은 대략 이렇게 잡았다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;제공된 JSON 데이터의 상호명, 카테고리, 위치, 영업시간, 리뷰, 서비스, 메뉴, 예약 URL, 웹사이트, 사진, 가격대를 먼저 사용한다.&lt;/li&gt;
&lt;li&gt;데이터에 없는 수상 이력, 창업 스토리, 프리미엄 포지셔닝, 감정적 주장을 만들지 않는다.&lt;/li&gt;
&lt;li&gt;모르는 정보는 그럴듯하게 채우지 말고, 알고 있는 정보 안에서 쓴다.&lt;/li&gt;
&lt;li&gt;제목과 문단을 반환하기 전에 &quot;이 문장이 아무 가게에나 붙을 수 있는가?&quot;를 스스로 확인한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;물론 피해야 할 표현도 함께 적었다. 하지만 목적은 &quot;이 단어를 쓰지 마&quot;가 아니라 &quot;근거 없는 문장을 쓰지 마&quot;에 가까웠다.&lt;/p&gt;
&lt;h2 id=&quot;바뀐-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%94%EB%80%90-%EC%A0%90&quot; aria-label=&quot;바뀐 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;바뀐 점&lt;/h2&gt;
&lt;p&gt;이 규칙을 넣고 나면 카피의 방향이 조금 달라진다.&lt;/p&gt;
&lt;p&gt;이전에는 이런 문장이 나오기 쉬웠다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;잊지 못할 프리미엄 경험을 선사하는 특별한 공간입니다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;이 문장은 그럴듯하지만 거의 아무 장소에나 붙일 수 있다.&lt;/p&gt;
&lt;p&gt;반대로 grounding을 강하게 걸면 이런 방향이 된다.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;홍대입구역 근처에서 예약 가능한 파스타 전문점입니다. 대표 메뉴와 영업시간을 확인하고 방문 계획을 세울 수 있습니다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;두 번째 문장이 더 평범해 보일 수 있다. 하지만 실제 랜딩페이지에서는 더 낫다. 사용자는 추상적인 감정보다 구체적인 방문 정보와 신뢰할 만한 단서를 먼저 필요로 하기 때문이다.&lt;/p&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;AI 카피 품질을 올린다는 말을 처음 들으면 더 멋진 문장을 만드는 일처럼 느껴진다. 하지만 실제 제품에서는 반대에 가까웠다.&lt;/p&gt;
&lt;p&gt;더 화려한 표현보다 더 덜 지어낸 문장이 중요했다. 제공된 데이터에 없는 말을 하지 않는 것, 같은 표현을 모든 장소에 반복하지 않는 것, 실제 사용자가 보고 행동할 수 있는 정보를 앞에 놓는 것이 더 중요했다.&lt;/p&gt;
&lt;p&gt;이건 prompt engineering이라기보다 product writing에 가까웠다. 모델에게 &quot;멋지게 써줘&quot;라고 하는 대신, &quot;알고 있는 것만으로 쓸모 있게 써줘&quot;라고 말해야 했다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;AI 생성 카피를 볼 때는 단어만 보지 않는다. 어떤 표현을 금지할지보다, 그 문장이 왜 나올 수 있었는지 먼저 본다. 입력 데이터에 근거하지 못하는 문장이라면 prompt의 문체보다 data grounding contract를 고쳐야 한다.&lt;/p&gt;
&lt;p&gt;문장마다 아래 질문을 한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;이 문장은 제공된 데이터에 근거하는가?&lt;/li&gt;
&lt;li&gt;이 문장이 다른 아무 장소에도 붙을 수 있는가?&lt;/li&gt;
&lt;li&gt;더 짧고 구체적으로 쓸 수 있는가?&lt;/li&gt;
&lt;li&gt;사용자가 이 문장을 보고 실제 행동을 할 수 있는가?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;금지어는 필요할 때가 있다. 하지만 금지어만으로는 좋은 카피가 나오지 않는다. 결국 중요한 것은 grounding이다.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Managing Prompt Experiments as Operational Assets, Not String Edits]]></title><description><![CDATA[At first, Place2Page prompts looked like ordinary strings. As experiments accumulated, the real problem became less about finding a better…]]></description><link>https://sewon.dev/en/place2page-prompt-experiments-admin-debug-workflow/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-prompt-experiments-admin-debug-workflow/</guid><pubDate>Fri, 15 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/f7e95ae4c212fc3281e5069e4e2e63fb/708e8/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 62.35294117647059%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAACFklEQVR42n2Su2sUURTG828oYqWI/0EKCyuLIAhCCgULCwsfYCMWahPBRtIoSIw2aVIJttEENSb43kSFmHVj1s1udnecze5k3jN37uMnO1kkGzYe+LgXzjnf+c5jSGuDH2T4YUbHFXjBztuFH0q8QBBEAtdLcdwU1xc5wkgyyIak1FitAHsrpG4F+b/W9Nm0Aux2iO0I2p7E6gjqrYSGHdD4E9DqRBhj+pAT7q3QVdz1dQO0BmmvEpcXiH8vIu2VPGbHZ1DK9OL3EOYEvXe3ZVLjrc7hFqZxvkwT/Zwjk4b/WU6olOpBslSJeLni8boYsrQRoUQCUmBySFIhsJsptXJCvZKy1ZR9QvpbNprZdcmTTxn3Xzg8Xw4HaDCUizGFdw5fP7r8+hF303YvRfFwYopbY+PcHhvn6o27XLt5j7WqhTKQiO7mI/wwxvNDhBBoaQh8gUgMKtvTcpKknBw5z4Ejwxw+foKDR4c5dGyYYmm9tySdD1hrhdIGbSDNdF5s4AyzTHL5+h1Onb7AmdFLjJy9yOi5K7xa+86HoMKbrRKFcBOtDMKv4ljLOM1lUre8/1L8LGE7jdgWEY6ICNKYme0iDxrzTNQWeNb+RhJLwlaBTnUGvzFLaL3/N9P+w9aK6fpnHm3MM1lbZLK2wOPqW5423zHlFWgIt5dmeve1C4MUdg+ykrQpxTaluMVa0o9IiQE69r/DvzZ6fr+fgw3cAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/f7e95ae4c212fc3281e5069e4e2e63fb/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/f7e95ae4c212fc3281e5069e4e2e63fb/e7570/situation-diagram.png 170w,
/static/f7e95ae4c212fc3281e5069e4e2e63fb/f46e7/situation-diagram.png 340w,
/static/f7e95ae4c212fc3281e5069e4e2e63fb/ca1dc/situation-diagram.png 680w,
/static/f7e95ae4c212fc3281e5069e4e2e63fb/02d09/situation-diagram.png 1020w,
/static/f7e95ae4c212fc3281e5069e4e2e63fb/708e8/situation-diagram.png 1218w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;At first, Place2Page prompts looked like ordinary strings. As experiments accumulated, the real problem became less about finding a better sentence and more about whether we could later explain which candidate won, on which input, and why. So temporary prompt changes stopped being one-off request strings and became part of an operational record: experiment group, candidate, judgment, snapshot, and production promotion.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: Copy-paste prompt experiments made it difficult to trace which wording produced which result.&lt;/li&gt;
&lt;li&gt;Decision: Prompt changes needed to be recorded as baselines, candidates, judgments, and promotion decisions, not only as &quot;looks better.&quot;&lt;/li&gt;
&lt;li&gt;Fix: Record experiment groups, candidates, judgments, prompt snapshots, and production promotion in one workflow.&lt;/li&gt;
&lt;li&gt;Lesson: Prompts become operable assets when they have experiment, record, comparison, and promotion workflows, much like code.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;Place2Page generates landing pages from place data. A user enters a Google Maps or Naver Map URL, and the service uses place information such as photos, opening hours, menus, and reviews to produce an HTML page.&lt;/p&gt;
&lt;p&gt;In the beginning, editing prompts was simple. Change one sentence, inspect a few generations, and decide whether the output looked better. After a while, that stopped scaling.&lt;/p&gt;
&lt;p&gt;It became hard to remember which prompt produced which result. Candidate A seemed good, but the exact wording was difficult to find again. There had also been a slightly modified B candidate, and it was unclear whether it had only been tested or actually promoted to production.&lt;/p&gt;
&lt;p&gt;As prompt experiments increased, copy-paste and memory became obvious weak points.&lt;/p&gt;
&lt;h2 id=&quot;Problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Problem&quot; aria-label=&quot;Problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;The riskiest state in prompt experimentation is stopping at &quot;this looks good.&quot;&lt;/p&gt;
&lt;p&gt;Even if one prompt appears better, it is hard to operate unless the team can answer these questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Which place input was used?&lt;/li&gt;
&lt;li&gt;What was the baseline, and what changed in the candidate?&lt;/li&gt;
&lt;li&gt;Why was it judged better?&lt;/li&gt;
&lt;li&gt;Which cases failed?&lt;/li&gt;
&lt;li&gt;Can the same prompt be selected again later?&lt;/li&gt;
&lt;li&gt;Is this prompt the current production default?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Prompts are easy to change because they are strings. That also makes them easy to scatter. If experiment results do not leave a code-diff-like trail, finding &quot;that wording from last time&quot; becomes a debugging task.&lt;/p&gt;
&lt;h2 id=&quot;Initial-Hypothesis&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Initial-Hypothesis&quot; aria-label=&quot;Initial Hypothesis permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Initial Hypothesis&lt;/h2&gt;
&lt;p&gt;I first thought moving prompt text into files would be enough. Files leave git diffs and can be reviewed.&lt;/p&gt;
&lt;p&gt;But real experiments did not end at files. I needed to rerun a specific place, apply a temporary prompt change, or compare multiple candidates against the same input. The experiment unit was not one file. It was &quot;which prompt was applied to which input, and how was the result evaluated?&quot;&lt;/p&gt;
&lt;p&gt;That meant prompt file management needed a layer above it: experiment management.&lt;/p&gt;
&lt;h2 id=&quot;Evidence&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Evidence&quot; aria-label=&quot;Evidence permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Evidence&lt;/h2&gt;
&lt;p&gt;This was not only a vague concern about future maintainability. Repeated experiments made the needed record shape clear.&lt;/p&gt;
&lt;p&gt;A single problem is grouped into one experiment, and baseline and candidate prompts are compared inside it. After inspecting generated output, the result is recorded as passed, held, or needing rework.&lt;/p&gt;
&lt;p&gt;The more important evidence is in tests. Even when a temporary prompt change is applied, the raw string is not allowed to remain only inside the request payload. The test verifies that the changed prompt is saved as a snapshot and that generation refers to that saved snapshot instead of carrying the raw string forward.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Experiment: copy quality check
Candidate: stricter grounding rule
Saved prompt snapshot exists
Generation request references the saved snapshot&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;So experiment wording does not disappear as a one-request string. It becomes a record that can be selected and compared again.&lt;/p&gt;
&lt;p&gt;The same structure mattered later when checking the production default. The default prompt in files and the prompt actually selected at runtime can differ. Without that check, it would have been hard to explain why production output changed while the file stayed the same.&lt;/p&gt;
&lt;h2 id=&quot;Implementation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Implementation&quot; aria-label=&quot;Implementation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Implementation&lt;/h2&gt;
&lt;p&gt;The workflow makes the experiment unit explicit.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Experiment group: one unit for validating a problem&lt;/li&gt;
&lt;li&gt;Candidate: the prompt or setting being compared inside that problem&lt;/li&gt;
&lt;li&gt;Judgment: the current decision on the result&lt;/li&gt;
&lt;li&gt;Notes: a short record of why that judgment was made&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For example, if duplicate external map links appear even though an embedded map is present, that issue becomes one experiment group. Inside it, a baseline and a stricter candidate can be compared. Results can then be labeled as passed, needing rework, or held.&lt;/p&gt;
&lt;p&gt;The key piece is the prompt snapshot.&lt;/p&gt;
&lt;p&gt;When a temporary prompt is applied, the raw string is not stored only in the request payload. The baseline prompt is copied, and the changed part is saved as a new snapshot. The generation request then refers to the saved snapshot instead of the raw string.&lt;/p&gt;
&lt;p&gt;That makes the experiment prompt recoverable. It can be opened again, edited, applied to another input, or promoted to production if it proves useful.&lt;/p&gt;
&lt;h2 id=&quot;Why-Production-Promotion-Was-Needed&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-Production-Promotion-Was-Needed&quot; aria-label=&quot;Why Production Promotion Was Needed permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why Production Promotion Was Needed&lt;/h2&gt;
&lt;p&gt;Prompt experiments need a separate path for the moment when &quot;this seems best&quot; becomes the actual default.&lt;/p&gt;
&lt;p&gt;If the system only edits a file or environment variable, it becomes hard to verify what production is currently using. If a verified prompt snapshot is promoted to production, the next generation uses that snapshot as the runtime default, while the file default remains as a fallback.&lt;/p&gt;
&lt;p&gt;The benefits are concrete:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;File default prompts and runtime production prompts can be distinguished.&lt;/li&gt;
&lt;li&gt;A verified experiment snapshot can be promoted directly to production.&lt;/li&gt;
&lt;li&gt;If a problem appears later, the promoted change can be traced.&lt;/li&gt;
&lt;li&gt;The current runtime default can be checked separately.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If prompts are deployed like code, their deployment state should also be inspectable like code.&lt;/p&gt;
&lt;h2 id=&quot;Lesson&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Lesson&quot; aria-label=&quot;Lesson permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Lesson&lt;/h2&gt;
&lt;p&gt;This work changed how I think about prompt engineering.&lt;/p&gt;
&lt;p&gt;At first, I thought the main job was finding better prompt wording. The wording still matters. But inside a product, the more important question is whether the prompt can be experimented with, selected by criteria, and traced once it becomes production.&lt;/p&gt;
&lt;p&gt;Prompt experiments disappear easily if they live in notes. When they are managed through experiment groups, candidates, judgments, snapshots, and promotion, they become operational assets.&lt;/p&gt;
&lt;p&gt;In Place2Page, changing a prompt is no longer described as just &quot;edited the prompt.&quot; The record also needs to say which problem we saw, which hypothesis we tested, which candidate won, and why.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Would-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Would-Judge-This-Next-Time&quot; aria-label=&quot;How I Would Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Would Judge This Next Time&lt;/h2&gt;
&lt;p&gt;For future prompt experiments, I will first ask whether the decision can be reproduced later, not whether the wording feels good. An unrecorded prompt win is closer to memory than an operational asset.&lt;/p&gt;
&lt;p&gt;At minimum, a prompt experiment should preserve:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Problem context&lt;/li&gt;
&lt;li&gt;Experiment input&lt;/li&gt;
&lt;li&gt;Baseline&lt;/li&gt;
&lt;li&gt;Candidate&lt;/li&gt;
&lt;li&gt;Judgment&lt;/li&gt;
&lt;li&gt;Failed cases&lt;/li&gt;
&lt;li&gt;Production promotion status&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Prompts are easy to change, so they need stricter records. Copy-paste can start an experiment, but it is a poor long-term operating model.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[프롬프트 실험을 문자열 수정이 아니라 운영 자산으로 관리하기]]></title><description><![CDATA[Place2Page…]]></description><link>https://sewon.dev/place2page-prompt-experiments-admin-debug-workflow/</link><guid isPermaLink="false">https://sewon.dev/place2page-prompt-experiments-admin-debug-workflow/</guid><pubDate>Fri, 15 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/f7e95ae4c212fc3281e5069e4e2e63fb/708e8/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 62.35294117647059%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAACFklEQVR42n2Su2sUURTG828oYqWI/0EKCyuLIAhCCgULCwsfYCMWahPBRtIoSIw2aVIJttEENSb43kSFmHVj1s1udnecze5k3jN37uMnO1kkGzYe+LgXzjnf+c5jSGuDH2T4YUbHFXjBztuFH0q8QBBEAtdLcdwU1xc5wkgyyIak1FitAHsrpG4F+b/W9Nm0Aux2iO0I2p7E6gjqrYSGHdD4E9DqRBhj+pAT7q3QVdz1dQO0BmmvEpcXiH8vIu2VPGbHZ1DK9OL3EOYEvXe3ZVLjrc7hFqZxvkwT/Zwjk4b/WU6olOpBslSJeLni8boYsrQRoUQCUmBySFIhsJsptXJCvZKy1ZR9QvpbNprZdcmTTxn3Xzg8Xw4HaDCUizGFdw5fP7r8+hF303YvRfFwYopbY+PcHhvn6o27XLt5j7WqhTKQiO7mI/wwxvNDhBBoaQh8gUgMKtvTcpKknBw5z4Ejwxw+foKDR4c5dGyYYmm9tySdD1hrhdIGbSDNdF5s4AyzTHL5+h1Onb7AmdFLjJy9yOi5K7xa+86HoMKbrRKFcBOtDMKv4ljLOM1lUre8/1L8LGE7jdgWEY6ICNKYme0iDxrzTNQWeNb+RhJLwlaBTnUGvzFLaL3/N9P+w9aK6fpnHm3MM1lbZLK2wOPqW5423zHlFWgIt5dmeve1C4MUdg+ykrQpxTaluMVa0o9IiQE69r/DvzZ6fr+fgw3cAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/f7e95ae4c212fc3281e5069e4e2e63fb/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/f7e95ae4c212fc3281e5069e4e2e63fb/e7570/situation-diagram.png 170w,
/static/f7e95ae4c212fc3281e5069e4e2e63fb/f46e7/situation-diagram.png 340w,
/static/f7e95ae4c212fc3281e5069e4e2e63fb/ca1dc/situation-diagram.png 680w,
/static/f7e95ae4c212fc3281e5069e4e2e63fb/02d09/situation-diagram.png 1020w,
/static/f7e95ae4c212fc3281e5069e4e2e63fb/708e8/situation-diagram.png 1218w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Place2Page의 프롬프트는 처음에는 그냥 문자열처럼 보였다. 하지만 실험이 늘어나자 진짜 문제는 좋은 문구를 찾는 것이 아니라 어떤 입력에서 어떤 후보안이 왜 이겼는지 다시 설명할 수 있는가였다. 그래서 임시로 바꾼 문구를 한 번의 요청으로 흘려보내지 않고 실험 묶음, 후보안, 판단 결과, 저장된 스냅샷, 기본값 반영으로 이어지는 기록 체계를 만들었다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: 프롬프트 실험을 복붙으로 관리하면 어떤 문구가 어떤 결과를 만들었는지 빠르게 추적하기 어려워졌다.&lt;/li&gt;
&lt;li&gt;판단: 프롬프트 변경도 &quot;좋아 보인다&quot;가 아니라 기준안, 후보안, 판단 결과, 반영 여부로 남겨야 했다.&lt;/li&gt;
&lt;li&gt;해결: 실험 묶음, 후보안, 판단 결과, 스냅샷, 기본값 반영 흐름을 하나의 기록 체계로 묶었다.&lt;/li&gt;
&lt;li&gt;배운 점: 프롬프트도 코드처럼 실험, 기록, 비교, 반영 흐름이 있어야 운영 가능한 자산이 된다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;Place2Page는 장소 정보를 받아서 랜딩페이지를 생성한다. 사용자는 Google Maps나 Naver Map URL을 넣고, 서비스는 장소 정보와 사진, 영업시간, 메뉴, 리뷰 같은 데이터를 바탕으로 HTML 페이지를 만든다.&lt;/p&gt;
&lt;p&gt;처음에는 프롬프트를 고치는 일이 단순했다. 문구 하나를 바꾸고, 생성 결과를 몇 개 보면서 더 나아졌는지 판단하면 됐다. 그런데 시간이 조금 지나자 문제가 생겼다.&lt;/p&gt;
&lt;p&gt;어떤 프롬프트로 만든 결과였는지 기억이 흐려졌다. A안이 좋았던 것 같은데, 정확히 어떤 문구였는지 다시 찾기 어려웠다. B안을 조금 수정한 B-안이 있었는데, 그게 실제 기본값에 반영된 건지 실험으로만 끝난 건지도 애매했다.&lt;/p&gt;
&lt;p&gt;프롬프트 실험이 많아질수록 복붙과 기억에 의존하는 방식은 한계가 분명했다.&lt;/p&gt;
&lt;h2 id=&quot;문제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%A0%9C&quot; aria-label=&quot;문제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문제&lt;/h2&gt;
&lt;p&gt;프롬프트 실험에서 가장 위험한 상태는 &quot;좋아 보인다&quot;에서 멈추는 것이다.&lt;/p&gt;
&lt;p&gt;예를 들어 어떤 프롬프트가 더 좋아 보였다고 해도, 아래 질문에 답하지 못하면 운영하기 어렵다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;어떤 장소 입력으로 실험했는가?&lt;/li&gt;
&lt;li&gt;기준안은 무엇이었고, 바꾼 후보안은 무엇이었는가?&lt;/li&gt;
&lt;li&gt;왜 이겼다고 판단했는가?&lt;/li&gt;
&lt;li&gt;실패한 케이스는 무엇인가?&lt;/li&gt;
&lt;li&gt;나중에 같은 프롬프트를 다시 선택할 수 있는가?&lt;/li&gt;
&lt;li&gt;이 프롬프트가 지금 기본값인가?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;프롬프트는 문자열이라 쉽게 바꿀 수 있다. 그래서 더 쉽게 흩어진다. 실험 결과가 코드 diff처럼 남지 않으면, 나중에는 &quot;그때 그 문구&quot;를 찾는 일이 디버깅이 된다.&lt;/p&gt;
&lt;h2 id=&quot;처음-생각한-가설&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C-%EC%83%9D%EA%B0%81%ED%95%9C-%EA%B0%80%EC%84%A4&quot; aria-label=&quot;처음 생각한 가설 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음 생각한 가설&lt;/h2&gt;
&lt;p&gt;처음에는 프롬프트 텍스트를 파일로 빼면 충분할 줄 알았다. 파일에 있으면 git diff가 남고, 리뷰도 할 수 있기 때문이다.&lt;/p&gt;
&lt;p&gt;하지만 실제 실험은 파일만으로 끝나지 않았다. 같은 장소 입력을 다시 생성하거나, 임시 문구를 적용하거나, 같은 입력에 대해 여러 후보안을 비교해야 했다. 즉, 실험의 단위는 파일 하나가 아니라 &quot;어떤 입력에 어떤 프롬프트를 적용했고, 그 결과를 어떻게 평가했는가&quot;였다.&lt;/p&gt;
&lt;p&gt;그래서 프롬프트 파일 관리보다 한 단계 위에 실험 관리가 필요했다.&lt;/p&gt;
&lt;h2 id=&quot;확인한-증거&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%95%EC%9D%B8%ED%95%9C-%EC%A6%9D%EA%B1%B0&quot; aria-label=&quot;확인한 증거 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;확인한 증거&lt;/h2&gt;
&lt;p&gt;이 문제는 단순히 &quot;나중에 관리하기 어려울 것 같다&quot;는 느낌만은 아니었다. 실험을 반복하다 보니 기록해야 하는 표면이 자연스럽게 드러났다.&lt;/p&gt;
&lt;p&gt;같은 문제는 하나의 실험 묶음으로 관리하고, 그 안에서 기준안과 후보안을 나눴다. 생성 결과를 본 뒤에는 어떤 후보안이 통과했고, 어떤 후보안은 보류하거나 다시 작업해야 하는지 판단 결과를 함께 남겼다.&lt;/p&gt;
&lt;p&gt;더 중요한 단서는 테스트에 있다. 임시 프롬프트를 적용해 생성하더라도, 그 문자열이 요청 payload 안에만 남고 사라지지 않도록 했다. 테스트는 변경된 프롬프트가 스냅샷으로 저장되고, 실제 생성 요청은 raw 문자열 대신 저장된 스냅샷을 참조하는지 확인한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;Experiment: copy quality check
Candidate: stricter grounding rule
Saved prompt snapshot exists
Generation request references the saved snapshot&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;즉, 실험 문구가 요청 한 번짜리 문자열로 사라지는 것이 아니라 다시 선택하고 비교할 수 있는 기록으로 남는다.&lt;/p&gt;
&lt;p&gt;나중에 현재 기본값을 확인했을 때도 같은 구조가 필요했다. 파일에 남은 기본 프롬프트와 실제 선택된 프롬프트가 다를 수 있기 때문이다. 이 확인이 없었다면 &quot;파일은 그대로인데 왜 결과가 바뀌었나&quot;를 설명하기 어려웠다.&lt;/p&gt;
&lt;h2 id=&quot;해결한-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%B4%EA%B2%B0%ED%95%9C-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;해결한 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;해결한 방식&lt;/h2&gt;
&lt;p&gt;실험 단위를 명시했다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;실험 묶음: 하나의 문제를 검증하는 단위&lt;/li&gt;
&lt;li&gt;후보안: 같은 문제 안에서 비교할 프롬프트 또는 설정&lt;/li&gt;
&lt;li&gt;판단 결과: 결과에 대한 현재 판단&lt;/li&gt;
&lt;li&gt;메모: 왜 그렇게 판단했는지 남기는 기록&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;예를 들어 &quot;지도 embed가 있는데도 외부 지도 링크가 중복으로 나오는 문제&quot;를 본다면 그 문제를 하나의 실험 묶음으로 잡는다. 그 안에서 기준안과 더 엄격한 후보안을 나누고, 결과를 보면서 통과, 재작업, 보류 같은 판단을 붙인다.&lt;/p&gt;
&lt;p&gt;여기서 중요한 것은 프롬프트 스냅샷이었다.&lt;/p&gt;
&lt;p&gt;임시 프롬프트를 넣고 실행하면, 그 문자열을 단순히 request payload에만 남기지 않는다. 기준이 되는 프롬프트를 복제하고, 바뀐 부분만 새 스냅샷으로 묶는다. 이후 생성 요청은 raw string이 아니라 저장된 스냅샷을 참조한다.&lt;/p&gt;
&lt;p&gt;이렇게 하면 실험 당시의 프롬프트를 다시 열 수 있다. 수정할 수도 있고, 다른 입력에 다시 적용할 수도 있고, 괜찮으면 기본값으로 반영할 수도 있다.&lt;/p&gt;
&lt;h2 id=&quot;왜-반영-흐름이-필요했나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EB%B0%98%EC%98%81-%ED%9D%90%EB%A6%84%EC%9D%B4-%ED%95%84%EC%9A%94%ED%96%88%EB%82%98&quot; aria-label=&quot;왜 반영 흐름이 필요했나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 반영 흐름이 필요했나&lt;/h2&gt;
&lt;p&gt;프롬프트 실험에서 &quot;이게 제일 나은 것 같다&quot;는 순간이 와도 그걸 실제 기본값으로 바꾸는 흐름이 따로 있어야 한다.&lt;/p&gt;
&lt;p&gt;그냥 파일을 고치거나 환경 변수를 바꾸면, 현재 무엇이 기본값인지 확인하기 어려워진다. 반대로 검증된 프롬프트 스냅샷을 기본값으로 반영하면, 다음 생성부터 그 기준이 적용되고 파일의 기본값은 fallback으로 남는다.&lt;/p&gt;
&lt;p&gt;이 구조의 장점은 명확했다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;파일에 있는 기본 프롬프트와 운영 중인 기본 프롬프트를 구분할 수 있다.&lt;/li&gt;
&lt;li&gt;검증된 실험 스냅샷을 기본값으로 반영할 수 있다.&lt;/li&gt;
&lt;li&gt;다시 문제가 생기면 어떤 변경이 반영됐는지 추적할 수 있다.&lt;/li&gt;
&lt;li&gt;현재 기본값을 별도로 확인할 수 있다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;프롬프트가 코드처럼 배포된다면, 배포 상태도 코드처럼 확인할 수 있어야 한다.&lt;/p&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;이 작업을 하면서 프롬프트 엔지니어링을 보는 관점이 조금 바뀌었다.&lt;/p&gt;
&lt;p&gt;처음에는 좋은 프롬프트 문장을 찾는 일이 핵심이라고 생각했다. 물론 문장 자체도 중요하다. 하지만 제품 안에서 더 중요한 것은 그 문장이 어떻게 실험되고, 어떤 기준으로 선택되고, 언제 기본값이 되었는지 추적할 수 있는가였다.&lt;/p&gt;
&lt;p&gt;프롬프트 실험은 메모장에 남기면 쉽게 사라진다. 반대로 실험 묶음, 후보안, 판단 결과, 스냅샷, 반영 흐름으로 관리하면 운영 자산이 된다.&lt;/p&gt;
&lt;p&gt;이제 Place2Page에서 프롬프트를 바꿀 때는 단순히 &quot;프롬프트를 수정했다&quot;고 말하지 않는다. 어떤 문제를 보고, 어떤 가설을 세웠고, 어떤 후보안이 어떤 이유로 이겼는지 같이 남긴다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;프롬프트 실험을 다시 할 때는 문구가 마음에 드는지보다, 나중에 같은 결정을 재현할 수 있는지 먼저 본다. 기록되지 않은 prompt win은 운영 자산이 아니라 기억에 가까워진다.&lt;/p&gt;
&lt;p&gt;앞으로 프롬프트 실험을 할 때는 최소한 아래는 남긴다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;문제 상황&lt;/li&gt;
&lt;li&gt;실험 입력&lt;/li&gt;
&lt;li&gt;기준안&lt;/li&gt;
&lt;li&gt;후보안&lt;/li&gt;
&lt;li&gt;판단 결과&lt;/li&gt;
&lt;li&gt;실패한 케이스&lt;/li&gt;
&lt;li&gt;기본값 반영 여부&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;프롬프트는 쉽게 바꿀 수 있어서 더 엄격하게 기록해야 한다. 복붙으로 시작할 수는 있지만, 운영은 복붙으로 오래 버티기 어렵다.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Why I Removed Time-Dependent Data from AI-Generated Static Pages]]></title><description><![CDATA[It was tempting to give the AI more place data and expect a better landing page. But values like "open now" may be correct at generation…]]></description><link>https://sewon.dev/en/place2page-static-page-temporal-data/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-static-page-temporal-data/</guid><pubDate>Fri, 15 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/895f4818d7cae4e8c6c38ad67f789102/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB+klEQVR42nVSzWsTQRSP/gF67EF60YuevHnpf+WpSLEIRbEHQexJD1pQStGmtrRNK0JTQmIai6ZCkTYfm91Nuh+zs+nOzH7N7syTbML6RX88hjfM+73f+5gC50LRiYF87ZzqBlOzUzOYgYK+wc5tXzd8yw0BpPzDIENBCIlc5rgUYWpjZmOGhz7CFA9HV/ciIIxHoYC/ITN6IfflOGn+knkAwEX63dPqnnLk6w2q10hPDYYwUpcFGNPSWIo0J8jIkZElJPAkcUL68qy8pOy/GlTfmNVlr9EM+llcRuZaw/6yTJprwjMFT1LSR+qe1d3mbJBIEFK43MecqQSXu9bnNqopXhCLSdnCaZOTUtCpcOryKIoZwvqBq5el78iYT0oDIIS9KNO5dWdui6pukvf8PwRIPhJlTBASWmZoWdyyj38M6l+1xonDcuXTVvfRk+cLi0sPF57Nzi/Ozj+9/+Dxz9NulgOAMa1Sax9Uhs3jtHMGSkva5niuI/LO3v7UrXvTd2amb89cv3H3yrWbhatTG1ufACBKeCoFpzTyLmLPiz2PEyKieLJnADAt9H5958PH0tpGqbi5W9zcXS1uY9ttB+h1r/pOq7/VD1eMo1Xr28qwWWPqeNSX9jxetMeDFjE71O4QsxugXoSV0LFjkodN9pyk6T8mf3+VS/EL63aKM0JATzUAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/895f4818d7cae4e8c6c38ad67f789102/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/895f4818d7cae4e8c6c38ad67f789102/e7570/situation-diagram.png 170w,
/static/895f4818d7cae4e8c6c38ad67f789102/f46e7/situation-diagram.png 340w,
/static/895f4818d7cae4e8c6c38ad67f789102/ca1dc/situation-diagram.png 680w,
/static/895f4818d7cae4e8c6c38ad67f789102/02d09/situation-diagram.png 1020w,
/static/895f4818d7cae4e8c6c38ad67f789102/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;It was tempting to give the AI more place data and expect a better landing page. But values like &quot;open now&quot; may be correct at generation time and still become risky as soon as they are saved into static HTML. I treated this as a data modeling problem, not a prompt wording problem: remove data that does not match the lifetime of the output.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: AI-generated static landing pages could freeze creation-time information such as &quot;open now&quot; into the visible page.&lt;/li&gt;
&lt;li&gt;Decision: Instead of telling the model not to use that data, it was safer not to provide data whose lifetime did not match the static output.&lt;/li&gt;
&lt;li&gt;Fix: Remove time-dependent fields such as &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt; from the final generation payload, and keep only durable opening-hours information.&lt;/li&gt;
&lt;li&gt;Lesson: Data that belongs in a static page and data that is valid only at request time need to be handled differently.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;Place2Page turns place data into static landing pages. When a user enters a URL, the service fetches information such as the place name, address, photos, reviews, menu, and opening hours. The AI then generates HTML from that data.&lt;/p&gt;
&lt;p&gt;At first, it seemed better to give the model as much information as possible. More data could produce a richer page.&lt;/p&gt;
&lt;p&gt;Opening hours seemed like part of that. If the model knew regular hours, current open status, and the next close time, the visit-planning section might become more useful.&lt;/p&gt;
&lt;p&gt;But that assumption breaks down once the output is static.&lt;/p&gt;
&lt;h2 id=&quot;Problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Problem&quot; aria-label=&quot;Problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;A statement can be true at generation time and false the next day.&lt;/p&gt;
&lt;p&gt;For example, imagine the AI writes this while generating a page on Monday night:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Currently closed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That may be true at that moment. But the HTML is saved as a static page. A user visiting on Tuesday afternoon could still see &quot;Currently closed.&quot;&lt;/p&gt;
&lt;p&gt;The reverse can happen too. A page generated on Sunday afternoon could say &quot;Open now&quot; and still show that on a Monday closure day.&lt;/p&gt;
&lt;p&gt;This is not just a wording issue. It can become incorrect information that affects a user&apos;s decision to visit.&lt;/p&gt;
&lt;h2 id=&quot;Initial-Hypothesis&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Initial-Hypothesis&quot; aria-label=&quot;Initial Hypothesis permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Initial Hypothesis&lt;/h2&gt;
&lt;p&gt;At first, I thought a prompt instruction like &quot;do not mention current status&quot; would be enough.&lt;/p&gt;
&lt;p&gt;But if the model input includes data such as &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt;, the model treats it as an important fact. A landing-page generation model is also trying to show useful visit-planning information, so it naturally tries to surface current opening status.&lt;/p&gt;
&lt;p&gt;That made prompt-only prevention too weak. Data the model should not use should be removed from the payload in the first place.&lt;/p&gt;
&lt;h2 id=&quot;Evidence&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Evidence&quot; aria-label=&quot;Evidence permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Evidence&lt;/h2&gt;
&lt;p&gt;The issue could happen in both Naver place fetches and Google place fetches.&lt;/p&gt;
&lt;p&gt;Regular opening hours are relatively durable. A line like &quot;Mon-Fri 10:00-21:00&quot; can remain on the page because users can interpret it with the current date and time.&lt;/p&gt;
&lt;p&gt;But statements like &quot;Open now,&quot; &quot;Currently closed,&quot; &quot;영업 종료,&quot; and &quot;곧 영업 시작&quot; are different. They are tightly bound to the request time.&lt;/p&gt;
&lt;p&gt;If that data enters the final model input, the model can pull it back into visible copy no matter how careful the prompt is.&lt;/p&gt;
&lt;p&gt;So I checked both code and tests.&lt;/p&gt;
&lt;p&gt;The generation payload test deliberately includes time-dependent data.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;opening_hours&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&quot;영업 종료&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&quot;10시 30분에 영업 시작&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&quot;매일 10:30 - 20:00&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&quot;Sunday: Closed&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;current_opening_hours&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;open_now&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;next_open_time&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2026-05-15T10:30:00+09:00&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;next_close_time&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2026-05-15T20:00:00+09:00&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The expected result is the opposite. The final model input should not contain &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;opening_hours&lt;/code&gt; should keep only lines that are safe to persist.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&quot;current_opening_hours&quot; not in payload[&quot;place_source_data&quot;]
payload[&quot;place_source_data&quot;][&quot;opening_hours&quot;] == [
  &quot;매일 10:30 - 20:00&quot;,
  &quot;Sunday: Closed&quot;
]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The Naver fetcher test points in the same direction. The input contains fetch-time status strings such as &lt;code class=&quot;language-text&quot;&gt;&quot;영업 종료&quot;&lt;/code&gt; and &lt;code class=&quot;language-text&quot;&gt;&quot;10시 30분에 영업 시작&quot;&lt;/code&gt;, but the normalized result either leaves &lt;code class=&quot;language-text&quot;&gt;opening_hours&lt;/code&gt; empty or keeps only regular hours, and &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt; becomes &lt;code class=&quot;language-text&quot;&gt;None&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;At the commit level, this was not a one-line prompt fix. &lt;code class=&quot;language-text&quot;&gt;d64b0ab0 Fix static opening hours in generated pages&lt;/code&gt; changed the prompt file, &lt;code class=&quot;language-text&quot;&gt;generation_service.py&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;naver_place_fetcher.py&lt;/code&gt;, and related tests. That is why I see this as a data modeling problem.&lt;/p&gt;
&lt;h2 id=&quot;Implementation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Implementation&quot; aria-label=&quot;Implementation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Implementation&lt;/h2&gt;
&lt;p&gt;The fix had two layers.&lt;/p&gt;
&lt;p&gt;First, remove time-dependent data from the generation payload. Fields that describe current state, such as &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt;, are not passed to final HTML generation.&lt;/p&gt;
&lt;p&gt;Second, clean the fetcher output so only opening-hours lines that can live inside a static snapshot remain. If current-status copy is mixed into the fetched data, it is removed while durable regular hours are kept.&lt;/p&gt;
&lt;p&gt;Third, remove prompt-contract language that encouraged active use of &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt;. If the model is told to use the field when present, the same problem can return.&lt;/p&gt;
&lt;h2 id=&quot;Why-This-Was-Data-Modeling&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-This-Was-Data-Modeling&quot; aria-label=&quot;Why This Was Data Modeling permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why This Was Data Modeling&lt;/h2&gt;
&lt;p&gt;This was ultimately a data modeling issue, not a prompt issue.&lt;/p&gt;
&lt;p&gt;When deciding what data to give an AI model, &quot;does this look useful?&quot; is not enough. The data also needs to match the lifetime of the output.&lt;/p&gt;
&lt;p&gt;A static page can live for a long time after generation. Its input data should also be safe to display for a long time.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An address can persist.&lt;/li&gt;
&lt;li&gt;Representative menu items can usually persist for some time.&lt;/li&gt;
&lt;li&gt;Regular opening hours are relatively durable.&lt;/li&gt;
&lt;li&gt;Current opening status should not be frozen into the page.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Time-varying values should not be embedded in static HTML. If they are needed, they belong in a runtime widget or an external link.&lt;/p&gt;
&lt;h2 id=&quot;Lesson&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Lesson&quot; aria-label=&quot;Lesson permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Lesson&lt;/h2&gt;
&lt;p&gt;When an AI-generated result is wrong, it is easy to blame the prompt first. In this case, payload design mattered more than prompt wording.&lt;/p&gt;
&lt;p&gt;Models try to use the data they receive. If some data should not be used, it is usually better not to provide it than to provide it and say &quot;do not use this.&quot;&lt;/p&gt;
&lt;p&gt;The right question for static-page data is not &quot;is this true at generation time?&quot; It is &quot;will this still be less wrong when a user sees it later?&quot;&lt;/p&gt;
&lt;h2 id=&quot;How-I-Would-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Would-Judge-This-Next-Time&quot; aria-label=&quot;How I Would Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Would Judge This Next Time&lt;/h2&gt;
&lt;p&gt;When designing a generation payload, I will not only ask whether the data seems useful. I will also ask whether its validity matches the output&apos;s lifetime.&lt;/p&gt;
&lt;p&gt;I would split generation payload data into three groups:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Data safe to include in a static page&lt;/li&gt;
&lt;li&gt;Data that can be included but must be expressed carefully&lt;/li&gt;
&lt;li&gt;Data that can become wrong immediately after generation and should not be included&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To fix a bad AI sentence, first ask why the AI was able to write it. In this case, the answer was not in the prompt. It was in the payload.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[AI가 만든 정적 페이지에서 시간 의존 데이터를 제거한 이유]]></title><description><![CDATA[AI에게 더 많은 장소 데이터를 주면 더 좋은 랜딩페이지가 나올 것처럼 보였다. 하지만 "현재 영업 중" 같은 값은 생성 시점에는 맞아도 정적 HTML로 저장되는 순간 위험한 정보가 된다. 그래서 이 문제는 prompt wording…]]></description><link>https://sewon.dev/place2page-static-page-temporal-data/</link><guid isPermaLink="false">https://sewon.dev/place2page-static-page-temporal-data/</guid><pubDate>Fri, 15 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/895f4818d7cae4e8c6c38ad67f789102/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB+klEQVR42nVSzWsTQRSP/gF67EF60YuevHnpf+WpSLEIRbEHQexJD1pQStGmtrRNK0JTQmIai6ZCkTYfm91Nuh+zs+nOzH7N7syTbML6RX88hjfM+73f+5gC50LRiYF87ZzqBlOzUzOYgYK+wc5tXzd8yw0BpPzDIENBCIlc5rgUYWpjZmOGhz7CFA9HV/ciIIxHoYC/ITN6IfflOGn+knkAwEX63dPqnnLk6w2q10hPDYYwUpcFGNPSWIo0J8jIkZElJPAkcUL68qy8pOy/GlTfmNVlr9EM+llcRuZaw/6yTJprwjMFT1LSR+qe1d3mbJBIEFK43MecqQSXu9bnNqopXhCLSdnCaZOTUtCpcOryKIoZwvqBq5el78iYT0oDIIS9KNO5dWdui6pukvf8PwRIPhJlTBASWmZoWdyyj38M6l+1xonDcuXTVvfRk+cLi0sPF57Nzi/Ozj+9/+Dxz9NulgOAMa1Sax9Uhs3jtHMGSkva5niuI/LO3v7UrXvTd2amb89cv3H3yrWbhatTG1ufACBKeCoFpzTyLmLPiz2PEyKieLJnADAt9H5958PH0tpGqbi5W9zcXS1uY9ttB+h1r/pOq7/VD1eMo1Xr28qwWWPqeNSX9jxetMeDFjE71O4QsxugXoSV0LFjkodN9pyk6T8mf3+VS/EL63aKM0JATzUAAAAASUVORK5CYII=&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/895f4818d7cae4e8c6c38ad67f789102/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/895f4818d7cae4e8c6c38ad67f789102/e7570/situation-diagram.png 170w,
/static/895f4818d7cae4e8c6c38ad67f789102/f46e7/situation-diagram.png 340w,
/static/895f4818d7cae4e8c6c38ad67f789102/ca1dc/situation-diagram.png 680w,
/static/895f4818d7cae4e8c6c38ad67f789102/02d09/situation-diagram.png 1020w,
/static/895f4818d7cae4e8c6c38ad67f789102/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;AI에게 더 많은 장소 데이터를 주면 더 좋은 랜딩페이지가 나올 것처럼 보였다. 하지만 &quot;현재 영업 중&quot; 같은 값은 생성 시점에는 맞아도 정적 HTML로 저장되는 순간 위험한 정보가 된다. 그래서 이 문제는 prompt wording이 아니라 출력물의 수명과 맞지 않는 데이터를 payload에서 빼는 데이터 모델링 문제로 봤다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: AI가 만든 정적 랜딩페이지에 &quot;현재 영업 중&quot; 같은 생성 시점 정보가 그대로 박제될 수 있었다.&lt;/li&gt;
&lt;li&gt;판단: 모델에게 &quot;쓰지 마&quot;라고 말하기보다, 정적 출력물의 수명과 맞지 않는 데이터는 애초에 주지 않는 편이 안전했다.&lt;/li&gt;
&lt;li&gt;해결: &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt;처럼 시점에 의존하는 데이터는 final generation payload에서 제거하고, 지속 가능한 영업시간만 남겼다.&lt;/li&gt;
&lt;li&gt;배운 점: 정적 페이지에 넣을 데이터와 요청 시점에만 유효한 데이터는 다르게 다뤄야 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;Place2Page는 장소 정보를 받아 정적 랜딩페이지를 만든다. 사용자가 URL을 넣으면 장소명, 주소, 사진, 리뷰, 메뉴, 영업시간 같은 데이터를 가져오고, AI가 이를 바탕으로 HTML을 생성한다.&lt;/p&gt;
&lt;p&gt;처음에는 가능한 많은 정보를 모델에게 주는 게 좋다고 생각했다. 데이터가 많으면 더 풍부한 페이지를 만들 수 있기 때문이다.&lt;/p&gt;
&lt;p&gt;영업시간도 마찬가지였다. 정규 영업시간뿐 아니라 현재 영업 중인지, 언제 닫는지 같은 정보가 있으면 방문 계획 섹션이 더 좋아질 것처럼 보였다.&lt;/p&gt;
&lt;p&gt;그런데 정적 페이지라는 점을 생각하면 문제가 생긴다.&lt;/p&gt;
&lt;h2 id=&quot;문제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%A0%9C&quot; aria-label=&quot;문제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문제&lt;/h2&gt;
&lt;p&gt;생성 시점에 &quot;현재 영업 중&quot;이 맞았다고 해도, 그 말이 다음 날에도 맞는 것은 아니다.&lt;/p&gt;
&lt;p&gt;예를 들어 월요일 밤에 페이지를 생성하면서 AI가 이렇게 썼다고 해보자.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;현재 영업 종료 상태입니다.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;이 문장은 생성 당시에는 맞을 수 있다. 하지만 이 HTML은 정적 페이지로 저장된다. 화요일 낮에 사용자가 들어와도 여전히 &quot;현재 영업 종료&quot;라고 보일 수 있다.&lt;/p&gt;
&lt;p&gt;반대로 일요일 오후에 &quot;현재 영업 중&quot;이라고 생성된 페이지가 월요일 휴무일에도 계속 그렇게 보일 수도 있다.&lt;/p&gt;
&lt;p&gt;이건 단순한 문구 문제가 아니다. 사용자가 방문 결정을 할 때 영향을 줄 수 있는 잘못된 정보다.&lt;/p&gt;
&lt;h2 id=&quot;처음-생각한-가설&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C-%EC%83%9D%EA%B0%81%ED%95%9C-%EA%B0%80%EC%84%A4&quot; aria-label=&quot;처음 생각한 가설 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음 생각한 가설&lt;/h2&gt;
&lt;p&gt;처음에는 프롬프트에서 &quot;현재 상태를 쓰지 말라&quot;고 하면 될 것 같았다.&lt;/p&gt;
&lt;p&gt;하지만 모델 입력에 &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt; 같은 데이터가 들어가 있으면, 모델은 그 정보를 중요한 사실로 본다. 특히 랜딩페이지 생성 모델은 &quot;방문 계획에 유용한 정보를 보여줘야 한다&quot;는 목표를 가지고 있기 때문에, 현재 영업 상태를 페이지에 넣으려고 한다.&lt;/p&gt;
&lt;p&gt;즉, 프롬프트만으로 막기에는 약했다. 모델에게 주지 말아야 할 데이터는 애초에 payload에서 빼야 했다.&lt;/p&gt;
&lt;h2 id=&quot;확인한-증거&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%95%EC%9D%B8%ED%95%9C-%EC%A6%9D%EA%B1%B0&quot; aria-label=&quot;확인한 증거 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;확인한 증거&lt;/h2&gt;
&lt;p&gt;문제는 Naver place fetch와 Google place fetch 양쪽에서 모두 발생할 수 있었다.&lt;/p&gt;
&lt;p&gt;정규 영업시간은 비교적 안정적인 정보다. &quot;월-금 10:00-21:00&quot; 같은 문장은 페이지에 남아 있어도 괜찮다. 사용자가 직접 현재 요일과 시간을 보고 판단할 수 있기 때문이다.&lt;/p&gt;
&lt;p&gt;하지만 &quot;Open now&quot;, &quot;Currently closed&quot;, &quot;영업 종료&quot;, &quot;곧 영업 시작&quot; 같은 문장은 다르다. 이 정보는 요청 시각과 강하게 묶여 있다.&lt;/p&gt;
&lt;p&gt;생성 pipeline에서 이 데이터가 final model input에 들어가면, prompt가 아무리 조심스러워도 모델이 다시 visible copy로 끌어올 가능성이 있었다.&lt;/p&gt;
&lt;p&gt;그래서 증거를 코드와 테스트에서 같이 봤다.&lt;/p&gt;
&lt;p&gt;generation payload 테스트에는 일부러 시점 의존 데이터가 들어간다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;json&quot;&gt;&lt;pre class=&quot;language-json&quot;&gt;&lt;code class=&quot;language-json&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;opening_hours&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&quot;영업 종료&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&quot;10시 30분에 영업 시작&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&quot;매일 10:30 - 20:00&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token string&quot;&gt;&quot;Sunday: Closed&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
  &lt;span class=&quot;token property&quot;&gt;&quot;current_opening_hours&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;open_now&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token boolean&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;next_open_time&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2026-05-15T10:30:00+09:00&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;
    &lt;span class=&quot;token property&quot;&gt;&quot;next_close_time&quot;&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&quot;2026-05-15T20:00:00+09:00&quot;&lt;/span&gt;
  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;그리고 기대 결과는 반대다. final model input에서는 &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt;가 없어야 하고, &lt;code class=&quot;language-text&quot;&gt;opening_hours&lt;/code&gt;에는 오래 남겨도 되는 라인만 있어야 한다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&quot;current_opening_hours&quot; not in payload[&quot;place_source_data&quot;]
payload[&quot;place_source_data&quot;][&quot;opening_hours&quot;] == [
  &quot;매일 10:30 - 20:00&quot;,
  &quot;Sunday: Closed&quot;
]&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Naver fetcher 테스트도 같은 방향이다. 입력에는 &lt;code class=&quot;language-text&quot;&gt;&quot;영업 종료&quot;&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;&quot;10시 30분에 영업 시작&quot;&lt;/code&gt; 같은 fetch-time status가 있지만, normalized 결과에서는 &lt;code class=&quot;language-text&quot;&gt;opening_hours&lt;/code&gt;가 비거나 정규 영업시간만 남고 &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt;는 &lt;code class=&quot;language-text&quot;&gt;None&lt;/code&gt;이 된다.&lt;/p&gt;
&lt;p&gt;커밋 단위로 봐도 이 수정은 prompt 한 줄이 아니었다. &lt;code class=&quot;language-text&quot;&gt;d64b0ab0 Fix static opening hours in generated pages&lt;/code&gt;는 prompt 파일뿐 아니라 &lt;code class=&quot;language-text&quot;&gt;generation_service.py&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;naver_place_fetcher.py&lt;/code&gt;, 그리고 관련 테스트를 같이 바꿨다. 이게 이 문제를 데이터 모델링 문제로 본 이유다.&lt;/p&gt;
&lt;h2 id=&quot;해결한-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%B4%EA%B2%B0%ED%95%9C-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;해결한 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;해결한 방식&lt;/h2&gt;
&lt;p&gt;해결은 두 겹으로 했다.&lt;/p&gt;
&lt;p&gt;첫째, generation payload에서 시점 의존 데이터를 제거했다. &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt;처럼 현재 상태를 나타내는 필드는 final HTML 생성 입력에 넘기지 않도록 했다.&lt;/p&gt;
&lt;p&gt;둘째, fetcher 쪽에서도 정적 snapshot에 넣을 수 있는 영업시간만 남기도록 정리했다. 현재 상태 문구가 섞여 들어오면 제거하고, 지속 가능한 정규 영업시간 라인만 남기는 식이다.&lt;/p&gt;
&lt;p&gt;셋째, prompt contract에서도 &lt;code class=&quot;language-text&quot;&gt;current_opening_hours&lt;/code&gt;를 적극 사용하라는 문구를 제거했다. 모델에게 &quot;있으면 써라&quot;라고 말하는 순간 다시 같은 문제가 생길 수 있기 때문이다.&lt;/p&gt;
&lt;h2 id=&quot;왜-데이터-모델링-문제였나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EB%8D%B0%EC%9D%B4%ED%84%B0-%EB%AA%A8%EB%8D%B8%EB%A7%81-%EB%AC%B8%EC%A0%9C%EC%98%80%EB%82%98&quot; aria-label=&quot;왜 데이터 모델링 문제였나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 데이터 모델링 문제였나&lt;/h2&gt;
&lt;p&gt;이 문제는 결국 프롬프트 문제가 아니라 데이터 모델링 문제였다.&lt;/p&gt;
&lt;p&gt;AI에게 어떤 데이터를 줄 것인가를 정할 때 &quot;유용해 보이는가&quot;만 보면 안 된다. 그 데이터가 출력물의 수명과 맞는지도 봐야 한다.&lt;/p&gt;
&lt;p&gt;정적 페이지는 생성된 뒤 오래 남는다. 그러면 입력 데이터도 오래 남아도 되는 정보여야 한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;주소는 오래 남아도 된다.&lt;/li&gt;
&lt;li&gt;대표 메뉴는 어느 정도 오래 남아도 된다.&lt;/li&gt;
&lt;li&gt;정규 영업시간도 비교적 오래 남아도 된다.&lt;/li&gt;
&lt;li&gt;하지만 현재 영업 상태는 오래 남으면 안 된다.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;시간에 따라 변하는 값은 정적 HTML 안에 박는 대신, 필요하다면 runtime widget이나 외부 링크로 처리해야 한다.&lt;/p&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;AI 생성 결과가 틀렸을 때, 자꾸 프롬프트를 먼저 의심하게 된다. 하지만 이번 문제는 prompt wording보다 payload 설계가 더 중요했다.&lt;/p&gt;
&lt;p&gt;모델은 받은 데이터를 최대한 활용하려고 한다. 그래서 쓰면 안 되는 데이터는 &quot;쓰지 마&quot;라고 말하기보다 처음부터 주지 않는 편이 낫다.&lt;/p&gt;
&lt;p&gt;정적 페이지에 들어갈 수 있는 데이터는 &quot;생성 시점에 맞는가&quot;가 아니라 &quot;사용자가 나중에 봐도 여전히 덜 틀리는가&quot;로 판단해야 한다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;생성 payload를 설계할 때는 데이터가 유용해 보이는지만 보지 않는다. 그 데이터가 출력물의 수명과 맞는지도 같이 본다.&lt;/p&gt;
&lt;p&gt;앞으로 생성 payload는 세 가지로 나눠 본다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;정적 페이지에 넣어도 되는 데이터&lt;/li&gt;
&lt;li&gt;페이지에 넣을 수는 있지만 조심해서 표현해야 하는 데이터&lt;/li&gt;
&lt;li&gt;생성 시점 이후 바로 틀릴 수 있으므로 넣으면 안 되는 데이터&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;AI가 잘못 쓴 문장을 고치려면, 먼저 AI가 왜 그 문장을 쓸 수 있었는지 봐야 한다. 이번 경우에는 답이 프롬프트가 아니라 payload 안에 있었다.&lt;/p&gt;</content:encoded></item><item><title><![CDATA[Treating Gemini Overload as a Product Path Problem, Not Just an Outage]]></title><description><![CDATA[When Gemini final generation failed with , the easy fix would have been to add another retry. But the more important Place2Page question was…]]></description><link>https://sewon.dev/en/place2page-gemini-overload-provider-fallback/</link><guid isPermaLink="false">https://sewon.dev/en/place2page-gemini-overload-provider-fallback/</guid><pubDate>Thu, 14 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/0babdd0295d6ff53a5863e88bfc7108b/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB8klEQVR42o1STWsTURTNj3EtuhG0IkUpQlEQqrhw53/Qjf4KV12400VdFAtCEReaUqEmlaRJpWkSO8lkZsJk3sxkMvPevO/7ZGbiZzce7uLy3jv3nMN9Nan0yE1dH9teNg2I6+PJFI+9rDrxEXV8QqgyxoApAWCggAGoaQ1BmKJwEYSLKMYowkGYoQiHMfFRlmY8xYJzCVJowTVl8XCYjSzhTDQhNXMe8G+jOVNJopkwBC/6g7TXl7Zt8rwgq/mEDD8xuwk0NSBDj5+dMqtPvZFQApSQdN4j4aGSKQP4HA523db7+CSWpbJymtO9zXnztYgcJXL7lDT3k8Y+GnYFy4FjPHfrM+udSMcJZa/GBy9G9ZdRw2PJT9sgjdHLVhlBDSWGU1haVznwuLqlwAIWEyDa6IIslZqh2EdRgMIAhSiKpJRlZNBQVjmCMPV1hI8mrDnOOxOZ85LcOe7duP3wyuq9S1fXL6/cuXBx9aDRLvT00osu5Z2IPdmyn76xn+8Ez3aJE4uC/O1ksL7x+NbdRytr96+vPbh2c+NL66iN3Q/e8Ue/t4cG9eT7mEdSmjPELMStGbOQYLJUBoC8BKUsp5Qznkvx1m1teYfbQXsn7m4vOl0yrYL8udOKfG7Tv36RKXJrraF8pOF3QUWuxP+C+S/8AK5skqC6JOA9AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/0babdd0295d6ff53a5863e88bfc7108b/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/0babdd0295d6ff53a5863e88bfc7108b/e7570/situation-diagram.png 170w,
/static/0babdd0295d6ff53a5863e88bfc7108b/f46e7/situation-diagram.png 340w,
/static/0babdd0295d6ff53a5863e88bfc7108b/ca1dc/situation-diagram.png 680w,
/static/0babdd0295d6ff53a5863e88bfc7108b/02d09/situation-diagram.png 1020w,
/static/0babdd0295d6ff53a5863e88bfc7108b/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;When Gemini final generation failed with &lt;code class=&quot;language-text&quot;&gt;503 UNAVAILABLE&lt;/code&gt;, the easy fix would have been to add another retry. But the more important Place2Page question was different: which failures should the product absorb inside the user flow, and which failures should stay visible to operators? I treated only capacity-like errors as eligible, sent them to a fallback provider once, and kept fallback metadata even when the generation succeeded.&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Problem: Temporary Gemini final HTML generation failures such as &lt;code class=&quot;language-text&quot;&gt;503&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;UNAVAILABLE&lt;/code&gt;, and &lt;code class=&quot;language-text&quot;&gt;overloaded&lt;/code&gt; interrupted the user creation flow.&lt;/li&gt;
&lt;li&gt;Decision: Do not hide every failure behind fallback. Only absorb errors that looked like provider capacity issues.&lt;/li&gt;
&lt;li&gt;Fix: Retry once with a fallback model, and record the primary provider, fallback provider, and reason in result metadata.&lt;/li&gt;
&lt;li&gt;Lesson: AI provider failures are not only outages to hide. They are reliability design decisions about which failures a product path should absorb.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;Place2Page uses Gemini for final HTML generation. The service fetches place data, builds a meta prompt, and asks Gemini to produce the final HTML in the last step.&lt;/p&gt;
&lt;p&gt;Most of the time, that works. But once a generative AI provider sits inside a product flow, one operational condition becomes unavoidable.&lt;/p&gt;
&lt;p&gt;Sometimes the external model is busy.&lt;/p&gt;
&lt;p&gt;The official Google Gemini API troubleshooting guide describes &lt;code class=&quot;language-text&quot;&gt;503 UNAVAILABLE&lt;/code&gt; as a state where the service may be temporarily overloaded or down. In other words, the error does not always mean our code is wrong.&lt;/p&gt;
&lt;p&gt;The user does not experience that distinction. They do not think, &quot;Gemini is busy.&quot; They think, &quot;My page creation failed.&quot;&lt;/p&gt;
&lt;h2 id=&quot;Problem&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Problem&quot; aria-label=&quot;Problem permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Problem&lt;/h2&gt;
&lt;p&gt;At first, model call failures were surfaced as errors. That was honest for debugging, but weak for the user flow.&lt;/p&gt;
&lt;p&gt;Final HTML generation happens near the end of the whole creation process. The user has already waited while the service fetched place data, built a meta prompt, and prepared the generation. If the last model call fails after that, the experience is poor.&lt;/p&gt;
&lt;p&gt;But falling back on every error would be wrong too.&lt;/p&gt;
&lt;p&gt;If the API key is invalid, the request payload is malformed, or the model is called in an unsupported way, fallback would hide a real defect. Later, it would become harder to explain why fallback keeps happening.&lt;/p&gt;
&lt;p&gt;So the system needed a boundary.&lt;/p&gt;
&lt;h2 id=&quot;Initial-Hypothesis&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Initial-Hypothesis&quot; aria-label=&quot;Initial Hypothesis permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Initial Hypothesis&lt;/h2&gt;
&lt;p&gt;I assumed not all failures should be treated the same. The product should absorb only temporary capacity problems inside the user flow.&lt;/p&gt;
&lt;p&gt;The rough split was:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Absorbable failures: &lt;code class=&quot;language-text&quot;&gt;503&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;UNAVAILABLE&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;high demand&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;overloaded&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Failures to surface immediately: invalid configuration, authentication errors, bad requests, code bugs&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The first group is closer to provider state. The same request may succeed a little later or on another model. The second group is something we need to fix. It should not be covered by fallback.&lt;/p&gt;
&lt;h2 id=&quot;Evidence&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Evidence&quot; aria-label=&quot;Evidence permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Evidence&lt;/h2&gt;
&lt;p&gt;This was not handled by reading one log line and guessing. The tests left in the repo show the intended boundary.&lt;/p&gt;
&lt;p&gt;The Gemini stream failure test simulates this error:&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;503 UNAVAILABLE. {&apos;error&apos;: {&apos;message&apos;: &apos;high demand&apos;}}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;That error is closer to provider capacity than internal validation or prompt parsing. So the generation service carries explicit markers for capacity failures.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;503
unavailable
high demand
overloaded
temporarily unavailable
try again later&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The fallback test verifies that the first call fails with &lt;code class=&quot;language-text&quot;&gt;503 UNAVAILABLE: high demand&lt;/code&gt;, then the second call moves to &lt;code class=&quot;language-text&quot;&gt;gpt-5.3-codex&lt;/code&gt;. The successful result keeps fallback metadata.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;provider_fallback_applied == True
provider_fallback_reason == &quot;gemini_provider_unavailable&quot;
primary_final_model_provider == &quot;gemini&quot;
final_model_provider == &quot;openai&quot;
final_model_id == &quot;gpt-5.3-codex&quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;There is also a test to make sure not every Gemini error falls back. Without that distinction, authentication errors or invalid requests could be hidden behind fallback.&lt;/p&gt;
&lt;p&gt;At the commit level, &lt;code class=&quot;language-text&quot;&gt;267b3fc fix(api): fallback from busy Gemini to OpenAI&lt;/code&gt; changed &lt;code class=&quot;language-text&quot;&gt;generation_service.py&lt;/code&gt;, config, tests, and model routing docs together. It was not a simple retry. It included model routing and operational metadata for later inspection.&lt;/p&gt;
&lt;h2 id=&quot;Implementation&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Implementation&quot; aria-label=&quot;Implementation permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Implementation&lt;/h2&gt;
&lt;p&gt;The final HTML generation path detects errors that look like Gemini capacity failures. If a fallback model is configured, the required API key exists, and the fallback is not the same model as the primary, it retries once with the fallback model.&lt;/p&gt;
&lt;p&gt;The important word is &quot;once.&quot;&lt;/p&gt;
&lt;p&gt;Fallback is not an infinite retry mechanism. It is the minimum safety net that can keep the user flow alive. If that also fails, the system should admit failure. Otherwise, error rate and root cause become harder to observe.&lt;/p&gt;
&lt;p&gt;Fallback events are also recorded in metadata. A successful generation does not mean everything was normal. If fallback made it succeed, operators need to be able to see that later.&lt;/p&gt;
&lt;h2 id=&quot;Why-Not-Just-Retry&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Why-Not-Just-Retry&quot; aria-label=&quot;Why Not Just Retry permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Why Not Just Retry?&lt;/h2&gt;
&lt;p&gt;For a temporary outage, retrying the same model can be reasonable. A short retry has value.&lt;/p&gt;
&lt;p&gt;But latency matters in an AI generation product. The user is already waiting for the page to be created. Retrying the same overloaded model several times increases the wait. In this product flow, a limited retry followed by a different provider or runtime fit better.&lt;/p&gt;
&lt;p&gt;The fallback model still needs to be understood as a different path. Its quality and style may not perfectly match the primary model. So fallback is not &quot;generate anything and mark it successful.&quot; It is an alternate path that is better than failing the user flow outright.&lt;/p&gt;
&lt;h2 id=&quot;Lesson&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Lesson&quot; aria-label=&quot;Lesson permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Lesson&lt;/h2&gt;
&lt;p&gt;AI provider failure is not an exceptional event. It is an operating condition.&lt;/p&gt;
&lt;p&gt;Products that call model APIs will eventually encounter rate limits, overload, and temporary unavailability. The important work is not eliminating failure. It is classifying failure.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is this a failure the user flow can absorb?&lt;/li&gt;
&lt;li&gt;Is this a failure operators should see?&lt;/li&gt;
&lt;li&gt;Is this a configuration issue that needs immediate correction?&lt;/li&gt;
&lt;li&gt;Is this external state that may improve with retry?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If fallback is added without that classification, it hides incidents. If there is no fallback at all, a brief external provider wobble becomes a direct user failure.&lt;/p&gt;
&lt;h2 id=&quot;How-I-Would-Judge-This-Next-Time&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#How-I-Would-Judge-This-Next-Time&quot; aria-label=&quot;How I Would Judge This Next Time permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;How I Would Judge This Next Time&lt;/h2&gt;
&lt;p&gt;When I see a similar provider failure again, I will not start by adding fallback. I will first separate temporary capacity issues from bad requests, authentication errors, and code defects. The former can be absorbed inside the user flow. The latter should surface quickly.&lt;/p&gt;
&lt;p&gt;For future provider fallback work, I will watch three things together.&lt;/p&gt;
&lt;p&gt;First, fallback rate should be a metric. If fallback happens too often, the primary provider choice, quota, or model routing needs another look.&lt;/p&gt;
&lt;p&gt;Second, fallback output quality should be reviewed separately. Success alone is not enough. The quality gap between primary and fallback output matters.&lt;/p&gt;
&lt;p&gt;Third, user-facing messages should distinguish the cases. Users do not need to be told every time a temporary alternate path was used, but when generation fully fails, they should know whether retrying is likely to help.&lt;/p&gt;
&lt;p&gt;Reliability in an AI product does not come from trusting one model. It comes from deciding in advance where the flow goes when that model fails.&lt;/p&gt;
&lt;h2 id=&quot;References&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#References&quot; aria-label=&quot;References permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://ai.google.dev/gemini-api/docs/troubleshooting&quot;&gt;Gemini API troubleshooting guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[Gemini overloaded를 장애가 아니라 제품 경로 문제로 보기]]></title><description><![CDATA[Gemini final generation이 로 실패했을 때 단순 retry만 붙이면 쉬웠다. 하지만 Place2Page…]]></description><link>https://sewon.dev/place2page-gemini-overload-provider-fallback/</link><guid isPermaLink="false">https://sewon.dev/place2page-gemini-overload-provider-fallback/</guid><pubDate>Thu, 14 May 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/0babdd0295d6ff53a5863e88bfc7108b/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB8klEQVR42o1STWsTURTNj3EtuhG0IkUpQlEQqrhw53/Qjf4KV12400VdFAtCEReaUqEmlaRJpWkSO8lkZsJk3sxkMvPevO/7ZGbiZzce7uLy3jv3nMN9Nan0yE1dH9teNg2I6+PJFI+9rDrxEXV8QqgyxoApAWCggAGoaQ1BmKJwEYSLKMYowkGYoQiHMfFRlmY8xYJzCVJowTVl8XCYjSzhTDQhNXMe8G+jOVNJopkwBC/6g7TXl7Zt8rwgq/mEDD8xuwk0NSBDj5+dMqtPvZFQApSQdN4j4aGSKQP4HA523db7+CSWpbJymtO9zXnztYgcJXL7lDT3k8Y+GnYFy4FjPHfrM+udSMcJZa/GBy9G9ZdRw2PJT9sgjdHLVhlBDSWGU1haVznwuLqlwAIWEyDa6IIslZqh2EdRgMIAhSiKpJRlZNBQVjmCMPV1hI8mrDnOOxOZ85LcOe7duP3wyuq9S1fXL6/cuXBx9aDRLvT00osu5Z2IPdmyn76xn+8Ez3aJE4uC/O1ksL7x+NbdRytr96+vPbh2c+NL66iN3Q/e8Ue/t4cG9eT7mEdSmjPELMStGbOQYLJUBoC8BKUsp5Qznkvx1m1teYfbQXsn7m4vOl0yrYL8udOKfG7Tv36RKXJrraF8pOF3QUWuxP+C+S/8AK5skqC6JOA9AAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/0babdd0295d6ff53a5863e88bfc7108b/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/0babdd0295d6ff53a5863e88bfc7108b/e7570/situation-diagram.png 170w,
/static/0babdd0295d6ff53a5863e88bfc7108b/f46e7/situation-diagram.png 340w,
/static/0babdd0295d6ff53a5863e88bfc7108b/ca1dc/situation-diagram.png 680w,
/static/0babdd0295d6ff53a5863e88bfc7108b/02d09/situation-diagram.png 1020w,
/static/0babdd0295d6ff53a5863e88bfc7108b/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;p&gt;Gemini final generation이 &lt;code class=&quot;language-text&quot;&gt;503 UNAVAILABLE&lt;/code&gt;로 실패했을 때 단순 retry만 붙이면 쉬웠다. 하지만 Place2Page에서 더 중요한 질문은 &quot;어떤 실패를 사용자 흐름 안에서 흡수하고, 어떤 실패를 운영자에게 드러낼 것인가&quot;였다. 그래서 capacity 계열 오류만 좁게 분류하고, 한 번만 fallback provider로 넘기며, 성공해도 fallback metadata를 남기도록 했다.&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;문제: Gemini final HTML generation에서 &lt;code class=&quot;language-text&quot;&gt;503&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;UNAVAILABLE&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;overloaded&lt;/code&gt; 같은 일시적 장애가 사용자 생성 흐름을 끊었다.&lt;/li&gt;
&lt;li&gt;판단: 모든 실패를 fallback으로 덮지 않고, provider capacity 문제로 볼 수 있는 오류만 흡수했다.&lt;/li&gt;
&lt;li&gt;해결: fallback model로 한 번만 재시도하고, 결과 metadata에 primary/fallback provider와 이유를 남겼다.&lt;/li&gt;
&lt;li&gt;배운 점: AI provider 장애는 숨길 문제가 아니라, 어떤 실패를 제품 경로에서 흡수할지 정하는 reliability 설계 문제다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;Place2Page의 final HTML generation은 Gemini를 사용한다. 장소 데이터를 가져오고, meta prompt를 만들고, 마지막 단계에서 Gemini가 완성된 HTML을 생성한다.&lt;/p&gt;
&lt;p&gt;대부분의 경우에는 잘 동작한다. 하지만 생성형 AI provider를 제품 흐름에 넣으면 피할 수 없는 문제가 있다.&lt;/p&gt;
&lt;p&gt;외부 모델이 가끔 바쁘다.&lt;/p&gt;
&lt;p&gt;Google Gemini API 공식 troubleshooting 문서에서도 &lt;code class=&quot;language-text&quot;&gt;503 UNAVAILABLE&lt;/code&gt;은 서비스가 일시적으로 overloaded 상태이거나 down 상태일 수 있다고 설명한다. 즉, 우리 코드가 항상 잘못되어서 발생하는 오류는 아니다.&lt;/p&gt;
&lt;p&gt;문제는 사용자 입장에서는 이유가 중요하지 않다는 점이다. 사용자는 &quot;Gemini가 바쁘구나&quot;가 아니라 &quot;내 페이지 생성이 실패했다&quot;고 느낀다.&lt;/p&gt;
&lt;h2 id=&quot;문제&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%AC%B8%EC%A0%9C&quot; aria-label=&quot;문제 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;문제&lt;/h2&gt;
&lt;p&gt;처음에는 모델 호출 실패를 그대로 에러로 보여줬다. 이 방식은 디버깅에는 솔직하지만 사용자 흐름에는 약했다.&lt;/p&gt;
&lt;p&gt;특히 final HTML generation은 전체 생성 과정의 마지막에 가깝다. 앞 단계에서 장소 정보를 가져오고, 메타 프롬프트를 만들고, 어느 정도 시간이 지난 뒤 마지막 모델 호출에서 실패하면 사용자 경험이 나쁘다.&lt;/p&gt;
&lt;p&gt;그렇다고 모든 에러를 fallback으로 덮을 수도 없다.&lt;/p&gt;
&lt;p&gt;예를 들어 API key가 잘못됐거나, 요청 payload가 잘못됐거나, 모델이 지원하지 않는 형식으로 호출된 경우까지 fallback으로 넘기면 진짜 문제를 숨기게 된다. 나중에는 왜 fallback이 자주 발생하는지 알기 어려워진다.&lt;/p&gt;
&lt;p&gt;그래서 기준이 필요했다.&lt;/p&gt;
&lt;h2 id=&quot;처음-생각한-가설&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%98%EC%9D%8C-%EC%83%9D%EA%B0%81%ED%95%9C-%EA%B0%80%EC%84%A4&quot; aria-label=&quot;처음 생각한 가설 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;처음 생각한 가설&lt;/h2&gt;
&lt;p&gt;모든 실패를 똑같이 보지 말고, 일시적 capacity 문제만 사용자 흐름 안에서 흡수하면 된다고 봤다.&lt;/p&gt;
&lt;p&gt;구분은 대략 이렇게 잡았다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;흡수할 수 있는 실패: &lt;code class=&quot;language-text&quot;&gt;503&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;UNAVAILABLE&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;high demand&lt;/code&gt;, &lt;code class=&quot;language-text&quot;&gt;overloaded&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;바로 드러내야 하는 실패: 잘못된 설정, 인증 오류, 잘못된 요청, 코드 버그&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;전자는 provider 상태에 가까운 문제다. 같은 요청을 잠시 뒤나 다른 모델로 보내면 성공할 수 있다. 후자는 우리 쪽에서 고쳐야 하는 문제다. fallback으로 덮으면 안 된다.&lt;/p&gt;
&lt;h2 id=&quot;확인한-증거&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%99%95%EC%9D%B8%ED%95%9C-%EC%A6%9D%EA%B1%B0&quot; aria-label=&quot;확인한 증거 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;확인한 증거&lt;/h2&gt;
&lt;p&gt;이 문제도 로그 문장만 보고 감으로 처리한 것은 아니었다. repo에 남은 테스트가 기준을 잘 보여준다.&lt;/p&gt;
&lt;p&gt;Gemini stream 호출 실패 테스트는 이런 에러를 흉내낸다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;503 UNAVAILABLE. {&apos;error&apos;: {&apos;message&apos;: &apos;high demand&apos;}}&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;이 에러는 내부 validation 실패나 prompt parsing 실패가 아니라 provider capacity 쪽에 가깝다. 그래서 generation service에는 capacity failure로 볼 marker가 따로 들어갔다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;503
unavailable
high demand
overloaded
temporarily unavailable
try again later&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;fallback 테스트는 첫 호출에서 Gemini가 &lt;code class=&quot;language-text&quot;&gt;503 UNAVAILABLE: high demand&lt;/code&gt;로 실패하고, 두 번째 호출에서는 &lt;code class=&quot;language-text&quot;&gt;gpt-5.3-codex&lt;/code&gt;로 넘어가는지를 본다. 성공 결과에는 fallback metadata도 남긴다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;text&quot;&gt;&lt;pre class=&quot;language-text&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;provider_fallback_applied == True
provider_fallback_reason == &quot;gemini_provider_unavailable&quot;
primary_final_model_provider == &quot;gemini&quot;
final_model_provider == &quot;openai&quot;
final_model_id == &quot;gpt-5.3-codex&quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;반대로 모든 Gemini 에러를 fallback하지 않도록 하는 테스트도 있다. 이 구분이 없으면 인증 오류나 잘못된 요청까지 fallback으로 숨길 수 있기 때문이다.&lt;/p&gt;
&lt;p&gt;커밋으로 보면 &lt;code class=&quot;language-text&quot;&gt;267b3fc fix(api): fallback from busy Gemini to OpenAI&lt;/code&gt;에서 &lt;code class=&quot;language-text&quot;&gt;generation_service.py&lt;/code&gt;, config, tests, model routing docs가 같이 바뀌었다. 단순 retry가 아니라 model routing과 운영 관찰 metadata까지 포함한 수정이었다.&lt;/p&gt;
&lt;h2 id=&quot;해결한-방식&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%95%B4%EA%B2%B0%ED%95%9C-%EB%B0%A9%EC%8B%9D&quot; aria-label=&quot;해결한 방식 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;해결한 방식&lt;/h2&gt;
&lt;p&gt;final HTML generation에서 Gemini capacity failure로 볼 수 있는 오류를 감지했다. 그리고 fallback model이 설정되어 있고, 필요한 API key가 존재하며, primary model과 같은 모델이 아니라면 한 번 fallback으로 재시도했다.&lt;/p&gt;
&lt;p&gt;중요한 점은 &quot;한 번&quot;이었다.&lt;/p&gt;
&lt;p&gt;fallback은 무한 재시도 장치가 아니다. 사용자 흐름을 살릴 수 있는 최소한의 안전망이다. 계속 실패하면 실패로 인정해야 한다. 그래야 오류율과 원인을 관찰할 수 있다.&lt;/p&gt;
&lt;p&gt;또 fallback이 발생했는지 metadata에 남겼다. 생성이 성공했다고 해서 모든 것이 정상인 것은 아니다. fallback으로 성공한 결과는 운영자가 나중에 볼 수 있어야 한다.&lt;/p&gt;
&lt;h2 id=&quot;왜-단순-retry가-아니었나&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%99%9C-%EB%8B%A8%EC%88%9C-retry%EA%B0%80-%EC%95%84%EB%8B%88%EC%97%88%EB%82%98&quot; aria-label=&quot;왜 단순 retry가 아니었나 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;왜 단순 retry가 아니었나&lt;/h2&gt;
&lt;p&gt;일시적 장애라면 같은 모델에 retry를 걸 수도 있다. 실제로 짧은 retry는 의미가 있다.&lt;/p&gt;
&lt;p&gt;하지만 AI 생성 제품에서는 latency도 중요하다. 사용자는 이미 페이지가 만들어지길 기다리고 있다. 같은 overloaded 모델에 여러 번 retry를 걸면 대기 시간이 늘어난다. 그래서 한 번의 제한적 retry 후 다른 provider/runtime으로 넘어가는 방식이 더 제품 흐름에 맞았다.&lt;/p&gt;
&lt;p&gt;이때도 fallback model의 성격을 알아야 한다. 결과 품질이나 스타일이 primary model과 완전히 같지는 않을 수 있다. 그래서 fallback은 &quot;아무거나 만들어서 성공 처리&quot;가 아니라 실패보다 나은 대체 경로로 봐야 한다.&lt;/p&gt;
&lt;h2 id=&quot;배운-점&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%B0%B0%EC%9A%B4-%EC%A0%90&quot; aria-label=&quot;배운 점 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;배운 점&lt;/h2&gt;
&lt;p&gt;AI provider 장애는 특별한 일이 아니라 운영 조건이다.&lt;/p&gt;
&lt;p&gt;모델 API를 호출하는 제품은 언젠가 rate limit, overloaded, temporary unavailable을 만난다. 이때 중요한 것은 실패를 없애는 것이 아니라, 실패를 분류하는 것이다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;사용자 흐름에서 흡수할 실패인가?&lt;/li&gt;
&lt;li&gt;운영자에게 드러내야 할 실패인가?&lt;/li&gt;
&lt;li&gt;바로 수정해야 할 설정 문제인가?&lt;/li&gt;
&lt;li&gt;재시도하면 나아질 수 있는 외부 상태인가?&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;이 구분 없이 fallback을 붙이면 장애를 숨긴다. 반대로 fallback이 전혀 없으면 외부 provider의 짧은 흔들림이 그대로 사용자 실패가 된다.&lt;/p&gt;
&lt;h2 id=&quot;다음에는-이렇게-판단한다&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EB%8B%A4%EC%9D%8C%EC%97%90%EB%8A%94-%EC%9D%B4%EB%A0%87%EA%B2%8C-%ED%8C%90%EB%8B%A8%ED%95%9C%EB%8B%A4&quot; aria-label=&quot;다음에는 이렇게 판단한다 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;다음에는 이렇게 판단한다&lt;/h2&gt;
&lt;p&gt;비슷한 provider 장애를 다시 보면 fallback부터 붙이지 않는다. 먼저 실패가 일시적 capacity 문제인지, 잘못된 요청/인증/코드 문제인지 분리한다. 전자는 사용자 흐름 안에서 흡수할 수 있지만, 후자는 빨리 드러나야 한다.&lt;/p&gt;
&lt;p&gt;앞으로 provider fallback을 다룰 때는 세 가지를 같이 본다.&lt;/p&gt;
&lt;p&gt;첫째, fallback rate를 지표로 본다. fallback이 너무 자주 발생하면 primary provider 선택이나 quota, model routing을 다시 봐야 한다.&lt;/p&gt;
&lt;p&gt;둘째, fallback 결과 품질을 별도로 본다. 성공 여부만 보지 않고, primary와 fallback의 output 품질 차이를 확인해야 한다.&lt;/p&gt;
&lt;p&gt;셋째, 사용자에게 보여줄 메시지를 구분한다. 일시적으로 다른 경로를 사용했는지 굳이 모두 설명할 필요는 없지만, 완전히 실패했을 때는 재시도 가능한 문제인지 명확히 알려야 한다.&lt;/p&gt;
&lt;p&gt;AI 제품에서 안정성은 모델 하나를 믿는 데서 나오지 않는다. 실패했을 때 어떤 길로 빠질지 미리 정해두는 데서 나온다.&lt;/p&gt;
&lt;h2 id=&quot;참고&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B0%B8%EA%B3%A0&quot; aria-label=&quot;참고 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;참고&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://ai.google.dev/gemini-api/docs/troubleshooting&quot;&gt;Gemini API troubleshooting guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[How I Keep Project Notes]]></title><description><![CDATA[Summary This post records the operating principles I set when I first opened this blog. The detailed writing rules are now managed in the…]]></description><link>https://sewon.dev/en/project-notes-template/</link><guid isPermaLink="false">https://sewon.dev/en/project-notes-template/</guid><pubDate>Thu, 01 Jan 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c6865486ffae631938fb6fa202a3d11e/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB1ElEQVR42m2S207bQBCG8/4X7QNwgypVVdsLuCGkJCA1atSiAGkJISGnxrEdO971+pA92Lve2co2gVRi9Gu0mp1P/+5oGrnUSzt1t8z2qLulHmIeYpa7W292jkd9xBHJAMyb0dAaMKGIMBwJHGdhUiogoqwQSoViQgHoA5laJVwm0JBzGXtF7EC60akLiQ05K2/KrjLpSiWmoY5nuFCKBhs0aKKbEzY6yyYtMTwtwrWpaQCQBIQF3II8BNCvzy5hKYUfsPmMT6fatozvGscyu7TuUOlMoCtst7Hd5uhKpU9Vee+slPIRafXdk59ecxCf/45P+8RG3BgjBc/JONpcBqtzvG5FblvR5X+wlMrdJN279OI6+f5Hde9V51b6RJtC5DSuOjOZB7nwjRbmYPKVs9RRkE8e8egBrxZ8tWDLGY8QlTwyxlCVXW6fmu5jJ172uN1NF7siq6yhci6UnaCL7egMD9ts2mHTJh071K9NcE7fj7+9GzaPvN5xcnMU/kKSvsLlzEBPEm8YOaPYfSDOPXH+stBRSaS4BsCSYknDvYr9wBv1F3Ktvlj94/mPD/Pex/X1Z//2Kx58igf93bo2eXvDXk4SigNpqQupi9pkv1TPeoH/AS8go5YAvgfRAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;Situation diagram&apos; title=&apos;&apos; src=&apos;/static/c6865486ffae631938fb6fa202a3d11e/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/c6865486ffae631938fb6fa202a3d11e/e7570/situation-diagram.png 170w,
/static/c6865486ffae631938fb6fa202a3d11e/f46e7/situation-diagram.png 340w,
/static/c6865486ffae631938fb6fa202a3d11e/ca1dc/situation-diagram.png 680w,
/static/c6865486ffae631938fb6fa202a3d11e/02d09/situation-diagram.png 1020w,
/static/c6865486ffae631938fb6fa202a3d11e/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;Situation diagram&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;Summary&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Summary&quot; aria-label=&quot;Summary permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Summary&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;This post records the operating principles I set when I first opened this blog.&lt;/li&gt;
&lt;li&gt;The detailed writing rules are now managed in the repository&apos;s &lt;code class=&quot;language-text&quot;&gt;AGENTS.md&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Public posts should preserve real context while clearly separating evidence, verification scope, and information that should not be published.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Context&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Context&quot; aria-label=&quot;Context permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Context&lt;/h2&gt;
&lt;p&gt;I started this blog not as a collection of finished tutorials, but as a place to record what I learned while building and operating real projects.&lt;/p&gt;
&lt;p&gt;A useful note should still be usable when I reread it later. So each post should leave behind the problem context, evidence I checked, judgment process, and the rule I want to avoid relearning next time.&lt;/p&gt;
&lt;p&gt;At first, this post itself was close to the writing standard. As the blog grew, more repository-level rules appeared: images, Excalidraw diagrams, SEO metadata, private-post handling, and security checks before publication.&lt;/p&gt;
&lt;p&gt;The current detailed writing standard now lives in &lt;code class=&quot;language-text&quot;&gt;AGENTS.md&lt;/code&gt;. This post remains as the initial operating principle explaining why I keep notes this way.&lt;/p&gt;
&lt;h2 id=&quot;Basic-Post-Structure&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Basic-Post-Structure&quot; aria-label=&quot;Basic Post Structure permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Basic Post Structure&lt;/h2&gt;
&lt;p&gt;When possible, project notes follow this flow.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;md&quot;&gt;&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Context&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Problem&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Initial Hypothesis&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Evidence Checked&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Fix&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Verification&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; Lesson&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; What I Will Do Next Time&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; References&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Not every post has to follow this order exactly. Retrospectives can focus on feedback and behavior changes. Experiments can focus on hypotheses and results. Incident records can focus on evidence and verification. Still, I try to keep a &lt;code class=&quot;language-text&quot;&gt;## Summary&lt;/code&gt;, the problem context, the evidence checked, and the next rule.&lt;/p&gt;
&lt;h2 id=&quot;Publication-Standard&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Publication-Standard&quot; aria-label=&quot;Publication Standard permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Publication Standard&lt;/h2&gt;
&lt;p&gt;When publishing project notes, I keep the real context but remove information that should not be public.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Do not include tokens, accounts, internal URLs, or customer names.&lt;/li&gt;
&lt;li&gt;Write incident or cost records around causes and decision criteria.&lt;/li&gt;
&lt;li&gt;Keep only the code snippets needed to explain the problem.&lt;/li&gt;
&lt;li&gt;Separate assumptions from confirmed facts.&lt;/li&gt;
&lt;li&gt;Do not treat private posts as secure storage. Clean up sensitive information and screenshots before publication.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;Image-and-Diagram-Standard&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Image-and-Diagram-Standard&quot; aria-label=&quot;Image and Diagram Standard permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Image and Diagram Standard&lt;/h2&gt;
&lt;p&gt;When possible, place a situation diagram near the top of the post.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;md&quot;&gt;&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;[&lt;span class=&quot;token content&quot;&gt;상황 설명 도식&lt;/span&gt;](&lt;span class=&quot;token url&quot;&gt;./situation-diagram.png&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The diagram does not replace the post. Colors, arrows, and boxes are supporting tools that make the problem structure easier to see. The core judgment still has to appear again in prose.&lt;/p&gt;
&lt;p&gt;For screenshots and experiment images, the alt text and surrounding paragraph should explain what is visible. If an image is evidence, the post should also tell the reader where to look.&lt;/p&gt;
&lt;h2 id=&quot;Tag-Standard&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#Tag-Standard&quot; aria-label=&quot;Tag Standard permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;Tag Standard&lt;/h2&gt;
&lt;p&gt;Tags should use words that make the post easy to find again later.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;debugging&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;deployment&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;analytics&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;frontend&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;backend&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;infra&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;product&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;retrospective&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;security&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;seo&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;First-Operating-Principle&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#First-Operating-Principle&quot; aria-label=&quot;First Operating Principle permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;First Operating Principle&lt;/h2&gt;
&lt;p&gt;I should not postpone writing because a post feels too long. If I learn one thing from a project, that is enough for one note.&lt;/p&gt;
&lt;p&gt;But I should not publish carelessly either. The current standard is simple.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Write only what I actually checked.&lt;/li&gt;
&lt;li&gt;Do not describe unverified outcomes as success.&lt;/li&gt;
&lt;li&gt;Use official external documentation first.&lt;/li&gt;
&lt;li&gt;Use &lt;code class=&quot;language-text&quot;&gt;AGENTS.md&lt;/code&gt; to check frontmatter, images, publication scope, and verification.&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item><item><title><![CDATA[프로젝트 기록을 어떻게 남길 것인가]]></title><description><![CDATA[요약 이 글은 블로그를 처음 열 때 세운 운영 원칙을 정리한 기록이다. 현재 글 작성의 세부 기준은 repo…]]></description><link>https://sewon.dev/project-notes-template/</link><guid isPermaLink="false">https://sewon.dev/project-notes-template/</guid><pubDate>Thu, 01 Jan 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;&lt;figure class=&apos;gatsby-resp-image-figure&apos; style=&apos;margin-bottom: 16px;&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-wrapper&apos; style=&apos;position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 680px; &apos;&gt;
      &lt;a class=&apos;gatsby-resp-image-link&apos; href=&apos;/static/c6865486ffae631938fb6fa202a3d11e/1e677/situation-diagram.png&apos; style=&apos;display: block&apos; target=&apos;_blank&apos; rel=&apos;noopener&apos;&gt;
    &lt;span class=&apos;gatsby-resp-image-background-image&apos; style=&quot;padding-bottom: 60.58823529411765%; position: relative; bottom: 0; left: 0; background-image: url(&apos;data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAIAAADtbgqsAAAACXBIWXMAAAsTAAALEwEAmpwYAAAB1ElEQVR42m2S207bQBCG8/4X7QNwgypVVdsLuCGkJCA1atSiAGkJISGnxrEdO971+pA92Lve2co2gVRi9Gu0mp1P/+5oGrnUSzt1t8z2qLulHmIeYpa7W292jkd9xBHJAMyb0dAaMKGIMBwJHGdhUiogoqwQSoViQgHoA5laJVwm0JBzGXtF7EC60akLiQ05K2/KrjLpSiWmoY5nuFCKBhs0aKKbEzY6yyYtMTwtwrWpaQCQBIQF3II8BNCvzy5hKYUfsPmMT6fatozvGscyu7TuUOlMoCtst7Hd5uhKpU9Vee+slPIRafXdk59ecxCf/45P+8RG3BgjBc/JONpcBqtzvG5FblvR5X+wlMrdJN279OI6+f5Hde9V51b6RJtC5DSuOjOZB7nwjRbmYPKVs9RRkE8e8egBrxZ8tWDLGY8QlTwyxlCVXW6fmu5jJ172uN1NF7siq6yhci6UnaCL7egMD9ts2mHTJh071K9NcE7fj7+9GzaPvN5xcnMU/kKSvsLlzEBPEm8YOaPYfSDOPXH+stBRSaS4BsCSYknDvYr9wBv1F3Ktvlj94/mPD/Pex/X1Z//2Kx58igf93bo2eXvDXk4SigNpqQupi9pkv1TPeoH/AS8go5YAvgfRAAAAAElFTkSuQmCC&apos;); background-size: cover; display: block;&quot;&gt;&lt;/span&gt;
  &lt;img class=&apos;gatsby-resp-image-image&apos; alt=&apos;상황 설명 도식&apos; title=&apos;&apos; src=&apos;/static/c6865486ffae631938fb6fa202a3d11e/ca1dc/situation-diagram.png&apos; srcset=&apos;/static/c6865486ffae631938fb6fa202a3d11e/e7570/situation-diagram.png 170w,
/static/c6865486ffae631938fb6fa202a3d11e/f46e7/situation-diagram.png 340w,
/static/c6865486ffae631938fb6fa202a3d11e/ca1dc/situation-diagram.png 680w,
/static/c6865486ffae631938fb6fa202a3d11e/02d09/situation-diagram.png 1020w,
/static/c6865486ffae631938fb6fa202a3d11e/1e677/situation-diagram.png 1220w&apos; sizes=&apos;(max-width: 680px) 100vw, 680px&apos; style=&apos;width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;&apos; loading=&apos;lazy&apos; decoding=&apos;async&apos;&gt;
  &lt;/a&gt;
    &lt;/span&gt;
    &lt;figcaption class=&apos;gatsby-resp-image-figcaption&apos;&gt;상황 설명 도식&lt;/figcaption&gt;
  &lt;/figure&gt;&lt;/p&gt;
&lt;h2 id=&quot;요약&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9A%94%EC%95%BD&quot; aria-label=&quot;요약 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;요약&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;이 글은 블로그를 처음 열 때 세운 운영 원칙을 정리한 기록이다.&lt;/li&gt;
&lt;li&gt;현재 글 작성의 세부 기준은 repo의 &lt;code class=&quot;language-text&quot;&gt;AGENTS.md&lt;/code&gt;를 기준으로 관리한다.&lt;/li&gt;
&lt;li&gt;공개 글은 실제 맥락을 살리되, 증거와 검증 범위, 공개하면 안 되는 정보를 명확히 나눠야 한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;상황&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%83%81%ED%99%A9&quot; aria-label=&quot;상황 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;상황&lt;/h2&gt;
&lt;p&gt;이 블로그는 완성된 튜토리얼을 모으기보다 실제 프로젝트를 만들고 운영하면서 배운 점을 기록하기 위해 시작한다.&lt;/p&gt;
&lt;p&gt;좋은 기록은 나중에 다시 읽었을 때 바로 쓸 수 있어야 한다. 그래서 글마다 문제 상황, 확인한 증거, 판단 과정, 다음에 반복하지 않을 기준을 남긴다.&lt;/p&gt;
&lt;p&gt;처음에는 이 글 자체가 작성 기준에 가까웠다. 하지만 글이 늘어나면서 이미지, Excalidraw 도식, SEO metadata, private 글 처리, 공개 전 보안 점검처럼 repo에 더 가까운 규칙이 생겼다.&lt;/p&gt;
&lt;p&gt;그래서 현재의 세부 작성 기준은 &lt;code class=&quot;language-text&quot;&gt;AGENTS.md&lt;/code&gt;에 둔다. 이 글은 &quot;왜 이런 방식으로 기록하는가&quot;를 설명하는 초기 운영 원칙으로 남긴다.&lt;/p&gt;
&lt;h2 id=&quot;글의-기본-구조&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B8%80%EC%9D%98-%EA%B8%B0%EB%B3%B8-%EA%B5%AC%EC%A1%B0&quot; aria-label=&quot;글의 기본 구조 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;글의 기본 구조&lt;/h2&gt;
&lt;p&gt;앞으로 프로젝트 기록은 가능하면 아래 흐름을 따른다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;md&quot;&gt;&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; 상황&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; 문제&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; 처음 생각한 가설&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; 확인한 증거&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; 해결한 방식&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; 검증&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; 배운 점&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; 다음에는 이렇게 할 것&lt;/span&gt;

&lt;span class=&quot;token title important&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;##&lt;/span&gt; 참고&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;모든 글이 이 순서를 그대로 따라야 하는 것은 아니다. 회고 글은 피드백과 행동 변화 중심으로, 실험 글은 가설과 결과 중심으로, 장애 기록은 증거와 검증 중심으로 바꿀 수 있다. 다만 &lt;code class=&quot;language-text&quot;&gt;## 요약&lt;/code&gt;, 문제 상황, 확인한 증거, 다음 기준은 가능하면 남긴다.&lt;/p&gt;
&lt;h2 id=&quot;공개-기준&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EA%B3%B5%EA%B0%9C-%EA%B8%B0%EC%A4%80&quot; aria-label=&quot;공개 기준 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;공개 기준&lt;/h2&gt;
&lt;p&gt;프로젝트 기록을 공개할 때는 실제 맥락을 남기되 공개하면 안 되는 정보는 제거한다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;토큰, 계정, 내부 URL, 고객명은 쓰지 않는다.&lt;/li&gt;
&lt;li&gt;장애나 비용 기록은 원인과 판단 기준 중심으로 정리한다.&lt;/li&gt;
&lt;li&gt;코드 조각은 문제를 설명하는 데 필요한 만큼만 남긴다.&lt;/li&gt;
&lt;li&gt;추측과 확인된 사실을 구분한다.&lt;/li&gt;
&lt;li&gt;private 글도 보안 저장소처럼 취급하지 않는다. 공개 전 민감정보와 스크린샷을 먼저 정리한다.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;이미지와-도식-기준&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%9D%B4%EB%AF%B8%EC%A7%80%EC%99%80-%EB%8F%84%EC%8B%9D-%EA%B8%B0%EC%A4%80&quot; aria-label=&quot;이미지와 도식 기준 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;이미지와 도식 기준&lt;/h2&gt;
&lt;p&gt;가능하면 글의 첫머리에 상황 설명 도식을 둔다.&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;md&quot;&gt;&lt;pre class=&quot;language-md&quot;&gt;&lt;code class=&quot;language-md&quot;&gt;&lt;span class=&quot;token url&quot;&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;[&lt;span class=&quot;token content&quot;&gt;상황 설명 도식&lt;/span&gt;](&lt;span class=&quot;token url&quot;&gt;./situation-diagram.png&lt;/span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;도식은 본문을 대신하지 않는다. 색, 화살표, 박스는 문제 구조를 빠르게 보여주는 보조 장치이고, 핵심 판단은 본문 문장으로 다시 설명한다.&lt;/p&gt;
&lt;p&gt;스크린샷이나 실험 이미지는 &quot;무엇이 보이는지&quot;가 alt text와 주변 문단에 드러나야 한다. 이미지가 근거라면 독자가 어디를 봐야 하는지도 같이 적는다.&lt;/p&gt;
&lt;h2 id=&quot;태그-기준&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%ED%83%9C%EA%B7%B8-%EA%B8%B0%EC%A4%80&quot; aria-label=&quot;태그 기준 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;태그 기준&lt;/h2&gt;
&lt;p&gt;태그는 나중에 다시 찾기 쉬운 단어로 붙인다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;debugging&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;deployment&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;analytics&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;frontend&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;backend&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;infra&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;product&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;retrospective&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;security&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;seo&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;첫-운영-원칙&quot; style=&quot;position:relative;&quot;&gt;&lt;a href=&quot;#%EC%B2%AB-%EC%9A%B4%EC%98%81-%EC%9B%90%EC%B9%99&quot; aria-label=&quot;첫 운영 원칙 permalink&quot; class=&quot;heading-anchor before&quot;&gt;&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width=&quot;15&quot; height=&quot;15&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path d=&quot;M6.188 8.719c.439-.439.926-.801 1.444-1.087 2.887-1.591 6.589-.745 8.445 2.069l-2.246 2.245c-.644-1.469-2.243-2.305-3.834-1.949-.599.134-1.168.433-1.633.898l-4.304 4.306c-1.307 1.307-1.307 3.433 0 4.74 1.307 1.307 3.433 1.307 4.74 0l1.327-1.327c1.207.479 2.501.67 3.779.575l-2.929 2.929c-2.511 2.511-6.582 2.511-9.093 0s-2.511-6.582 0-9.093l4.304-4.306zm6.836-6.836l-2.929 2.929c1.277-.096 2.572.096 3.779.574l1.326-1.326c1.307-1.307 3.433-1.307 4.74 0 1.307 1.307 1.307 3.433 0 4.74l-4.305 4.305c-1.311 1.311-3.44 1.3-4.74 0-.303-.303-.564-.68-.727-1.051l-2.246 2.245c.236.358.481.667.796.982.812.812 1.846 1.417 3.036 1.704 1.542.371 3.194.166 4.613-.617.518-.286 1.005-.648 1.444-1.087l4.304-4.305c2.512-2.511 2.512-6.582.001-9.093-2.511-2.51-6.581-2.51-9.092 0z&quot;/&gt;&lt;/svg&gt;&lt;/a&gt;첫 운영 원칙&lt;/h2&gt;
&lt;p&gt;길게 쓰려고 미루지 않는다. 한 프로젝트에서 하나만 배워도 글 하나로 남긴다.&lt;/p&gt;
&lt;p&gt;대신 공개할 때는 대충 내보내지 않는다. 현재 기준은 단순하다.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;내가 실제로 확인한 것만 쓴다.&lt;/li&gt;
&lt;li&gt;검증하지 않은 결과를 성공처럼 말하지 않는다.&lt;/li&gt;
&lt;li&gt;외부 문서는 공식 문서를 먼저 본다.&lt;/li&gt;
&lt;li&gt;&lt;code class=&quot;language-text&quot;&gt;AGENTS.md&lt;/code&gt;를 기준으로 frontmatter, 이미지, 공개 범위, 검증을 확인한다.&lt;/li&gt;
&lt;/ul&gt;</content:encoded></item></channel></rss>