전체 글
-
5장 - 트랜잭션과 잠금CS/Real MySQL 8.0 요약 2023. 10. 26. 00:01
트랜잭션이란? 데이터 정합성을 보장하기 위해 논리적인 작업을 묶어 일부만 적용되는 현상을 발생하지 않도록 만들어주는 기능이다. 잠금이란? 잠금과 트랜잭션은 비슷한 개념 같지만 잠금은 동시성을 제어하기 위한 기능이다. 하나의 데이터를 여러 커넥션이 동시에 변경하지 못하게 막는 역할을 수행한다. 격리 수준이란? 하나의 트랜잭션 내에서 또는 여러 트랜잭션 강의 작업 내용을 어떻게 공유하고 차단할지 결정하는 레벨을 의미한다. MySQL에서 트랜잭션 MyISAM이나 Memory 스토리지 엔진은 트랜잭션을 지원하지 않고 InnoDB부터 트랜잭션을 지원한다. MyISAM의 경우에는 Partial Update가 발생하여 데이터 정합을 맞추기 까다롭다. 트랜잭션의 범위는 최소화해야 커넥션풀을 점유하는 시간이 줄어들고 부..
-
Redis를 통해 분산락 구현하기 - 이론편프로젝트/redis 2023. 10. 25. 00:01
분산락이란 무엇일까? 여러 개의 분산된 서버가 존재할 때 동일한 데이터에 대한 동기화를 보장하기 위해 사용하는 락의 종류 중 하나입니다. 분산락은 어떤 상황에서 필요할까? Java Spring 기반의 웹 애플리케이션은 기본적으로 멀티 스레드 환경에서 기동 됩니다. 이에 따라 여러 스레드가 함께 접근할 수 있는 공유자원에 대해 race condition이 발생하지 않도록 별도의 처리가 필요합니다. Java의 synchonized라는 키워드를 통해 해결할 수 있지만, 서버를 여러 대 사용하여 분산되어 있는 상황에서는 사용하기 어렵습니다. 이런 상황일 때 분산락을 활용하여 해결할 수 있습니다. MySQL의 네임드락 대신에 SELECT FOR UPDATE을 활용할 수도 있습니다. 하지만 그런경우 timeout ..
-
같이 일하고 싶은 동료가 되기 위해 노력하기회고 2023. 10. 24. 00:01
개요회사를 선택할 때 급여, 일의 자유도, 회사의 비전과 개인의 성장은 모두 중요한 요소 중 하나입니다.하지만 가장 중요한 건 좋은 사람과 일하는 것이라고 생각합니다. 개발자는 개발만 잘하면 될까?개발을 잘하는 것은 개발자의 필요조건 중 하나일 뿐이라고 생각하며 가장 먼저 나부터 좋은 동료가 되기 위해 노력해보고자 합니다.일하면서 주위에 만나는 사람들에게서 또는 스스로에게 배울 점을 찾고 기억하고 싶은 내용들을 복기하기 위해 정리해보고자 합니다. 이런 동료가 되자기술을 발전하고 내가 모르는 것은 많다, 꾸준하게 개발공부를 하기요구사항에 대해서 철저하게 분석하고 이 일을 왜 해야 하는지에 대한 본질을 찾기 문제가 발생하면 분석을 통해 원인파악을 하고 해결방안에 대해서도 제시하기공유를 많이 하기현재 내가 ..
-
신뢰성 있는 카프카 애플리케이션을 만드는 3가지 방법세미나, 영상 요약정리 2023. 10. 23. 00:01
https://www.youtube.com/watch?v=7_VdIFH6M6Q 최원영 님의 Kakao Tech Meet의 발표를 요약해보고자 합니다. 메시지 전달 신뢰성 정확히 한 번 적어도 한 번 최대 한 번 보통 정확히 한 번을 요구하는 경우가 많은데 어떻게 요구사항을 잘 반영할 수 있을까요? 방법 1 - Producer의 메시지 전달 신뢰도 실제로 적재되었지만 네트워크로 인해 Acknowlegement가 유실되는 경우에 Retry를 수행하게 되고 2번 레코드(이벤트 메시지) 적재될 수 있습니다. 불안정한 경우에는 2번 이상 발생할 수도 있습니다. Kafka에서는 멱등성 producer를 활용할 수 있습니다. enable.idempotence라는 옵션을 활용할 수 있는데 kafka 3.0이후로는 옵션..
-
폭증하는 카카오톡 트래픽에 대처하는 방법 - 신성열세미나, 영상 요약정리 2023. 10. 22. 00:01
https://www.youtube.com/watch?v=U905BeDQ_BA Kakao Tech Meet에서 신성열 님이 발표하신 폭증하는 카카오톡 트래픽에 대처하는 방법에 대해 정리해보고자 합니다. 메시지 전송 트래픽 평상시에는 최대 초당 4만5천건정도트래픽이 발생합니다. 하지만 신년, 월드컵이나 지진과 같은 특별한 이벤트가 발생하면 트래픽은 갑자기 폭증합니다. 폭증하는 트래픽으로 장애가 발생할 수 있습니다. 경주 지진 재난안내 문자를 안내받은 모바일 기기가 깨어나면서 카카오톡의 백그라운드 로그인 기능 때문에 전 국민이 로그인을 트래픽을 요청하게 됩니다. 따라서 모든 스레드가 로그인 기능을 처리하는데 모두 사용되게 되고, 메시지는 실패하게됩니다. 트래픽에 따라 부하레벨을 조정 활성화된 스레드의 비율..
-
ThreadPoolTaskExecutor란? (ThreadPoolTaskExecutor vs ThreadPoolExecutor)Java/Executor Service 2023. 10. 21. 00:01
ThreadPoolTaskExecutor란? public class ThreadPoolTaskExecutor extends ExecutorConfigurationSupport implements AsyncListenableTaskExecutor, SchedulingTaskExecutor { private final Object poolSizeMonitor = new Object(); private int corePoolSize = 1; private int maxPoolSize = Integer.MAX_VALUE; private int keepAliveSeconds = 60; private int queueCapacity = Integer.MAX_VALUE; private boolean allowCore..
-
ThreadPoolExecutor란?Java/Executor Service 2023. 10. 20. 00:01
ThreadPoolExecutor란? public static ExecutorService newFixedThreadPool(int nThreads) { return new ThreadPoolExecutor(nThreads, nThreads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue()); } Executors의 클래스의 메서드에서 고정된 스레드풀의 개수를 반환하는 newFixedThreadPool에서는 내부적으로 ThreadPoolExecutor를 생성하여 반환합니다. newFixedThreadPool을 호출할 때는 스레드의 개수만 지정해 주면 되지만 내부적으로는 기본적인 값들이 세팅돼서 제공됩니다. // Executors를 사용해서 간편하게 스레드풀 ..
-
ExecutorService란?Java/Executor Service 2023. 10. 19. 00:01
Executor란? public interface Executor { void execute(Runnable command); } ExecutorService가 Executor 인터페이스를 구현하고 있습니다. Executor 인터페이스는 Runnable 객체를 미래의 어느 시점에 주어진 명령으로 실행합니다. Runnable이란? @FunctionalInterface public interface Runnable { public abstract void run(); } Runnable 인터페이스는 인스턴스가 스레드에 의해 실행되는 의도된 모든 클래스에서 구현합니다. 예를 들어 Runnable 인터페이스는 Thread 클래스가 구현하고 있습니다. 스레드를 시작하면 별도의 실행 중인 스레드에서 객체의 run ..