Post on 11-Apr-2017
Serverless
( … ) Server-less
Serverless?
Not having to think about servers
Serverless is
• BaaS (Backend as a Service)• FaaS (Function as a Service)
Serverless
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
BaaS
• Analytics• Cloud Messaging• Authentication• Realtime Database• Cloud Storage• Notification
BaaS : Firebase
AWS Mobile
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
running back end code without managing your own server systems or your own server applications.
FaaS
FaaS
BaaS & FaaS
BaaS & FaaS
Cloud evolution
What’s different?
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.
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
Traffic pattern
Architecture
• Stateless Function• API gateway• Event-driven Architecture
Stateless functions : 1st version
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.
Stateless functions : 2nd version
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.
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.
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
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.
API Gateway
• Encapsulates the internal structure of the ap-plication.
• Reduces the number of round trips between the client and application.
• Simplifies the client
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.
CQRS
Command Query Responsibility Segregation
1. fabric• 인프라 리소스가 환경에 따라 빠르게 동적으로 구성 , 혹은 재배치될 수 있도록 최적화된 서버 , 네트워크 , 스토리지의 묶음 .• RTI(Real-Time Infrastruncture)• 개발자가 운영 신경 쓰지 않고 개발 코딩 자체에 집중 .
2. framework• 이벤트 기반 프로그래밍 모델에 기반한 코드 생성 .• 대량 입출력 애플리케이션 (ex : IoT) 에 적합• 작성된 코드의 인과를 관리 .
3. function layer• 애플리케이션 조합 / 빌드를 위한 패키지 , 패턴 , 참조 아키텍처 제공 .• 원하는 출력을 얻기 위한 로직과 인텔리전스가 있는 곳 .
Serverless Architecture
AWS Lambda 예
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
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
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/