01 · Concept

네트워크 디버깅

웹 성능 최적화의 첫 단계는 네트워크 병목을 정확히 진단하는 것입니다. 워터폴 차트와 HTTP 상태 코드를 읽는 능력이 핵심입니다.

브라우저 DevTools의 네트워크 탭은 각 리소스의 DNS, TCP, TLS, TTFB, Download 단계를 워터폴로 시각화합니다.Performance API를 활용하면 프로그래밍적으로 네트워크 성능을 측정하고 모니터링할 수 있습니다.

02 · Interactive Demo

워터폴 차트와 HTTP 상태 코드

리소스별 로딩 단계와 HTTP 상태 코드의 의미를 확인하세요.

DNS
TCP
TLS
TTFB
Download
Stalled
NameTypeWaterfallSize
index.htmldocument
155ms
5.2KB
style.cssstylesheet
65ms
18KB
app.jsscript
188ms
245KB
api/dataxhr
215ms
1.8KB
hero.webpimage
135ms
85KB
03 · Code Example

코드 예시

실제 코드로 동작 원리를 확인하세요.

// Resource Timing API
const resources = performance.getEntriesByType('resource');

resources.forEach(entry => {
  console.log(entry.name);
  console.log('DNS:', entry.domainLookupEnd
    - entry.domainLookupStart, 'ms');
  console.log('TCP:', entry.connectEnd
    - entry.connectStart, 'ms');
  console.log('TLS:', entry.connectEnd
    - entry.secureConnectionStart, 'ms');
  console.log('TTFB:', entry.responseStart
    - entry.requestStart, 'ms');
  console.log('Download:', entry.responseEnd
    - entry.responseStart, 'ms');
  console.log('Total:', entry.duration, 'ms');
});

// Navigation Timing
const nav = performance.getEntriesByType('navigation')[0];
console.log('DOM Interactive:', nav.domInteractive);
console.log('DOM Complete:', nav.domComplete);
console.log('Load Event:', nav.loadEventEnd);
04 · Interview Point

면접 핵심 질문

네트워크 병목은 DevTools Network 탭에서 TTFB가 길거나, Download 시간이 긴 경우, 많은 요청이 Stalled 상태인 경우에 나타납니다.CPU 병목은 네트워크는 빠르지만 렌더링이 느리고, Performance 탭에서 Long Task(50ms+)가 감지되며 메인 스레드가 블로킹되는 경우입니다. 네트워크 병목은 CDN, 압축, 코드 스플리팅으로, CPU 병목은 코드 최적화, Web Worker, 지연 로딩으로 해결합니다.
워터폴의 각 막대는 리소스 로딩 단계를 나타냅니다.DNS: 도메인 → IP 변환,TCP: 3-way handshake,TLS: 암호화 핸드셰이크,TTFB(Time to First Byte): 서버 처리 시간,Download: 콘텐츠 다운로드입니다. TTFB가 길면 서버 최적화가, Download가 길면 파일 크기 최적화가 필요합니다.Stalled는 브라우저 커넥션 제한으로 대기하는 시간입니다.
2xx (성공): 200 OK, 201 Created, 204 No Content.3xx (리다이렉트): 301 영구 이동(캐시됨), 302 임시 이동, 304 Not Modified(캐시 사용).4xx (클라이언트 오류): 400 잘못된 요청, 401 인증 필요, 403 권한 없음, 404 리소스 없음.5xx (서버 오류): 500 서버 내부 오류, 502 게이트웨이 오류, 503 서비스 중단. 특히 401(인증 안 됨)과 403(인증됨, 권한 없음)의 차이를 명확히 알아야 합니다.