Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
コンテナによるPDF Generatorについて
Search
toumakido
May 20, 2026
240
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
コンテナによるPDF Generatorについて
at
https://fin-jaws.connpass.com/event/388549/
toumakido
May 20, 2026
More Decks by toumakido
See All by toumakido
AWSのPQC対応について
toumakido
0
19
SESから理解する DMARC
toumakido
0
18
若手エンジニアがAIとどう向き合っているか
toumakido
0
39
Featured
See All Featured
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
300
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
Why Our Code Smells
bkeepers
PRO
340
58k
Color Theory Basics | Prateek | Gurzu
gurzu
1
490
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
260
Being A Developer After 40
akosma
92
590k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
550
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
530
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
Transcript
© 2015 - 2026 Nowcast Inc. JAWS-UG Fin-JAWS × コンテナ⽀部
⾦融コンテナ⼤全 〜ビジネスから技術まで〜 コンテナによるPDF Generatorについて 2026-05-20 1
© 2015 - 2026 Nowcast Inc. ⽬次 1. ⾦融業界とPDF 2.
PDF⽣成の負荷特性 3. PDF Generatorについて 4. なぜ「コンテナ」でLambdaにデプロイするか 5. 実装上の技術的⼯夫 2
© 2015 - 2026 Nowcast Inc. ⾦融とPDFについて ⾦融業界ではPDF⽣成が頻繁に⾏われる • 契約書
• 取引明細 • 運⽤報告書 • その他帳票 3
© 2015 - 2026 Nowcast Inc. リクエストは周期的に集中してくる リクエスト数 時間 →
⽉末 ⼤量発⽣ 平時はほぼゼロ 4 ⾦融業界の書類は年次、⽉次でまとめて作成するものが多い • ⽉次レポート • 運⽤報告書
© 2015 - 2026 Nowcast Inc. PDF Generator コンテナ Lambdaで稼働
常時稼働はせず、1ファイルの⽣成を1リクエストで即時で返す Lambdaのメリット • ECSタスクと⽐べて、初回起動、スケールアウトが速い • ⼤量のリクエストが来た時に、ウォーム状態をキープしながら、並列で処理できる 5
© 2015 - 2026 Nowcast Inc. Chromiumを使ったHTML→PDF変換 HTML テンプレート Chromium
(ヘッドレス) PDF 出⼒ /main (Go binary) Chromium Playwright (Go) アーキテクチャ サブプロセス CDP (Chrome DevTools Protocol) フロー page.PDF() PDF バイト列
© 2015 - 2026 Nowcast Inc. 安定したPDF⽣成のために 1 HTMLレンダリング ChromiumでHTMLを読み込む
2 networkidle 待機 ネットワークリクエストが500ms発⽣しなくなるまで待つ→画像‧フォントのロード完了を確 認 3 CSSセレクタ出現待機 指定セレクタが現れるまで待つ→JS動的コンテンツの⽣成完了を確認 4 <img>ロード確認 全画像のロード完了をJavaScriptで確認 5 PDF出⼒ A4サイズ(297mm × 210mm)でPDF⽣成 7 PDF⽣成は5ステップの順序制御で、画像が表⽰されないPDFが⽣成されない問題を解消
© 2015 - 2026 Nowcast Inc. なぜ「コンテナ」を使⽤したか 理由1: サイズ上限 デプロイ⽅式
サイズ上限 Chromium zipデプロイ 250MB(展開後) ✗ 不可 (300〜400MB) コンテナイメージ 最⼤10GB ✓ 可能 理由2: コンテナのメリットとして、依存ライブラリを管理が楽 Dockerfile(抜粋) RUN ~/go/bin/playwright install --with-deps chromium ↑ Chromiumと依存ライブラリをイメージに焼き込み → コールドスタート時のダウンロード不要
© 2015 - 2026 Nowcast Inc. 起こった問題と解決策
© 2015 - 2026 Nowcast Inc. 課題1:Lambdaペイロード制限 → S3中継の2段階パターン 問題:Lambda直接呼び出しのレスポンス上限は
6MB。HTML、PDFともにこれを超える 10 クライアント 解決:S3中継 署名付きURL PDF Generator S3 署名付きURL ファイル配置 ファイル配置
© 2015 - 2026 Nowcast Inc. 課題2:Chromiumのメモリリーク → コンテナ⾃殺(suicide関数) 問題:Chromiumは⻑期稼働でメモリリーク。LambdaはAWSがコンテナを管理し、直接終了できない
解決:→ 環境変数更新という "⾃殺トリガー" で対処 起動から10分経過 ⾃分の環境変数をAPIで更新 Lambda基盤が新しいコンテナを 起動 古いコンテナが⾃然に交代 11
© 2015 - 2026 Nowcast Inc. 12