Back-End
-
웹 크롤러 프로젝트 docker-image 빌드하기Back-End/Docker 2022. 4. 11. 15:24
이제 크롤러를 docker 컨테이너화를 해 볼 것이다. 먼저 docker desktop (데몬) 실행 해서 빌드 하려는데, 오류가 뜬다. FROM openjdk:17-jdk-alpine 해당 이미지를 pull 하는 과정에서 오류가 떠서, build시 추가 옵션을 줬더니 해결됐다. 내 맥북이 m1칩을 사용해서, 인텔의 아키텍쳐가 아닌 arm 아키텍쳐를 사용해서 그런 것이었다. 다음으로, build를 통해 jar 파일을 만든다. ./gradlew build 일단 먼저 gradlew파일에 권한을 주어야 한다. chmod +x gradlew 명령어로 권한을 주고 실행하면 - 다음과 같이 compileJava에서 실패 오류가 떴다. 이 에러는 다음 링크에서 잘 설명되어 있다. https://binux.tistor..
-
웹 크롤러에 Kafka 도입(2)Back-End/Kafka 2022. 4. 1. 15:37
자동 토픽 생성 - 크롤러에 필요한 토픽은 총 2개이다. "queue-html", "reverse-queue-html" - 2개의 토픽을 CLI를 통해 생성할 수 있으나, html-worker를 실행하면서 동시에 만들어질 수 있도록 설정을 해 본다. @Bean public KafkaAdmin.NewTopics crawlerTopics(){ return new KafkaAdmin.NewTopics( TopicBuilder.name(KafkaTopicConfig.QUEUE_HTML).build(), TopicBuilder.name(KafkaTopicConfig.REVERSE_QUEUE_HTML).build() ); } 간단하게 KafkaAdmin.newTopics를 빈으로 등록 해 주면, 어플리케이션이 실행..
-
웹 크롤러에 Kafka 도입Back-End/Kafka 2022. 3. 30. 15:40
수습 기간 프로젝트로 진행한 웹 크롤러에 RabbitMQ에 이어서 Kafka를 넣기로 결정. 원래는 consumer group이 하나라서 메세지가 재활용되지 않고, 적은 데이터에서는 Kafka보다 우위이기 때문에 RabbitMQ를 사용하기로 했지만, Kafka를 그냥 써 보고 싶어서 브랜치를 하나 따서 Kafka를 사용해서 성능을 비교하기로 했다. 간단한 Flow - 카프카 브로커 URL 부트스트랩 : 카프카 프로듀서는 카프카 클러스터에 대한 메타데이터를 가져오기 위해 최소 하나 이상의 브로커에 연결한다. 프로듀서가 연결하길 원하는 첫 번째 브로커가 다운될 경우를 대비하여 보통 한개 이상의 브로커 URL 리스트를 설정한다. - 데이터 직렬화 : 카프카는 TCP 기반의 데이터 송수신을 위해 이진 프로토콜을..
-
kafka란?Back-End/Kafka 2021. 10. 21. 20:54
공식 문서를 보면, kafka는 다음과 같이 정의되어 있다. Apache Kafka is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications. kafka와 RabbitMQ의 성능 비교 https://www.confluent.io/blog/kafka-fastest-messaging-system/ - source application은 kafka에 data를 전송하고, target application은 kafka에서 ..
-
jenkins란Back-End/Jenkins 2021. 10. 14. 14:31
- jenkins란, CI(Continuous integration) Tools이다. - 개발자가 어플리케이션의 코드를 작성을 한 이후 master branch에 merge를 한다면, 이 후 빌드, 테스트, 배포까지 자동으로 수행을 해 준다. - Jenkins를 사용하기 이전, 개발자들이 각 branch로 push를 한 이후 merge를 하려 할 때, 따로 merge를 승인해주고, build와 test 등을 해 주는 인력이 있었다. - 따라서, 해당 인력과 정해진 날에 merge를 해야하는 경우, 개발자들이 작업을 미리 끝낸 경우 merge를 하기로 한 날까지 노는 경우가 생기거나, 그와 반대로 매우 타이트하게 개발을 마쳐야 하는 경우가 생기고 만다. - jenkins등장 이후, 개발자들이 PR을 올리고..
-
nginx의 reverse proxy 적용하여 http => https 적용하기Back-End/nginx 2021. 9. 11. 13:41
- Front server에서, nginx 서버를 reverse proxy용으로 활용한다. 물론 redirecting 과정에서 error 발생 시 정적 html 파일을 내려주기도 한다. - 여기서 nginx는 SSL 인증서를 적용하여 클라이언트와 서버가 https 통신을 하도록 기능을 부여 할 것이다. - 443번 포트(https 전용 포트)로 request가 들어오면 그대로 next로(host의 3060포트) redirecting 해줄 것이고, 80번 포트로 request가 들어오는 경우 nginx 내부 configuration 설정을 통해 443으로 redirecting 을 해 줄 것이다. - 먼저, http://nodebird.com 도메인으로 브라우저가 request를 보내면, nginx의 80포..
-
apache vs nginxBack-End/nginx 2021. 9. 10. 12:01
apache - http 웹 서버 소프트웨어이다. - Apache는 MPM(Multi-Process Module) 방식으로 http request를 처리한다. MPM방식은 2가지의 유형으로 나뉜다. PreFork MPM(다중 프로세스) - http request가 들어올 시, apache 자식 프로세스를 생성하여 처리한다. - 하나의 자식 프로세스당 하나의 스레드를 가진다.(최대 1024개) - 프로세스간 메모리 공유를 하지 않으므로 독립적이어서 안정적이지만, 메모리 소모가 크다는 단점이 있다. Worker MPM(멀티 프로세스 - 스레드) - 요청이 들어오면, 프로세스가 스레드를 생성하여 request를 처리한다.(프로세스당 최대 64개) - 스레드 간의 메모리 공유가 가능하다. - Prefork MP..
-
KubernetesBack-End/Kubernetes 2021. 9. 9. 17:15
Kubernetes - kubernetes란, 컨테이너를 쉽고 빠르게 배포, 확장시켜주고 컨테이너들의 관리를 자동화해주는 오픈소스 플랫폼이다. - 도커의 등장 이후, 많은 어플리케이션이 도커 컨테이너를 기반으로 활용이 되었다. - 하지만, 컨테이너를 여러 서버에서 수 십, 수 백개를 실행하게 되면서 이들의 관리가 쉽지 않게 되었다. - 코드를 작성하고, 이를 이미지화 한 뒤, DockerHub에 배포(ship)하고, 해당 이미지를 pull해서 사용하는 방식에서, 추가적인 작업이 필요하다. 왜 Kubernetes가 필요할까? - 여러 서버에서 컨테이너를 실행하려면, 일일이 서버마다 CLI 명령어를 입력해야 한다. - 또한, 컨테이너를 실행할 때 여러 개의 서버 중에 컨테이너가 실행중이지 않은, 놀고 있는 ..