전체 글
-
PostgreSQL 데드락 발생시키기CS/데이터베이스 2023. 8. 23. 00:01
데드락이란? Dead Lock 다른 말로는 교착상태를 뜻합니다. 동일한 자원을 공유하고 있는 두 개 이상의 작업이 자신들의 작업을 수행하기 위해 사용해야 하는 리소스를 서로 미리 선점함으로써 상대방이 자원에 접근하지 못하도록 막습니다. 컴퓨터 사이언스에서 많이 나오는 용어로 데이터베이스에서는 여러 개의 트랜잭션이 실행을 하지 못하고 서로 무한정 기다리는 상태를 말합니다. 조금 더 학문적으로 보면 데드락이 발생하기 위한 조건 4가지가 있습니다. (동시에 성립해야 함) 상호 배제 - 자원은 한 번에 하나씩만 사용 점유 대기 - 자원을 점유하기 위해 대기하는 시간이 존재 비선점 - 자원을 강제로 빼앗을 수 없음 순환대기 - P0은 P1가 점유한 자원을 대기하고, P1은 P0가 점유한 자원을 대기 데이터베이스의..
-
kafka 주키퍼가 필수가 아니다?프로젝트/kafka 2023. 8. 22. 00:01
개요 kafka를 docker로 구성해서 사용하다 보면 zookeeper도 같이 구성해서 사용하곤 했습니다. 하지만 zookeeper는 필수가 아니라는 이야기를 듣고 궁금하여 공부해보려 합니다. Zookeeper란 무엇인가? 쿠버네티스, 카프카 등의 분산 시스템에서는 분산된 시스템끼리 정보를 공유하기 위해 코디네이션 시스템이 필요하고 대표적인 오픈 소스로 Apache Zookeeper가 존재합니다. 공식문서에서는 고성능 코디네이션 시스템으로 소개하며, 이름, 설정 관리, 동기화, 그룹 관리, 리더 선출 등을 수행해 준다고 설명합니다. Kafka에서 Zookeeper가 필요없어졌다 Apache Kafka 2.8.0에 출시되면서 Apache Zookeeper의 의존성이 모두 제거되었습니다. Zookeeper..
-
kafka는 어떻게 고가용성을 유지할까?프로젝트/kafka 2023. 8. 21. 00:01
개요 kafka는 고가용성, 내결함성이 보장된다고 합니다. 고가용성 및 내결함성이란 시스템의 일부 구성 요소가 작동하지 않더라도 계속 작동할 수 있는 기능을 말합니다. 그러면 Kafka는 어떻게 고가용성을 유지할 수 있을까요? 핵심키워드인 kafka replication factor, leader & follower, ISR를 통해 알아보고자 합니다. Kafka replication factor kafka에서는 replication 수를 임의로 지정하여 topic을 만들 수 있습니다. replication-factor 옵션을 통해서 설정할 수 있습니다. replication-factor가 1일 때 topic1 그리고 topic2의 replication factor가 1인 경우입니다. broker1에만 저..
-
토스 SLASH 23 - Kafka 이중화로 다양한 장애 상황 완벽 대처하기세미나, 영상 요약정리 2023. 8. 20. 00:01
https://www.youtube.com/watch?v=Pzkioe7Dvo4 토스증권의 Data Engineer인 강병수 님의 발표를 요약해보고자 합니다. 대주제 : IDC 장애가 발생한 상황에 서비스를 지속할 수 있는 방법 토스증권 Kafka 활용 현황 거래서 정보, 체결가, 서비스 간 통신 및 비동기처리, 로그, cdc 등 매우 다양하게 kafka를 활용하고 있습니다. 실시간으로 발생하는 로그를 필요에 맞게 변환하기 위해 스트리밍 프로세싱 플랫폼이 필요한데 ksqlDB를 적극적으로 활용하고 있습니다. 위와 같이 핵심이 되는 부분이 kafka를 통해 이루어지기 때문에 kafka는 시스템에서 막중한 임무를 가지고 있습니다. Kafka 이중화 목적 Kafka Cluster 내의 일부 노드 장애 -> 가용..
-
OpenAPI 3.0 Specification Document Cheat Sheet카테고리 없음 2023. 8. 19. 00:01
개요 Swagger의 OpenAPI 3.0 Specification Document를 만들때 사용하는 문법들을 기록합니다. 나중에 빠르게 재사용하기 위해서 기록해두는 목적입니다. api.yaml openapi: 3.0.3 info: title: My Product description: |- My Product description termsOfService: http://swagger.io/terms/ contact: email: bababrll@naver.com version: 0.0.1 externalDocs: description: Find out more about Swagger url: http://swagger.io servers: - url: http://localhost:8080 - ur..
-
11장 - 단위 테스트 안티 패턴테스트코드(Test Code)/단위테스트 - 생산성과품질을위한 단위테스트원칙과패턴 2023. 8. 18. 00:01
11장에서 다루는 내용 비공개 메서드 단위 테스트 단위 테스트를 하기 위한 비공개 메서드 노출 테스트로 유출된 도메인 지식 구체 클래스 목 정리 비공개 메서드를 테스트해야 하는가? 이 질문은 자주 받는 질문이며 짧게 대답하면 하지 말아야 합니다. 테스트의 원칙 중 하나인 식별할 수 있는 동작만 테스트해야 합니다. 비공개 메서드를 테스트하는 것은 구현 세부사항과 결합되고 리팩터링 내성이 떨어지게 됩니다. 따라서 직접 테스트하지 않고 간접적으로 테스트하는 것이 좋습니다. 비공개 메서드가 덩치가 너무 커진 경우는 오히려 추상화를 통해 별도의 클래스를 추출해야 할 수 있습니다. 물론 정말 정말 특별한 경우라면 리플랙션을 통해 테스트할 수 있다. 책에서는 ORM에서 비공개 생성자를 이용하지만 중요한 로직이라 테스..
-
10장 - 데이터베이스 테스트테스트코드(Test Code)/단위테스트 - 생산성과품질을위한 단위테스트원칙과패턴 2023. 8. 17. 00:01
10장에서 다루는 내용 데이터베이스 테스트를 위한 전제 조건 데이터베이스 테스트 모범 사례 테스트 데이터 생명 주기 테스트 내 데이터베이스 트랜잭션 관리 데이터베이스 테스트를 위한 전제 조건 목을 사용하지 않으면 테스트하기 힘들 수 있습니다. 데이터베이스를 형상 관리 시스템에 유지 Git과 같은 형상 관리 시스템에 데이터베이스를 저장하는 것이 최선이다. (예시: Flyway) 그렇지 않다면 버그 재현을 위해 과거의 특정 시점으로 되돌리기 어렵다. 참조 데이터도 데이터베이스 스키마다 애플리케이션이 데이터를 수정할 수 있으면 일반 데이터이며, 그렇지 않으면 참조 데이터이다. 애플리케이션이 참조 데이터를 수정하지 못하게 해야한다. 개발자마다 별도의 데이터베이스 인스턴스를 활용 데이터베이스 트랜잭션 관리 트랜잭..
-
다양한 배포전략을 이해해보자MSA & 쿠버네티스(Kubernetes) - k8s 2023. 8. 16. 00:01
무중단 배포란? 서비스가 중단되지 않은 상태로 새로운 버전을 사용하에게 배포하는 것을 말합니다. 무중단 배포를 하기 위해서는 최소 2대 이상의 서버가 확보되어야합니다. 무중단 배포에는 롤링, 블루/그린, 카나리 등의 배포전략이 존재합니다. 무중단 배포가 필요한 이유는? 만약 유저가 서비스를 이용할 수 없는 시간인 다운타임이 존재한다면, 유저는 불편함을 느끼고 그로 인해 유저가 이탈하는 경우 회사 입장에서는 그 사이에 금전적인 손실이 발생할 수 있습니다. Rolling 배포 롤링의 사전적 정의 중 하나로는 "규칙적인 단계로 이뤄진"이라는 뜻이 있습니다. 트래픽을 점진적으로 구버전에서 새로운 버전으로 옮기는 방식입니다. 인스턴스를 하나 추가하고, 새로운 버전(V2)을 실행합니다. 로드밸런서를 해당 인스턴스(..