惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
N
Netflix TechBlog - Medium
Engineering at Meta
Engineering at Meta
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
F
Fortinet All Blogs
P
Privacy & Cybersecurity Law Blog
The Hacker News
The Hacker News
博客园 - 司徒正美
博客园 - 聂微东
T
The Blog of Author Tim Ferriss
I
Intezer
WordPress大学
WordPress大学
Security Archives - TechRepublic
Security Archives - TechRepublic
Scott Helme
Scott Helme
T
Threat Research - Cisco Blogs
T
Tailwind CSS Blog
月光博客
月光博客
Recent Announcements
Recent Announcements
博客园 - 叶小钗
J
Java Code Geeks
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
News and Events Feed by Topic
A
Arctic Wolf
B
Blog RSS Feed
Recorded Future
Recorded Future
D
DataBreaches.Net
有赞技术团队
有赞技术团队
Project Zero
Project Zero
U
Unit 42
T
Tor Project blog
The GitHub Blog
The GitHub Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
C
CERT Recently Published Vulnerability Notes
博客园 - Franky
博客园 - 【当耐特】
Microsoft Security Blog
Microsoft Security Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Security Latest
Security Latest
C
Cisco Blogs
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Blog — PlanetScale
Blog — PlanetScale
H
Heimdal Security Blog
Vercel News
Vercel News
Stack Overflow Blog
Stack Overflow Blog
S
Securelist

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
ECR image layers thực ra lưu trên S3 — và 4 bài học khác từ buổi audit AWS cắt $4,440/năm
TAI THANH · 2026-04-28 · via DEV Community

Cắt ~$4,440/năm chi phí AWS — 5 bài học từ 1 buổi audit

Mình vừa làm xong, thấy có vài thứ hay mà AWS docs không nói rõ. Share lại đầy đủ context để ai gặp tình huống tương tự đỡ phải mò như mình. Kết quả: ~$374/tháng tiết kiệm = ~$4,440/năm, hết khoảng 5 giờ làm việc.

TL;DR

Optimization Saving/tháng Effort
Tạo S3 Gateway Endpoint cắt NAT data ~$196 5 phút
Migrate EC2 c3 → c7i (gen upgrade) ~$156 1 giờ
Release EIP idle ~$22 5 phút
TỔNG ~$374/tháng ~5 giờ

ROI: ~$900/giờ effort.


Bối cảnh

Tuần trước team đã làm 1 đợt optimize Karpenter + right-size pod, giảm 15%. Nhưng cost vẫn cao. Câu hỏi: có còn dư địa nào không?

Mình nhận task audit + thực hiện. Spoiler: nhiều thứ tưởng đã optimize hết hóa ra mới chỉ động được vào tảng băng trên.


Bài học #1 — ECR image layers thực ra lưu trên S3

S3 Gateway Endpoint (free, setup 5 phút) — bật thử cho VPC chạy K8s. Theory bảo cắt 50-80% NAT data. Đo CloudWatch ngay sau bật:

Hour trước endpoint:    ~14 GB qua NAT
Hour ngay sau:          ~0.4 GB qua NAT
                        ↑ drop ~97%

Enter fullscreen mode Exit fullscreen mode

Drop sâu hơn theory tận này — mình tò mò trace lại, thì ra: ECR API endpoint serve metadata thôi (manifest, tags), còn binary layers thì redirect về S3 presigned URL. Mỗi pod scaling/restart → docker daemon pull layers → traffic đến S3 ngầm.

Người chỉ tính traffic "S3 trực tiếp" (app gọi S3 SDK trong code) sẽ underestimate massively. ECR pull traffic không hiển thị trong S3 metric thông thường vì client là docker daemon, không phải app code.

Mình rút ra: action nào reversible + cost thấp thì cứ thử + đo, đừng paralyze-by-analysis. Endpoint free, có thể delete ngay.

Vài cái đáng note:

  • Gateway Endpoint chỉ free cho S3 và DynamoDB. Các service khác (ECR API, STS, SSM, KMS...) phải dùng Interface Endpoint ($0.01/giờ/AZ + $0.01/GB) → tính lại ROI cho từng case.
  • Nếu app dùng S3 cross-region (vd VPC ap-southeast-1, bucket us-east-1), Gateway Endpoint không apply — vẫn qua NAT.
  • ECR Pull Through Cache (feature mới) thay đổi pattern này — layers cache local trong region, giảm cross-region pull nhưng không thay được nhu cầu cho S3 endpoint.

→ Anh em chạy K8s/EKS với image lớn + autoscale nhiều, S3 Gateway Endpoint nên làm trước cả khi audit kỹ. Quick win quá rõ.


Bài học #2 — Pre-flight check trước cross-generation EC2 migration

c3.large → c7i.large = Xen-based → Nitro hypervisor, gap price/performance ~15-20%. Nghe free lunch nhưng có catch: Nitro yêu cầu ENA driver (network) + NVMe driver (storage) trong kernel của AMI.

Nếu AMI thiếu driver → instance "running" theo EC2 API nhưng OS không boot được. Cluster brick. Worse: rollback phải stop + change type lại + restart, prod thì là incident.

Pre-flight check 3 phút mình dùng:

for inst in instances_to_migrate:
    assert inst["EnaSupport"] == True              # ENA driver loaded
    assert inst_ami["VirtualizationType"] == "hvm" # not paravirtual (Xen-only)

Enter fullscreen mode Exit fullscreen mode

Subtle gotcha — sau migrate, nhiều script dùng:

aws ec2 wait instance-running  # SAI cho gen migration

Enter fullscreen mode Exit fullscreen mode

running chỉ confirm hypervisor đã boot hardware, không confirm OS responding. Nếu thiếu driver, instance sẽ stuck "running" forever, OS không up — silent failure.

Đúng phải là:

aws ec2 wait instance-status-ok  # confirm cả system status + instance status

Enter fullscreen mode Exit fullscreen mode

status-ok confirm 2/2 checks: system (hypervisor) + instance (OS responding). Thiếu driver → status stuck "initializing" → wait timeout → biết có vấn đề ngay.

Vài cái đáng note:

  • AMI build trước 2017 rất khả năng thiếu ENA. Amazon Linux 2 / Ubuntu 18.04+ thường OK nhưng vẫn nên check.
  • Custom AMI nội bộ là rủi ro cao nhất — đặc biệt nếu base từ snapshot cũ.
  • ENA có thể modprobe runtime, nhưng nếu init không có driver, network sẽ down trong giai đoạn boot — SSH vào fix là không khả thi.

Bài học #3 — Estimate ban đầu sai 30-100% là chuyện thường

Trong session này, NHIỀU lần mình estimate sai trước khi đo:

Item Estimate ban đầu Thực tế Lý do sai
EIP idle overcounted ~3x thực tế ít hơn nhiều Đếm cả EIP gắn vào EC2 stopped (intentionally reserved)
c3 → c7 saving "~40%" "~15%" Confused giá c3 với t2/m4 đời cũ
NAT data nguồn "Phân bố nhiều VPC" gần như 1 NAT duy nhất Không đo trước khi giả định
DynamoDB endpoint "Nên làm vì FREE" KHÔNG cần 0 K8s pod gọi DynamoDB

Pattern: cả 4 lần đều suy luận từ mental model thay vì đo data thực.

Mình rút ra: estimate sai không phải vấn đề. Estimate sai mà không đo lại trước khi report ra mới là vấn đề. Mình từng nhiều lần ngại đo lại vì lỡ thừa nhận estimate ban đầu sai — bài học là phải tách rõ 2 việc:

  1. Estimate để rank ưu tiên (việc nào làm trước)
  2. Đo CloudWatch/Cost Explorer để claim ROI với stakeholder

Skip step 2 = báo cáo "$400/tháng" rồi thực tế delivery $110 = lose credibility với stakeholder mãi mãi.


Bài học #4 — Pareto cực mạnh trong AWS cost (drill-down 3 tầng)

Pareto trong AWS cost extreme hơn 80/20 thông thường — thường gặp 95/5 hoặc 99/1. Lý do: pricing model AWS + scale infrastructure tạo concentration tự nhiên.

Khi audit NAT data charge:

NAT Gateway     traffic share
nat-A           ~97%  ← 1 NAT này thôi
nat-B            ~2%
các NAT khác    <1%

Enter fullscreen mode Exit fullscreen mode

1 NAT chiếm ~97% cost. Phân bổ effort đều cho mọi NAT (audit từng cái 30 phút × 8 NAT = 4 giờ) = waste 8x effort cho 3% ROI.

Drill-down framework mình dùng:

  1. Service breakdown — Cost Explorer → Group by Service. Top 3 service thường > 80% bill.
  2. usage_type breakdown trong service — vd EC2 có BoxUsage:t3.medium, EBS:VolumeUsage.gp3, DataTransfer-Out-Bytes. Cost Explorer cho group by usage_type → thấy cụ thể chi phí đến từ compute hay storage hay transfer.
  3. resource_id breakdown trong usage_type — cần tagging strategy tốt (Project, Environment, Owner tags), hoặc dùng Cost & Usage Report (CUR) export → query Athena.

Action chính xác vào contributor đó, bỏ phần đuôi dài.

Vài cái đáng note:

  • Reserved Instance / Savings Plan discount apply theo proportional logic, có thể distort breakdown — phải look at "unblended cost" nếu muốn thấy real consumption.
  • Cross-account org thì Pareto apply ở account level trước (account nào dominant), rồi xuống service trong account đó.
  • CUR query qua Athena là endgame — nếu audit > 5 lần/năm, đáng setup.

Bài học #5 — Helm uninstall order: dependent trước, dependency sau

Mình uninstall vài helm release theo thứ tự ngẫu nhiên:

apm-server uninstall → OK
kibana uninstall     → HANG (state "uninstalling")
elasticsearch uninstall → OK (đã uninstall trước rồi)

Enter fullscreen mode Exit fullscreen mode

Trace nguyên nhân: Kibana có post-delete hook job call ES master để cleanup security token. Trình tự đã xảy ra:

  1. ES master helm uninstall trước → ES pod deleted, Service elasticsearch-master deleted
  2. Kibana helm uninstall chạy → trigger post-delete hook
  3. Hook job pod start, gọi elasticsearch-master.namespace.svc.cluster.local
  4. K8s DNS không resolve được (Service đã chết) → connection refused
  5. Hook retry vài lần → fail → kibana stuck "uninstalling" forever
WRONG: ES uninstall → Kibana uninstall (hook FAIL)
RIGHT: Kibana uninstall trước → ES uninstall sau

Enter fullscreen mode Exit fullscreen mode

Workaround khi đã sai thứ tự:

# Option 1: Force delete hook job + uninstall không hook
kubectl delete job post-delete-kibana-kibana
helm uninstall kibana --no-hooks

# Option 2: Patch finalizers nếu Helm release stuck
kubectl patch helmrelease kibana -p '{"metadata":{"finalizers":[]}}' --type=merge

Enter fullscreen mode Exit fullscreen mode

--no-hooks skip toàn bộ hook → uninstall xong nhưng có thể leave orphan resource. Acceptable cho destructive cleanup vì dependency đã chết rồi anyway.

Mình rút ra: stateful chart có dependency chain → uninstall theo thứ tự DEPENDENT trước, DEPENDENCY sau.

Áp dụng cho:

  • App trước Database
  • Cache trước Storage backend
  • Sidecar trước main service
  • Webhook controller trước CRD nó depend

Vài cái đáng note:

  • Operator (CRD-based) thì khác — uninstall Operator trước CRD instance → orphan custom resource. Phải uninstall CRD instance trước, Operator sau.
  • helm uninstall --wait flag confirm tất cả resource deleted trước khi return — chậm hơn nhưng catch hang state sớm.
  • Production: nên có runbook cho từng helm release stack ghi rõ uninstall order. Đừng assume team member nhớ.

Pattern playbook (reusable cho lần sau)

1. Get cost trend (Cost Explorer) → identify magnitude
2. Group-by service → find Pareto concentration
3. Drill usage_type/resource_id → find specific contributor
4. Pre-flight check before destructive action
5. Confirm explicit với stakeholder (đặc biệt prod)
6. Execute với reversibility in mind
7. MEASURE actual impact (CloudWatch metrics, không chỉ Cost Explorer)
8. Build verification command để re-check trong tương lai
9. Document findings + remaining TODOs in source repo

Enter fullscreen mode Exit fullscreen mode


Số liệu tổng hợp

Sau ~5 giờ work:

Category Saving/tháng
Network (S3 Gateway Endpoint) ~$196
Compute (EC2 generation upgrade) ~$156
Public IPv4 idle ~$22
TỔNG ~$374/tháng
TỔNG/năm ~$4,488

Vẫn còn dư địa đáng kể trong các TODO chưa làm (RDS right-sizing, EBS audit, ECR Interface Endpoint, Spot ratio increase).


Lời kết

Cost optimization AWS không phải về việc biết hết tricks AWS. Nó về:

  1. Audit có hệ thống (top-down, Pareto)
  2. Đo thực tế (CloudWatch, Cost Explorer)
  3. Action reversible (thử + đo > paralysis-by-analysis)
  4. Pre-flight check trước destructive action

Cuối session, mình bỏ thêm 30 phút build 1 Python script aws-cost-check.py chạy 1 command → dump 5 sections (cost trend, top services, NAT trend, endpoint state, legacy instance remaining). Lần sau câu hỏi "endpoint còn hiệu quả không?" trả lời trong 5 giây thay vì repeat 30 phút audit. Đầu tư 30 phút này compounding rất nhanh — recommend mọi optimization session đều kết thúc bằng tool verification.

Pattern này apply cho bất kỳ AWS account nào. Lần sau apply cho account khác chắc chắn cũng sẽ tìm thấy 5-15% saving giấu đâu đó.


Account AWS của ae lần cuối được audit khi nào? Pattern nào ae dùng? Comment chia sẻ với mình ↓

Tags: #aws #devops #costoptimization #kubernetes #vpc #ec2