Skip to content

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป ํ•™์Šต ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ์ €์žฅ์†Œ

Notifications You must be signed in to change notification settings

brainbackdoor/study

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

์ธํ”„๋ผ๊ณต๋ฐฉ

ํ•™์Šต ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ์ €์žฅ์†Œ


๐Ÿ’ก Introduction

ํ•™์Šต ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ์˜ˆ์ œ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

  • HTTP Cache, gzip ๋“ฑ
  • Servlet
  • Thread

1. HTTP Cache, gzip ์‹ค์Šต

HomeControllerTest ํ…Œ์ŠคํŠธ ๋ฉ”์†Œ๋“œ๋ฅผ ๋ชจ๋‘ ํ†ต๊ณผ์‹œ์ผœ ๋ณธ๋‹ค.

  • ๋ฏธ์…˜1: Cache-Control: no-cache, private ์„ค์ •์„ ํ•ด๋ณธ๋‹ค.
  • ๋ฏธ์…˜2: gzip ์„ค์ •์„ ํ•ด๋ณธ๋‹ค.
  • ๋ฏธ์…˜3: ETag ์„ค์ •์„ ํ•ด๋ณธ๋‹ค.
  • ๋ฏธ์…˜4: ์บ์‹œ ๋ฌดํšจํ™” ์„ค์ •์„ ํ•ด๋ณธ๋‹ค.
  • ๋ฏธ์…˜5: Cache-Control: no-store, no-cache, must-revalidate ์„ค์ •์„ ํ•ด๋ณธ๋‹ค.


2. Servlet ์‹ค์Šต

ServletTest์™€FilterTest ํด๋ž˜์Šค์˜ ๋ชจ๋“  ํ…Œ์ŠคํŠธ๋ฅผ ํ†ต๊ณผ์‹œํ‚จ๋‹ค.

A. ์„œ๋ธ”๋ฆฟ ํ•™์Šต ํ…Œ์ŠคํŠธ

  • SharedCounterServlet, LocalCounterServlet ํด๋ž˜์Šค๋ฅผ ์—ด์–ด๋ณด๊ณ  ์–ด๋–ค ์ฐจ์ด์ ์ด ์žˆ๋Š”์ง€ ํ™•์ธํ•œ๋‹ค.
  • init, service, destroy ๋ฉ”์„œ๋“œ๊ฐ€ ๊ฐ๊ฐ ์–ธ์ œ ์‹คํ–‰๋˜๋Š”์ง€ ์ฝ˜์†” ๋กœ๊ทธ์—์„œ ํ™•์ธํ•œ๋‹ค.
  • ์ง์ ‘ ํ†ฐ์บฃ ์„œ๋ฒ„๋ฅผ ๋„์›Œ๋ณด๊ณ  ์‹ถ๋‹ค๋ฉด ServletApp ํด๋ž˜์Šค์˜ main ๋ฉ”์„œ๋“œ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค.
    • ์›น ๋ธŒ๋ผ์šฐ์ €์—์„œ localhost:8080/shared-counter ๊ฒฝ๋กœ์— ์ ‘๊ทผ ๊ฐ€๋Šฅํ•œ์ง€ ํ™•์ธํ•œ๋‹ค.

B. ํ•„ํ„ฐ ํ•™์Šต ํ…Œ์ŠคํŠธ

  • doFilter ๋ฉ”์„œ๋“œ๋Š” ์–ด๋Š ์‹œ์ ์— ์‹คํ–‰๋ ๊นŒ? ์ฝ˜์†” ๋กœ๊ทธ์—์„œ ํ™•์ธํ•œ๋‹ค.
  • ์™œ ์ธ์ฝ”๋”ฉ์„ ๋”ฐ๋กœ ์„ค์ •ํ•ด์ค˜์•ผ ํ• ๊นŒ?
    • ServletResponse
    • ์œ„ ๋งํฌ์—์„œ character encoding์— ๋Œ€ํ•œ ์„ค๋ช…์„ ์ฐธ๊ณ ํ•œ๋‹ค.


3. Thread ์‹ค์Šต

ThreadTest์™€ ThreadPoolsTest ํด๋ž˜์Šค์˜ ๋ชจ๋“  ํ…Œ์ŠคํŠธ๋ฅผ ํ†ต๊ณผ์‹œํ‚จ๋‹ค.

  • ๋ฏธ์…˜1: ๋™๊ธฐํ™”๋ฅผ ์ด์šฉํ•ด์„œ ์“ฐ๋ ˆ๋“œ ๊ฐ„์„ญ์„ ํ•ด๊ฒฐํ•œ๋‹ค.
  • ๋ฏธ์…˜2: synchronized ์˜ˆ์•ฝ์–ด๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  Thread safeํ•˜๊ฒŒ ๊ตฌ์„ฑํ•œ๋‹ค.
  • ๋ฏธ์…˜3: newFixedThreadPool์™€ newCachedThreadPool์˜ ์ฐจ์ด๋ฅผ ๊ตฌ๋ถ„ํ•˜๊ณ  ํ…Œ์ŠคํŠธ๋ฅผ ํ†ต๊ณผ์‹œํ‚จ๋‹ค.

About

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป ํ•™์Šต ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ์ €์žฅ์†Œ

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages