์ „์ฒด ๊ธ€

๊ฐœ๋ฐœ ์ง€์‹์„ ์Œ“๊ณ  ๊บผ๋‚ด ์“ฐ๋Š” ๋ธ”๋กœ๊ทธ์ž…๋‹ˆ๋‹ค.
๋ฌธ์ œ [๋ฐฑ์ค€ 1260๋ฒˆ] ๊ทธ๋ž˜ํ”„๋ฅผ DFS๋กœ ํƒ์ƒ‰ํ•œ ๊ฒฐ๊ณผ์™€ BFS๋กœ ํƒ์ƒ‰ํ•œ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ๋‹จ, ๋ฐฉ๋ฌธํ•  ์ˆ˜ ์žˆ๋Š” ์ •์ ์ด ์—ฌ๋Ÿฌ ๊ฐœ์ธ ๊ฒฝ์šฐ์—๋Š” ์ •์  ๋ฒˆํ˜ธ๊ฐ€ ์ž‘์€ ๊ฒƒ์„ ๋จผ์ € ๋ฐฉ๋ฌธํ•˜๊ณ , ๋” ์ด์ƒ ๋ฐฉ๋ฌธํ•  ์ˆ˜ ์žˆ๋Š” ์ ์ด ์—†๋Š” ๊ฒฝ์šฐ ์ข…๋ฃŒํ•œ๋‹ค. ์ •์  ๋ฒˆํ˜ธ๋Š” 1๋ฒˆ๋ถ€ํ„ฐ N๋ฒˆ๊นŒ์ง€์ด๋‹ค. ์ž…๋ ฅ ์ฒซ์งธ ์ค„์— ์ •์ ์˜ ๊ฐœ์ˆ˜ N(1 ≤ N ≤ 1,000), ๊ฐ„์„ ์˜ ๊ฐœ์ˆ˜ M(1 ≤ M ≤ 10,000), ํƒ์ƒ‰์„ ์‹œ์ž‘ํ•  ์ •์ ์˜ ๋ฒˆํ˜ธ V๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๋‹ค์Œ M๊ฐœ์˜ ์ค„์—๋Š” ๊ฐ„์„ ์ด ์—ฐ๊ฒฐํ•˜๋Š” ๋‘ ์ •์ ์˜ ๋ฒˆํ˜ธ๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ์–ด๋–ค ๋‘ ์ •์  ์‚ฌ์ด์— ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๊ฐ„์„ ์ด ์žˆ์„ ์ˆ˜ ์žˆ๋‹ค. ์ž…๋ ฅ์œผ๋กœ ์ฃผ์–ด์ง€๋Š” ๊ฐ„์„ ์€ ์–‘๋ฐฉํ–ฅ์ด๋‹ค. ์ถœ๋ ฅ ์ฒซ์งธ ์ค„์— DFS๋ฅผ ์ˆ˜ํ–‰ํ•œ ๊ฒฐ๊ณผ๋ฅผ, ๊ทธ ๋‹ค์Œ ์ค„์—๋Š” BFS๋ฅผ ์ˆ˜ํ–‰ํ•œ ๊ฒฐ๊ณผ๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. V๋ถ€ํ„ฐ ๋ฐฉ๋ฌธ๋œ ์ ์„ ์ˆœ์„œ๋Œ€..
์ด์ „ ํฌ์ŠคํŒ…์—์„  Webclient๋ฅผ ์ด์šฉํ•˜์—ฌ ์„œ๋น„์Šค๋“ค๊ฐ„์˜ ํ†ต์‹ ์„ ๊ตฌ์ถ•ํ–ˆ๋‹ค. ์ด๋ฒˆ์—๋Š” Kafka๋ฅผ ํ†ตํ•ด์„œ ๋ฉ”์„ธ์ง€ ํ๋ฅผ ๊ธฐ์šฉํ•˜์—ฌ ์„œ๋น„์Šค๋“ค ๊ฐ„์˜ ํ†ต์‹  ํ™˜๊ฒฝ์„ ๊ตฌ์ถ•ํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค. kafka์— ๋Œ€ํ•œ ์˜ˆ์ „ ํฌ์ŠคํŒ…์„ ์ฐธ๊ณ ํ•ด์„œ ๊ตฌ์ถ•ํ–ˆ๋‹ค. ํ˜„์žฌ ๋‚ด ์„œ๋น„์Šค๋Š” app-service ์™€ user-service๊ฐ€ ์žˆ๋Š”๋ฐ, app-service๋ฅผ ํ†ตํ•ด ์‚ฌ์šฉ์ž๊ฐ€ ์ž์‹ ์˜ ์•ฑ์„ ์„œ๋ฒ„์— ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•ด ๋†“์•˜๋‹ค. ํ•„์ž๋Š” ์ง€๊ธˆ ์‚ฌ์šฉ์ž๊ฐ€ ์•ฑ์„ ๋“ฑ๋กํ•  ๋•Œ, User ์—”ํ‹ฐํ‹ฐ์— ์žˆ๋Š” appCount๋ฅผ +1ํ•ด์ฃผ๋Š” ์„œ๋น„์Šค๋ฅผ ๊ตฌํ˜„ํ•˜๋ ค๊ณ  ํ•œ๋‹ค. 0. Depdency ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์˜์กด์„ฑ์„ ์ถ”๊ฐ€ํ•˜๋ฉด kafka๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. dependencies { implementation 'org.springframework.kafka:spring-..
Spring Cloud์— ๋Œ€ํ•œ ์„ค์ •์„ ์–ด๋Š์ •๋„ ๋งˆ์ณค๋‹ค. ์ด์ œ ๊ฐ ์„œ๋น„์Šค๋“ค ๊ฐ„์˜ ํ†ต์‹  ํ™˜๊ฒฝ์„ ๊ตฌ์ถ•ํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค. 0. WebClient Spring Boot์—์„œ๋Š” ์—ฌ๋Ÿฌ HTTP ํ†ต์‹  ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์žˆ๋‹ค. ๋‚ด๊ฐ€ ์˜›๋‚ ์— ๋งŽ์ด ๋ดค๋˜ ํด๋ž˜์Šค๋Š” RestTemplate์ด์—ˆ๋‹ค. Spring Doc์—์„œ๋„ WebClient๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ๊ณ ํ•˜๊ณ  ์žˆ๊ณ , RestTemplate๋ณด๋‹ค ๋” ๋งŽ์€ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•˜๊ธฐ ๋•Œ๋ฌธ์— WebClient๋กœ ์ง„ํ–‰ํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค. 1. ๋™๊ธฐ vs ๋น„๋™๊ธฐ / Blocking vs Non-Blocking ๋จผ์ € ๋™๊ธฐ์™€ ๋น„๋™๊ธฐ๋ฅผ ๊ตฌ๋ถ„ํ•ด๋ณด์ž. - ๋™๊ธฐ(Synchronous) : ์š”์ฒญ ํ›„ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•  ๋•Œ ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆผ - ๋น„๋™๊ธฐ(Asynchronous) : ์š”์ฒญ ํ›„ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•  ๋•Œ ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆฌ์ง€ ์•Š์Œ ๊ทธ๋ ‡๋‹ค๋ฉด,..
์ €๋ฒˆ ํฌ์ŠคํŒ…์—์„  ์ž„์‹œ๋กœ Public Repository๋ฅผ ์‚ฌ์šฉํ–ˆ์ง€๋งŒ, ์ค‘์š”ํ•œ ํŒŒ์ผ์ด ๋“ค์–ด์žˆ๋Š” ๋ ˆํฌ์ง€ํ† ๋ฆฌ๋Š” ๋‹น์—ฐํžˆ private์œผ๋กœ ์„ค์ •๋˜์–ด ์žˆ์„ ๊ฒƒ์ด๋‹ค. ๊ทธ๋Ÿผ ์ด๋ฒˆ ํฌ์ŠคํŒ…์—์„ , Config Server์—์„œ private repository๋กœ๋ถ€ํ„ฐ ์„ค์ • ํŒŒ์ผ์„ ๊ฐ€์ ธ์˜ฌ ์ˆ˜ ์žˆ๋„๋ก ์„ธํŒ…ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ๋‹ค. 1. ๋น„๋Œ€์นญ ํ‚ค ์ƒ์„ฑ ๋งฅ์—์„œ๋Š” ssh ๋น„๋Œ€์นญ ํ‚ค๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•œ๋‹ค. $ ssh-keygen -m PEM -t rsa -b 4096 -C {๊นƒํ—ˆ๋ธŒ ๊ณ„์ •} ์ €์žฅํ•  ์œ„์น˜์™€ ๋น„๋ฐ€๋ฒˆํ˜ธ(passphrase)๋ฅผ ์„ค์ •ํ•˜๊ณ  ๋งŒ๋“ค์–ด์ฃผ์ž. 2. Deploy Key ๋“ฑ๋ก ๋งŒ๋“ค์–ด ์ฃผ๋ฉด, .pub ์˜ Public key๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋Š”๋ฐ ์ด๋ฅผ ๊ฐ€์ ธ์˜ค๋ ค๋Š” Private repository์— Deploy Key๋กœ ..
0. Spring Cloud Bus ์ง€๋‚œ ํฌ์ŠคํŒ…์—์„  Actuator๋ฅผ ์ด์šฉํ•ด์„œ refresh๋ฅผ ํ†ตํ•ด configuration ์ •๋ณด๋“ค์„ ๊ฐ€์ ธ์˜ค๋Š” ๋ฐฉ๋ฒ•์„ ์‚ดํŽด๋ณด์•˜๋‹ค. ์ด ๋ฐฉ๋ฒ•์„ ์‚ฌ์šฉํ•˜๊ฒŒ ๋œ๋‹ค๋ฉด, ์„ค์ • ์ •๋ณด๊ฐ€ ๋ฐ”๋€”๋•Œ ๋งˆ๋‹ค refresh๋ฅผ ํ•ด์ค˜์•ผ ํ•˜๋Š” ๋‹จ์ ์ด ์žˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ์‚ดํŽด๋ณด์ž. https://spring.io/projects/spring-cloud-bus/ Spring Cloud Bus Spring Cloud Bus links nodes of a distributed system with a lightweight message broker. This can then be used to broadcast state changes (e.g. configuration changes) or o..
๋ฌธ์ œํ”„๋กœ์ ํŠธ ์ „์ฒด๋ฅผ Spring Cloud๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ธฐ๋ณธ ๋ผˆ๋Œ€๋ฅผ MSA๊ตฌ์กฐ๋กœ ๊ตฌ์ถ•ํ–ˆ๋‹ค. ํ•˜์ง€๋งŒ ์—ฌ๊ธฐ์„œ ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒผ๋‹ค. public class App extends BaseTimeEntity { //... @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) private User user;} ๊ธฐ์กด์— ์„ค๊ณ„ํ–ˆ๋˜ App Entity ๋Š” User Entity์™€ ์—ฐ๊ด€๊ด€๊ณ„ ๋งคํ•‘์œผ๋กœ ํ•ด๊ฒฐํ•˜๋ ค๊ณ  ์„ค๊ณ„ํ–ˆ๋‹ค. ํ•˜์ง€๋งŒ, ์ง€๊ธˆ ํ”„๋กœ์ ํŠธ ๊ตฌ์„ฑ์ƒ app-service์™€ user-service๋ฅผ ๋‚˜๋ˆ„์–ด ๋‘์—ˆ๋‹ค. ๊ทธ๋ž˜์„œ app-service์—์„  user๋ฅผ ์ฐธ์กฐํ•  ์ˆ˜ ์—†๋Š” ๊ฒƒ์ด๋‹ค. ์ด์— ๊ด€๋ จํ•ด์„œ ๋ช‡ ๊ฐ€์ง€ ๊ธ€๋“ค์„..
ddonghyeo
๐Ÿ—ƒ๏ธ๊ฐœ๋ฐœ์Šคํƒ