기술 스택을 위한 Amazon CloudFront

Amazon CloudFront , 짧은 대기 시간으로 콘텐츠를 안전하게 제공하도록 구축된 글로벌 CDN(콘텐츠 전송 네트워크)입니다.

이 블로그 게시물에서는 기술 스택에 Amazon CloudFront을 포함하는 것을 고려해야 하는 이유를 살펴보겠습니다.
  • Edge advantage
  • CloudFront Functions
  • Power of distributions and origins
  • Geo restrictions
  • Monitoring and reports

  • 에지 이점

    Amazon CloudFront은 에지 위치와 연결되는 것으로 알려져 있습니다. 엣지 로케이션은 각 AWS 리전과 지속적으로 성장하는 AWS 가용 영역에 전 세계적으로 퍼져 있는 AWS 데이터 센터입니다! CloudFront는 이러한 엣지 로케이션을 사용하여 CloudFront 배포 콘텐츠를 캐싱하므로 해당 배포를 요청하는 사용자는 최소한의 지연 시간으로 더 빠르게 서비스를 받을 수 있습니다. 엣지 로케이션은 전 세계 거의 모든 지역에 분산되어 있으므로 가장 가까운 엣지 PoP(Point of Presence)를 사용하여 콘텐츠를 캐시하고 해당 PoP에서 전달합니다.

    https://aws.amazon.com/cloudfront/features의 이미지

    그러나 이것은 정적 콘텐츠에 대해 쉽게 수행되지만 동적 콘텐츠에 대해서는 Lambda@Edge 가 있습니다. 이것은 CloudFront의 이벤트를 기반으로 실행하기 위해 Lambda@Edge를 사용하는 CloudFront의 기능이며 고가용성으로 확장성을 관리합니다. Lambda@Edge는 다양한 용도로 사용됩니다.
  • 웹사이트 보안 및 개인 정보 보호
  • 동적 웹 앱
  • 검색 엔진 최적화(SEO)
  • 라우팅 및 리라우팅
  • 사용자 추적 및 분석

  • Lambda@Edge는 가장 가까운 AWS 지역 엣지 캐시에서 실행됩니다.

    CloudFront 기능

    While Lambda@Edge enables faster and running code near to the user, CloudFront functions enables using light weight JavaScript functions directly in edge location. This is cheaper than Lambda@Edge and also faster as this is executed at the edge location itself.

    function handler(event) {
        // NOTE: This example function is for a viewer request event trigger. 
        // Choose viewer request for event trigger when you associate this function with a distribution. 
        console.log(JSON.stringify(event,null,2))
        var response = {
            statusCode: 200,
            statusDescription: 'OK',
            headers: {
                'cloudfront-functions': { value: 'generated-by-CloudFront-Functions' }
            }
        };
        return response;
    }
    
    Similar to the AWS Lambda functions console experience but you can also test out the functions before deploying them and associating with a CloudFront distribution.

    다양한 요청으로 더 쉽게 테스트할 수 있습니다.

    CloudFront 기능의 일반적인 사용 사례는 다음과 같습니다.
  • URL 재작성 및 리디렉션
  • 캐시 조작
  • HTTP 헤더 조작
  • 승인

  • 분포 및 기원의 힘

    When we are talking about CloudFront distributions, each of these distribution is routed to an origin. Origins are the content which is been served over the distribution. Currently CloudFront supports multiple origins such as -

    • Amazon S3
    • Amazon ELB
    • Amazon Mediastore Container
    • Amazon Mediapackage Container

    Of these, Amazon S3 is the most popular one where the static web hosting of S3 is served securely with Amazon CloudFront. Even provides an option of S3 + CloudFront.

    The ease of defining access controls with respect to what protocol and HTTP methods are allowed. The regex patter is also supported for enforcing needed cache policy for matching request URI pattern.

    각각의 배포에 대해 캐시 동작을 정의하여 성능을 향상시킬 수 있습니다.

    이전에 Lambda@Edge 및 CloudFront Functions에 대해 이야기했는데 이들은 최종 사용자 또는 오리진 요청-응답과 연결되어 있습니다.

    CloudFront 배포는 모든 독자에게 친숙한 URL이 아니며 독자에게 친숙한 사용자 지정 도메인이 있는지 확인하기 위해 CNAME 레코드를 사용하거나 사용자 지정 도메인이 있고 연결된 SSL 인증서가 있는 경우 이 배포로 다시 라우팅할 수 있습니다. , SSL 인증서를 AWS Certificate Manager에 매핑하여 동일하게 사용할 수 있습니다.
    CloudFront는 CloudFront 배포에서 제공된 도메인으로 도메인을 관리할 수 있는 Amazon Route53과 잘 연결됩니다.

    지리적 제한

    If the content you are server over CloudFront distributions have to be geographically restricted to users, then with CloudFront helps with detecting the origin (request's actual origin and not CloudFront origin) and if any geo restriction rules are matched with request's origin then they can be blocked or granted access.

    특정 국가에 대한 액세스를 차단할 수 있을 뿐만 아니라 특정 국가에 대해서만 허용할 수도 있습니다.

    지리적 제한을 설정한 경우 콘텐츠를 캐싱할 수 있는 엣지 로케이션의 올바른 리전을 선택하여 CloudFront 결제 비용을 더 많이 절약할 수 있습니다.

    모니터링 및 보고

    CloudFront not only helps with content delivery network but it features some fantastic monitoring and report capabilities. We can set alarms to each of the distribution when the requests are crossing a threshold and use Amazon SNS ' 주제를 알림 대상으로 지정합니다.

    CloudFront는 로깅을 지원하며 이러한 로깅은 로그온되어Amazon CloudWatch 요청 및 응답이 포함된 모든 로그 및 메트릭 대시보드를 쉽게 해석할 수 있습니다.
    CloudFront는 장치/위치/운영 체제/브라우저별로 뷰어 형식으로 배포에 대한 트래픽 세부 정보를 제공하는 다양한 요청 오리진 세부 정보를 캡처합니다.

    또는 상위 리퍼러, 캐시 통계 및 더 많이 요청된 인기 있는 개체에 대한 보고서도 있습니다!

    결론



    이는 대기 시간을 줄여 성능을 개선할 수 있을 뿐만 아니라 지리적 제한 및 보고를 통해 더 많은 작업을 수행할 수 있는 기술 스택에 포함해야 할 중요한 AWS 서비스입니다.

    좋은 웹페이지 즐겨찾기