Serverless Application - Event-driven Serverless Backend 구축

2024. 1. 12. 16:29클라우드/AWS

1월 AWS Design (DevAx) (1/12)

  1. Serverless on AWS
  2. Serverless Computing 구축
  3. API 구성 및 Web Application 배포
  4. Event-driven Serverless Backend 구축

 


 

 

Event-driven Serverless Backend 구축

AWS Cognito

Amazon cognito

Flexible, scalable API and SDK support

Agile development and integrated customer analytics

Extensible AuthN and AuthZ

Built-in UI for applications

Secure and available

Out-of-the-box support for social federation

Out-of-the-box support for open standards

 

 

OAuth2 - Authorisation code grant flow

 

 

Identifying the actors

 

 

OAuth2 OIDC with Amazon Cognito

  1. User Pool 생성
  2. User pool에 도메인 추가
    [custom].auth.[region].amazoncognito.com
    auth.enterprise.com

 

 

Amazon Cognito user pools as OpenID provider

 

 

Event-Driven Architecture

"Events are the language of serverless applications"
Dave Boyne
Serverless Developer Advaocate, AWS

 

 

이벤트 (Events)

  • 상태 변경에 대한 정보를 서비스 간에 공유하기 위한 기본 메커니즘
  • 간접성
  • 일반적으로 비동기 방식으로 처리

 

 

이벤트 기반(Event-driven) 아키텍처

이벤트 라우터
(Evenet Routers)
비동기 이벤트
(Asynchronous Events)
이벤트 저장소
(Event Stores)
생산자와 소비자간의
추상화
응답성 향상 및
종속성 감소
서비스를 처리할 수 있을 때까지
메시지 버퍼링

 

 

서비스간의 상호 작용을 위한 이벤트

이벤트 라우팅, 저장, 배포를 위한 관리형 서비스

Amazon SQS Amazon SNS EventBridge Step Functions
메시징 이벤트 Choreography 오케스트레이션
내구성과 확장성
완전 관리형
포괄적인 보안
대규모 성능
완전 관리형
Enterprise-ready
이벤트 필터링
관리 및 확장 가능
SaaS 통합
시퀀싱
병렬 실행
상태 관리

 

 

이벤트 기반(Event-driven) 아키텍처 패턴

Decoupled messaging

Publish/subscribe

 

 

모놀리식에서 마이크로서비스로 전환

푸드트럭에서 고급레스토랑으로 전환

 

 

직접 명령을 통한 통신

도넛 준비하세요.
영수증 준비하세요.
영수증 입니다.
도넛 만듭니다.

 

 

API를 활용한 통신

생산자(Producer)는 각각의 소비자(cunsumer)와 상호작용하는 방법을 알아야 합니다.

 

 

소비자의 추가에는 생산자의 서비스 업데이트 필요

 

 

 

동기 방식의 요청-응답 모델

이점

  • 낮은 레이턴시
  • 단순한 구현
  • Fail fast 전략

 

단점

  • Receiver 이슈는 전체 서비스 장애
  • 많은 요청은 Receiver Throttle

 

 

이벤트 기반의 통신

이벤트: 도넛 주문입니다.
영수증 발행합니다.
도넛 만듭니다.
파이가 아니네요? 무시합니다.

 

 

이벤트 라우팅과 필터링

이벤트: 파이 주문입니다.
무상입니다.
재고 반영합니다. 파이 만듭니다.

 

 

다운스트림 소비자에게 버퍼 제공

 

 

비동기 방식의 point-to-point 모델 (Queue)

이점

  • 시간적(Temporal) 결합 감소
  • Receiver 장애에 
  • Receiver
  • 에러에 대한 DLQ (Dead-Letter Queue) 처리
  • 각각의 메시지는 하나의 Receiver가 처리

 

단점

  • 응답 방식 구현의 어려움

 

Amazon SQS

  • 완전 관리형 메시지 대기열 서비스
  • 거의 무한대로 

 

비동기 방식의 메시지 Router (Bus)

이점

  • 주소(Location) 결합 감소

 

 

AWS 서버리스 - 현대적인 이벤트 기반 디자인에 적합

 

 

Module2

 

 

실시간 Ride Time Publish - backend update