Files
Resume/dist/01-backend-performance-portfolio.html

374 lines
20 KiB
HTML

<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>01-backend-performance-portfolio</title>
<style>:root {
color-scheme: light;
--ink: #17212b;
--muted: #5c6b77;
--rule: #dbe2e7;
--accent: #0f766e;
--accent-dark: #0b5f59;
--soft: #f2f8f7;
--soft-2: #f6f8fa;
--card: #ffffff;
}
@page {
size: 297mm 167mm;
margin: 10mm 14mm 9mm;
}
* { box-sizing: border-box; }
body {
margin: 0;
background: #fff;
color: var(--ink);
font-family: "Noto Sans CJK KR", "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif;
font-size: 9.15pt;
line-height: 1.42;
word-break: keep-all;
overflow-wrap: break-word;
}
main {
width: 100%;
margin: 0 auto;
}
h1, h2, h3 {
margin: 0;
line-height: 1.18;
letter-spacing: -0.015em;
}
/* Each page is exactly the content box, so its figure can flex into the slack. */
.page {
display: flex;
flex-direction: column;
height: 148mm;
overflow: hidden;
}
.page + .page {
break-before: page;
}
.page > h1 {
flex: 0 0 auto;
padding-top: 1mm;
padding-bottom: 2.2mm;
border-bottom: 2px solid var(--accent);
font-size: 21.5pt;
font-weight: 900;
}
.page:first-child > h1 {
margin-top: 3mm;
padding-bottom: 0;
border-bottom: 0;
font-size: 26pt;
color: var(--ink);
}
h2 {
margin-top: 3.4mm;
color: var(--accent-dark);
font-size: 14pt;
font-weight: 850;
}
h3 {
margin-top: 2.5mm;
font-size: 10.8pt;
font-weight: 850;
}
p {
margin: 1.4mm 0;
}
strong { font-weight: 850; }
a {
color: #0b5cad;
text-decoration: none;
}
hr {
height: 1px;
margin: 2.5mm 0;
border: 0;
background: var(--rule);
}
blockquote {
margin: 2mm 0 2.4mm;
padding: 2mm 2.6mm;
border: 0;
border-left: 4px solid var(--accent);
border-radius: 3px;
background: var(--soft);
color: #28433f;
font-size: 9.1pt;
}
blockquote p { margin: 0; }
ul, ol {
margin: 1.3mm 0 2mm;
padding-left: 5mm;
}
li {
margin: .65mm 0;
padding-left: .4mm;
}
code {
padding: .1mm .55mm;
border-radius: 2px;
background: #eef2f4;
color: #23303c;
font-family: "JetBrains Mono", "D2Coding", Consolas, monospace;
font-size: .91em;
}
pre {
margin: 1.8mm 0;
padding: 2mm 2.4mm;
border: 1px solid var(--rule);
border-radius: 5px;
background: var(--soft-2);
white-space: pre-wrap;
}
pre code {
padding: 0;
background: transparent;
font-size: 7.5pt;
line-height: 1.35;
}
table {
width: 100%;
margin: 1.8mm 0 2.3mm;
border-collapse: separate;
border-spacing: 0;
table-layout: fixed;
font-size: 8.0pt;
line-height: 1.32;
}
td {
padding: 1.15mm 1.55mm;
border-right: 1px solid var(--rule);
border-bottom: 1px solid var(--rule);
vertical-align: top;
background: #fff;
}
tr:first-child td {
border-top: 1px solid var(--rule);
font-weight: 800;
color: #34424e;
}
td:first-child { border-left: 1px solid var(--rule); }
tr:first-child td:first-child { border-top-left-radius: 5px; }
tr:first-child td:last-child { border-top-right-radius: 5px; }
tr:last-child td:first-child { border-bottom-left-radius: 5px; }
tr:last-child td:last-child { border-bottom-right-radius: 5px; }
.two-col-table td:first-child {
width: 33mm;
background: #f7f9fa;
color: var(--muted);
font-weight: 800;
}
.metric-table {
border-spacing: 2mm 0;
border-collapse: separate;
margin-top: 2.3mm;
}
.metric-table td {
border: 0;
text-align: center;
background: var(--soft-2);
}
.metric-table tr:first-child td {
border: 0;
padding-top: 2.3mm;
padding-bottom: .8mm;
color: var(--accent-dark);
font-size: 14.5pt;
font-weight: 900;
}
.metric-table tr:last-child td {
padding-top: .7mm;
padding-bottom: 2.3mm;
color: var(--muted);
font-size: 8.0pt;
}
.data-table tr:first-child td {
background: #f3f6f7;
color: #34424e;
font-weight: 850;
}
figure {
display: flex;
flex: 1 1 auto;
flex-direction: column;
justify-content: center;
min-height: 0;
margin: 1.6mm auto;
text-align: center;
}
figure img {
display: block;
max-width: 100%;
max-height: 100%;
min-height: 0;
margin: 0 auto;
object-fit: contain;
}
figcaption {
margin-top: .7mm;
color: var(--muted);
font-size: 6.8pt;
}
.project {
display: block;
}
h2, h3, blockquote, table, figure {
break-after: avoid;
}
tr, blockquote, figure {
break-inside: avoid;
}
/* ── Cover: headline > experience axis > headline results > stack > contact ── */
.page:first-child > h1 {
margin-top: 6mm;
font-size: 34pt;
}
.page:first-child > h1 + h2 {
margin-top: 3.4mm;
max-width: 235mm;
color: var(--accent-dark);
font-size: 18.5pt;
line-height: 1.24;
}
.page:first-child > h1 + h2 + blockquote {
max-width: 235mm;
margin-top: 3.6mm;
padding: 2.6mm 3.2mm;
font-size: 9.6pt;
}
/* Headline results on the cover read louder than anything below them. */
.page:first-child > h1 + h2 + blockquote + .metric-table {
margin-top: 5.5mm;
}
.page:first-child > h1 + h2 + blockquote + .metric-table td {
background: var(--soft);
}
.page:first-child > h1 + h2 + blockquote + .metric-table tr:first-child td {
padding-top: 3.4mm;
padding-bottom: 1.1mm;
font-size: 19pt;
}
.page:first-child > h1 + h2 + blockquote + .metric-table tr:last-child td {
padding-bottom: 3.4mm;
font-size: 8.4pt;
}
/* Stack and contact are the quietest elements on the page. */
.page:first-child > h1 + h2 + blockquote + .metric-table + p {
margin-top: 4.2mm;
color: var(--muted);
font-size: 8.6pt;
}
.page:first-child > h1 + h2 + blockquote + .metric-table + p + .two-col-table {
width: 118mm;
margin-top: 3.4mm;
font-size: 7.8pt;
}
.page:first-child > h1 + h2 + blockquote + .metric-table + p + .two-col-table td {
padding: .85mm 1.4mm;
}
.page:first-child > h1 + h2 + blockquote + .metric-table + p + .two-col-table td:first-child {
width: 26mm;
}
/* ── Section pages ── */
/* The deck line under a section title stays subordinate to the h2 claim. */
h2 + p strong:first-child {
color: #34424e;
}
@media print {
a { color: #0b5cad; }
}
/* ── Figures ──────────────────────────────────────────────────────────────
A figure is the flexible row of its .page column, so it receives exactly the
space the text on that page leaves over and the image scales into it. Width
(269mm of content box) is the binding constraint for wide diagrams, so the
viewBox aspect ratio decides how large the labels inside an SVG end up:
rendered height(mm) = viewBox height / viewBox width * 269
A 1260x450 diagram therefore prints at ~96mm and its 20-unit labels at ~12pt.
Nothing here caps the figure in millimetres; overflow is impossible because
the page box is a fixed 148mm and the figure is the only element that flexes.
------------------------------------------------------------------------ */
figcaption {
flex: 0 0 auto;
margin-top: 1mm;
font-size: 7.2pt;
}
</style>
</head>
<body>
<main>
<section class="page"><h1>강동현 · Backend Engineer</h1><h2>같은 조회를 query 수, 읽은 row, buffer, 실행 계획으로 나눠 비교했습니다</h2><blockquote><p>멘토링 과제로 진행한 Feed Query 성능 비교입니다. N+1, Batch Fetch, Projection, Top-N, index 의존성, pagination을 같은 데이터셋과 같은 측정 조건에서 비교했습니다. 뒤쪽에는 TechLog Backend에서 게시 상태와 module 경계, 인증 경계를 정리한 내용이 이어집니다.</p></blockquote><table class="metric-table"><tbody><tr><td><strong>2,022 → 23</strong></td><td><strong>1,569 → 0</strong></td><td><strong>2,000 → 20</strong></td></tr><tr><td>N=1,000 요청 1건의 PreparedStatement</td><td>Projection 적용 후 entity load</td><td>100번째 페이지에서 읽은 row</td></tr></tbody></table><p>PostgreSQL 16 · Hibernate Statistics · EXPLAIN (ANALYZE, BUFFERS) · Testcontainers · Java 21 · Spring Boot</p><table class="two-col-table"><tbody><tr><td>GitHub</td><td><a href="https://github.com/donghyeon-ka">github.com/donghyeon-ka</a></td></tr><tr><td>TechLog</td><td><a href="https://hyeonworks.com">hyeonworks.com</a></td></tr><tr><td>Email</td><td>donghyeonka68@gmail.com</td></tr></tbody></table></section>
<section class="page"><h1>01 · Performance Lab · N+1 Baseline</h1><h2>요청 1건이 SQL 2,022개로 늘어났습니다</h2><p><strong>목록 1페이지를 여는 데 실제로 몇 번 질의하는가?</strong> · 별도 멘토링 과제 · Feed Query Performance Lab</p><p><code>loadFeed(0, N)</code> 한 번이 N=1,000에서 PreparedStatement 2,022개를 만들었습니다. content 1 + count 1 + User 20 + Page 1,000 + Highlight 1,000으로 분해됩니다. 부모 행이 늘어난 만큼 질의가 따라 늘어나는 구조였습니다.</p><figure><img src="file:///home/donghyeon/workspace/chat-gpt-container/Resume/assets/portfolio/query-baseline-growth.svg" alt="WIDE"></figure><table class="data-table"><tbody><tr><td>N</td><td>Highlight collection</td><td>PreparedStatement</td><td>median (5)</td><td>max (5)</td></tr><tr><td>10</td><td>10</td><td>25</td><td>32.8 ms</td><td>36.1 ms</td></tr><tr><td>100</td><td>100</td><td>222</td><td>85.9 ms</td><td>108.3 ms</td></tr><tr><td>1,000</td><td>1,000</td><td><strong>2,022</strong></td><td>193.7 ms</td><td>238.4 ms</td></tr></tbody></table><p>PostgreSQL 16 Testcontainers · Hibernate Statistics · 동일 JVM · warm DB cache · single thread. 지연은 7회 중 앞 2회를 warm-up으로 제외한 5회의 median / max입니다.</p></section>
<section class="page"><h1>02 · Performance Lab · Batch / Projection</h1><h2>PreparedStatement 2,022 → 23, entity load 1,569 → 0</h2><p><strong>왕복을 줄이는 것과 읽기 경로를 분리하는 것은 같은 선택인가?</strong> · 별도 멘토링 과제 · Feed Query Performance Lab</p><p>같은 <code>loadFeed(0, N)</code>에서 조회 전략만 바꿔 N=1,000으로 다시 측정했습니다.</p><figure><img src="file:///home/donghyeon/workspace/chat-gpt-container/Resume/assets/portfolio/query-growth.svg" alt="CHART"></figure><p>Batch Fetch는 PreparedStatement를 2,022 → 23으로, collection fetch를 1,000 → 10으로 줄였습니다. Projection은 query를 2개로 고정하고 entity load를 1,569 → 0으로 없앴습니다.</p><p>Batch는 기존 entity 조회 구조를 그대로 두고 왕복만 줄인 최적화이고, Projection은 읽기 전용 contract를 따로 만들어 경로 자체를 나눈 선택입니다. Projection 쪽은 수정 경로에서 쓰던 entity 기능을 쓸 수 없으므로, 목록처럼 읽기만 하는 화면에만 적용했습니다.</p></section>
<section class="page"><h1>03 · Performance Lab · Top-N &amp; Index</h1><h2>LATERAL은 index가 있을 때만 60행에서 멈췄습니다</h2><p><strong>부모별 최신 3건을 가져오려고 전체 row를 정렬해야 하는가?</strong> · 별도 멘토링 과제 · Feed Query Performance Lab</p><p>부모 20개에서 각각 최신 3건을 가져오는 질의를 Window Function / LATERAL / 2-step으로 비교한 뒤, 이긴 계획이 무엇에 기대고 있는지 다시 확인했습니다.</p><figure><img src="file:///home/donghyeon/workspace/chat-gpt-container/Resume/assets/portfolio/topn-lateral-index.svg" alt="CHART"></figure><ul><li>Window: 60 rows · 430 buffers · 1.552 ms</li><li>LATERAL: 60 rows · <strong>204 buffers · 0.323 ms</strong></li><li>2-step: 1,509 rows · 430 buffers · 1.686 ms</li></ul><p>LATERAL이 빠른 기법이어서가 아니라, 부모별로 원하는 row를 바로 찾을 composite index가 있어서 <code>LIMIT 3</code>에서 멈출 수 있었습니다. 작은 K와 큰 group, 그리고 해당 index가 함께 있는 조건에서 측정한 결과입니다.</p></section>
<section class="page"><h1>04 · Performance Lab · Pagination</h1><h2>100번째 페이지에서 OFFSET은 2,000행, Keyset은 20행을 읽었습니다</h2><p><strong>깊은 페이지에서 OFFSET은 무엇을 더 하고 있는가?</strong> · 별도 멘토링 과제 · Feed Query Performance Lab</p><p>seed 2,000건 · page size 20 · 같은 정렬 조건에서 마지막 페이지를 요청했습니다. OFFSET은 건너뛸 행도 일단 읽은 뒤 버리기 때문에 페이지가 깊어질수록 읽는 양이 같이 늘어납니다.</p><figure><img src="file:///home/donghyeon/workspace/chat-gpt-container/Resume/assets/portfolio/pagination-depth.svg" alt="WIDE"></figure><ul><li>OFFSET 1980: 2,000 rows · 141 buffers · 0.996 ms</li><li>Keyset + index: <strong>20 rows · 1 buffer · 0.076 ms</strong></li></ul><p>Keyset이 항상 빠른 것은 아니고, 정렬 key가 안정적이고 cursor로 이어서 탐색하는 화면에서만 성립합니다. 같은 keyset 조건이어도 정렬 index를 제거하면 다시 전체 scan으로 돌아갔습니다.</p></section>
<section class="page"><h1>05 · TechLog · Publication Workflow</h1><h2>저장되는 시점과 공개되는 시점을 분리했습니다</h2><p><strong>Studio에서 고치는 중인 글이 그대로 공개되어도 되는가?</strong> · TechLog Backend · 개인 프로젝트</p><p>Studio에서는 글을 고치는 동안 저장이 계속 일어납니다. 초기 구현에서는 저장된 내용이 곧 공개 화면의 내용이었기 때문에, 검증을 통과하지 못한 문서도 링크만 알면 보였습니다.</p><figure><img src="file:///home/donghyeon/workspace/chat-gpt-container/Resume/assets/portfolio/techlog-publication-workflow.svg" alt="CHART"></figure><p>Create / Save / Validate / Preview / Publish를 각각 별도 use case로 나누고 working version과 publishedVersion을 따로 저장합니다. 검증에 실패하면 publish 단계로 넘어가지 않고, 문서나 dependency의 revision이 바뀌면 이전 preview는 stale로 표시됩니다. 공개 화면은 endpoint 여러 개의 응답을 조합해 게시 여부를 추측하지 않고 publication status와 publishedVersion만 봅니다.</p></section>
<section class="page"><h1>06 · TechLog · Contract Drift</h1><h2>게시까지 끝난 글의 링크가 404로 끝났습니다</h2><p><strong>같은 public path를 몇 군데에서 만들고 있었는가?</strong> · TechLog Backend · 개인 프로젝트</p><p>Project Decision은 publish까지 끝났고 목록에도 보였지만, 링크를 누르면 404가 났습니다. contract, publisher, projection, frontend route가 각각 같은 public path를 따로 만들고 있었고, 그중 한 곳만 규칙이 달라도 목록과 상세가 어긋났습니다.</p><figure><img src="file:///home/donghyeon/workspace/chat-gpt-container/Resume/assets/portfolio/techlog-contract-drift.svg" alt="FULL"></figure><p>지금은 route contract 한 곳에서 path를 만들고, 경계를 넘을 때마다 같은 정의를 쓰는지 확인합니다.</p><ul><li>OpenAPI operation과 RecordKind가 adapter 등록에서 빠졌는지 검사</li><li>server가 응답한 path가 frontend route로 실제 해석되는지 검사</li><li>Nginx serving pattern도 같은 route contract에서 유도</li><li>RecordKind는 <code>Record&lt;RecordKind, _&gt;</code>와 exhaustive switch로 누락이 컴파일 단계에서 드러나게 함</li></ul></section>
<section class="page"><h1>07 · TechLog · Dependency Direction</h1><h2>의존 방향을 사람 기억이 아니라 build에서 막습니다</h2><p><strong>module 18개에서 참조해도 되는 방향을 누가 기억하는가?</strong> · TechLog Backend · 개인 프로젝트</p><p>web / gRPC / GraphQL / WebSocket과 outbound adapter가 늘면서, 어떤 module이 어떤 module을 참조해도 되는지가 각 Gradle 파일에 흩어졌습니다. 규칙을 리뷰에서 걸러내는 방식으로는 module 18개를 감당하기 어려웠습니다. 허용 edge를 <code>modules.json</code>에 한 번 선언하고 실제 project dependency와 비교합니다.</p><figure><img src="file:///home/donghyeon/workspace/chat-gpt-container/Resume/assets/portfolio/clean-architecture-gates.svg" alt="CHART"></figure><ul><li><code>domain-core</code> / <code>shared-contract</code>는 허용 project dependency 0</li><li>선언하지 않은 project edge는 Gradle <code>check</code>에서 실패</li><li>domain의 framework dependency와 application의 adapter / transport dependency는 ArchUnit class graph에서 실패</li></ul></section>
<section class="page"><h1>08 · TechLog · Contract Ownership</h1><h2>inbound adapter가 만든 interface를 outbound adapter가 구현하고 있었습니다</h2><p><strong>adapter 하나를 바꿀 때 어디까지 같이 고쳐야 하는가?</strong> · TechLog Backend · 개인 프로젝트</p><p>inbound adapter가 자기 interface를 정의하고 outbound adapter가 그 타입을 구현하면서, outer adapter끼리 직접 참조하는 project dependency가 생겼습니다. transport 하나를 바꾸면 관계없는 저장소 adapter까지 같이 열어야 했습니다.</p><figure><img src="file:///home/donghyeon/workspace/chat-gpt-container/Resume/assets/portfolio/clean-architecture-contract-ownership.svg" alt="CHART"></figure><p>port를 application이 소유하도록 옮겼습니다. 이제 adapter는 서로를 모르고 application port만 구현합니다.</p><ul><li>application이 호출하는 동작은 application port로 선언</li><li>여러 adapter가 같이 봐야 하는 최소 타입만 <code>shared-contract</code>에 둠</li><li><code>app-bootstrap</code>은 구현체 선택과 runtime 조립만 담당</li></ul></section>
<section class="page"><h1>09 · Authentication · 패턴 비교</h1><h2>네 가지 인증 구조를 같은 네 가지 질문으로 비교했습니다</h2><p><strong>구조 이름 말고 무엇을 기준으로 고를 것인가?</strong> · 4-pattern 인증 실험 · Authorization Code + PKCE</p><p>SPA / Token Mediator / BFF / Forward-Auth를 같은 Authorization Code + PKCE 흐름으로 각각 구현했습니다. 브라우저가 무엇을 들고 있는지, API를 누가 호출하는지, 서버가 무엇을 저장하는지, 무엇을 검증하는지를 네 구조에 똑같이 물었습니다.</p><figure><img src="file:///home/donghyeon/workspace/chat-gpt-container/Resume/assets/portfolio/oauth-pattern-comparison.svg" alt="CHART"></figure><p>브라우저에서 token을 치우면 서버 쪽에 세션 상태가 생기고, 세션 쿠키를 쓰면 CSRF 경계가 따라옵니다. 이 표는 네 구조를 모두 구현해 본 실험 결과이고, 이 가운데 두 가지를 TechLog에 실제로 넣었습니다.</p></section>
<section class="page"><h1>10 · TechLog · Authentication Modes</h1><h2>TechLog에는 <code>jwt</code>와 <code>redis-session</code> 두 mode를 구현했습니다</h2><p><strong>같은 endpoint인데 상태는 어디에 남는가?</strong> · TechLog Backend · <code>SecurityConfig</code> runtime branch</p><p><code>SecurityConfig</code>는 <code>auth-mode</code> 값에 따라 두 SecurityFilterChain 중 하나를 고릅니다. 두 branch는 같은 endpoint를 서비스하지만 상태가 남는 위치가 다릅니다.</p><figure><img src="file:///home/donghyeon/workspace/chat-gpt-container/Resume/assets/portfolio/oauth-techlog-boundaries.svg" alt="CHART"></figure><p><code>jwt</code>는 Resource Server가 서명만 검증하고 서버에 session을 만들지 않습니다. <code>redis-session</code>은 <code>oauth2Login</code>으로 session을 만들고 SecurityContext를 Redis에 보관하며, session cookie를 쓰는 만큼 CSRF token 경계가 함께 붙습니다. repository 기본값과 현재 로컬 <code>.env</code>는 <code>jwt</code>이고, 공개 배포가 어느 mode로 떠 있는지는 이 작업공간에서 확인되지 않아 단정하지 않습니다. Forward-Auth는 비교 실험 범위이고 TechLog security branch에는 넣지 않았습니다.</p></section>
</main>
</body>
</html>