๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
  • ์žฅ์›์ต ๊ธฐ์ˆ ๋ธ”๋กœ๊ทธ

๐Ÿ”ฌweb application40

100๋งŒ๊ฐœ 1000๋งŒ๊ฐœ์˜ ๋”๋ฏธ๋ฐ์ดํ„ฐ๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฐ€์žฅ ์‰ฌ์šด ๋ฐฉ๋ฒ• TL;DR ์ด๋ฒˆ ๊ธ€์˜ ํ•ต์‹ฌ์„ ์š”์•ฝํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค ๊ฐ€์žฅ ํšจ์œจ์ ์ธ ๋”๋ฏธ๋ฐ์ดํ„ฐ ์ƒ์„ฑ ๋ฐฉ๋ฒ•temp table ์„ ์ด์šฉํ•˜์—ฌ insert Query ๋‚ ๋ฆฌ๊ธฐtemp table ์ƒ์„ฑgenerate_series ์™€ random ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ insertdocker-compose ๋กœ ์‹คํ–‰docker-compose ์ด์šฉํ•˜๊ธฐapplication runner ์ด์šฉํ•˜๊ธฐ๋“ฑ๋“ฑ ๊ฐ€์žฅ ํšจ์œจ์ ์ธ ๋”๋ฏธ๋ฐ์ดํ„ฐ ์ƒ์„ฑ ๋ฐฉ๋ฒ• DB ๋‚˜ Application ์˜ ์ฒ˜๋ฆฌ๋Ÿ‰ ํ˜น์€ ํŠน์ • ๋Œ€๋Ÿ‰ ๋ฐ์ดํ„ฐ์˜ ์ƒํ™ฉ์„ ํ…Œ์ŠคํŠธํ•˜๊ธฐ ์œ„ํ•ด ๋”๋ฏธ ๋ฐ์ดํ„ฐ๊ฐ€ ํ•„์š”ํ•˜๋‹ค. excel, mockaroo, bulk insert ๋“ฑ๋“ฑ ๋‹ค์–‘ํ•œ ๋ฐฉ๋ฒ•์„ ์ด์šฉํ•ด์„œ ๋Œ€๋Ÿ‰์˜ ๋ฐ์ดํ„ฐ๊ฐ€ ์žˆ๋Š” ์‹ค์Šต ํ™˜๊ฒฝ์„ ๊ตฌ์„ฑํ•ด๋ดค๋Š”๋ฐ ์ผ€์ด์Šค์— ๋”ฐ๋ผ ๋‹ค๋ฅด๊ฒ ์ง€๋งŒ ์ด ๋ฐฉ๋ฒ•์ด ๊ฐ€์žฅ ํšจ์œจ์ ์ด์—ˆ๋‹ค. ์•„๋ž˜์˜ ํ•ต์‹ฌ ์ปจ์…‰๋งŒ ์ดํ•ดํ•œ.. 2024. 10. 20.
DDD ์˜ aggregate ์— ๋Œ€ํ•œ ์ด์•ผ๊ธฐ TL;DR ์ด๋ฒˆ ๊ธ€์˜ ํ•ต์‹ฌ์„ ์š”์•ฝํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค aggregate ๋ž€ ๋ฌด์—‡์ธ๊ฐ€ 3๊ฐ€์ง€ ํ•ต์‹ฌ ๋„๋ฉ”์ธ ๊ตฌ์„ฑ์š”์†Œ ์ค‘ ๊ฐ€์žฅ ๊ธฐ๋ณธ entity ์™€ value ์˜ composition ์™„์ „ํ•œ ํ•˜๋‚˜์˜ ๊ฐœ๋… ์™œ aggregate ๊ฐ€ ํ•„์š”ํ• ๊นŒ ๊ณ ์ •์ž(invariant) ์™€ ์ผ๊ด€์„ฑ (consistency) ์„ ์ง€ํ‚ค๋Š” ํ•ต์‹ฌ ๊ฐ์ฒด aggregate ์˜ ํ•ต์‹ฌ ๊ตฌ์„ฑ์š”์†Œ 3๊ฐ€์ง€ entity, root-entity, value aggregate ์„ ์„ค๊ณ„ํ•˜๊ธฐ 3๊ฐ€์ง€ ์„ค๊ณ„ ์ง€ํ‘œ ์ผ๊ด€์„ฑ์„ ๊ธฐ์ค€์œผ๋กœ ๋‚˜๋ˆ„๊ธฐ actor ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋‚˜๋ˆ„๊ธฐ usecase ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋‚˜๋ˆ„๊ธฐ ์ž˜ ๋‚˜๋‰˜์–ด์ง„ aggregate ์˜ ํŠน์„ฑ aggregate ๋ž€ ๋ฌด์—‡์ธ๊ฐ€ ์—๋ฆญ ์—๋ฐ˜์Šค๊ฐ€ ์ œ์‹œํ•œ DDD, domain driven design ์—์„œ ํ•ต์‹ฌ ๋„๋ฉ”์ธ ๊ตฌ์„ฑ์š”์†Œ๋Š” 3๊ฐ€.. 2024. 4. 10.
cache 101 - Spring Cache ์— ๋Œ€ํ•˜์—ฌ (feat. ์บ์‹œ๋กœ todo list ๋ฅผ ๋งŒ๋“ค์–ด๋ณด์ž) cache 101 ์‹œ๋ฆฌ์ฆˆ๋Š” web application ์„ ๊ฐœ๋ฐœํ•˜๋ฉฐ ๋งˆ์ฃผํ•˜๋Š” cache ์— ๋Œ€ํ•ด ํ•„์š”ํ•œ ์ง€์‹๊ณผ ๋„๊ตฌ๋“ค์˜ ์‚ฌ์šฉ๋ฒ•์„ ํ•™์Šตํ•˜๋Š” ์‹œ๋ฆฌ์ฆˆ์ž…๋‹ˆ๋‹ค. 1. Cache ์— ๋Œ€ํ•œ ๊ฑฐ์˜ ๋ชจ๋“  ๊ฒƒ ์˜ ์ˆœ์„œ๋Œ€๋กœ ๊ธ€์„ ์ฝ์œผ์‹œ๋ฉด ํ•™์Šต์— ๋” ๋งŽ์€ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค. ์˜ค๋Š˜์€ Spring ์—์„œ ์ œ๊ณตํ•˜๋Š” Cache ์— ๋Œ€ํ•ด์„œ ์ด์•ผ๊ธฐ ํ•ด๋ณผ ๊ฒƒ์ด๋‹ค Spring ์—์„œ๋Š” Cache ์— ๋Œ€ํ•˜์—ฌ Spring Transaction ๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋†’์€ ์ถ”์ƒํ™”๋ฅผ ์ œ๊ณตํ•œ๋‹ค @Transactional // spring transaction support public Todo create() {} @Cacheable // spring cache support public Todo create() {} Spring ์—์„œ๋Š” ์ด๋ฅผ Cache Abstr.. 2024. 3. 13.
cache 101 - ์บ์‹œ์— ๋Œ€ํ•œ ๊ฑฐ์˜ ๋ชจ๋“  ๊ฒƒ ์ด๋ฒˆ์—๋Š” cache ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณผ ๊ฒƒ์ด๋‹ค. cache ๋ผ๊ณ  ํ•œ๋‹ค๋ฉด computer science ์—์„œ ์ •๋ง ๋‹ค์–‘ํ•œ ๋ถ„์•ผ์—์„œ ์‚ฌ์šฉ๋˜๊ณ , ๋™์ผํ•œ ๊ธฐ๋Šฅ์„ ์ˆ˜ํ–‰ํ•˜์ง€๋งŒ ๋ฌธ๋งฅ์— ๋”ฐ๋ผ์„œ ๋‹ค๋ฅธ ์ดํ•ด๋„๊ฐ€ ํ•„์š”ํ•˜๋‹ค. ๋‚˜๋Š” cache ์— ๋Œ€ํ•ด์„œ web application layer ์˜ ๋ฌธ๋งฅ์—์„œ ์„ค๋ช…์„ ํ•  ๊ฒƒ์ด๊ณ , software cache ์— ๋Œ€ํ•œ ์„ค๋ช…์„ ์ฃผ๋กœ ํ•  ๊ฒƒ์ด๋‹ค. hardware cache ์™€ ๋” low level ์˜ cache ๋ฅผ ์›ํ•œ๋‹ค๋ฉด ์ด ๊ธ€์€ ์ ํ•ฉํ•˜์ง€ ์•Š์„ ์ˆ˜ ์žˆ๋‹ค. TL;DR ์ด๋ฒˆ ๊ธ€์˜ ํ•ต์‹ฌ์„ ์š”์•ฝํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™๋‹ค 1. ์บ์‹œ๋ž€ ๋ฌด์—‡์ธ๊ฐ€ cache: ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜์—ฌ ๋ฏธ๋ž˜์— ํ•ด๋‹น ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•œ ์š”์ฒญ์„ ๋” ๋น ๋ฅด๊ฒŒ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” hardware ํ˜น์€ software cache ์˜ ์ข…๋ฅ˜ h/w ca.. 2024. 2. 1.
์˜คํ”„์…‹ ํŽ˜์ด์ง•, ๋‹จ๊ณ„๋ณ„๋กœ ์ตœ์ ํ™”ํ•˜๊ธฐ ์ด ๊ธ€์€ offset based pagination ์„ ๋นŒ๋ฏธ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ๋‚ด๋ถ€ ๋™์ž‘๊ณผ ์—ฌ๋Ÿฌ ๊ฐœ๋…๋“ค์„ ์•Œ์•„๋ณด๋Š” ๊ธ€ ์ž…๋‹ˆ๋‹ค. 2๊ฐœ์˜ ๊ธ€๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๊ณ , ๊ฐ๊ฐ์˜ ๊ธ€์—์„œ ์–ป์„ ์ˆ˜ ์žˆ๋Š” insight ๊ฐ€ ๋‹ค๋ฅด๋‹ˆ ํ•จ๊ป˜ ์ฝ์œผ๋ฉด ๋”์šฑ ์œ ์ตํ•ฉ๋‹ˆ๋‹ค. ์˜คํ”„์…‹ ํŽ˜์ด์ง•์ด ๋Š๋ฆฐ ์ง„์งœ ์ด์œ  ์˜คํ”„์…‹ ํŽ˜์ด์ง•, ๋‹จ๊ณ„๋ณ„๋กœ ์ตœ์ ํ™”ํ•˜๊ธฐ 2023. 11. 19.
์˜คํ”„์…‹ ํŽ˜์ด์ง•์ด ๋Š๋ฆฐ ์ง„์งœ ์ด์œ  ์ด ๊ธ€์€ offset based pagination ์„ ๋นŒ๋ฏธ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ๋‚ด๋ถ€ ๋™์ž‘๊ณผ ์—ฌ๋Ÿฌ ๊ฐœ๋…๋“ค์„ ์•Œ์•„๋ณด๋Š” ๊ธ€ ์ž…๋‹ˆ๋‹ค. 2๊ฐœ์˜ ๊ธ€๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๊ณ , ๊ฐ๊ฐ์˜ ๊ธ€์—์„œ ์–ป์„ ์ˆ˜ ์žˆ๋Š” insight ๊ฐ€ ๋‹ค๋ฅด๋‹ˆ ํ•จ๊ป˜ ์ฝ์œผ๋ฉด ๋”์šฑ ์œ ์ตํ•ฉ๋‹ˆ๋‹ค. ์˜คํ”„์…‹ ํŽ˜์ด์ง•์ด ๋Š๋ฆฐ ์ง„์งœ ์ด์œ  ๋Š๋ฆผ์˜ ๊ทผ๋ณธ์ ์ธ ์›์ธ 0๋ฒˆ offset ๋ถ€ํ„ฐ ์‹œ์ž‘ offset ๊นŒ์ง€์˜ ๋ฐ์ดํ„ฐ๋Š” ๋ฒ„๋ ค์ง€๊ณ  10๊ฑด๋งŒ ๊ฒฐ๊ณผ๋กœ ๋ฐ˜ํ™˜๋จ offset based pagination ์ด ๋Š๋ฆฐ ์ด์œ  ๋ฌธ์ œ๋Š” ์ •๋ ฌ ๋ฐฉ์‹์— ์žˆ์Œ ์ •๋ ฌ์„ ์œ„ํ•ด ๊ฒฐ๊ณผ ์ฒ˜๋ฆฌ๋ฅผ streaming ์ด ์•„๋‹Œ buffering ๋ฐฉ์‹์œผ๋กœ ์ „ํ™˜ streaming vs buffering streaming: ์ฟผ๋ฆฌ ์‹คํ–‰ ๊ฒฐ๊ณผ๋ฅผ ์ฆ‰์‹œ client ์—๊ฒŒ ๋ฐ˜ํ™˜ LIMIT ๊ตฌ๋ฌธ๊ณผ ํ•จ๊ป˜ ์‚ฌ์šฉํ•  ๋•Œ ์ด์  ์กด์žฌ bufferi.. 2023. 11. 19.