<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Allan Bae on Medium]]></title>
        <description><![CDATA[Stories by Allan Bae on Medium]]></description>
        <link>https://medium.com/@gjbae1212?source=rss-8762f94a1b9f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*7rSqlgADHTXZWNZuIhOUzQ.png</url>
            <title>Stories by Allan Bae on Medium</title>
            <link>https://medium.com/@gjbae1212?source=rss-8762f94a1b9f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 14:27:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gjbae1212/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[WATCHA K8S 전환 -PART 2]]></title>
            <link>https://medium.com/watcha/watcha-k8s-%EC%A0%84%ED%99%98-part-2-caea323da57d?source=rss-8762f94a1b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/caea323da57d</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[envoy-proxy]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Allan Bae]]></dc:creator>
            <pubDate>Wed, 04 Aug 2021 07:58:01 GMT</pubDate>
            <atom:updated>2021-08-17T04:45:46.196Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zajrs3Ay5pBac3KzZbpong.png" /></figure><p><strong>PART 2 — Api-Gateway 소개</strong></p><h3>NOTICE</h3><p>해당 블로그 는 <strong>PART 2 — Api-Gateway 소개 </strong>입니다.</p><p>총 <strong>3 PART </strong>의<strong> </strong>시리즈로 구성했으며 아래와 같습니다.</p><ul><li><a href="https://medium.com/watcha/watcha-k8s-%EC%A0%84%ED%99%98-part-1-3ac7193d04d7"><strong>PART 1 — 전반적인 소개 및 POD 내 CONTAINER 알아보기</strong></a></li><li><strong>PART 2 — Api-Gateway 소개</strong></li><li><strong>PART 3 — GitOps 소개</strong></li></ul><h3>개요</h3><p>안녕하세요. <strong>WATCHA </strong>에서 서버 개발을 하고 있는 Allan 입니다.<br>이전 포스팅 에서는 <strong>WATCHA</strong> 에서 Kubernetes 로 인프라를 전환한 전반적인 구조에 대해서 이야기 해보았습니다.</p><p><strong>이번 포스팅</strong>은 Kubernetes 로 인프라 전환시 구축한 API GATEWAY 에 대해서 이야기 해보고자 합니다.</p><h3>What’s API GATEWAY?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IMP9tkf-YmhboHx0gaHW5Q.png" /></figure><p>MSA 구조로 바뀌면서 큰서비스들이 여러 작은 서비스들 분리되었습니다. <br>하지만 분리된 서비스들이 CLIENT 를 통해서 직접 호출하는 형태라고 한다면, 각 서비스별로 Endpoint 와 인증 및 권한 관리를 해야하는 번거로움이 생깁니다.<br>게다가 클라이언트와 통신을 위해서 어느 정도 외부로 시스템을 노출시켜서 보안이 취약해 질 수도 있습니다.</p><p>API GATEWAY 를 이용하게 된다면 인증 및 권한 관리, 라우팅 및 로드밸런싱, 보안, Rate Limit, Circuit Breaker … 등 다양한 기능을 활용할수 있어서 효율적으로 요청 처리가 가능합니다.<br> <br>하지만 큰 단점은 API GATEWAY 가 <strong>SPOF(Single Point Of Failure) </strong>이라는 <br>점입니다. API GATEWAY 장애시 전체 서비스 장애로 번질수 있어, 적절한 Fallback 또는 장애 대응 프로세스가 필요 할수도 있습니다.</p><p>따라서 현 상황에 맞게 잘 활용하는게 중요합니다.</p><h3>Which API GATEWAY is Selected?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2NaBWJKfTAelSj9YqIaA9w.png" /><figcaption>다양한 API GATEWAY 들</figcaption></figure><p>OpenSource 또는 Enterprise 로 제공하는 다양한 API GATEWAY 들이 있습니다. <br>그 중에서 <strong>WATCHA </strong>에서는 <a href="https://docs.solo.io/gloo-edge/latest/"><strong>Gloo Edge</strong></a>를 이용해서 API GATEWAY 를 구축했습니다.</p><p>Gloo Edge 선택했던 이유는 정리해보면 아래와 같습니다.</p><ul><li><strong>CRD 지원 :</strong> 대부분 모든 서비스가<strong> </strong>K8S 내에서 동작하기 때문에, <strong>CRD</strong>를 이용하여 쉽게 다양한 기능들을 활용 할 수 있습니다.</li><li><strong>Envoy 기반 </strong>: Gloo Edge 는 API GATEWAY 로 <a href="https://www.envoyproxy.io/"><strong>Envoy</strong></a>를 이용합니다. <br>따라서 Envoy 기능을 활용한 적절한 커스텀마이징 이 가능하고, 커뮤니티가 활성화 되어 있어 트러블슈팅에 용이합니다.</li><li><strong>Golang 기반: </strong>Proxy를 컨트롤 하기 위한 Control Plane 역할을 하는 Controller(App) 들이 Golang 으로 만들어져 있습니다. <br>회사 내에서 <strong>Golang</strong> 을 주력으로 이용하는 팀인지라, 적절한 커스텀마이징, 트러블슈팅에 쉽게 접근이 가능한 장점이 있습니다.</li><li><strong>귀여운 ICON: </strong>Gloo Edge 를 상징하는 아이콘이 귀엽습니다. 😂 😂 😂</li></ul><h3>Gloo Edge 를 이용한 인프라 구조</h3><p>WATCHA 에서 Gloo Edge 를 이용한 인프라 구조는 아래와 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8svXk9_ehlY_yKCClCfhyQ.png" /><figcaption>WATCHA 에서 적용된 API GATEWAY 구조</figcaption></figure><h4>1. 프록시</h4><p>요청된 트래픽은 NLB 를 통해서 Envoy 로 들어오게 됩니다. Envoy는 L7 역할을 담당하며, Envoy 설정을 기반으로 Upstream 으로 트래픽을 전달하게 됩니다.<br>Envoy 설정은 static(하드코딩) 하게 설정도 할수 있습니다. <br>하지만 static 한 형태로만 설정을 하게 된다면 설정 변경시 Envoy 를 재시작을 시켜야하는 듯 불편함이 많습니다. <br>그래서 동적으로 Envoy 설정을 주입할 필요가 있는데, 보통은 <a href="https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/operations/dynamic_configuration"><strong>xDS</strong></a><strong> </strong>서버를 통해서 Envoy 가 API 통신으로 설정을 주입받게 됩니다.<br><strong>Gloo Edge</strong>는 주기적으로 서비스 상태 와 고유의 CRD 설정을 모니터링 하고, 만약 변경이 발생시 자동으로 Envoy 설정을 생성하고 <strong>xDS </strong>서버를 통해서 Envoy에 설정을 주입하게 됩니다.</p><h4>2. 모니터링</h4><p>Envoy 자체에도 다양한 매트릭을 지원합니다. <br>WATCHA 에서는 Proxy 전용 POD 에 <strong>DataDog Agent</strong> 를 사이드카 컨테이너로 주입해서 IN/OUT 트래픽 및 Envoy 제공하는 매트릭 수집 하고 모니터링을 하고 있습니다.</p><h4>3. 로깅</h4><p>Envoy 에서 발생하는 IN/OUT 트래픽 및 다양한 로그들은 <a href="https://www.envoyproxy.io/docs/envoy/latest/api-v3/service/accesslog/v3/als.proto.html"><strong>gRPC Access Log Service (ALS)</strong></a><strong> </strong>기반으로 개발된 WATCHA 내부 서버를 통하여 <a href="https://medium.com/watcha/%EB%A9%80%ED%8B%B0%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EB%A1%9C%EA%B7%B8-%EB%B6%84%EC%84%9D-%ED%94%8C%EB%9E%AB%ED%8F%BC-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-8c5f671df559"><strong>WATCHA 로그플랫폼</strong></a>으로 전달되며 빅쿼리에 저장됩니다.<br>참고로 WATCHA에서는 대부분 로그들은 로그플랫폼을 통해서 수집, 통합 및 분석을 하고 있습니다.</p><h4>4. 라우팅 및 옵션</h4><p>Gloo Edge 에서 제공되는 다양한 CRD 를 활용하여서 손쉽게 라우팅룰을 변경하고, 상황에 따라 Retry, Rate Limit, Circuit Breaker …등도 포함시켜서 가급적 장애 전파가 일어나지 않도록 관리하고 있습니다.</p><h3>미래의 청사진</h3><p><strong>WATCHA</strong> 에서 Gloo Edge 를 API GATEWAY 선택한 가장 큰 이유는 <br>앞으로 가고자 하는 방향에 부합했기 때문입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*28qGa_IvCtaR9hz9BSi_ow.png" /><figcaption>미래의 청사진</figcaption></figure><p>Envoy 앞단에 다양한 Filter 를 배포하여, 실제 요청이 각 MSA 서비스에 전달되기 전에 전처리 작업을 진행할 계획입니다.</p><p>예를 들면 실제 서비스에 전달 되기전에 어뷰징 체크 및 웹 방화벽 같은 역할을 하는 Envoy Filter를 개발하여서 서비스 안정성을 높힐수 있고, 외부에 노출 되는 인증 토큰과 내부에서 사용하는 인증 토큰을 분리하여 보안에 좀더 신경 쓰고, 내부 MSA 기반 서비스들을 내부 인증 토큰 통합하여서 인증에 큰 신경쓰지 않아도 MSA 서비스를 손쉽게 늘려 나갈수 있도록 할수 있습니다.</p><blockquote>참고로 Envoy 에서는 기본으로 지원하는 여러 Filter 를 활용 할수 있고, 뿐만아니라 WASM 기반으로 Filter 개발을 지원하기 때문에 사용하는 언어에 제한없이 개발할 수 있는 장점이 있어서 개발자 익숙한 언어로 빠르게 Filter 들을 개발할 수 있습니다.</blockquote><h3>Conclusion</h3><p>지금 까지 간략하게 <strong>PART 2 — Api-Gateway 소개</strong>에 대해서 알아보았습니다.<br>아직은 고민할 부분이 많이 남아 있지만 지속적으로 개선해볼 생각입니다.</p><p>다음 포스팅은 <strong>PART 3 — GitOps 소개 </strong>에 대해 포스팅 해보도록 하겠습니다.</p><p><strong>WATCHA</strong>에서는 다양한 기술들을 활용해 서비스를 지속적으로 개선, 발전시켜 갈 실력 있고 뜻있는 개발자들을 모집하고 있습니다. 관심있는 분은 <a href="https://watcha.team/"><strong>채용공고</strong></a>를 참고해주세요.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=caea323da57d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/watcha/watcha-k8s-%EC%A0%84%ED%99%98-part-2-caea323da57d">WATCHA K8S 전환 -PART 2</a> was originally published in <a href="https://medium.com/watcha">WATCHA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WATCHA K8S 전환 -PART 1]]></title>
            <link>https://medium.com/watcha/watcha-k8s-%EC%A0%84%ED%99%98-part-1-3ac7193d04d7?source=rss-8762f94a1b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ac7193d04d7</guid>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Allan Bae]]></dc:creator>
            <pubDate>Wed, 21 Jul 2021 08:07:05 GMT</pubDate>
            <atom:updated>2021-08-17T04:44:59.994Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NEWwg5xOl3p3DdZEwG6DCA.png" /></figure><p><strong>PART 1- 전반적인 소개 및 POD 내 CONTAINER 알아보기</strong></p><h3>NOTICE</h3><p>해당 블로그 는 <strong>PART 1- 전반적인 소개 및 POD 내 CONTAINER 알아보기 </strong>입니다.</p><p>총 <strong>3 PART </strong>의<strong> </strong>시리즈로 구성했으며 아래와 같습니다.</p><ul><li><strong>PART 1 - 전반적인 소개 및 POD 내 CONTAINER 알아보기</strong></li><li><strong>PART 2 - Api-Gateway 소개</strong></li><li><strong>PART 3 - GitOps 소개</strong></li></ul><h3>개요</h3><p>안녕하세요. <strong>WATCHA </strong>에서 서버 개발을 하고 있는 Allan 입니다.<br>이번 포스팅은 <strong>WATCHA </strong>에서 사용하고 있는 서비스 인프라를 <a href="https://kubernetes.io/"><strong>Kubernetes</strong></a><strong> </strong>로 변경한 스토리를 이야기해보고자 합니다.</p><p>바야흐로 <strong>2020년 12월 말,</strong> 서버 및 인프라 시니어 개발자들이 모여 2021년 한해 <br>목표를 논의하는 중에 아래와 같은 의견이 나왔습니다.</p><blockquote>현재 폭발적으로 사용자가 증가하고 있다.<br>게다가 추가적으로 진행될 서비스들이 준비되어 있어 MSA가 더욱 가속화 될 것이다.<br>그것에 맞추어 서비스 인프라를 Kubernetes 기반으로 이전하자.</blockquote><p>참가자들이 해당 의견에 동의하면서, <strong>2021년 1월 Kubernetes 원정대</strong>에<strong> <br>3인</strong>의 개발자들이 참전하게 됩니다. 🎉</p><h3>What’s Kubernetes?</h3><p>Kubernetes는 컨테이너화된 애플리케이션을 자동으로 배포, 스케일링 및 관리해주는 오픈소스 시스템입니다.</p><p>이전 WATCHA 에서는 AWS EC2 를 직접 운영하거나, ElasticBeanstalk 를 이용해서 EC2 또는 ECS 기반으로 운영하고 있었습니다.</p><p>하지만 Kubernetes로 이전 하면서 각 서비스 개발자들이 인프라담당자 지원 없이도 <br>손쉽게 원하는 자원(CPU, Memory)을 이용하여 서버를 운영해 볼수 있으며 <br>배포와 각종 설정을 코드 또는 YAML 로 관리하여 서비스 서버에 관련된 모든 설정 들을 한곳에 모으기 용이 했습니다. <br>게다가 빠른 배포와 자원을 효율적으로 이용할수 있었습니다.</p><p>물론 단점도 있습니다. <br>운영 관리가 어렵다. 사용이 어렵다. 진입장벽이 꽤 높다 … 등이 있습니다.<br><strong>(결론은 어렵다는 것입니다. </strong>😮‍💨<strong>)</strong></p><p>그럼에도 불구하고, 장점이 단점보다 크기 때문에 많은 IT 회사에서 Kubernetes 로 <br>이전하고 있고, WATCHA 도 Kubernetes 로 이전하게 되었습니다.</p><h3><strong>EKS VS</strong> GKE ?</h3><p><strong>WATCHA </strong>에서는 AWS 와 GCP 모두를 운영을 하고 있습니다. <br>그래서 각 클라우드서비스 관리형 Kubernetes 서비스인 <a href="https://aws.amazon.com/ko/eks">EKS</a> 와 <a href="https://cloud.google.com/kubernetes-engine">GKE</a><br>둘다 검토 대상이었습니다.<br> <br>하지만 서비스에서 사용하는 주요 자원들이 AWS 에 종속된 상황이기때문에 <br>GKE를 사용하기에는 많은 사이드이펙트가 우려되어 결국은 <strong>EKS</strong>를 선택하게 되었습니다. (개인적으로는 <strong>GKE</strong> 를 선호합니다.)</p><p>물론 <a href="https://cloud.google.com/anthos"><strong>Google Anthos</strong></a> 이용하여서 AWS 에서 Kubernetes 를 운영하는 방안도 고민해 보았으나 이것 또한 적용사례를 찾아 볼수 없었고, 사이드이펙트가 우려되어 고려 대상이 아니었습니다.</p><h3>EKS NodeGroup VS EKS Fargate ?</h3><p>AWS EKS 에서는 Node 들을 NodeGroup 또는 Fargate 로 운영이 가능합니다. <br><strong>NodeGroup</strong>는<strong> </strong>EC2 머신을 사내 인프라 관리자들이 업데이트 및 관리를 하고<br><strong>Fargate</strong>는 EC2 머신을 AWS에서 직접 업데이트 및 관리를 해주는 차이점이 있습니다.</p><p>하지만<strong> Fargate</strong>를 아래와 같은 단점이 있습니다.</p><ul><li><strong>Daemonset 을 이용할수 없다.</strong></li><li><strong>SecurityContext 를 이용할수 없다. (권한 문제)</strong></li><li><strong>Istio 같은 Service Mesh를 이용할수 없다. (권한 문제)</strong></li><li><strong>사용할 머신 타입이 제한이 있다. (GPU 머신 사용 X)</strong></li><li><strong>트러블슈팅이 어렵다. (접근이 제한되어 있음.)</strong></li></ul><p>EKS Fargate 특성상 1 Node 에 1 Pod 만 가능해서 구조상 <strong>Daemonset </strong>이 뜰수<br>없으며, AWS쪽에서 직접 운영 하기때문에 권한이 제한되어 있습니다. <br>그래서 특정 ROOT 권한이 필요한 <strong>SecurityContext</strong> 를 이용할수가 없고, <a href="https://istio.io/">Istio</a> <br>도 이용할수 없습니다.</p><p>하지만 Fargate 를 이용하면 인프라 관리자들이 관리포인트가 줄어들고, <br>1 Node에 1 Pod 구조만 가능하여 같은 Node 에 떠 있는 특정 Pod의 영향으로 인한 <br>성능저하를 일으킬수 있는 이슈가 없고 머신 성능을 풀로 사용할수 있어서 <br>상황에 맞게 사용하면 좋습니다.</p><p>물론 <strong>WATCHA</strong>에서는 서비스 종류에 따라 NodeGroup 과 Fargate 를 동시에 <br>이용하는 하이브리드 구조로 운영하고 있습니다.</p><h3>EKS 운영하기 위한 기본적인 패키지들</h3><p>EKS NodeGroup 및 EKS Fargate 를 운영 하기 위해서 필요한 패키지들이 <br>매우 많습니다. 그중에서도 중요한것들만 정리해보면 아래와 같습니다.</p><ul><li><a href="https://prometheus.io/"><strong>PROMETHEUS</strong></a><strong>: </strong>매트릭 수집 저장 및 커스텀 오토스케일링(HPA)사용</li><li><a href="https://github.com/kubernetes-sigs/metrics-server"><strong>METRIC-SERVER</strong></a><strong>: </strong>노드의 리소스 매트릭 수집 및 오토스케일링(HPA)에 사용</li><li><a href="https://docs.aws.amazon.com/ko_kr/eks/latest/userguide/cluster-autoscaler.html"><strong>CLUSTER AUTO SCALER</strong></a>: NODE 가 부족할시 자동으로 NODE를 늘려줌.</li><li><a href="https://docs.aws.amazon.com/ko_kr/eks/latest/userguide/aws-load-balancer-controller.html"><strong>AWS LOAD BALANCER CONTROLLER</strong></a><strong>: </strong>Ingress 및 service 생성시 AWS NLB 또는 ALB 를 프로비저닝.</li><li><a href="https://github.com/kubernetes-sigs/external-dns"><strong>EXTERNAL DNS</strong></a><strong>: </strong>Ingress 와 service 에 연결된 AWS NLB, ALB 에 쉽게 도메인을 연결.</li><li><a href="https://github.com/external-secrets/external-secrets"><strong>EXTERNAL SECRETS</strong></a><strong>: </strong>AWS Secrets Manager 등록된 Key, Value 들을 쉽게 Container 쪽 주입.</li></ul><h3>전체 구조</h3><p>아래는 3편의 블로그 포스팅으로 공유 해보려고 하는 개략적인 전체 구조 입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-yIlEAql9_WwHOhcCSyAeQ.png" /><figcaption><strong>개략적인 WATCHA EKS 인프라 구조</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PD16o-X4VMXn830kmHo5mg.png" /><figcaption><strong>개략적인 WATCHA GitOps 구조</strong></figcaption></figure><h3>사용한 기술 스택</h3><p>사용한 기술 스택에 대해서 아래와 같이 파트 별로 정리 해보았습니다.</p><h4><strong>PART 1</strong></h4><ul><li><a href="https://fluentbit.io/"><strong>Fluent-Bit</strong></a>: <a href="https://www.fluentd.org/">Fluentd</a> 의 경량버전입니다. C로 구현되어 있고, 라이브러리에 의존성이 없습니다. 가볍고 빨라서 대용량 로그 수집에 최적화 되어있습니다. <br>WATCHA 에서는 POD 에서 수집한 로그를 <a href="https://medium.com/watcha/%EB%A9%80%ED%8B%B0%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EB%A1%9C%EA%B7%B8-%EB%B6%84%EC%84%9D-%ED%94%8C%EB%9E%AB%ED%8F%BC-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-8c5f671df559"><strong>로그플랫폼</strong></a>으로 전달하기 위해 사용하고 있습니다.</li><li><a href="https://www.datadoghq.com/"><strong>DataDog</strong></a>: 다양한 모니터링 서비스를 제공하는 솔루션 입니다. <br>WATCHA 에서는 AWS 와 GCP 및 EKS 인프라 모니터링에 이용하고 있고, <br>각 서비스 별로 <a href="https://opentracing.io/">Opentracing</a> 또는 <a href="https://opentelemetry.io/">Opentelemetry</a> 를 활용해서 서비스 성능 측정 및 개선을 위한 <strong>APM </strong>과<strong> </strong><a href="https://openmetrics.io/"><strong>OpenMetrics</strong></a> 을 이용해서 모니터링 지표를 수집합니다.</li><li><a href="https://aws.amazon.com/ko/app-mesh"><strong>App Mesh</strong></a>: AWS 에서 서비스로 제공하는 Service Mesh 솔루션입니다.<br>EKS Fargate 에서는 <a href="https://istio.io/"><strong>Istio</strong></a><strong> </strong>같은 Service Mesh를 사용할수 없어, 대안으로 <br>App Mesh 를 이용하고 있습니다. Istio 와 비슷하게 Pod의 Sidecar 로 <a href="https://www.envoyproxy.io/"><strong>Envoy</strong></a> 를 이용합니다.<br>WATCHA 에서는 Service Mesh 솔루션으로 App Mesh 를 이용하고 있습니다.</li></ul><h4>PART 2</h4><ul><li><a href="https://docs.solo.io/gloo-edge/"><strong>Gloo Edge</strong></a>: 오픈 소스로 개발중인 <strong>API GATEWAY</strong> 입니다. <br>Control Plane 으로 <a href="https://golang.org/">Golang</a> 개발된 Controller 와 Data Plane 으로<br>Envoy 를 이용하고 있습니다. Kubernetes 친화적으로 다양한 <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/">CRD</a>를 지원합니다.<br>WATCHA 에서는 API GATEWAY 로 Gloo Edge를 이용하고 있습니다. <br>자세한 설명은 <strong>PART 2</strong> 블로그 포스팅때 이야기 해보도록 하겠습니다.</li></ul><h4>PART 3</h4><ul><li><a href="https://helm.sh/"><strong>HELM</strong></a>: Kubernetes에서 이용하는 패키지 매니저입니다. <br>WATCHA 에서는 Application 배포할때 Helm Chart 를 작성해서 <br>배포를 하고 있습니다.</li><li><a href="https://circleci.com/"><strong>CircleCI</strong></a><strong> 와 </strong><a href="https://docs.github.com/en/actions"><strong>Github Action</strong></a><strong>: </strong>CI/CD에 사용하는 솔루션입니다. <br>WATCHA 에서는 테스트와 도커 이미지 생성 및 배포에 해당 솔루션을 <br>사용하고 있습니다.</li><li><a href="https://argoproj.github.io/argo-cd/"><strong>ArgoCD</strong></a>: Kubernetes 에 Application 배포를 위해 사용하는 솔루션입니다. <br>ArgoCD는 사용하기 쉬운 UI 를 제공하며 다양한 Repository 를 이용하여 <br>Canary 와 Blue-Green 형태의 배포를 지원합니다. <br>게다가 지속적으로 상태를 감지하면서 Sync를 맞춰주며, 문제 발생시 쉽게 <br>롤백도 할수 있습니다.<br>WATCHA 에서는 서비스 배포에 ArgoCD를 이용하고 있으며, 자세한 설명은 <br><strong>PART 3 </strong>블로그 포스팅때 이야기 해보도록 하겠습니다.</li></ul><h3>POD 내 CONTAINER 구조</h3><p>각 서비스별로 차이는 있지만, WATCHA 에서 일반적으로 Pod 내에 구동되는 Container 들은 아래 그림과 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r4fVwZZT6VNyamjSkJbXzg.png" /></figure><p>보통 Sidecar Container 로 <strong>FluentBit</strong>, <strong>Datadog Agent</strong>, <strong>Envoy(App Mesh)<br></strong>3개의 Container가 뜨게 됩니다.</p><p>맨 앞에 <strong>App Mesh</strong> 가 Service Mesh 역할로써 모든 Inbound 와 outbound 트래픽을 제어합니다. 익명의 Inbound 또는 outbound 요청을 차단하여 보안적으로 좋습니다.<br>게다가 App 서버에서 일시적으로 에러 발생시 Retry 및 Timeout 기능도 제공하고 <br>장애상황에 대비하여 Circuit Breaker 와 Rate Limit 기능도 제공합니다.</p><p><strong>DataDog Agent</strong> 는 App 에서 발생하는 다양한 metric 을 App 코드에 큰 변경 없이도 손쉽게 수집이 가능하며, Opentracing 및 Opentelemetry 기반을 데이터를 수집하여서 손쉽게 APM 을 사용할수 있도록 해줍니다.<br>가장 큰 장점은 metric 통합하여 서비스들간 연관관계를 손쉽게 UI로 확인<br>가능하며, 장애 대응 및 분석에도 좋습니다.</p><p><strong>FluentBit</strong> 는 App 에서 발생하는 RAW 한 로그를 수집하여 <a href="https://medium.com/watcha/%EB%A9%80%ED%8B%B0%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EB%A1%9C%EA%B7%B8-%EB%B6%84%EC%84%9D-%ED%94%8C%EB%9E%AB%ED%8F%BC-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-8c5f671df559"><strong>WATCHA 로그플랫폼</strong></a>으로 전송합니다. 이렇게 수집된 로그는 <a href="https://cloud.google.com/bigquery/?hl=ko&amp;utm_source=google&amp;utm_medium=cpc&amp;utm_campaign=japac-KR-all-ko-dr-bkws-all-super-trial-e-dr-1009882&amp;utm_content=text-ad-none-none-DEV_c-CRE_521780252286-ADGP_Hybrid%20%7C%20BKWS%20-%20EXA%20%7C%20Txt%20~%20Data%20Analytics%20~%20BigQuery_big%20query-google%20bigquery-en-KWID_43700030027797576-kwd-63326440124&amp;userloc_1030723-network_g&amp;utm_term=KW_google%20bigquery&amp;gclid=Cj0KCQjwxJqHBhC4ARIsAChq4auI9NVF7DVABlG_tq4I8yhFTgV3zMbF2S7Ukb6NpippbwsPpZe45H4aApNpEALw_wcB&amp;gclsrc=aw.ds"><strong>BigQuery</strong></a> 에 저장되어서 데이터 분석에 활용하고 있습니다.</p><h3>Conclusion</h3><p>지금 까지 간략하게 <strong>PART 1</strong>- <strong>전반적인 소개 및 POD 내 CONTAINER 알아보기 </strong>에 <br>대해서 알아보았습니다.</p><p>이글 전체에 담을수 없지만 Kubernetes 인프라를 구축 하면서 많은 삽질과 좌절 😂로 <br>고생하신 Kubernetes 원정대<strong> </strong>분들의 노력이 있었습니다.</p><p>그리고 컨테이너와 Kubernetes 에 익숙하지 못한 서비스 개발자 분들도 고생 끝에 <br>단기간에 모든 서비스를 Kubernetes 로 이전 하시느라 많은 노력을 하셨습니다.</p><p>고생하신 모든 분들께 감사하다고 말씀드리고 싶습니다.</p><p>Kubernetes 인프라를 구축 하면서 삽질😂 끝에 알게된 노하우들도 해당 시리즈 블로그 외에도 다른 블로그 포스팅에서 하나하나 공유해 보도록 하겠습니다.</p><p>다음 포스팅은 <strong>PART 2 — Api-Gateway </strong>대해 포스팅 해보도록 하겠습니다.</p><p><strong>WATCHA</strong>에서는 다양한 기술들을 활용해 서비스를 지속적으로 개선, 발전시켜 갈 실력 있고 뜻있는 개발자들을 모집하고 있습니다. 관심있는 분은 <a href="https://watcha.team/"><strong>채용공고</strong></a>를 참고해주세요.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ac7193d04d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/watcha/watcha-k8s-%EC%A0%84%ED%99%98-part-1-3ac7193d04d7">WATCHA K8S 전환 -PART 1</a> was originally published in <a href="https://medium.com/watcha">WATCHA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WATCHA 푸시 서버 개선하기]]></title>
            <link>https://medium.com/watcha/watcha-%ED%91%B8%EC%8B%9C-%EC%84%9C%EB%B2%84-%EA%B0%9C%EC%84%A0%ED%95%98%EA%B8%B0-56070b73c287?source=rss-8762f94a1b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/56070b73c287</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Allan Bae]]></dc:creator>
            <pubDate>Fri, 04 Dec 2020 08:06:41 GMT</pubDate>
            <atom:updated>2021-03-03T05:43:29.959Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7cNbizlGd-XejxZ7-Xp3bA.png" /></figure><p>WATCHA 푸시 서버 개선 사례를 공유합니다.</p><h3>소개</h3><p>안녕하세요. <strong>WATCHA</strong>에서 서버 개발을 하고 있는 Allan 입니다.<br>이번 포스팅은 WATCHA 푸시 서버를 개선한 사례에 대해 이야기를 해보고자 합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nQ_lo5VTc-YZre1QxTBw-A.png" /><figcaption><strong>개선전 푸시 서버</strong></figcaption></figure><p>기존의 푸시 서버는 <a href="https://github.com/appleboy/gorush">GORUSH</a> 를 이용하여 왓챠, 왓챠피디아 각각 서비스 별로 <br>따로 프로세스를 띄워 구동되고 있었습니다.</p><p>당시에도 큰 무리가 없이 쓰고 있었지만, 아래와 같은 개선이 요구되었습니다.</p><h4>1. 푸시 발송에 관련된 로깅 및 분석</h4><p>기존 푸시 서버는 따로 로그를 남기고 분석하고 있지 않았습니다. 그래서<br><strong>어떤 유저에게 푸시를 전송했는지</strong>, <strong>푸시받은 유저 행동은 어떠한지 … 등 <br></strong>푸시 관련된 유저에 대한 행동 분석이 어려운 상황이었습니다.<br>이러한 까닭에 적절한 <strong>로그수집</strong> 과 유저 행동에 대한 <strong>trace</strong>가<strong> </strong>필요했습니다.</p><h4><strong>2. 푸시 발송 제어</strong></h4><p>기존 푸시 서버는 푸시 요청 오는 즉시 푸시를 발송하는 형태 입니다. <br><strong>이벤트성 푸시 경우와 같이 많은 푸시 요청이 푸시서버로 들어오는 경우</strong><br>푸시가 특정시간에 몰려서 유저들에게 전달되어 순간적으로 많은 트래픽이 <br>왓챠 또는 왓챠피디아 서비스로 유입되게 됩니다.</p><p>서버가 아주 넉넉히 유지 되는 상황에서는 큰 무리가 없을수도 있지만, <br>순간적으로 몰린 트래픽이 응답을 지연시키고 장애를 발생을 원인이 되곤 했습니다.<br>그래서 한번에 많은 푸시 발송전 미리 여유있게 서버를 증설해두거나, <br>푸시를 발송하는 <strong>각 서비스별 Client</strong>가 푸시 발송 지연 로직을 적용하여 푸시 서버로 발송을 요청하고 있었습니다.</p><p>이러한 불편함을 해결하기 위해서는 푸시서버가 <strong>발송 제어 로직 </strong>기반으로<br>푸시를 발송하여, 왓챠 또는 왓챠피디아 서비스 서버들이 적절히 <strong>Warming Up(Scale Out) </strong>되도록 하는것이 필요 했습니다.</p><h4>3. <strong>WebPush 와 같은 브라우저 푸시 및 커스텀 가능한 푸시 제공</strong></h4><p>좀더 세련된 형태의 푸시 메세지를 발송 할수 있고, 모바일 뿐만 아니라 웹(브라우저) 환경에서 많은 이용을 하고 있기 때문에, 웹(브라우저)환경에서 푸시 알림을 받을수 있도록 기능을 제공할 필요성이 있었습니다.</p><h4>4. 각 서비스별 CLIENT 들이 손쉽게 푸시 발송을 요청</h4><p>각 서비스별 Client<strong> </strong>에서<strong> </strong>사용하는 개발 언어에 상관 없이 쉽게 푸시를 발송할수 있고, 푸시 발송 스펙도 쉽게 이해하고, 활용할수 있는 구조가 필요 했습니다.</p><h4>5. <strong>서버 구조 변경 및 서버 지표 제공</strong></h4><p>기존 푸시 서버는 왓챠, 왓챠피디아 각각 푸시 서버를 서비스 별로 따로 띄워야 하고 트래픽 분산 및 <strong>Scale Out</strong> 이 되는 구조도 아니었습니다 .<br>게다가 실시간으로 서버 상태 및 푸시 발송수, 발송 성공, 발송 실패 … 등 유의미한 서버 지표를 매트릭으로 제공 할수 있는 기능도 제공하고 있지 않아서 운영 및 관리가 힘들 상황이었고, 개선이 필요 했습니다.</p><p>그래서 위와 같은 개선점을 적용한 신규 푸시 서버를 구축 하였습니다.<br>(프로젝트 이름은 <strong>HERA</strong> 이고 <a href="https://golang.org/"><strong>Golang</strong></a> 으로 구현되어 있습니다.)</p><h3>개선된 푸시 서버</h3><p>개선된 푸시 서버는 아래와 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nC7x-qmqV2fFyLieu87BIg.png" /><figcaption><strong>개선된 푸시 서버 구조</strong></figcaption></figure><h4><strong>[개선] 1. 푸시 발송에 관련된 로깅 및 분석</strong></h4><p>우선 <strong>IOS</strong> 는 APNS, <strong>Android </strong>는 FCM 을 이용하고 있는 구조에서 모든 디바이스가 <strong>FCM</strong>을 이용하는 형태로 변경하기로 했습니다.</p><p>모든 푸시 발송이 <strong>FCM</strong>(Firebase Cloud Messaging) 을 이용하게 되면 <br><strong>Firebase BigQuery Export</strong> 기능을 이용해서 푸시 발송 관련 로그들도 쉽게 BigQuery<strong> </strong>로 전송이 가능합니다.<br>게다가 기존 App들도 <strong>Firebase SDK </strong>를<strong> </strong>이용하고 있어, App에서도 푸시 관련 <br>이벤트 뿐만 아니라 다양한 이벤트들도 수집이 가능하여 <strong>푸시 발송 </strong>과 <strong>유저 행동</strong>에 대한 연관 분석이 가능합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3hGVq_Ra7bAO9r7kQJIPdw.png" /></figure><p>물론, 좀더 세밀한 분석을 위해서는 <strong>푸시 발송 성공유무</strong>, <strong>발송된 푸시 종류</strong>, <strong>타입 및 개별 유저에 대한 푸시를 식별하기 위한 MessageID</strong>…등 추가 정보가 필요했고, <br>추가적으로 푸시서버(<strong>Hera</strong>)에 발송시 필요 정보를 로그수집을 통하여 <strong>BigQuery</strong> 저장 하여 분석이 가능하도록 하였습니다.</p><p>푸시서버에서 로그수집은 이전에 포스팅 한 <a href="https://medium.com/watcha/%EB%A9%80%ED%8B%B0%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EB%A1%9C%EA%B7%B8-%EB%B6%84%EC%84%9D-%ED%94%8C%EB%9E%AB%ED%8F%BC-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-8c5f671df559"><strong>로그플랫폼</strong></a>을 통해 쉽게 수집하였습니다.</p><h4>[개선] 2. 푸시 발송 제어</h4><p>부하 분산을 위해 Client<strong> </strong>에서 발송제어(<strong>delay</strong>)를 하게 되면, Client 별 따로 발송제어 로직을 가지게 되어 관리 이슈가 생기고, 서비스 측면에서 발송제어가 어렵습니다. <br>(개별 <strong>Client</strong> 별 제어만 가능)</p><p>그래서 각 Client는 발송제어 없이 무조건 요청하고, 실제 발송을 담당하는 푸시서버(<strong>Hera</strong>) 에서 푸시 발송 <strong>Rate Limiter</strong> 를 구현해 적용하여 발송제어를 하도록 하였습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OiSGc6LdKwru9weggzsQ5w.png" /><figcaption><strong>개략적인 Rate Limiter 동작 방식</strong></figcaption></figure><p><strong>Rate Limiter</strong> 구현은 간단히 구현 할수 있는 Time Window 방식을 이용했습니다. <br>Time Window 은 분당 생성되며, 각 Time Window 마다 발송제어 Limit가 존재합니다.</p><p>여러 푸시서버에서 Time Window 을 공유하고(<strong>Redis</strong> 를 이용), 각 푸시서버에서 푸시발송시 현재 발송하는 시점에 해당 하는 Time Window를 가져와 현재 발송 Limit 에 도달 했는지 확인 한 후 발송 또는 지연을 하게 됩니다.</p><p>그리고 <a href="https://en.wikipedia.org/wiki/TCP_congestion_control"><strong>TCP Congestion Control Policy</strong></a><strong>(</strong>Tahoe, Reno … 등)와 같이 <strong>Slow Start</strong> 방식을 이용해, 특정 기간동안 발송 내역을 참고하여 발송 Limit 를<strong> 주기적으로 재조절 하는 로직</strong>을<strong> </strong>적용하여 Limit를 적절히 <strong>늘리거나 줄여서 </strong>발송 제어를 하게 됩니다.</p><p>Limit 에 도달 하여 발송 제한 되어 Pending 된 푸시 요청은 <strong>AWS SQS</strong>에 저장되어 추후 자동으로 발송되게 됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c7WvnhT_GS38apwgKAsw7A.png" /><figcaption><strong>푸시 발송 브로커 구조</strong></figcaption></figure><p>전반적인 푸시 발송 구조는 위 그림 처럼 Broker들이 처리 하도록 구현되어 있습니다. <br>각 푸시 요청은 메인 <strong>Broker</strong> 의 <strong>Queue</strong>에 들어가게 되고, Rate Limiter 의해서 <br>발송 가능 상태면 <strong>FCM Broker</strong> 로, 발송 지연 상태이면 <strong>SQS Broker </strong>로 가게 됩니다.</p><p>FCM Broker 로 전송된 메시지는 FCM을 통한 푸시 발송이 이뤄지고, SQS Broker 로 전송된 메시지는 SQS 에 enqueue 되고, 추후 발송이 이뤄지게 됩니다.</p><h4>[개선] 3. WebPush 와 같은 브라우저 푸시 및 커스텀 가능한 푸시 제공</h4><p>푸시서버(<strong>Hera</strong>)는 FCM 이 지원하는 WebPush 뿐 만아니라 커스텀 형태로 <br>푸시메시지 전송 가능하도록 FCM 이 지원하는 API 및 구조를 그대로 포팅해서 구현되어 있습니다. <br>따라서<strong> </strong><a href="https://firebase.google.com/docs/reference/fcm/rest/v1/projects.messages"><strong>FCM V1 API</strong></a> 에서 제공하는 기능을 대부분 지원 하도록 구현 되어 있습니다.</p><h4>[개선] 4. 각 서비스별 CLIENT 들이 손쉽게 푸시 발송을 요청</h4><p>푸시서버(<strong>Hera</strong>)는 <strong>GRPC</strong> 기반으로 만들어져 있어서, 각 Client 가 이용하는 언어 따라 쉽게 사용할수 있도록 라이브러리 형태로 제공하고 있어서, 손쉽게 원하는 push가 전송가능하도록 되어 있습니다.</p><h4>[개선] 5. 서버 구조 변경 및 서버 지표 제공</h4><p>각 서비스 별 푸시 서버를 따로 띄우지 않고, 통합된 푸시 서버로 구현하여<br>서비스 상관 없이 해당 서비스에 대한 푸시를 발송이 가능합니다.</p><p>확장성 및 관리 측면 효율적으로 하기 위해서, <a href="https://docs.aws.amazon.com/ko_kr/elasticbeanstalk/latest/dg/create_deploy_docker_ecs.html">AWS Elastic Beanstalk With ECS</a><strong> </strong>기반의 Multi Container를 이용해서 운영하고 있습니다.</p><p>그리고 실시간으로 현재 <strong>Rate Limiter limit 값, Pending 된 푸시 메시지 수, <br>푸시 발송수(성공, 실패), 각종 서버 상태</strong> …등을 모니터링 하기 위해서 Prometheus Metric Exporter를 구현하고 모니터링 플랫폼을 통해 수집하고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U5EMTA4buDSW0O2hb3XeoQ.png" /><figcaption><strong>Metric 수집</strong></figcaption></figure><p>이전에 포스팅한 <a href="https://medium.com/watcha/%EB%A9%80%ED%8B%B0%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EB%A1%9C%EA%B7%B8-%EB%B6%84%EC%84%9D-%ED%94%8C%EB%9E%AB%ED%8F%BC-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-8c5f671df559"><strong>로그플랫폼</strong></a>에서 제공하는 <strong>모니터링 플랫폼</strong>을 이용하여, 각 서버의 매트릭들을 수집 하고 있습니다.</p><h3>결론</h3><p>푸시 서버 개선에 대한 과정을 간략히 공유해 보았습니다.</p><p>로그수집을 통한 분석이 용이하게 하며, 각 서비스별로 발송 제어를 하여 각 서비스들이 큰 부담을 주지 않도록 개선하며, 확장성 및 관리 편리하도록 구조 변경 및 모니터링을 지원하고, 각 Client 들이 쉽게 사용할수 있도록 개선해 보았습니다.</p><p>물론 아직 미흡하고, 고민해볼 포인트가 많아 지속적으로 개선할 예정입니다.</p><p>긴 글 읽어주셔서 감사합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56070b73c287" width="1" height="1" alt=""><hr><p><a href="https://medium.com/watcha/watcha-%ED%91%B8%EC%8B%9C-%EC%84%9C%EB%B2%84-%EA%B0%9C%EC%84%A0%ED%95%98%EA%B8%B0-56070b73c287">WATCHA 푸시 서버 개선하기</a> was originally published in <a href="https://medium.com/watcha">WATCHA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduce Hits: Easy Way to Show View Count in Github]]></title>
            <link>https://medium.com/@gjbae1212/introduce-hits-easy-way-to-show-view-count-in-your-page-7987cb4abede?source=rss-8762f94a1b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7987cb4abede</guid>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[badges]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Allan Bae]]></dc:creator>
            <pubDate>Sat, 12 Sep 2020 01:16:37 GMT</pubDate>
            <atom:updated>2020-09-17T15:04:56.258Z</atom:updated>
            <content:encoded><![CDATA[<p>How to know and show view count in your Github, Notion, Website .. and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W0mlub_xIboJUEqeyT0GCA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@kellysikkema?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Kelly Sikkema</a> on <a href="https://unsplash.com/s/photos/page?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3><strong>OVERVIEW</strong></h3><p>Hello Friends.</p><p>I have worked developer over the past decade, personally working open sources using Github.</p><p>By working open sources using Github, I feel like to need somethings such as <strong>tracing page view count</strong>, <strong>visualizing</strong> it.</p><p>You can find various ways of presenting, but I would like to <strong>badge</strong>, such as <a href="https://shields.io/"><strong>https://shields.io</strong></a> looks excellent and fantastic.</p><p>Of course, similar solutions exist, but I don’t find it supported features below.</p><ul><li>Support <strong>daily</strong> and <strong>total</strong> view count.</li><li>Support <strong>customize style badge</strong> such as change color, logo, text …</li><li>Use it in <strong>everything</strong> such as <strong>Github</strong>, <strong>Notion</strong> …</li></ul><p>So I built Badge Service, which supports its features, so that can use it for everyone.</p><h4><strong>TL;DR</strong></h4><p>This service is running to <a href="https://hits.seeyoufarm.com/"><strong>it</strong></a> and Github is <a href="https://github.com/gjbae1212/hit-counter"><strong>here</strong></a></p><h3><strong>HOW TO USE</strong></h3><p>Set the Target URL you want to count page view, Options for Badge. <br>It’s very easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MtAtDnRA_w2NzbYeCPZu1A.png" /><figcaption><a href="https://hits.seeyoufarm.com/">Generate your badge!</a></figcaption></figure><ol><li><strong>Insert to Target URL</strong> which you want to count page view, such as Github Profile, Github Project, Notion, and so on.</li><li><strong>Make custom your style Badge</strong> changing icon, text, color, and so on. <br>badge style applied is showing under OPTIONS text in real-time.</li><li>If you like it, <strong>Copy MarkDown or HTML Link</strong>, which you want to format that clicks copy button.</li><li><strong>Apply it</strong> which you copied to <strong>Github Profile, Project, Notion</strong>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9RaJcPwInj65vS2m8nxB5g.png" /><figcaption><a href="https://hits.seeyoufarm.com/">Copy your badge!</a></figcaption></figure><blockquote><em>Want to read this story later? Save it in </em><a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=blog&amp;utm_campaign=noteworthy&amp;utm_content=eid7"><em>Journal</em></a><em>.</em></blockquote><h3><strong>Add-Ons</strong></h3><p>You can look <strong>daily view counting</strong> <strong>graph</strong> for six months that you have used a badge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7vVeDxLY7XephR5QDb6QzA.png" /><figcaption><a href="https://hits.seeyoufarm.com/">Show your badge history</a></figcaption></figure><p>Now, many people have been used it, such as Github profile, Github Project, Notion, Site, Etc, and such active histories <strong>can look in the stream.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FjM-OwLP0cpyTJsHd81BmQ.png" /></figure><h3><strong>Conclusion</strong></h3><p>This service is serving <a href="https://hits.seeyoufarm.com/"><strong>https://hits.seeyoufarm.com</strong></a> and Github is <a href="https://github.com/gjbae1212/hit-counter"><strong>https://github.com/gjbae1212/hit-counter</strong></a>.</p><p>Consistently<strong>, </strong>we will update it so that you have only to enjoy it.</p><p><strong>Thank you.</strong></p><p>📝 Save this story in <a href="https://usejournal.com/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_read_later_text">Journal</a>.</p><p>👩‍💻 Wake up every Sunday morning to the week’s most noteworthy stories in Tech waiting in your inbox. <a href="https://usejournal.com/newsletter/noteworthy-in-tech/?utm_source=medium.com&amp;utm_medium=noteworthy_blog&amp;utm_campaign=tech&amp;utm_content=guest_post_text">Read the Noteworthy in Tech newsletter</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7987cb4abede" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WATCHA 사내 VPN 개발하기]]></title>
            <link>https://medium.com/watcha/watcha-%EC%82%AC%EB%82%B4-vpn-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-e04f946d3ccb?source=rss-8762f94a1b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e04f946d3ccb</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[vpn]]></category>
            <dc:creator><![CDATA[Allan Bae]]></dc:creator>
            <pubDate>Fri, 29 May 2020 09:04:46 GMT</pubDate>
            <atom:updated>2020-06-05T10:00:37.884Z</atom:updated>
            <content:encoded><![CDATA[<p>Google OAuth, AWS IAM 이용한 인증으로 접속할수 있는 VPN 개발</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UB-5yNFH8qTKqZaDnjqf-A.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@lagopett?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Petter Lagson</a> on <a href="https://unsplash.com/@lagopett?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>소개</h3><p>안녕하세요. <strong>WATCHA</strong>에서 서버 개발을 하고 있는 Allan 입니다.<br>이번 포스팅은 이전 <a href="https://medium.com/watcha/watcha-%EC%84%9C%EB%B2%84-%EC%A0%91%EC%86%8D%EC%9D%84-%EC%9C%84%ED%95%9C-cli-%EC%99%80-ssh-%EC%9D%B8%EC%A6%9D%EC%84%9C%EB%B2%84-%EC%86%8C%EA%B0%9C-264cc31f411a"><strong>포스팅</strong></a>에 이어서 WATCHA 에서 사내 <strong>VPN</strong> 서버 개발에 대해서<br>이야기 해보자 합니다.</p><p>최근들어 많은 IT 회사들이 <strong>COVID-19</strong> 영향으로 재택근무 늘면서 원격근무를 위한 <strong>TOOL</strong> 필요성이 대두 되었습니다.</p><p><strong>WATCHA</strong>에서도 재택근무, 그리고 자율출퇴근제(+시차출퇴근제)를 운영하면서 새로운 이슈들이 생겼는데, <br>특히 사내 오피스에서만 접근되던 사이트 와 리소스들을 <strong>재택근무</strong>시에는 이용 할 수 없어 업무에 차질이 발생하고, 필요시에는 일시적으로 접근을 허용 또는 제한 하면서 관리 와 보안 측면에서 리스크가 발생할 수 있는 상황이었습니다.</p><h3>How About VPN?</h3><p>이러한 문제를<strong> </strong>해결할수 있는 방법으로,</p><p><strong>WATCHA</strong> 직원들은 본인 인증을 한후에 <strong>VPN</strong>을 연결해서 재택시에도 제한된 리소스를 접근 할 수 있도록 하는 것이좋겠다고 생각했습니다.</p><p>그래서 <strong>WATCHA</strong>에 적합한 <strong>상용 VPN</strong>을 모색해 봤으나, 몇가지 불편한 점이 있었습니다:</p><ul><li><strong>인증 : </strong>일반적인 상용 VPN은 LDAP 과 같은 별도의<strong> </strong>계정 관리 시스템<strong> </strong>또는<strong> </strong>설정파일(KEY<strong> </strong>공유) 같은 인증을 지원합니다. VPN 만을 위해 별도의 계정 관리 시스템이나 LDAP을<strong> </strong>구축하기에는 운영 및 관리이슈가 크고, 설정파일(KEY 공유)을 하기에는 보안 측면에서 리스크가 있어, <strong>WATCHA </strong>실상에는 맞지 않는 걸로 판단하였습니다.</li><li><strong>모니터링 및 관리: </strong>보안<strong> </strong>측면에서 이상징후 추적 및 모니터링, 사용자가 늘거나 트래픽이 증가할때 서버가 Auto Scaling 하는 등 관리 측면에서 적합한 솔루션을 찾기 힘들었습니다.</li></ul><p>그리하여 <strong>모니터링</strong>에 용이하고, <strong>확장성</strong>이 있고 개발자들은 기존에 사용하는 <strong>AWS</strong> IAM, 비 개발자들은 사내 <strong>Google</strong> 계정(<strong>G Suite</strong>)을 통한 OAuth 인증을 이용 할 수 있는 <strong>VPN 서버 및 클라이언트</strong> 를 개발했습니다. (<a href="https://golang.org/"><strong>Golang</strong></a> 으로 개발)</p><h3>What Protocol To Use For VPN?</h3><p>VPN 에는 다양한 프로토콜이 존재합니다. (L2TP, SSTP, OPENVPN …)</p><p>그중에서 <strong>OPENVPN</strong> 와 같이 <strong>SSL/TLS 채널</strong>을 이용한 VPN 연결이 안정적이면서 구성이 편하고, 방화벽도 쉽게 통과 하는 걸로 판단하여 이를 활용하기로 하였습니다.</p><p>SSL/TLS 채널 위에서 여러개의 인증을 지원하고, 클라이언트와 서버간의 패킷을 주고 받기 위해서는 클라이언트 와 서버 간의 약속, 즉 <strong>Protocol </strong>을<strong> </strong>정의<strong> </strong>해야합니다.<br><strong> <br></strong>그리고 다양한 인증을 쉽게 추가 할려면 <strong>인증 </strong>과 <strong>VPN 연결 및 패킷 교환</strong>이<strong> </strong>명확하게 <br>구별 될 필요성이 있다고 판단하여 최종적으로 <strong>GRPC</strong>를 이용하기로 결정하였습니다.</p><p><a href="https://grpc.io/"><strong>GRPC</strong></a><strong> </strong>를 이용하면 <strong>HTTP 2.0</strong> + <strong>SSL/TLS</strong> 로 생성된 채널을 통해 <strong>인증 부분</strong> 과 <br><strong>VPN 연결 및 패킷 교환</strong> 부분을 RPC로 명확하게 구별할수 있다고 생각했고,<br>특히<strong> </strong>VPN 연결 및 패킷 교환<strong> </strong>부분은 특히<strong> GRPC Stream</strong>을 이용하여 전반적으로 구현이 쉬울 것이라 생각 했습니다.</p><h3>인증 부분</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lnIrDHFiPXcy5PMD7xIU9Q.png" /><figcaption><strong>인증 부분</strong></figcaption></figure><p>인증 부분은 위의 그림과 같습니다.<br>AWS IAM, 구글 계정을 통해 WATCHA 에서 사용이 가능한 유저 인지 확인 되면 <a href="https://jwt.io/"><strong>JWT</strong></a><strong> </strong>토큰을 발행합니다.</p><p>JWT<strong> </strong>토큰에는 발행일, 사용자, 시간제한 … 등 같은 정보를 포함하고 있으며, <br>VPN 연결시 해당 JWT 토큰 유효성 확인 절차를 거쳐서 연결을 유지합니다.</p><p>JWT 토큰을 이용한 이유는 <strong>인증 부분</strong> 과 <strong>VPN 연결 </strong>부분에 대해 서로 의존성 제거하기 위해서 VPN 연결시 참고 할 데이터를 JWT에 정보를 담을수 있고, 서명(Hashing)하여서 변조 및 위조에도 안전하다고 판단해 이용하게 되었습니다. <br>(다른 인증을 추가 시에도 큰 변화 없이 손쉽게 적용 가능합니다.)</p><p>AWS 인증 같은 경우에는 AWS KEY 로 통해 해당 유저가 허용된 AWS 계정이 맞는지, 권한이 있는지 … 등을 확인 후 JWT 토큰을 발급해 줍니다.</p><p>Google 인증의 경우에는 브라우저에서 사용자 WATCHA 구글 계정으로 로그인하게 되면 Google OAuth을 통하여 사용자 및 권한 확인후에 JWT 토큰을 발급해 줍니다.</p><h3>VPN 연결 및 패킷 교환 부분</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7mjgWNzrfqbE5twuiBWm6A.png" /><figcaption><strong>VPN 연결 및 패킷 교환</strong></figcaption></figure><p>VPN 연결 및 패킷 교환 부분은 위의 그림과 같습니다.</p><p>인증과정에서 할당 받은 JWT 토큰을 VPN 서버에 전달하면 서버는 JWT 토큰 검증후 클라이언트에게 할당할 VPN IP, VPN GATEWAY 설정 …등 VPN 연결에 필요한 네트워크 설정을 내려줍니다.</p><p>클라이언트는 <a href="https://en.wikipedia.org/wiki/TUN/TAP"><strong>TUN</strong></a>(가상디바이스) 및 <strong>네트워크 설정</strong>후 VPN 연결이 이뤄지고 <br><strong>GRPC Stream</strong> 을 통하여 패킷을 송수신이 이뤄지게 됩니다.</p><blockquote><strong>TAP/TUN 및 네트워크 설정 부분</strong>은 Network 디바이스, 패킷필터(Iptables) … 등 <strong>Low </strong>레벨에 대한<strong> </strong>깊은 이해와 방대한 설명이 필요 하여 해당 포스트에서는 다루지 않겠습니다. 🙏🏻</blockquote><p>클라이언트 와 서버간에 VPN 연결이 이뤄진후 순간적인 네트워크 이슈로 순단이 일어나더라도, <strong>Exponential Backoff </strong>적용되어 있어 자동으로 간격을 두며 재 연결을 시도를 하며 이용중에 JWT 토큰이 만료 되면 자동으로 VPN 연결을 종료하도록 되어 있습니다.</p><p>그리고 이상징후 및 모니터링을 위해서 <br>필요한 로그도 남길수 있어 <a href="https://aws.amazon.com/en/cloudwatch/"><strong>CloudWatch</strong></a><strong> </strong>를 이용한 분석도 가능합니다.</p><blockquote><strong>참고</strong> <br><strong>TUN</strong>을 이용하기 때문에<strong> OSI 7계층 </strong>중<strong> Network Layer </strong>상위 계층 이상은 <br>로깅 및 분석이 가능합니다.</blockquote><h3>전체 구조</h3><p>VPN 서버 및 클라이언트 전체 구성은 아래와 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lnWX9BRJcEWKjlDZKAp-2Q.png" /><figcaption><strong>전체 구조</strong></figcaption></figure><p>직군에 따라 필요한 리소스가 다르다고 판단하여 <a href="https://docs.aws.amazon.com/vpc/latest/userguide/VPC_SecurityGroups.html"><strong>Security Group</strong></a>을 이용하여 접근 허용 범위가 다른 개발자용 VPN 과 비 개발자용 VPN 따로 운영하고 있습니다.<br>개발자용 VPN은 AWS 이용한 인증을 하고 있고, 비 개발자용 VPN은 사내 구글 계정을 이용한 인증을 지원 하고 있습니다.</p><p>VPN 서버는 <a href="https://aws.amazon.com/elasticbeanstalk/?nc1=h_ls"><strong>Elastic Beanstalk</strong></a><strong> </strong>로 운영하고 있고 상황에 따라 <strong>Auto Scaling</strong> 가능합니다. (사용자 수 와 트래픽 사용량에 따라 유연한 확장이 가능합니다.)</p><p><a href="https://aws.amazon.com/cloudwatch/?nc1=h_ls"><strong>CloudWatch</strong></a>를 사용하여 로그인한 유저, 발생된 트래픽양 … 등 로그 등의 취합하여, 이상징후 판단 및 모니터링에 활용하고 있습니다.</p><h3>배포</h3><p>개발자용 클라이언트 와 비 개발자용 클라이언트 따로 사내에 배포 되고 있습니다.</p><p><strong>개발자용 클라이언트</strong></p><ul><li>개발자들이 친숙한 <strong>CLI TOOL</strong>로 통하여 손쉽게 VPN 을 키고 끌수 있습니다.</li><li>개발자들은 다들 맥북을 이용하고 있어, 사내 Private HomeBrew Repository 를 통하여 손쉽게 설치 및 업그레이드가 가능합니다.</li></ul><p><strong>비개발자용 클라이언트</strong></p><ul><li>개발자가 아닌 직군들은 CLI 가 익숙하지 않고 접근이 쉽지 않은 상황이라고 판단하여 <a href="https://www.electronjs.org/"><strong>Electron</strong></a><strong> </strong>같은 데스크탑 앱으로 만들어서 쉬운 UI로 접근할수 있습니다.</li><li><strong>DMG</strong> 파일로 배포 하고 있습니다.</li></ul><h3>결론</h3><p>지금까지 <strong>WATCHA</strong> <strong>사내 VPN</strong>에 대해서 공유해 보았습니다.</p><p><strong>WATCHA VPN</strong>은 다양한 인증 방식을 통해서 손쉽게 접근을 할 수 있고,<br>직군에 따라 접근 리소스를 제한 하여 효율적으로 VPN 을 관리 할수 있습니다.<br>게다가 상황에 따라 <strong>Auto Scaling</strong> 하여 사용량 증가에 따른 VPN 서버 증설 및 관리에 대한 이슈가 적으며, 이상징후에 대한 모니터링도 가능합니다.</p><p><strong>COVID-19 </strong>인한 재택근무에 필요한 기술들이 요즘 부각되고 있는데, 해당 포스트가 조금이라도 도움이 되었으면 좋겠습니다. <br>(VPN 일부 구현체를 🤘🏻<a href="https://github.com/gjbae1212/grpc-vpn"><strong>이곳</strong></a>🤘🏻에서 오픈소스로 제공하고 있습니다.)</p><blockquote>해당 VPN 은 <strong>WATCHA</strong> 내의 <strong>짬데이</strong>라는 개발 문화 와 약간의 업무시간을 할애 하여 개발 했습니다. <strong>짬데이</strong>가 궁금하시다면 <a href="https://team.watcha.com/joinus/"><strong>채용공고</strong></a><strong> </strong>를 통해<strong> </strong>입사해서 알아보는걸로 😈</blockquote><p><strong>WATCHA</strong>에서는 다양한 기술들을 활용해 서비스를 지속적으로 개선, 발전시켜 갈 실력 있고 뜻있는 개발자들을 모집하고 있습니다. 관심있는 분은 <a href="https://team.watcha.com/joinus/"><strong>채용공고</strong></a>를 참고해주세요.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e04f946d3ccb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/watcha/watcha-%EC%82%AC%EB%82%B4-vpn-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-e04f946d3ccb">WATCHA 사내 VPN 개발하기</a> was originally published in <a href="https://medium.com/watcha">WATCHA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WATCHA 서버 접속을 위한 CLI 와 SSH 인증서버 소개]]></title>
            <link>https://medium.com/watcha/watcha-%EC%84%9C%EB%B2%84-%EC%A0%91%EC%86%8D%EC%9D%84-%EC%9C%84%ED%95%9C-cli-%EC%99%80-ssh-%EC%9D%B8%EC%A6%9D%EC%84%9C%EB%B2%84-%EC%86%8C%EA%B0%9C-264cc31f411a?source=rss-8762f94a1b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/264cc31f411a</guid>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Allan Bae]]></dc:creator>
            <pubDate>Tue, 31 Mar 2020 01:14:20 GMT</pubDate>
            <atom:updated>2020-03-31T04:55:48.499Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ciewr0R0nuy7ZqIHyAWRjw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@sandym10?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Sandy Millar</a> on <a href="https://unsplash.com/s/photos/connect?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>소개</h3><p>안녕하세요. <strong>WATCHA</strong>에서 서버 개발을 하고 있는 Allan 입니다.<br>이번 포스팅은 이전 <a href="https://medium.com/watcha/watcha-play-%EC%84%9C%EB%B9%84%EC%8A%A4-msa-%EC%A0%81%EC%9A%A9%ED%95%98%EA%B8%B0-31e06fe039a0"><strong>포스팅</strong></a>에 이어서 WATCHA 에서 AWS 서버에 접속하는 방법에 대해서 이야기 해보고자 합니다.</p><p>현재 WATCHA에서는 <strong>3가지 </strong>방법을 이용해서 서버에 접속하고 있습니다.</p><ul><li>AWS Systems Manager(<strong>SSM</strong>) <a href="https://aws.amazon.com/ko/blogs/korea/new-session-manager/"><strong>Session Manager</strong></a></li><li><strong>SSH(</strong>WITH SSH 인증서버<strong>)</strong></li><li>AWS Systems Manager(<strong>SSM</strong>) <strong>Session Manager </strong>를<strong> </strong>통한<strong> SSH(</strong>With SSH 인증서버<strong>)</strong></li></ul><p>위 방법을 이용하는 방식은 내부적으로 개발된 <strong>CLI</strong>(<strong>allakey</strong>) 와 <strong>SSH 인증서버</strong>(<strong>bintang</strong>)로 편리하게 이용할 수 있으며, 해당 프로그램은 <a href="https://golang.org/"><strong>Golang</strong></a>으로 개발되어 있습니다. (<strong>allakey</strong>, <strong>bintang</strong> 은 내부 프로젝트 명입니다.)</p><p>그럼 3가지 방법에 대해 하나씩 설명해 보도록 하겠습니다.</p><h3>1. AWS Systems Manager(SSM) Session Manager</h3><p><a href="https://aws.amazon.com/ko/blogs/korea/new-session-manager/"><strong>SSM Session Manager</strong></a>는 EC2에 설치된 <a href="https://docs.aws.amazon.com/ko_kr/systems-manager/latest/userguide/ssm-agent.html"><strong>SSM Agent</strong></a>를 통하여 암호화된 연결을 통하여 Interactive Shell 을 제공하는 방식입니다.</p><p>해당 방식을 이용하게 되면 SSH 키 설정 및 SSH 포트를 오픈 하지 않고도 이용할수 있어 조금 더 보안측면에서 좋습니다.</p><p>또한 IAM을 이용한 권한 관리로 접근 제어가 가능하며, 실행된 명령어 및 응답들도 S3 버킷에 로깅으로 남아서 <strong>보안 및 추적 </strong>용으로도 좋습니다.</p><p>접속 방식은<strong> 브라우저</strong>에서<strong> AWS Console </strong>또는 <strong>터미널</strong>에서 <strong>AWS CLI</strong> + <strong>SSM</strong> 플러그인을 통하여 터미널에서 접속이 가능합니다.</p><p>개발자의 경우에는 터미널을 많이 이용하는데, 이 때 외우기 힘든 <strong>실행 명령어</strong> 와 EC2<strong> InstanceID</strong>를 알아야만 접근할 수 있어서 굉장히 불편합니다.</p><p>그래서 내부에서 개발한 <strong>CLI</strong>(<strong>allakey)</strong>를 통하여 간단한 명령어로 터미널 Interactive UI 를 실행시켜, 쉽게 서버를 선택하고 접속할 수 있도록 하고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DH5yaWEy18udpcFYplEDZA.png" /><figcaption><strong>allakey를 이용한 ssm 접속</strong></figcaption></figure><h3><strong>2. SSH(</strong>WITH SSH 인증서버<strong>)</strong></h3><p>이 방식은 <strong>OPENSSH</strong> 5.4 이후 부터 지원하는 <a href="https://www.openssh.com/txt/release-5.4"><strong>SSH Certificates</strong></a>를 이용하여 <strong>CA</strong>(Certificate Authority)를 통해 서명한 SSH Public Key를 이용해서 접속하는 방식입니다. (쉽게 설명하면, SSL(TLS) 인증서 방식을 생각하시면 됩니다.)</p><p>이 방식을 이용하게 되면, <strong>서버 유저(ec2-user, ubuntu … 등)</strong>, <strong>시간제한</strong>(예: 1시간, 6시간, 1일) 등을 서명 시 적용하여 SSH 접속을 제한할수 있습니다.</p><p>해당 방식을 이용한 SSH 접속 방식은 <a href="https://engineering.fb.com/security/scalable-and-secure-access-with-ssh/"><strong>Facebook</strong></a>, <a href="https://medium.com/uber-security-privacy/introducing-the-uber-ssh-certificate-authority-4f840839c5cc"><strong>Uber</strong></a><strong>, </strong><a href="https://medium.com/swlh/run-netflix-bless-ssh-certificate-authority-in-aws-lambda-f507a620e42"><strong>Netflix</strong></a><strong> </strong>등<strong> </strong>규모가 큰 회사들도 SSH 키 권한 관리를 위해 활용하고 있습니다.</p><p><strong>WATCHA</strong>에서는 <strong>CLI</strong>(<strong>allakey)</strong>를<strong> </strong>이용하여 요청한 개발자의 <strong>AWS IAM</strong> <strong>유저</strong> <strong>권한</strong> 및 <strong>그룹</strong>을 체크한후, <strong>유저 권한</strong>(ec2-user, ubuntu … 등)과 <strong>시간제한</strong>(1시간, 1일 … 등 )이 적용된 <strong>SSH Certification </strong>을<strong> </strong>발급해주는 <strong>SSH 인증서버(bintang)</strong>를 운영하고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wJSzfypO1cuU2Ta3WZ9K0Q.png" /><figcaption><strong>allakey 와 SSH 인증서버(bintang) 이용한 SSH 접속</strong></figcaption></figure><p><strong>CLI(allakey)</strong>를<strong> </strong>이용하여 <strong>SSH 인증서버(bintang)</strong>에 요청하면, 요청 유저 AWS 권한을 체크한 후 시간제한 및 권한이 적용된 SSH 인증서와 키를 발급해주고 자동으로 로컬 PC의 <strong>ssh-agent</strong> 에 등록하게 됩니다. <br>그래서 따로 SSH Key 파일 인자를 넘겨줄 필요 없이 편하게 SSH 접속을 할 수 있습니다.</p><h3>3. AWS Systems Manager(<strong>SSM</strong>) <strong>Session Manager를 </strong>통한<strong> SSH(</strong>With SSH 인증서버<strong>)</strong></h3><p>이 방식은 위 1번과 2번 방식을 동시에 이용한 방법입니다.<br>해당 방식을 이용하면 아래와 같은 장점이 있습니다:</p><ul><li><strong>SSH 포트(22)를 외부에 오픈 하지 않아도</strong> SSH 이용이 가능하여 보안 향상<br>(SSM Session Manager 보안 채널을 Proxy로 이용한 SSH 접속)</li><li>SSM Session Manager에서는 사용할 수 없는 <strong>SCP 를 이용 가능</strong></li><li>SSH만 이용했을때 쉽지 않은 <strong>추적 및 로깅이 가능</strong></li></ul><p><strong>WATCHA</strong>에서는 <strong>CLI</strong>(<strong>allakey)</strong>를<strong> </strong>이용하여 <strong>SSH Certification</strong>을<strong> </strong>발급 받은 후, <br><strong>CLI</strong>(<strong>allakey)</strong>를<strong> </strong>이용하여 SSM Session Manager를 통한 <strong>SSH</strong> 또는 <strong>SCP</strong>를 손쉽게 이용할수 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B2PHewzMIgmJrL_IkpPJJQ.png" /><figcaption><strong>allakey를 이용한 SSM Session Manager를 통한 SSH 연결</strong></figcaption></figure><h3>결론</h3><p><strong>WATCHA</strong>에서는 주로 1. <strong>SSM Session Manager </strong>와<strong> 3. SSM Session Manager를 통한 SSH </strong>방식을 활용하고 있습니다.</p><p>SSH 포트를 외부에 오픈하거나 동일한 SSH KEY 를 여러 사람에게 공유하게 되면 보안이 취약해 질 수 있어 지양하고 있습니다.</p><p>그래서 위 방식(<strong>1번, 3번</strong>)과 <strong>CLI</strong>(<strong>allakey)</strong>를 이용하게 되면 보안측면에서도 안전하며 손쉽게 서버에 접근이 가능합니다. <br>게다가 요즘과 같은 <strong>COVID-19 확산에 따른 재택근무 전환 </strong>시에도 보안 이슈 없이 사무실과 동일한 환경으로 접속이 가능합니다.</p><p><strong>SSM Session Manager</strong>를<strong> </strong>이용하는 일부 기능을 <a href="https://github.com/gjbae1212/gossm"><strong>이곳</strong></a>에서 오픈소스로 제공하고 있으며,<br>추후 SSH 인증서버와 클라이언트도 오픈소스로 제공해 보도록 하겠습니다.</p><p><strong>다음 포스팅</strong>은 <strong>COVID-19 확산에 따른 재택근무</strong>를 위해 개발한 <strong>WATCHA</strong> <strong>VPN 서버</strong>에 대해 포스팅 해보도록 하겠습니다.</p><p>긴 글 읽어 주셔서 감사합니다.</p><p><strong>WATCHA</strong>에서는 다양한 기술들을 활용해 서비스를 지속적으로 개선, 발전시켜 갈 실력 있고 뜻있는 개발자들을 모집하고 있습니다. 관심있는 분은 <a href="https://team.watcha.com/joinus/"><strong>채용공고</strong></a>를 참고해주세요.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=264cc31f411a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/watcha/watcha-%EC%84%9C%EB%B2%84-%EC%A0%91%EC%86%8D%EC%9D%84-%EC%9C%84%ED%95%9C-cli-%EC%99%80-ssh-%EC%9D%B8%EC%A6%9D%EC%84%9C%EB%B2%84-%EC%86%8C%EA%B0%9C-264cc31f411a">WATCHA 서버 접속을 위한 CLI 와 SSH 인증서버 소개</a> was originally published in <a href="https://medium.com/watcha">WATCHA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Search for Many Repositories You Have Starred in Github Quickly]]></title>
            <link>https://medium.com/@gjbae1212/how-to-search-for-many-repositories-you-have-starred-in-github-quickly-1cabc8cd0525?source=rss-8762f94a1b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1cabc8cd0525</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[developer]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Allan Bae]]></dc:creator>
            <pubDate>Fri, 28 Feb 2020 15:47:06 GMT</pubDate>
            <atom:updated>2020-02-28T15:49:17.827Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a useful tool to search from README, topics, etc for wanted repositories quickly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X8qFaxyyMKtBATQdl_fKWA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@saeedanathema?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">saeed mhmdi</a> on <a href="https://unsplash.com/s/photos/search?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>I have starred useful repositories in Github for using it in the future.<br>As time went on, I was stacked many starred repositories, but I was frustrated when open Github Site for searching it.</p><p>I wanted to search text from <strong>README</strong>, but Github Site didn’t support it.<br>So I should have searched repositories one by one.</p><p>Eventually, I have made an interactive CLI that searches from README, Name, Topics for wanted repositories quickly.</p><p>This tool is <strong>FindGS</strong>, You can see it on <a href="https://github.com/gjbae1212/findgs">Github</a>.</p><h3>What is FindGS?</h3><p>FindGS is an interactive CLI tool to support such as Mac, Linux, Window.</p><p>This tool is to need your <a href="https://github.com/settings/tokens">Github personal token</a> to be able to get your starred repositories information.</p><p>For searching with higher performance, It makes caching and indexing files to a local machine. But it would slow it boots somewhat for caching and indexing if the first run it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TUnT2IQ_ol2Hw25wOLXODg.png" /><figcaption>Screenshot of FindGS</figcaption></figure><p><strong>After CLI is running, you can use to main features following:</strong></p><ul><li><strong>search: <br></strong>This command supports <strong>general full-text</strong> searching and <strong>wildcard full-text</strong> searching. It’s to show searched repositories based on a <strong>score</strong>.<br>You can search repositories having equal to or higher than the applied score. Of course, this score is changed using the <strong>score</strong> command.</li><li><strong>open:<br></strong>This command can <strong>open</strong> one of the recently searched repositories to <strong>Web Browser</strong>.</li><li><strong>list:<br></strong>This command can show recently searched repositories.</li><li><strong>score</strong>:<br>This command can change a <strong>score</strong>. <br>Applied score appears <strong>left position</strong> in the command line.</li><li><strong>exit:<br></strong>This command can exit <strong>FindGS</strong>.</li></ul><p>If you want to delete all of the cached files, calling “<strong>findgs clear” </strong>in terminal.</p><p>You can see all the information like installation and execution in <a href="https://github.com/gjbae1212/findgs">Github</a>.<br>I hope this tool helps someone needed.</p><p>Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1cabc8cd0525" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[WATCHA PLAY 서비스 MSA 적용하기]]></title>
            <link>https://medium.com/watcha/watcha-play-%EC%84%9C%EB%B9%84%EC%8A%A4-msa-%EC%A0%81%EC%9A%A9%ED%95%98%EA%B8%B0-31e06fe039a0?source=rss-8762f94a1b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/31e06fe039a0</guid>
            <category><![CDATA[servers]]></category>
            <dc:creator><![CDATA[Allan Bae]]></dc:creator>
            <pubDate>Mon, 16 Dec 2019 05:03:28 GMT</pubDate>
            <atom:updated>2019-12-16T13:54:22.002Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oSSyUHqRwX2ZbXpIZq-ZtA.jpeg" /><figcaption><strong>Photo by </strong><a href="https://unsplash.com/@linharex?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"><strong>Linh Pham</strong></a><strong> on </strong><a href="https://unsplash.com/s/photos/collection-with-small?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText"><strong>Unsplash</strong></a></figcaption></figure><h3>소개</h3><p>안녕하세요. <strong>WATCHA</strong>에서 서버 개발을 하고 있는 Allan 입니다. <br>이번 포스팅에서는 WATCHA PLAY 동영상 플랫폼에서 MSA를 적용한 사례에 대해 이야기를 해보고자 합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q1IIEtWplBhakxSGwasxbw.png" /><figcaption><strong>적용전 시스템</strong></figcaption></figure><p>기존의 WATCHA PLAY 동영상 플랫폼은 크게는 WEB 서버, API 서버, 추천 서버 등으로 구성되어 있었습니다.</p><p>이 중 API 서버가 거의 모든 요청을 처리하고 있었고, 지속적으로 다양한 기능이 추가되며 잦은 배포가 이뤄지면서 간혹 장애가 발생하기도 했습니다.</p><p>특히 영상 재생과 관련된 트래픽이 전체 트래픽의 30% 이상을 차지하고 있었고, 영상 재생 부분과 관련 없는 곳에서 장애가 발생하였을 경우에도 영상 재생에 영향을 끼치게 되어, 장애 대응 및 성능 측면에서 분리가 필요한 상황이었습니다.</p><h4>그래서</h4><p>영상 재생 관련 일부 서비스를 분리하여 성능 향상을 도모하며, 장애에도 견고한 서비스를 만들어 최대한 영상 재생에 영향을 적게 끼칠 수 있도록 하기 위해 <strong>MSA(MicroService Architecture) </strong>기반으로<strong> </strong>서비스를<strong> </strong>구축하였습니다.</p><h3><strong>사용 기술 스택</strong></h3><p>새롭게 적용된 시스템 소개에 앞서, 사용한 기술 및 용어에 대해 설명합니다.</p><ul><li><a href="https://docs.aws.amazon.com/ko_kr/elasticbeanstalk/latest/dg/create_deploy_docker_ecs.html"><strong>AWS Elastic Beanstalk With ECS</strong></a><strong>: </strong>적용된 서버는<strong> </strong>ECS 기반의 <strong>Elastic Beanstalk</strong> 에서 운영하고 있습니다. 멀티 컨테이너 기반으로 동작하고 있으며 <strong>Nginx, App(Moneta) </strong>요청 처리를 위한 2개의 컨테이너와 <strong>Sidecar 패턴</strong>으로 로그 수집을 위해 <strong>Fluent Bit </strong>컨테이너를 운영하고 있습니다.</li><li><a href="https://wcha.it/35NvpMx"><strong>모니터링 시스템</strong></a>: 모니터링 시스템은 Fluent-Bit 정보, App 서버 프로세스 정보를 수집하여 보여주고 이상 징후 발견 시 알림이 발생합니다. 자세한 정보는 <a href="https://wcha.it/35NvpMx"><strong>이전 블로그</strong></a>를 참고하시면 됩니다.</li><li><a href="https://wcha.it/35NvpMx"><strong>로그 플랫폼</strong></a>: 로그를 수집 및 가공해서 BigQuery 및 Elastic Cloud 에 전송하는 플랫폼입니다. 자세한 정보는 <a href="https://wcha.it/35NvpMx"><strong>이전 블로그</strong></a>를 참고하시면 됩니다.</li><li><strong>Elastic APM: </strong>여러 서비스 간의 <strong>Distributed Tracing</strong>(분산추적)을 통하여, 지연시간 및 요청 흐름에 대해 추적하기 위해 도입되었습니다. <br><a href="https://www.cncf.io/"><strong>CNCF</strong></a><strong> </strong>프로젝트중<strong> </strong>하나인 <a href="https://opentracing.io/"><strong>OpenTracing</strong></a><strong> </strong>와<strong> </strong><a href="https://www.elastic.co/kr/products/apm"><strong>Elastic APM</strong></a><strong> </strong>을 통하여 각기 다른 서비스간에 <strong>Context</strong>를 전파하여 분산추적이 가능하도록 구현되어 있습니다.</li><li><strong>Circuit Breaker: </strong>서킷브레이커는 장애 발생 시 빠르게 Fallback으로 전환하여 장애 전파를 막기 위한 패턴입니다. 주로 MSA 구조에서 많이 사용되고 있습니다. 현재 적용된 시스템에서는 <a href="https://github.com/Netflix/Hystrix"><strong>HYSTRIX</strong></a> 라는 해당 패턴이 구현된 라이브러리를 <strong>Go</strong>로 포팅된 것을 이용하고 있습니다.</li><li><strong>내부 API 서버</strong>: 내부적으로 이용되는 Private API를 제공합니다.</li><li><strong>Redis</strong>: Redis 에서 재생 관련 정보를 저장하고 있으며, 내부 API 를 통하지 않고 최대한 빠르게 정보를 제공하기 위해서 이용하고 있습니다.</li><li><a href="https://jwt.io/"><strong>JWT</strong></a>: JWT(JSON WEB TOKEN)를 이용하여 클라이언트와 통신 하고 있습니다.</li><li><strong>CI/CD</strong>: Elastic Beanstalk로 테스트와 배포는 <a href="https://circleci.com/"><strong>CircleCI</strong></a>를<strong> </strong>이용하고 있습니다. 특정 Git 브랜치에 커밋되면, 테스트케이스 통과 후 자동으로 배포되도록 운영하고 있습니다.</li><li><a href="https://golang.org/"><strong>Golang</strong></a><strong>: </strong>동시성 처리 면에서 우수한 성능과 편리성을 제공하는 언어입니다. 개선된 시스템에서 APP 서버는 <strong>Golang</strong>을 이용하고 있습니다.</li></ul><h3><strong>적용된 재생 관련 인프라 구조</strong></h3><p>적용된 재생 관련 인프라 전체 구조는 아래와 같습니다.</p><p><strong>EB 기반의 인프라 구조</strong>, <strong>클라이언트 통신</strong> 2부분으로 나눠서 설명하겠습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BvV-Iquq7GIQbZuktv3NtA.png" /><figcaption><strong>적용된 시스템</strong></figcaption></figure><h4><strong>EB 기반의 인프라 구조</strong></h4><p>새로 적용된 서비스는 Elastic Beanstalk With ECS (<strong>EB</strong>) 기반의 멀티 컨테이너를 이용하여 구축되어 있습니다.<br>EB기반으로 구축하였을 때 장점으로는 다음과 같습니다.</p><ul><li><strong>AWS에서 제공하는 EB 전용 CLI 또는 콘솔에서 쉽게 설정, 배포가 가능합니다.</strong></li><li><strong>ALB 설정, Autoscale 설정, EC2 설정, Security 설정, 배포 설정 등 대부분 설정들이 코드로 관리 가능합니다.</strong></li><li><strong>EB With ECS 를 이용하게 되면 독립적인 환경에서 동작하는 Docker 이미지만 만들어 관리할 수 있어 안정적으로 운영 가능하여, ECS 클러스터, 모니터링 등 자동으로 알아서 처리하여 인프라에 신경 쓸 필요 없이 코드에만 집중이 가능합니다.</strong></li></ul><p>ECS 내의 Task별 Container 구조는 아래와 같습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Hrsa1kPHj0gEN6heN1P4g.png" /><figcaption><strong>TASK 별 CONTAINER 구조</strong></figcaption></figure><p><strong>NGINX <br></strong>해당 Container는 ALB 요청에 직접 응답 합니다. <br>물론 App 서버를 바로 ALB 요청에 직접 응답하도록 하면 성능적으로 장점이 있지만, <br>NGINX를 통해 ALB요청을 처리하도록 하는것 또한 다음과 같은 장점이 있습니다.</p><ul><li>불필요한 헤더 정리(불필요한 헤더 삭제 등)</li><li>보안(비정상적인 BODY 사이즈를 가진 요청을 거부, 허용되지 않은 PATH 거부)</li></ul><p>APP<strong> </strong>서버에서 굳이 처리할 필요 없는 것들을 손쉽게 처리 할수 있는 장점이 있어, Reverse Proxy 형태로 활용하고 있습니다.</p><p><strong>APP</strong><br>Go로 만들어진 Server이며 영상 재생 관련된 요청을 처리 합니다. <br>(내부적으로는 <strong>MONETA</strong> 라고 불리고 있습니다.)<br>들어온 요청에 대해 정상적인 요청인지를 확인후 서비스를 제공합니다. <br>해당 서버는 크게 <strong>안정성</strong>, <strong>성능</strong> 부분에 맞춰 작업을 진행했습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d_Oxn3hboh09BHh8qzlpmg.png" /><figcaption><strong>Moneta App 구조</strong></figcaption></figure><ul><li><strong>안정성:</strong> APP 서버 내에서 요청이 발생하는 Redis 나 Private API 서버 장애발생 시에도 안정적인 서비스를 제공하기 위해서, 장애 발생 시에 서킷브레이커를 오픈하여 자동으로 Fallback 시나리오로 동작하도록 구현되어 있습니다. 장애상황에서 요청이 밀려 CPU 부하가 올라가고, 불필요한 Autoscale 이 발생하지 않도록 하여 장애 전파가 이뤄지지 않도록 되어 있습니다.</li><li><strong>성능</strong>: 최대한 적은 서버 수로 많은 요청을 처리하기 위해서,<br>첫 번째로 외부 리소스 접근과 같이 Network I/O 병목이 적게 발생하도록 설계 및 구현되어 있습니다.<br>두 번째로 프로세스 메모리 최적화를 많이 하여 메모리 HEAP 할당을 최소화하는 등 GC 부하가 적어지도록 구현되어 있습니다. <br><br><a href="https://www.consul.io/"><strong>CONSUL</strong></a> 과 <a href="https://prometheus.io/"><strong>PROMETHEUS</strong></a>를 이용하여 스레드 및 고루틴 수, 메모리 HEAP 사이즈 … 등 프로세스 정보와 <strong>Circuit Breaker</strong> 또한 <a href="https://github.com/gjbae1212/prometheus-hystrix-go"><strong>PROMETHEUS METRIC</strong></a> 이용하여 오픈 여부, 요청 수, 에러 수 … 등 정보 수집하여 알림 및 모니터링에 활용하고 있습니다.<br><br>그리고 <strong>OpenTracing</strong> 과 <strong>Elastic APM</strong>을 이용한 분산 추적을 통하여 <br>클라이언트 요청 -&gt; 응답 사이에 발생 하는 여러 내부 서비스 요청에 대해서 지연시간 및 요청 흐름을 추적하여 모니터링 및 서비스 개선에 활용되고 있습니다.</li></ul><p><strong>FLUENT BIT<br></strong>Sidecar 형태로 서비스에는 관련없지만 APP에서 발생한 로그를 수집하여 PROTOBUF 포맷으로 로그플랫폼에 전송합니다. <br>자세한 정보는 <a href="https://wcha.it/35NvpMx"><strong>이전 블로그</strong></a>를 참고하시면 됩니다.</p><h4><strong>클라이언트 통신</strong></h4><p><strong>MONETA </strong>와 <strong>클라이언트</strong> 간의 요청은 <strong>JWT </strong>를 이용해서 통신하고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oWQHQaxSXgguKfBFeDjABA.png" /><figcaption><strong>클라이언트 서버 간 통신</strong></figcaption></figure><p><strong>JWT </strong>를 이용하게 되면 서명을 통해 데이터 변조 및 무결성 체크도 가능하며, <br><strong>JWT</strong> 자체에 만료 시간을 정할 수도 있고, 필요한 메타정보를 담을 수 있습니다.<br>게다가 저장소(DB, CACHE ...등) 없이도 인증 처리를 할 수 있어서, 분산된 여러 서비스 간에 의존성 없이 인증 처리가 가능합니다.<br><strong>JWT</strong> 서명을 위한 KEY 값은 <a href="https://docs.aws.amazon.com/secretsmanager/"><strong>AWS SECRETS MANAGER</strong></a>를 통해 여러 서비스에 공유 되어 있어 안전하게 공유 가능합니다.</p><h3><strong>CI/CD 및 서버접속</strong></h3><h4><strong>CI/CD</strong></h4><p>테스트와 배포는 <a href="https://circleci.com/"><strong>CIRCLE CI</strong></a>를 통하여 이뤄지고 있습니다. <br>특정 <strong>GIT</strong> 브랜치에 커밋하게 되면 테스트 케이스를 통과후 Docker Image를 만들어 태깅하여 <a href="https://aws.amazon.com/ecr/"><strong>ECR</strong></a>에 올리고 자동으로 배포되도록 구현되어 있습니다.</p><p>배포 정책은 <strong>ROLLING </strong>방식, <strong>IMMUTABLE</strong> 방식,<strong> BLUE/GREEN</strong> 방식 등 다양하게 선택할 수 있는데, 현재는 <strong>IMMUTABLE</strong> 방식으로 배포를 하고 있습니다.<br>배포 방식에 대해서는 <a href="https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.deploy-existing-version.html"><strong>링크</strong></a>를 참조하시면 되겠습니다.</p><h4>서버접속</h4><p>서버 상태 확인 및 문제 발생 시 서버에 접속하기 위해서는 간단히 Elastic Beanstalk 전용 CLI 툴로 손쉽게 접근이 가능합니다.</p><p><strong>EB</strong>에서도 기존의 서버를 접근하는 방식과 동일하게 SSH KEY를 이용해야 접속이 가능합니다. 하지만 접속 제한이 없고, 동일한 SSH KEY를 여러 사람한테 공유를 하게 되면 보안적으로 굉장히 취약합니다.</p><p><strong>WATCHA</strong>에서는 내부적으로 <strong>SSH 인증서버 및 CLI </strong>툴을 개발했습니다.<br><strong>AWS IAM</strong> <strong>유저</strong> <strong>권한</strong> 및 <strong>그룹</strong>을 체크해 <strong>유저 별</strong>로 <strong>시간 제한</strong>(1시간, 1일 …등)있는 서버에 접속 가능한 <strong>SSH KEY</strong>를 발급하고, 해당 시간이 지나면 발급된 <strong>SSH KEY</strong>는 자동 만료됩니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ASVSzcCPZ68hrCHs1b4oBg.png" /><figcaption><strong>WATCHA SSH 인증서버</strong></figcaption></figure><p>해당 SSH 인증 서버 및 CLI 은 <strong>다음 포스팅</strong>에서 자세히 설명을 해보도록 하겠습니다.</p><h3><strong>얼마나 개선 되었나?</strong></h3><p>Elastic Beanstalk With ECS(<strong>EB)</strong>에서 c5.large (VCPU 2 개, MEM 4GiB) 인스턴스를 사용하고 있으며 주말 피크 타임에 3대로 유지되고 있습니다.</p><p>그러나 기존 API 서버 c5.xlarge(VCPU 4개, MEM 8GiB) 인스턴스는 7대 정도 줄어들도록 개선되었습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wwrX33RD6klIdbWeE6UPHQ.png" /><figcaption><strong>개선</strong></figcaption></figure><h3><strong>결론</strong></h3><p>재생 관련 서비스를 MSA구조로 만든 과정에 이용한 기술에 대해 공유해 보았습니다.</p><p>MSA구조로 분리되면서, 메인 API 서버는 잦은 배포에도 안정적으로 운영이 가능해졌습니다.</p><p>영상 재생 관련된 모든 API가 새로 구축된 시스템으로 마이그레이션 된 건 아니지만, 일부 API만 마이그레이션 하여도 많은 성능 향상이 있는 것을 볼 수 있었습니다.</p><p>그리고 지속적으로 일부 남아 있는 API도 새로 구축된 시스템으로 마이그레이션 하게 되면 성능은 물론 안정성도 높아질 것으로 예상합니다.</p><p>여기서 못다 한 SSH 인증서버는 <strong>다음 포스팅</strong>에서 다루도록 하겠습니다.</p><p><strong>WATCHA</strong>에서는 다양한 기술들을 활용해 서비스를 지속적으로 개선, 발전시켜 갈 실력 있고 뜻있는 개발자들을 모집하고 있습니다. 관심있는 분은 <a href="https://team.watcha.com/joinus/"><strong>채용공고</strong></a>를 참고해주세요.</p><p>긴 글 읽어 주셔서 감사합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31e06fe039a0" width="1" height="1" alt=""><hr><p><a href="https://medium.com/watcha/watcha-play-%EC%84%9C%EB%B9%84%EC%8A%A4-msa-%EC%A0%81%EC%9A%A9%ED%95%98%EA%B8%B0-31e06fe039a0">WATCHA PLAY 서비스 MSA 적용하기</a> was originally published in <a href="https://medium.com/watcha">WATCHA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[멀티클라우드를 이용한 로그 분석 플랫폼 개발하기]]></title>
            <link>https://medium.com/watcha/%EB%A9%80%ED%8B%B0%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EB%A1%9C%EA%B7%B8-%EB%B6%84%EC%84%9D-%ED%94%8C%EB%9E%AB%ED%8F%BC-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-8c5f671df559?source=rss-8762f94a1b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c5f671df559</guid>
            <category><![CDATA[servers]]></category>
            <dc:creator><![CDATA[Allan Bae]]></dc:creator>
            <pubDate>Wed, 30 Oct 2019 09:29:49 GMT</pubDate>
            <atom:updated>2019-10-30T09:29:49.520Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M1hYXODiQnh8nobB9YF3RA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@alfonsmc10?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Alfons Morales</a> on <a href="https://unsplash.com/s/photos/book?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>소개</h3><p>안녕하세요. WATCHA에서 서버 개발을 하고 있는 Allan 이라고 합니다. 이번에 개발한 WATCHA 로그 분석 플랫폼에 대해 간략히 공유하고자 합니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IOfX-ot8xS3ZDYFu5L2RKQ.png" /><figcaption>이전 분석 방법</figcaption></figure><p>지금까지 WATCHA에서는 필요에 따라 로그 데이터를 접근성이 편리한 RDB에 저장하거나, 여러 외부 솔루션을 적용하여 다양한 패턴을 분석 하고 앞으로의 방향을 결정하거나 서비스 개선을 하고 있었습니다.</p><p>하지만 점점 서비스가 성장하고 사용자가 늘어남에 따라, 로그 데이터가 빠르게 증가하면서 기존에 구축된 방식을 이용해서는 분석이 어려워졌습니다.</p><p>그리고 여러 영역에 분산된 데이터의 통합 분석이 어려워져서 빠른 개선이 필요한 상황이었습니다.</p><h3>그래서?</h3><p>로그를 <strong>한곳에 통합</strong>하고, 데이터를 <strong>빠르게 분석 </strong>할 수 있고, 어떠한 환경에서도 <strong>유연하게 수집 및 가공</strong>이 가능한 시스템을 구축하기로 하였습니다.</p><h4>1. 한곳에 통합</h4><p>로그를 한곳에 저장, 빠르게 분석할수 있는 <strong>Google BigQuery</strong>를 이용하게 되었습니다.<br>선택했던 이유는 Google 솔루션인 <strong>FireBase</strong>, <strong>Google Analytics</strong> 등 클라이언트 영역에서 발생하는 로그들도 손쉽게 <strong>BigQuery</strong>에 통합이 가능하여, <strong>Web</strong>, <strong>App</strong>, <strong>Server </strong>등 모든 영역에서 발생하는 로그를 한곳에 모을 수가 있기 때문입니다.</p><h4>2. 빠르게 분석</h4><p>한곳에 분석용 로그가 모여 있으면, 원하는 데이터를 쉽게 취합하여 분석할 스 있고, <strong>Google BigQuery</strong>를 이용하게 되면 대용량 데이터도 빠르게 분석하는 것이 가능합니다.</p><h4>3. 유연하게 수집 및 가공</h4><p>WATCHA 에서는 여러 서비스들이 AWS 내에 구성되어 있습니다.<br>서비스별로 Rails, Nodejs, Scala, Java, Python 등 다양한 플랫폼 및 언어로 구성되어 있고, 실행 환경도 다릅니다.<br>그래서 멀티클라우드, OS 및 특정 언어와 라이브러리에 종속되어 있지 않고, 실시간으로 로그를 유실 없이 수집하기 위해서 여러 기술을 사용하여 구현하였습니다.</p><h3>사용 기술스택</h3><p>전체 로그 시스템 구성 설명에 앞서, 사용한 기술에 대해서 간략하게 설명합니다.</p><ul><li><strong>멀티 클라우드</strong>(<strong>GCP</strong>, <strong>AWS, Elastic Cloud</strong>): 현재 WATCHA의 대부분의 서비스들은 AWS를 이용하여 서비스하고 있습니다. 그리고 로그 분석 시스템 중 인프라는 GCP를 이용하고 있으며 Elastic Search는 Hot-Warm 클러스터 구조로 Elastic Cloud에서 운영하고 있습니다. AWS &lt;-&gt; GCP 사이의 연결은 VPN으로 통신하며, VPN 연결은 해당 <a href="https://cloud.google.com/files/CloudVPNGuide-UsingCloudVPNwithAmazonWebServices.pdf">링크</a> 를 참고 하시면 됩니다.</li><li><a href="https://kubernetes.io/"><strong>Kubernetes</strong></a>: 도커 컨테이너 오케스트레이션 플랫폼이며, WATCHA에서는 <a href="https://helm.sh/">Helm</a>을 이용하여 배포, 운영중에 있습니다. 로그 모니터링 시스템은 <a href="https://www.consul.io/">Consul</a>, <a href="https://prometheus.io/">Prometheus</a>, <a href="https://grafana.com/">Grafana</a> 와 데이터 가공툴은 <a href="https://airflow.apache.org/">Airflow</a>, <a href="https://www.embulk.org/">Embulk</a> 를 운영하고 있습니다.</li><li><a href="https://fluentbit.io/"><strong>Fluent-Bit</strong></a>: <a href="https://www.fluentd.org/">Fluentd</a> 의 경량버전입니다. C로 구현되어 있고, 라이브러리에 의존성이 없습니다. Fluentd보다는 가볍고 빨라서 대용량 로그 수집에 최적화 되어있습니다. 단점으로는 Zero Dependencies를 지향하고 있어 기본적으로 제공하는 기능이 적습니다.</li><li><a href="https://cloud.google.com/pubsub"><strong>PubSub</strong></a>: GCP에서 SAAS형태로 제공하는 Queue 서비스입니다. 대용량에 최적화 되어 있으며, 비슷한 기술로는 <a href="https://kafka.apache.org/">Kafka</a> 와 비교 되고 있습니다.</li><li><a href="https://www.consul.io/"><strong>Consul</strong></a>, <a href="https://prometheus.io/"><strong>Prometheus</strong></a>, <a href="https://grafana.com/"><strong>Grafana</strong></a>: Consul은 Service Discovery 서비스이고, Prometheus은 Metric 수집, Grafana는 수집한 Metric을 Visualization하는 서비스입니다. WATHCA에서는 해당 서비스들을 로그 모니터링 시스템에 사용하고 있습니다.</li><li><a href="https://cloud.google.com/bigquery"><strong>BigQuery</strong></a>: 모든 로그저장 및 분석용으로 사용합니다. Standard SQL 형태로 검색 가능하며, <a href="https://firebase.google.com/">FireBase</a>, <a href="https://analytics.google.com/">Google Analytics</a> 데이터도 BigQuery에 통합 가능합니다.</li><li><a href="https://airflow.apache.org/"><strong>AirFlow</strong></a>: 데이터 가공을 위한 플로우를 관리하는 서비스입니다. WATCHA에서는 BigQuery에 있는 데이터를 여러 단계로 나눠서 원하는 데이터 생성(ETL) 시 이용하고 있습니다.</li><li><a href="https://www.embulk.org/"><strong>Embulk</strong></a>: 여러 데이터소스로부터 다른 곳으로 Migration 해주는 서비스 입니다. 현재 WATCHA에서는 RDS데이터를 BigQuery로 Migration 하며, 좀더 분석이 편리하도록 하고 있습니다.</li><li><a href="https://cloud.google.com/appengine/docs/flexible/"><strong>Flexible App Engine</strong></a>: GCP에서 Docker로 배포하고 자동으로 Autoscaling 해주는 SAAS 형태로 제공하는 솔루션입니다. 여기에서는 Pubsub으로 받은 Data를 분석하여 처리하는 작업에 이용합니다.</li><li><a href="https://datastudio.google.com/u/0/navigation/reporting"><strong>DataStudio</strong></a>: Google에서 제공하는 Visualization 솔루션입니다. BigQuery와 통합하여 가공한 데이터를 그래프 형태로 사내에 공유하고 있습니다.</li><li><a href="https://cloud.google.com/cloud-build"><strong>CloudBuild</strong></a>: GCP에서 제공하는 CI/CD 툴입니다. CI/CD Pipeline을 구축하여 코드 Commit 시 TestCase에 통과되면 자동으로 배포되도록 이용하고 있습니다.</li><li><a href="https://www.terraform.io/"><strong>Terraform</strong></a>: Code로 인프라를 관리해주는 툴로서 GCP 인프라 설정은 Terraform을 이용하고 있습니다.</li><li><a href="https://golang.org/"><strong>Golang</strong></a>: 동시성 처리 부분에 우수한 성능과 편리성을 제공하는 언어입니다. WATCHA에서는 Fluent-Bit 플러그인 개발이나 실시간으로 받은 데이터를 가공 후 처리할 때 등 여러 로직에서 이용하고 있습니다.</li><li><a href="https://developers.google.com/protocol-buffers/"><strong>Protocol Buffers</strong></a>: 여러 언어를 지원하는 직렬화 프로토콜입니다. WATCHA에서는 로그구조를 Protobuf로 정의 후, 여러팀에 문서화 필요없이 쉽게 공유하며, 사용언어에도 구애받지 않고 로그 수집에 이용하고 있습니다.</li></ul><h3>전체 로그 시스템 구성</h3><p>로그 시스템은 <strong>수집파트</strong>, <strong>처리파트</strong>, <strong>모니터링파트</strong> 총 3부분으로 나누어져 있습니다. 아래는 전체적인 로그 시스템 구성도 입니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5YO5kAKxbhnoDOa85o70w.png" /><figcaption>전체 로그 시스템 구성도</figcaption></figure><h4>수집부분</h4><p>로그 파일에서 데이터를 수집하여서 전송하거나, 서비스내에서 직접로그를 전송하는 경우, 여러환경(사용언어, 라이브러리, OS ..등)을 고려해야 하고, 로그를 추가할 때마다 SPEC에 대한 커뮤니케이션 비용이 발생하는 애로사항이 많습니다.<br>그래서 로그구조를 쉽게 공유하고, 여러언어로 라이브러리로 제공 할 수 있는 Protobuf를 표준 프로토콜로 이용하고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yMT6DthBkvvhelhmquZeeQ.png" /><figcaption>수집 부분</figcaption></figure><p>수집 부분에서는 총 <strong>3가지 방식</strong>으로 로그를 수집하고 있습니다.</p><ul><li><strong>FireBase</strong>: FireBase를 사용해 Client에서 발생하는 로그를 수집합니다. 관리툴에서 설정만 조절하면 쉽게 BigQuery로 Migration 됩니다.</li><li><strong>Fluent-Bit</strong>: 여러 서비스의 로그 파일에서 로그를 수집합니다. Fluent-Bit 기능이 적은 관계로, PubSub으로 로그전송과 모니터링을 위해 Consul에 등록하는 플러그인을 Golang 개발 후 C Shared Library형태로 컴파일해 이용하고 있습니다.<br>전송 포맷은 Protobuf를 이용하고 있으며, 다른 서비스에 추가 시에 쉽게 배포가 가능하도록 CLI툴을 개발하여 배포하고 있습니다.</li><li><strong>Direct 전송</strong>: 결제 이력과 같은 주요 이벤트는 서비스에서 직접 전송하고 있습니다. 전송 포맷은 Protobuf를 이용하고 여러 언어(Ruby, Scala, Javascript, Go .. 등)로 라이브러리 형태로 제공하여 편리하게 전송가능합니다.</li></ul><h4>처리부분</h4><p>PubSub으로 받은 데이터와 AWS내에 있는 RDS 데이터를 BigQuery에 저장하거나, BigQuery에 저장된 데이터를 배치처리로 가공, 분석 및 Visualization 하는 부분을 담당합니다.</p><p>그리고 실시간 분석 및 모니터링을 위해서 Elastic Cloud에서 Elastic Search 및 Kibana를 이용하고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XnUNYbWKif4QYvilBPPLUw.png" /><figcaption>처리 부분</figcaption></figure><ul><li><strong>실시간 가공 및 처리</strong>: Pubsub에서 로그를(Protobuf 형태) 전송받아 가공 후 저장을 하고 있습니다. 데이터 가공 및 처리 부분은 새로운 형태의 로그가 추가되거나 변경이 일어나더라도 자동으로 알아서 BigQuery 테이블에 저장합니다. 그리고 중복된 로그는 조건에 따라 자동으로 필터를 할 수 있고, Elastic Search 와 같은 실시간 데이터가 필요한 곳에 원하는 형태로 전달해줄 수 있는 다양한 용도로 이용하기 위해 개발했습니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cOELrG7DlnTuPma-B0mnPw.png" /><figcaption>실시간 가공 및 처리 과정</figcaption></figure><p>동시성을 처리하는 데 있어 개발 편리성과 성능에 장점이 있는 Golang으로 개발했습니다. 또한 성능적으로도 튜닝하여 적은 머신으로 많은 데이터를 빠르게 처리하고 있습니다.</p><p>간략하게 프로세스를 정리해보면 Pubsub으로부터 Protobuf 포맷의 데이터를 Restful API로 받아 스키마 및 데이터를 분석하여, 비동기로 동작하는 Worker들에게 전달하여 해당 목적에 맞게 수행하도록 되어 있습니다.</p><p>로직 변경 없이도 새로운 로그 포맷에 대응할 수 있도록 되어 있고, 상황상 발생할 수 있는 중복데이터는 해쉬를 이용한 중복 체크 및 로직을 통해 중복 저장되지 않도록 구현되어 있습니다.</p><p>해당 프로세스는 Flexible App Engine에서 동작하고 있고, CloudBuild로 CI/CD 파이프라인을 구현하여 코드 변경 시 자동으로 트리거되어 TestCase 통과후 자동으로 배포 되고 있습니다.</p><p>배포 방식은 카나리(Canary)로 하고 있어, 일부 트래픽을 새로 배포된 프로세스로 옮기고, 이상 징후가 없을 시 전체 트래픽을 옮기는 방식으로 운영하고 있습니다.</p><ul><li><strong>Embulk를 이용한 BigQuery 저장</strong>: 서비스 데이터는 AWS내에서 RDS로 저장되어 서비스에 이용되고 있습니다.<br>로그만으로 데이터를 분석하기에는 한계가 있고, 서비스 데이터도 BigQuery내에서 로그와 함께 분석하면 좀더 정확한 데이터를 얻을수 있어 주기적으로 Embulk를 통해 RDS 데이터를 BigQuery에 동기화 하고 있습니다.<br>Embulk 프로세스는 Packer를 이용해 빌드후 주기적으로 K8S Pod 형태로 돌고 있습니다.</li><li><strong>Elastic Cloud 이용한 실시간 분석</strong>: BigQuery와 같은 빅데이터 분석용으로 만들어진 솔루션은 실시간 분석, 가벼운 검색 및 특정 상황에 대한 모니터링에 이용하기에 비용, 성능에 있어서 적합하지 않습니다. 그래서 Elastic Cloud에서 Elastic Search 와 Kibana를 SAAS형태로 이용하고 있습니다.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3eWABftJ-3aIO0syuR2-g.png" /><figcaption>Elastic Cloud (HOT-WARM) 구조</figcaption></figure><p>Elastic Cloud에서 Elastic Search와 Kibana를 이용하게 되면 Elastic사에서 직접 관리 해주고 Downtime 없이 ElasticSearch 업데이트가 가능하며, X-PACK 및 Custom 플러그인도 손쉽게 사용가능하게 되어 있습니다.</p><p>현재 WATCHA에서는 Hot-Warm 클러스터 구조로 Elastic Search를 구성하여서, 최신 데이터는 Hot 노드에 저장하고, 일정 기간이 지난 데이터는 자동으로 Warm 노드로 이동시키고 있습니다.</p><p>X-PACK을 이용하여 Kibana에 Single Sign On을 적용해 쉽게 로그인이 가능하고, Security 설정 및 모니터링에 적극 활용하고 있습니다.</p><ul><li><strong>가공 및 Visualization</strong>: BigQuery에 1차 가공되어 저장된 데이터에서 좀더 원하는 정보를 얻거나, 특정 지표를 보여주기 위해서는 더 세부적인 데이터 가공이 필요합니다.<br>그래서 AirFlow를 이용해서 여러 단계로 걸쳐 데이터를 가공하여서 BigQuery 또는 Storage에 저장을 하고 있습니다. 이렇게 가공된 데이터는 DataStudio로 그래프 형태로 만들어져 사내에 공유하고 있습니다.</li></ul><h4>모니터링 부분</h4><p>로그 수집 부분은 로그 플랫폼에서 아주 중요한 부분을 차지 합니다.</p><p>모니터링 부분은 이런 로그 수집에 대한 모니터링 및 대응을 하기 위해 만들어 졌습니다.</p><p>물론 만들어진 배경은 이전에 예상치 못한 문제로 로그수집을 이뤄지지 않고 로그가 유실되는 상황이 있었습니다.(유실된 상황을 인지하는데도 오랜 시간이 걸렸습니다.)</p><p>서비스 중인 서버들뿐만 아니라 새로 개발되는 서비스 서버들도 유동적으로 변화하는 환경에서 대응할수 있도록 개발했고, Kubernetes + Helm을 이용하여 손쉽게 배포 및 관리를 하고 있습니다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vndtcMf1qgAQXpS15Wdrkg.png" /><figcaption>모니터링 부분</figcaption></figure><ul><li><strong>Consul</strong>: Fluent-Bit가 Consul에 등록을 하게 되면, 서비스별로 로그 수집 Agent가 Live한지 확인이 가능합니다. 방법으로는 주기적으로 HealthCheck 메시지를 보내어 로그 수집 Agent가 Live한지 체크합니다.</li><li><strong>Prometheus</strong>: Consul을 이용하여 서비스별로 Live한 Agent 리스트를 찾아, 직접 Agent에 접근하여 Metric을 수집합니다. CPU/메모리 사용량, 수집된 로그의 IN/OUT 수치 등을 수집합니다.</li><li><strong>Grafana</strong>: Prometheus에서 수집한 Metric을 Visualization해서 보여줍니다. 또한 모니터링 알림을 설정하여, 이상이 있을 시 Slack으로 알림을 전송합니다.</li></ul><p>설명해보면, Fluent-Bit는 시작 시 Consul에 서비스를 등록하게 되고, 등록된 Fluent-Bit Agent 기반으로 모니터링하게 됩니다. 만약 Fluent-Bit 프로세스가 문제가 발생해 죽게 되면, 서비스중인 서버 리스트와 Consul에 등록된 서비스중인 리스트를 비교하여 알림으로 알려주게 되어 있습니다.</p><p>또한 Fluent-Bit가 떠있더라도 문제가 발생해 로그가 전송되지 않은 상황에 있더라도, Input/Ouput 처리량을 분석하여 알림으로 알려주도록 되어 있습니다.</p><p>모니터링 부분은 전반적으로 로그 유실을 최소화하기 위한 목적으로 만들어져 있습니다.</p><h3>배포/인프라 관리</h3><p>배포 및 인프라 관리는 모든 개발 영역에서 필수적인 부분입니다.</p><p>전반적으로 잘 만들어진 Tool을 사용하고, 코드로 관리하도록 해서 Manual하게 사람이 배포 및 관리하는 작업을 최소화하는 방향으로 진행하였습니다.</p><p><strong>간략하게 정리해보면</strong></p><ul><li><strong>AWS 및 GCP 인프라 구성</strong>: Terraform 으로 관리되어 있어, 코드로 인프라를 관리하게 되어 변경이력을 알기 쉽고, 편리하게 이용하고 있습니다.</li><li><strong>Log Agent</strong>: 배포를 위한 CLI TOOL을 직접 개발하여 운영을 하고 있습니다.</li><li><strong>Embulk</strong>: Packer를 이용하여 빌드후 Private Docker Hub에 저장하고 있습니다.</li><li><strong>Data Pipeline(Go)</strong>: CloudBuild를 이용하여 Github에 Commit이 되게 되면 자동으로 트리거 되어 TestCase 통과 후 카나리(Canary) 배포를 하고 있습니다.</li><li><strong>K8S Application</strong>: HELM 패키지 매니저를 통하여 배포를 하고 있습니다.</li></ul><h3>결론</h3><p>지금까지 멀티클라우드 환경에서 로그 수집, 로그 가공, 로그 모니터링, 배포/관리에 이용했던 기술에 대해 공유해 보았습니다.</p><p>한가지의 클라우드 서비스만을 이용하기보다는, 다른 클라우드에 있더라도 장점이 있는 솔루션을 이용할 수 있다면, 좀더 유연하게 서비스를 운영할 수 있습니다.</p><p>대용량 데이터 분석에 큰 메리트가 있는 BigQuery를 이용하여 클라이언트, 서버 등의 데이터를 통합하여 다양한 분석이 가능해 졌고, Standard Query 형태로 분석이 가능해 접근성도 많이 좋아졌습니다.</p><p>그리고 Elastic Cloud를 이용하면 Hot-Warm 구조 ElasticSearch 클러스터를 손쉽게 운영하는 것이 가능하며 SSO, Security 등 X-PACK 및 Custom 플러그인 사용이 가능합니다. 또 Elastic사에서 직접 개발 서포트 및 Downtime 없는 빠른 업데이트를 할 수 있어 큰 메리트가 있습니다.</p><p>지금까지 왓챠와 왓챠플레이의 이용자가 늘어나고 서비스가 커져 감에 따라 분산돼 있던 로그 분석 시스템을 멀티클라우드를 이용해 통합한 과정에 대해 이야기해 드렸는데요, 여전히 서비스 성능을 개선하기 위해 앞으로 더 진행해야 할 과제들이 많이 남아있습니다. 왓챠에서는 이처럼 서비스도 발전시키고 자신도 성장하는 데 관심이 많은 능력 있는 개발자를 모집하고 있습니다. 관심있는 분은 <a href="https://team.watcha.com/joinus/"><strong>채용공고</strong></a>를 참고해주세요.</p><p>긴글 읽어 주셔서 감사합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c5f671df559" width="1" height="1" alt=""><hr><p><a href="https://medium.com/watcha/%EB%A9%80%ED%8B%B0%ED%81%B4%EB%9D%BC%EC%9A%B0%EB%93%9C%EB%A5%BC-%EC%9D%B4%EC%9A%A9%ED%95%9C-%EB%A1%9C%EA%B7%B8-%EB%B6%84%EC%84%9D-%ED%94%8C%EB%9E%AB%ED%8F%BC-%EA%B0%9C%EB%B0%9C%ED%95%98%EA%B8%B0-8c5f671df559">멀티클라우드를 이용한 로그 분석 플랫폼 개발하기</a> was originally published in <a href="https://medium.com/watcha">WATCHA</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Github Repository 방문수를 트래킹 하는 방법]]></title>
            <link>https://medium.com/@gjbae1212/github-repository-%EB%B0%A9%EB%AC%B8%EC%88%98%EB%A5%BC-%ED%8A%B8%EB%9E%98%ED%82%B9-%ED%95%98%EB%8A%94-%EB%B0%A9%EB%B2%95-1df4dfc5509c?source=rss-8762f94a1b9f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1df4dfc5509c</guid>
            <category><![CDATA[readme]]></category>
            <category><![CDATA[badges]]></category>
            <category><![CDATA[github]]></category>
            <dc:creator><![CDATA[Allan Bae]]></dc:creator>
            <pubDate>Sat, 21 Sep 2019 00:00:00 GMT</pubDate>
            <atom:updated>2020-01-05T00:27:38.205Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o-zT_Nd-AS6lBA1eMlc2nA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@brina_blum?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Brina Blum</a> on <a href="https://unsplash.com/s/photos/git?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><strong>해당 글인 이전에 썻던 블로그를 Medium으로 마이그레이션 한것이다.</strong></p><h3>개요</h3><p>Github에서 개인 프로젝트를 작업후에 README에 방문수 트래킹 하기위해서 <strong>badge</strong> 로 표현하는 것을 이용할려고 했었다.<br>그중 가장 인기가 많아 보이는것은<a href="https://gjbae1212.github.io/posts/2019-09-21-hits/!http://hits.dwyl.io/"><strong>hits</strong></a> 라는 오픈소스 프로젝트 였는데, 내가 사용하기에는 몇가지 부족한점이 있었다.</p><ol><li><strong>https 지원 안한다. 보안 이슈로 업계 전반으로 https 를 기본 으로 하는 추세인지라, 마음적으로 거슬리는 부분이 컸다.</strong></li><li><strong>github 프로젝트만 badge 를 지원 한다. github 프로젝트 외에도 개인 블로그나 사이트에서도 이용하고 싶은 부분이 컸다.</strong></li><li><strong>페이지수 카운팅 할때, 최대한 개인정보를 저장하고 싶지 않다. 유저를 식별할수 있다고 판단될수 있는 정보를 남기고 싶지 않았다.(ip .. 등)</strong></li><li><strong>날짜별 페이지 방문수를 알고 싶다. 보통 전체 누적으로만 알수 있는데, 날짜별 페이지 방문수를 간략하게 확인해 볼수 있을 정도는 있었으면 좋겠다고 생각했다.</strong></li><li><strong>badge 달때 좀더 다양한 옵션이 있었으면 한다. 그냥 페이지 카운터를 계산하지 않고, 노출만 시키는 </strong><strong>badge 라던가, </strong><strong>badge 타이틀을 바꾸는 등 기능이 있었으면 좋겠다.</strong></li></ol><p>결국은 만들어 쓰자고 생각하여 개발을 시작하기로 했었고, 그 후기를 남겨본다. <a href="https://hits.seeyoufarm.com/"><strong>https://hits.seeyoufarm.com</strong></a></p><h3>준비 작업</h3><h4>1. 도메인 준비</h4><p>일단 먼저 개발 보다 어떤 도메인을 쓸까 부터 고민했었다.(<strong>김치국부터 마시는…</strong>)<br>어차피 계속 운영 할테니 돈주고 살까 생각도 했었지만, 문뜩 부모님 과수원 홈페이지 만들려고 구매한 도메인인이 생각났었다. ( <strong>seeyoufarm.com</strong>)<br>서브도메인으로 이용하기로 했고 <a href="https://hits.seeyoufarm.com/"><strong>https://hits.seeyoufarm.com</strong></a> 으로 하기로 결정을 했었다.</p><h4>2. 플랫폼 선택</h4><p>당시 구글 클라우드 개발자행사에서 <strong>Cloud Run</strong> 을 소개 되었는데 컨셉이 마음에 들어서 사용해야지 생각했으나 1가지 문제가 있었다.</p><blockquote><strong>구글클라우드 내 SASS 서비스(Cloud SQL, Redis ..등)을 이용할수 없습니다.</strong></blockquote><p>물론 Cloud Run 을 인프라를 <strong>Kubernetes</strong>로 하면 가능하다는 이야기가 있었지만, 배보다 배꼽이 큰 사항(비용!!!!)이라 당연히 그냥 패스하고, 그냥 <strong>Flexible AppEngine</strong> 쓰기로 결정했다.</p><h4>3. 데이터 저장소 선택</h4><p>성능적인 장점이랑 여러 고려했을테 <strong>Redis</strong> 가 가장 무난했고, 그걸 이용하기로 했다.</p><h4>4. 언어 선택</h4><p>머 딱히 선택할꺼 없이 무조건 <strong>Golang</strong> 이였다.</p><h3>개발</h3><p>일단 <strong>echo</strong> 프레임워크로 기반을 HTTP 서버 기반을 만들었다. 그리고 급 개발 욕심에 몇가지 기능을 더 만들게 되었는데…</p><h4>1. 뱃지 생성</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bvKwvsXlMMsGceO4.gif" /><figcaption>링크 생성하기</figcaption></figure><p>누구나 편하게 넣기 쉽게 하기 위해서, <strong>html link</strong> 또는 <strong>markdown</strong> 을 복사해서 가져 갈수 있게 기능을 넣었다. 그냥 URL EDIT 폼에서 URL 변경하면 복사해서 가져 갈수 있게 작업을 했었다.</p><h4>2. 랭킹</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MsUvlC-c8QoiY1ljnpzfNQ.png" /><figcaption>상위 10위 랭킹</figcaption></figure><p>일단 목적 자체가 Github 프로젝트에 이용할 목적으로 제작을 했었다.<br>(물론 github repository 아니어도 사용 가능하다.)</p><p>그래서 해당 서비스를 사용하는 Github Repository중 페이지 방문수 상위 10위 까지 프로젝트를 보여주는게 좋다고 생각했다.</p><p>그래서 Redis 데이터 구조를 해당 검색이 가능하도록 <strong>Index</strong> 를 만드는 작업을 비동기로 생성하도록 구현을 해두었다.</p><h4>3. 히스토리</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aITFK6xaUvzG62NP.gif" /><figcaption>날짜별 방문수 확인</figcaption></figure><p>간략히 날짜별 페이지수를 보고 싶었기에, URL만 수정하면 날짜별 방문율이 보여질수 있게 작업을 했었다.</p><h4>4. 스트림</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*BdF22-EQLSGKQUxD.png" /><figcaption>실시간으로 트래킹 확인</figcaption></figure><p>실시간으로 페이지 카운팅 되는것을 스트림 형태로 보여주는 기능이다.<br>내부적으로 이용해서 실시간으로 보여주는 방식이고, <strong>WASM</strong> 이용해서 작업을 했다.<br><a href="https://gjbae1212.github.io/posts/2019-09-21-hits/!https://developer.mozilla.org/ko/docs/WebAssembly"><strong>WASM</strong></a> 자세한 설명은 여기에 있고, 관련히 설명 하면 C,C++,Go,Rust 같은 언어를 이용해서 컴파일해서 웹에서 이용할수 있는 기법이라고 생각하면 된다.(javascript 코드 짜는 대신에)</p><p><strong>WASM 이용시 장점은</strong></p><ul><li><strong>내가 원하는 언어로 javascript 일부 대체할수 있다.<br>(javascript 완전 대체할 목적으로 만들어진 프로젝트는 아니고, 상호 보완 형태로 이용한다.)</strong></li><li><strong>의도치 않게 코드 난독화가 된다.<br>(컴파일 되니깐… 물론 풀어서 보는 방법이 없는건 아니다.)</strong></li><li><strong>성능적인 장점이 있다</strong></li></ul><p>그래서 익숙한 언어(Go)로 개발을 했으나, Go로 이용했을때 1가지 단점이 있었다.</p><p>Go로 만들때 바이너리 사이즈가 MB 단위를 훌쩍 넣어간다. <br>머 별거 들어간것도 없는데, 사이즈 너무 커서 별로 였다.</p><p>물론 방법이 없는건 아니다. <strong>TinyGo</strong>를 쓰면 획기적으로 줄어들수 있긴하지만, 네트워크 관련 기본 라이러리를 서포트하지 않는다.<br>(사실 이때 WASM 사이즈 벤치마킹 한 결과 찾아보면서 <strong>Rust</strong> 좋군아 하는 생각도 했었다.)</p><h3>배포</h3><p>편하게 배포하기 위해서는, Github에 master 브랜치에 푸쉬될때 테스트 통과후 자동 배포가 되길 원했다.</p><p>별도의 외부 CI/CD 툴을 이용하기 보다는, 그냥 Google Cloud 내에서 지원하는걸 써야겠다는 생각에<a href="https://gjbae1212.github.io/posts/2019-09-21-hits/!https://cloud.google.com/cloud-build"><strong>Cloud Build</strong></a> 이용 했었다.</p><p>그러나 Public 하게 공개된 프로젝트에 <strong>Cloud Build</strong> 설정을 넣기에는 조금 민감한 데이터들이 있었다. 이런것들은 Google Cloud 에서 제공하는 서비스를 이용하여 암호화후 이용하는하는걸로 작업을 했었다.</p><h3>결론</h3><p>혼자 사용할 목적으로 만들었으나, 점점 사용자가 늘어서 푸듯함을 느끼고 있다.<br>(달 마다 invoice 가 날라오는 압박이 있지만…)</p><p>필요로 하시는 분들이 편하게 사용하시면 좋을꺼 같다.</p><p><a href="https://hits.seeyoufarm.com/"><strong>https://hits.seeyoufarm.com</strong></a></p><p>코드는 여기서 확인 가능하다<strong>. <br></strong><a href="https://github.com/gjbae1212/hit-counter"><strong>https://github.com/gjbae1212/hit-counter</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1df4dfc5509c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>