34
Serverless

Serverless Architecture

Embed Size (px)

Citation preview

Page 1: Serverless Architecture

Serverless

Page 2: Serverless Architecture

( … ) Server-less

Serverless?

Page 3: Serverless Architecture

Not having to think about servers

Serverless is

Page 4: Serverless Architecture

• BaaS (Backend as a Service)• FaaS (Function as a Service)

Serverless

Page 5: Serverless Architecture

Serverless was 1st used to describe applications that significantly or fully de-pend on 3rd party applications / services (‘in the

cloud’) to manage server-side logic and state.

BaaS

Page 6: Serverless Architecture

BaaS

Page 7: Serverless Architecture

• Analytics• Cloud Messaging• Authentication• Realtime Database• Cloud Storage• Notification

BaaS : Firebase

Page 8: Serverless Architecture

AWS Mobile

Page 9: Serverless Architecture

Serverless can also mean applications where some amount of server-side logic is still written by the application developerbut unlike traditional architectures is run in stateless compute containers that are event-triggered, ephemeral(may only last for one invocation), and fully managed by a 3rd party.

FaaS

Page 10: Serverless Architecture

running back end code without managing your own server systems or your own server applications.

FaaS

Page 11: Serverless Architecture

FaaS

Page 12: Serverless Architecture

BaaS & FaaS

Page 13: Serverless Architecture

BaaS & FaaS

Page 14: Serverless Architecture

Cloud evolution

Page 15: Serverless Architecture

What’s different?

Page 16: Serverless Architecture

Applications / Services

A lightweight, event-based, asynchronous compute solution that allows you to create small, single-purpose functions that respond to cloud events without the need to manage a server or a runtime environment.

Page 17: Serverless Architecture

Infrastructure• Fully-managed by vendor

• Without managing server system / applications• Functions

• AWS Lambda: JS, Python, JVM lang, C#• Deploy

• BYOC: bring your own code. ZIP or code in console• Scaling

• Request based automatically• Trigger by events

• Defined by vendors: eg AWS S3, CloudWatch, Message Queue• Http/s requests: eg. API Gateway, Webtask

Page 18: Serverless Architecture

Traffic pattern

Page 19: Serverless Architecture

Architecture

• Stateless Function• API gateway• Event-driven Architecture

Page 20: Serverless Architecture

Stateless functions : 1st version

Page 21: Serverless Architecture

Stateless functions : 1st version

All 3 operations are scaled based on the overall load across them, and state is transferred in-memory, creating complication around caching and/or routing sessions to instances in order to maintain state.

Page 22: Serverless Architecture

Stateless functions : 2nd version

Page 23: Serverless Architecture

Stateless functions : 2nd version

Each function scales individually and as-needed. All state is in DynamoDB so there is no cluster co-ordination of any sort, at the cost of a small in-crease in latency.

Page 24: Serverless Architecture

Stateless functions

• Processes are stateless and share-nothing• Any data that needs to persist must be stored

in a stateful backing service, typically a DB.

Page 25: Serverless Architecture

Stateless functions - Benefits

• Reduce operational costs• Infrastructure cost: without pay as it is idle• People cost: focus on function development

• Reduce development cost• BaaS: eg. Firebase, Auth0• Spend development time on business-specific

code• Maximize iterations• Minimize dependences: IT Ops, DBAs

• Easier Operational management• Scaling benefits of FaaS• Reduced packaging complexity

Page 26: Serverless Architecture

API Gateway

• HTTP server where routes / endpoints are de-fined in configuration and each route is associ-ated with a FaaS function.

• perform authentication, input validation, re-sponse code mapping, etc.

Page 27: Serverless Architecture

API Gateway

• Encapsulates the internal structure of the ap-plication.

• Reduces the number of round trips between the client and application.

• Simplifies the client

Page 28: Serverless Architecture

Event Driven Architecture

• Scale: it enables the implementation of trans-actions that span multiple services and provide eventual consistency.

• Materialized view: It enables an application to maintain a data store that contains the result of a query. It may be a join result or a summary using an aggregate function.

Page 29: Serverless Architecture

CQRS

Command Query Responsibility Segregation

Page 30: Serverless Architecture

1. fabric• 인프라 리소스가 환경에 따라 빠르게 동적으로 구성 , 혹은 재배치될 수 있도록 최적화된 서버 , 네트워크 , 스토리지의 묶음 .• RTI(Real-Time Infrastruncture)• 개발자가 운영 신경 쓰지 않고 개발 코딩 자체에 집중 .

2. framework• 이벤트 기반 프로그래밍 모델에 기반한 코드 생성 .• 대량 입출력 애플리케이션 (ex : IoT) 에 적합• 작성된 코드의 인과를 관리 .

3. function layer• 애플리케이션 조합 / 빌드를 위한 패키지 , 패턴 , 참조 아키텍처 제공 .• 원하는 출력을 얻기 위한 로직과 인텔리전스가 있는 곳 .

Serverless Architecture

Page 31: Serverless Architecture

AWS Lambda 예

Page 32: Serverless Architecture

Cloud 비교 (1)Category AWS Lambda Azure Functions Google Cloud Functions

Version Production ready Preview - Beta Closed Alpha

Support Lang Nodejs, Python, Java, C# Nodejs, Python, PHP, F#, C# Javascript

Dependency Management

Compile all external pack-ages and zip the source code

Using package.json – node.jsproject.json – F#, C#

Using package.json

Event Source S3, DynamoDBKinesisStreamsSNS, SESCognitoCloud FormationCloud WatchCode CommitScheduled EventsConfigEchoAlexaAPI Gateway

Bindings/Triggers SchedulerHttp(webhook)Azure StorageEvents HubsQueues, TablesDocumentDB(No-sql)Notification HubTwilio

HTTP functions :Http TriggersWebhooks (drive, gmail, calendar) Background functions :Cloud Pub/Sub, Cloud Stor-age Pub/Sub : Cloud LoggingGmail, Twilio

Architecture On top of LinuxMemory allocated per func-tion

On top of WindowsMemory allocated per app ser-vice

Not Specified

Page 33: Serverless Architecture

Cloud 비교 (2)Category AWS Lambda Azure Functions Google Cloud Functions

Persistent Storage No persistent storageCompletely Stateless

Env variables can be set in App services which can be used in functions.

Not Specified

HTTP Endpoint API Gateway HTTP Webhooks HTTP TriggerMaximum Execu-tionTime per request

300 seconds 300 sec max runtime per function invocation

No limit

Deployment Zip upload to Lambda/s3, Serverless Framework

Git, dropbox, visual studio, One drive, Kudu Console

Zip upload, Cloud Storage, Cloud Source repositories, Git

Maximum no. of Functions

No limit Not Specified 20 functions per project

Concurrent execu-tions

100 parallel executions per account per region but users can increase it

No limit No limit

Pricing Request Charges : $0.20 / 1M requests Compute Charges :$0.00001667 / GB-s

Request Charges : $0.20 / 1M requests Compute Charges :$0. 000008 / GB-s

Unknown until Open beta

Concurrent Execu-tions

100 parallel Executions, but Can be increased

10 instances which is sev-eral 100 executions

Not Specified

Page 34: Serverless Architecture

Reference• Serverless: The next step in cloud computing’s evolution

• http://netformation.com/your-it-reality/serverless-the-next-step-in-cloud-computings-evolution

• ( 번역 ) 서버리스 아키텍처• http://blog.aliencube.org/ko/2016/06/23/serverless-architecture

s/• Serverless by Young Yang (Slideshare)

• https://www.slideshare.net/young.yang/serverless-73008636Reduced packaging complexity

• 기타 볼만한 …• Technical Introduction to AWS Lambda - Serverless

Compute on AWS• https://www.youtube.com/watch?v=QzipnZzAQEk

• 개발자들이 말하는 AWS 기반 ‘서버 없는 아키텍처’• https://aws.amazon.com/ko/blogs/korea/serverless-architect

ure-by-korean-developers/