์ ์ฒด ๊ธ (74) ์ธ๋ค์ผํ ๋ฆฌ์คํธํ [SpringWebflux] reactor operator - 4 Backpressure ๊ด๋ จ ์ฐ์ฐ์ delaySequence / limitRate sample delaySequence ์ฃผ์ด์ง duration ๋งํผ ์ง์ฐ์ํต๋๋ค. limitRate() backpressure์ request๋ฅผ ์กฐ์ ํ๋ ๊ธฐ๋ฅ์ ๋๋ค. limitRate()์์ ์ ํ ์ ๋ง์ request๋ฅผ ๊ฐ์ ํฉ๋๋ค. ์ฆ request๋ฅผ 2๋ฒ๋ง ์์ฒญํ ์ ์์ต๋๋ค. TestCode public class Operator4 { // limit public Flux fluxDelayAndLimit(){ return Flux.range(1,10) .delaySequence(Duration.ofSeconds(1)) .log() .limitRate(2); } } class Operator4Test { private O.. [SpringWebflux] Reactor operator - 3 ์ง๊ณ ์ฐ์ฐ์ count distinct reduce groupby count count: ์ก์ถ๋๋ ์์๋ฅผ ํฉ์ณ์ ๋จ์ผ ๊ฐ์ผ๋ก ์ ๋ฌํ๋๊ฒ count ์ ๋๋ค. ๊ทธ๋ฆผ๊ณผ ๊ฐ์ด 4๊ฐ์ ์์๊ฐ ์ ๋ฌ๋์์๋ ์์์ ์ด ๊ฐฏ์์ธ 4๋ฅผ ๋ฆฌํดํฉ๋๋ค. TestCode public class Operator3 { // count public Mono fluxCount(){ return Flux.range(1, 10).count().log(); } } class Operator3Test { private Operator3 operator3 = new Operator3(); @Test void fluxCount() { StepVerifier.create(operator3.fluxCount()) .expectNext(10L) .ve.. [Spring Webflux] CPU bound vs I/O Bound CPU๋? CPU๋ Computing Process Unit์ ์ฝ์์ ๋๋ค. ๊ธฐ๊ณ์ด ๋ช ๋ น์ด๋ค์ ๊ธฐ๋ฐ์ผ๋ก ๊ณ์ฐ์ ์ํํ๋ ์ค์ ์ฒ๋ฆฌ ์ฅ์น ์ ๋๋ค. ์ฌ์ค ์ปดํจํฐ์์ ์ฌ์ฉ๋๋ ๋๋ถ๋ถ์ ๋์๋ค์ CPU๋ฅผ ์ฌ์ฉํ๊ฒ ๋๋๋ฐ CPU Bound ์์ ์ด๋ ๋จ์ํ CPU๋ฅผ ์ฌ์ฉํ๋ ๊ฒ์ด ์๋ CPU๋ฅผ ์ค์ ์ ์ผ๋ก ๋ค๋ฃจ๋ ์์ ๋ค์ ๋งํฉ๋๋ค. ์๋ฅผ๋ค์ด ์ํธํ, ์์ถ๊ณผ ๊ฐ์ ์ํ์ ์ธ ์๊ณ ๋ฆฌ์ฆ ๊ณ์ฐ, ๋ค์์ ๋ฐ์ดํฐ๋ฅผ ์ง๊ณํ๋ ์์ ๋ฑ์ด ์์ต๋๋ค. ์ฃผ๋ก CPU ๊ณ์ฐ ๋ฅ๋ ฅ์ ๋ฐ๋ผ ์ฑ๋ฅ์ด ์ข์ฐ๋๋ ๊ทธ๋ฌํ ์์ ๋ค์ ๋งํฉ๋๋ค. CPU Bound ์ ๊ทธ๋ฆผ์ Hardware, Kernel, Application์ ๊ณ์ธตํ, ์ถ์ํํ์ฌ ๋ํ๋ธ ๊ทธ๋ฆผ์ ๋๋ค. Application ๋ ์ด์ด์์๋ App #1์ ์คํ๋ ํ๋ก์ธ์ค์ด๊ณ ๋ฌผ๋ฆฌ์ ์ธ ํ๋์ CPU์ฝ์ด.. [SpringWebflux] Spring Webflux ์๊ฐ Spring Webflux์์ Spring์ ์ฐ๋ฆฌ๊ฐ ์ ์๊ณ ์๋ Spring framework๋ฅผ ๋งํฉ๋๋ค. Webflux๋ Reactive Stream API๋ฅผ ์ฌ์ฉํ์ฌ non-blocking๊ณผ asynchronous๋ฅผ ์ง์ํ๋ ๋น๋๊ธฐ spring web framework์ ๋๋ค. Reactive Stream API, non-block, asynchronous ๋ springwebflux์ ์ฃผ์ ํค์๋๋ผ ๋งํ ์ ์์ต๋๋ค. ์ด๋ฌํ ์ฃผ์ ๊ธฐ์ ๋ค์ด ๋๋์ ์น ํธ๋ํฝ, ํนํ I/O๊ฐ ๋ง์ ์น ์๋น์ค ๋ก์ง์์ ๊ธฐ์กด ์๋ธ๋ฆฟ ๊ธฐ๋ฐ MVC ๋๋น ํจ์จ์ ์ด๊ณ ๋์ ์ฑ๋ฅ์ ๋ณด์ฌ์ค๋๋ค. ์๋ฅผ๋ค์ด ๋ง์ดํฌ๋ก ์๋น์ค์์ ๋ค์ํ ๋์ ์์ฒญ์ ์ํํด์ผํ๋ ๊ฒ์ดํธ์จ์ด ์๋ฒ๋, ์ค์๊ฐ ๋ฐ์ดํฐ ์คํธ๋ฆผ์ ์ํ ์น์์ผ, ๋๋์ ๋ฐ์ดํฐ๋ฅผ ์ฒ๋ฆฌ.. [Redis] Redis๋? 1. Redis๋? Remote Dictionary Server in-memory, key-value ๋ฐ์ดํฐ ์ ์ฅ์๋ฅผ ์ง์ํ๋ ์คํ ์์ค ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ ๋๋ค. Dictionary ๋ผ๋ ์ด๋ฆ์ ์๋ฃ๊ตฌ์กฐ๋ก ๋ฐ๋ผ๋ณด๋ฉด ํนํ ์๋ฐ์์ Hash Table์ด๋ผ๊ณ ๋งํ ์ ์์ต๋๋ค. ์ด๋ฅผ ํตํด์ key-value ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ๊ณ ๋ค๋ฃฌ๋ค๋๊ฒ์ ์ ์ถํ ์ ์์ต๋๋ค. ์คํ ์์ค ์ด๊ธฐ๋๋ฌธ์ ๊นํ๋ธ, ๋ ํฌ์งํ ๋ฆฌ๋ฅผ ํตํด ๋ด๋ถ ๊ตฌํ์ด ์ด๋ป๊ฒ ๋์ด์๋์ง ์ง์ ํ์ธํด ๋ณผ ์ ์๊ณ ๋น ๋ฅธ ์๋์ ์ด์์ฑ์ ๊ฐ์ ์ด ์๋ C์ธ์ด๋ก ๊ตฌํ์ด ๋์ด ์์ต๋๋ค. 2. Redisํน์ง in-memory database Redis๋ ์ง๋ ํฌ์คํ ์์ ๋ค๋ฃฌ in-memory database ํน์ง์ ๊ฐ์ง๊ณ ์์ต๋๋ค. ๋น ๋ฅธ ์๋ต์๋๋ฅผ ์ํด์ ๋์คํฌ๊ฐ ์๋ ๋ฉ๋ชจ๋ฆฌ.. [Redis] in-memory database๋? in-memory database in-memory๋ ์ปดํจํฐ์ ๋ฉ์ธ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์๋ฏธํฉ๋๋ค. database๋ ์ปดํจํฐ์ ๋ฐ์ดํฐ๋ฅผ ์ ์ฅํ ์ ์๋ ์์คํ ์ ๋งํฉ๋๋ค. ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋ฐ์ดํฐ๋ฅผ ์ ์ฌํ์ฌ ํ์ฉํ๋ ๋ฐ์ดํฐ๋ฒ ์ด์ค ์์คํ ์ ๋งํฉ๋๋ค. in-memory database ์ฃผ์ ํน์ง ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ก์ ์ฌ์ฉํ๋ค๋๊ฒ์ ์ด๋ค ์๋ฏธ๋ฅผ ๋งํ ๊น์? 1. Millisecond Response (1ms = 0.001s) ๋์คํฌ ๋๋น ๋งค์ฐ ๋น ๋ฅธ ์๋ต์๋๋ฅผ ๋ณด์ฅํฉ์์์ต๋๋ค. ms ๋จ์์ ๋น ๋ฅธ ์๋ต์๋๋ฅผ ๋ณด์ฅํ๊ธฐ ์ํ ์์คํ ์์ ํ์ฉํ๊ธฐ ์ ํฉํ๋ฉฐ, ๋๋์ ํธ๋ํฝ์ init๋๋ ์๋น์ค์์ ์ด์ฉํ๊ธฐ ์ ์ฉํฉ๋๋ค. ๋น ๋ฅธ ์๋๋ก ์ธํ ๋์ ์ฒ๋ฆฌ๋์ ์ ๊ณตํ๊ธฐ ๋๋ฌธ์ ๋๋ค. 2. Volatility of RAM ๋ฉ๋ชจ๋ฆฌ๋ฅผ ํ์ฉํ๊ธฐ ๋๋ฌธ์ ๋ฐ์ด.. [MongoDB] ๋ชฝ๊ณ DB 7.0 ๋ฒ์ , mongo ์ฐพ์ง ๋ชปํ๋ ๊ฒฝ์ฐ ์ค์น ํ๊ฒฝ: MongoDB 7.0 ๋ชฝ๊ณ DB ์ค์น ํ ํ๊ฒฝ๋ณ์๊น์ง ์ก์ ์คฌ๋๋ฐ mogo ๋ช ๋ น์ด๋ฅผ ์ฐพ์ง ๋ชปํ๋ค. ๊ตฌ๊ธ๋ง ํด๋ณด๋ mongo.exe๊ฐ ์์ด์ ธ์ mongosh๋ฅผ ๋ค์ด๋ฐ์์ ์ฌ์ฉํ๋ผ๊ณ ํ๋ค. ์ ์ฌ์ดํธ์์ sh๋ฅผ ๋ค์ด๋ฐ์ ํ mongosh.exe์ dllํ์ผ์ ๋ชฝ๊ณ db ์ค์น ๊ฒฝ๋ก/bin ์ ๋ณต๋ถ ํ ๋ค์ cmd์์ "mongosh"๋ฅผ ์ ๋ ฅํ๋ฉด ์๋๋ค ( ํ๊ฒฝ๋ณ์ ์ ํ ๋์ด ์์ด์ผ ํจ) [Spring] Spring Core(2): ์์กด์ฑ ์ฃผ์ (DI), ๊ฐ๋ , ๋ฐฉ๋ฒ, ์ฅ๋จ์ , ์์ฑ์ ์ฃผ์ ์ ์ฌ์ฉํ์ ์์กด์ฑ ์ฃผ์ (DI)์ด๋? ์์กด์ฑ ์ฃผ์ = Dependency Injection = DI ๋จผ์ '์์กด์ฑ' ์ด ๋ฌด์์ธ์ง ๋ถํฐ ์์๋ณด์! ์์กด์ฑ (Dependnecy) ๊ธฐ์ ์์ ์ฌ์ฉํ๋ ์ ํ๋ฆฌ์ผ์ด์ ์ ํ๋์ ๊ฐ์ฒด๋ก ์ด๋ฃจ์ด์ ธ ์์ง ์๋ค. ์์ ๊ฐ๋จํ ์ ํ๋ฆฌ์ผ์ด์ ์ด๋๋ผ๋, ๋ช ๊ฐ์ ๊ฐ์ฒด๊ฐ ์๋ก ํ๋ ฅํ๊ณ ์๋ค. ๊ฐ์ฒด๊ฐ ํ๋ ฅํ๋ค๋ ๊ฒ์ ๊ฐ์ฒด ๊ฐ์ ์์กด์ฑ์ด ์กด์ฌํ๋ค๋ ๊ฒ์ด๋ค. ์์กด์ฑ์ด๋ ํ๋ผ๋ฏธํฐ๋ ๋ฆฌํด๊ฐ ๋๋ ์ง์ญ ๋ณ์ ๋ฑ์ผ๋ก ๋ค๋ฅธ ๊ฐ์ฒด๋ฅผ ์ฐธ์กฐํ๋ ๊ฒ์ ์๋ฏธํ๋ค. ์ด๋ ๊ฒ ํ์ ๊ฐ์ฒด๋ ๋ค๋ฅธ ๊ฐ์ฒด์ ๋ถํ์ด ๋๋ค. ์ด ๊ธ์์ ๋งํ ์์กด์ฑ ์ฃผ์ ์ Spring์ ์์กด์ฑ ์ฃผ์ ์ด๋ค. Spring์์ ๊ด๋ฆฌํด์ฃผ๋ ๊ฐ์ฒด๋ฅผ Spring Bean์ด๋ผ๊ณ ํ๋๋ฐ, ์ฃผ๋ก Controller, Service, Repository๋ฅผ ์คํ๋ง ์ปจํ ์ด๋.. ์ด์ 1 ยทยทยท 4 5 6 7 8 9 10 ๋ค์