02. Topic, Partition, Segment
Last updated
Last updated
Producer: ๋ฉ์์ง๋ฅผ ์์ฐ(Produce)ํด์ kafka์ Topic์ผ๋ก ๋ฉ์์ง๋ฅผ ๋ณด๋ด๋ ์ ํ๋ฆฌ์ผ์ด์
Consumer: Topic์ ๋ฉ์์ง๋ฅผ ๊ฐ์ ธ์์ ์๋น(Cosume)ํ๋ ์ ํ๋ฆฌ์ผ์ด์
Consumer Group: Topic์ ๋ฉ์์ง๋ฅผ ์ฌ์ฉํ๊ธฐ ์ํด ํ๋ ฅํ๋ consumer๋ค์ ์งํฉ
Producer์ Consumer๋ ์๋ก ์์ง ๋ชปํ๋ฉฐ, Producer์ Consumer๋ ๊ฐ๊ฐ ๊ณ ์ ์ ์๋๋ก Commit Log์ Write ๋ฐ Read๋ฅผ ์ํ
๋ค๋ฅธ Consumer Group์ ์ํ Consumer๋ค์ ์๋ก ๊ด๋ จ์ด ์์ผ๋ฉฐ, Commit Log์ ์๋ Event(Message)๋ฅผ ๋์์ ๋ค๋ฅธ ์์น์์ Readํ ์ ์์
Kafka ์์์ ๋ฉ์์ง๊ฐ ์ ์ฅ๋๋ ์ฅ์, ๋ ผ๋ฆฌ์ ์ธ ํํ
Commit Log, ํ๋์ Topic์ ํ๋ ์ด์์ Partition์ผ๋ก ๊ตฌ์ฑ ๋ณ๋ ฌ์ฒ๋ฆฌ ํฅ์์ ์ํด์ ๋ค์์ Partition ์ฌ์ฉ
Partition ๋ฒํธ๋ 0 ๋ถํฐ ์์ํ๊ณ ์ค๋ฆ์ฐจ์
Topic ๋ด์ Partition ๋ค์ ์๋ก ๋ ๋ฆฝ์ ์
Partition ์ ์ ์ฅ๋ ๋ฐ์ดํฐ(Message)๋ ๋ณ๊ฒฝ์ด ๋ถ๊ฐ๋ฅ(Immutable)
Partition์ Segment File๋ค๋ก ๊ตฌ์ฑ
๋ฉ์์ง๊ฐ ์ ์ฅ๋๋ ์ค์ ๋ฌผ๋ฆฌ File segment file์ด ์ง์ ๋ ํฌ๊ธฐ๋ณด๋ค ํฌ๊ฑฐ๋ ์ง์ ๋ ๊ธฐ๊ฐ๋ณด๋ค ์ค๋๋๋ฉด ์ ํ์ผ์ด ์ด๋ฆฌ๊ณ ๋ฉ์์ง๋ ์ํ์ผ์ ์ถ๊ฐ๋จ
Topic ์์ฑ์ Partition ๊ฐ์๋ฅผ ์ง์ ํ๊ณ , ๊ฐ Partition์ Broker๋ค์ ๋ถ์ฐ๋๋ฉฐ Segment File๋ค๋ก ๊ตฌ์ฑ๋จ
Rolling Strategy: log.segment.bytes(default 1GB), log.roll.hours(default 168hours)