분류 전체보기
-
[Kafka 개념] Kafka 토픽과 파티션 (2)Apache Kafka/개념 정리 2024. 2. 5. 21:41
토픽과 파티션 토픽을 삭제하면 데이터는 삭제되고 파이프라인은 중단된다. 데이터의 생명주기 한가운데에 토픽이 있다. 그만큼 토픽은 카프카에서 중요한 역할을 하므로 잘 이해하고 상세 옵션들에 대해서 자세히 알 필요가 있다. 적정 파티션 개수 토픽의 파티션 개수는 카프카의 성능과 관련이 있다. 그렇기 때문에 토픽을 운영함에 있어 적절한 파티션 개수를 설정하고 운영하는 것이 매우 중요하다. 토픽 최초 생성 시, 파티션의 개수를 정하는 데에 고려해야 할 점은 3가지가 있다. 데이터 처리량 메시지 키 사용 여부 브로커, 컨슈머 영향도 데이터 처리량 파티션은 카프카의 병렬처리의 핵심이다. 파티션의 개수가 많아지면 많아질수록 1:1 매핑되는 컨슈머 개수가 늘어나기 때문이다. 그렇기 때문에 파티션 개수를 정할 때는 해당..
-
[Kafka 개념] Kafka 토픽, 파티션 (1)Apache Kafka/개념 정리 2024. 2. 2. 09:28
토픽과 파티션 그리고 레코드 토픽은 카프카에서 데이터를 구분하기 위해 사용하는 단위이다. 토픽은 1개 이상의 파티션을 소유하고 있으며 파티션에는 프로듀서가 보낸 데이터들이 들어가 저장되는데, 이 데이터들을 '레코드(record)'라고 부른다. 토픽 카프카에는 다양한 데이터가 들어갈 수 있는데, 데이터가 들어가는 공간을 토픽이라고 부른다. 카프카에서는 토픽을 여러 개 생성할 수 있다. 또한 토픽은 이름을 가질 수 있는데, 무슨 데이터를 담는지 명확하게 명시하면 추후 유지 보수 시 편리하게 관리할 수 있다. 토픽은 데이터베이스의 테이블이나 파일 시스템의 폴더와 유사한 성질을 가지고 있는데, 프로듀서가 토픽에 데이터를 넣게 되고 컨슈머는 데이터를 가져가게 된다. 파티션 토픽안에 1개 이상으로 존재하는 파티션은..
-
Spring-Data-DynamoDB를 사용하여 SpringBoot와 AWS DynamoDB 연동하기SpringBoot 2024. 1. 28. 23:39
들어가며 현재 진행하고 있는 실시간 채팅방 관련 프로젝트에서 채팅방에서 나눈 이전 대화들을 저장하여 사용자가 다시 채팅방에 접속하면 이전 대화 내용들을 보여주는 기능을 추가적으로 구현해야 했다. 이를 위해서는 채팅방 메시지들을 저장하고 조회, 삭제를 수행하게 될 데이터베이스를 무엇을 사용해야 할지 선택해야 했다. 💁♂️ RDB...? 아니면 NoSQL?? 💁♂️ 기존 데이터베이스는 RDB인 MySQL을 사용하고 있었는데, 원래 사용하던 MySQL을 사용할지 아니면 채팅방 메시지 관리를 위한 추가적인 NoSQL DB를 사용할지에 대한 고민이 깊어졌다. 그러나 NoSQL이 기존의 RDB보다 더 빠른 읽기 쓰기 성능을 가지고 있기 때문에, 각 채팅방 별, 채팅 내용을 저장하고 불러오기에는 NoSQL을 추가..
-
[프로그래머스 Level 4] 우유와 요거트가 담긴 장바구니SQL 문제 풀이 2024. 1. 25. 15:44
테이블 정보 문제 데이터 분석 팀에서는 우유(Milk)와 요거트(Yogurt)를 동시에 구입한 장바구니가 있는지 알아보려 합니다. 우유와 요거트를 동시에 구입한 장바구니의 아이디를 조회하는 SQL 문을 작성해주세요. 이때 결과는 장바구니의 아이디 순으로 나와야 합니다. 결과 예시 정답 코드 1 (MySQL) SELECT CART_ID FROM CART_PRODUCTS WHERE NAME IN ('Milk', 'Yogurt') GROUP BY CART_ID HAVING COUNT(DISTINCT NAME) >= 2 ORDER BY CART_ID ASC; 문제 풀이 1 Level 4라고 하기에는 생각보다 문제가 쉽게 풀렸다. 나만 그렇게 느낀 게 아닌 건지 정답률이 70%나 된다... 위 코드는 상품 이름이..
-
SpringBoot와 Kafka 연동 간의 SASL을 사용한 암호화 적용하기SpringBoot 2024. 1. 19. 00:44
최근에 카프카에 SASL 인증 방식을 적용한 상태여서 기존 스프링부트와 카프카 간의 연동에 더해서 스프링부트에 SASL 인증과 관련된 추가적인 설정이 필요하다. 이번에는 해당 설정들에 대해서 기록을 해보고자 한다. https://kjungw1025.tistory.com/27 Docker compose로 올린 Kafka에 ACL, SASL/PLAIN 인증 설정하기 들어가며 기본적으로 카프카는 어느 누구나 클러스터에 접근하여 메시지를 생성하거나 읽을 수 있다. 이로인해 보안이 적용되지 않은 상태에서는 데이터의 무단 액세스와 무단 조작이 가능하 kjungw1025.tistory.com 참고로 스프링부트와 카프카 연동하는 방법으로는 application.yml에 간단하게 관련 설정을 하는 방법과 직접 Produ..
-
Docker compose로 올린 Kafka에 ACL, SASL/PLAIN 인증 설정하기Apache Kafka/보안 2024. 1. 19. 00:34
들어가며 기본적으로 카프카는 어느 누구나 클러스터에 접근하여 메시지를 생성하거나 읽을 수 있다. 이로인해 보안이 적용되지 않은 상태에서는 데이터의 무단 액세스와 무단 조작이 가능하므로, 중요한 정보를 다루는 시스템에서는 보안을 강화하는 것이 중요하다. 그러므로 카프카에 누가 요청을 보내고, 그 요청자의 권한에 따라서 요청 범위를 제한하는 카프카 인증, 인가에 대해서 알아보고 직접 적용해보고자 한다. 개념 카프카 인증 카프카에서 인증을 처리하는 방식으로 SSL 방식과 SASL 방식으로, 크게 두 가지 방식이 존재한다. SSL : 인증서를 활용한 인증 방식 데이터를 암호화하고 통신 채널을 안전하게 유지하여 중간에서의 데이터 탈취나 변조를 방지한다. SASL : SASL 프로토콜을 이용한 인증 방식 클라이언트..
-
[LeetCode Hard] 601. Human Traffic of StadiumSQL 문제 풀이 2024. 1. 16. 15:55
이번 문제는 개인적으로 많이 어려웠던 문제였다...ㅜ 다른 사람들의 풀이를 보니 LEAD()와 LAG()를 이용한 문제 풀이가 있었는데 솔직히 이번 문제를 풀면서 저런 함수가 있다는걸 처음 알았다 꾸준히 복습하면서 내껄로 만들어야지... 테이블 정보 문제 Write a solution to display the records with three or more rows with consecutive id's, and the number of people is greater than or equal to 100 for each. Return the result table ordered by visit_date in ascending order. The result format is in the followi..
-
Kafka Jsonserializer/JsonDeserializer 한글 처리 오류Apache Kafka/오류 해결 2024. 1. 15. 10:59
문제 현재 스프링부트에서 STOMP를 활용한 채팅방을 구현하는 도중에 아래 오류를 해결한 후에 또 다른 오류를 직면하게 되었다. https://kjungw1025.tistory.com/24 SpringBoot와 Kafka 연동 시 발생한 ErrorHandlingDeserializer 관련 오류 문제 스프링부트에서 STOMP를 활용한 채팅방을 구현하기 위해 기존 In memory broker 방식에서 External broker 중 하나인 Kafka를 통해 아래 형태의 메시지를 전달하려는데, @Getter @NoArgsConstructor @ToString publi kjungw1025.tistory.com KafkaTemplate 부분을 보다시피 채팅방 메시지를 전달하기 위해서 value 값을 Messa..