#WISSENTEILEN
Cloud Architekuren
Von „less Server“ zu Serverless
Lars Röwekamp | open knowledge GmbH
@_openKnowledge | @mobileLarson
ÜBER OPEN KNOWLEDGE
Branchenneutrale Softwareentwicklung & IT-Beratung
ÜBER MICH
Wer bin ich - und wenn ja, wie viele?
• CIO New Technologies
• Enterprise & Mobile
• Autor, Speaker, Coach & Mentor
• Snowboard & MTB Enthusiast (a.k.a. “stets bemüht“)
Lars Röwekamp (a.k.a. @mobileLarson)
Mein Server
und ich ...
Mein Server
und ich ...
„The Nightmare“
#WISSENTEILEN
Server Q&A„Dinge, über die ich mir Gedanken machen sollte!“
#WISSENTEILEN
#Servers:
#Customer:
#Traffic:
#Security:
Anzahl? OS? Storage? CPU? Memory?
Start small! Grow fast! Die faster?
Moderat, aber mit Peaks?
OS? Patches? Access Control?
“We have to be great at a number of things…
operating data centers is not one of those things.”
I had a
dream ...
#WISSENTEILEN
#LaborCost:
#Risk:
#ResourceCost:
#Scaling:
#LeadTime:
DIY? Nein, danke!
Risiko liegt zu 100% beim Provider
nur zahlen, was ich nutze
on-the-fly Up- und Down-Scaling
neue System stehen „sofort“ zur Verfügung
„Kein Server ist
einfacher zu
verwalten, als
kein Server.“
(Werner Vogels, CTO Amazon)
out-of-the-box self-scaling
out-of-the-box
self-scaling
cloud-based
super-backend
I had a dream ...
Aber warum
ICH?
#1
Agilität
#2
Plattform
#3
Kosten
#4
Innovationen
“We are a hospitality management
organization, not an IT services company.”
80 Mio Gäste / 1500 EC2
„We have a 5 person operations team.”
„Kein Server ist
einfacher zu
verwalten, als
kein Server.“
(Werner Vogels, CTO Amazon)
SERVERLESS
The Road to
less Server?
The Road to the Cloud ...
Der Serverless Showcase
Road to less Server
IaaS
Road to less Server
Road to less Server
Self-Managed Cloud-Managed
Road to less Server
Self-Managed Cloud-Managed
Provisioning
Security
Maintenance
Road to less Server
Self-Managed Cloud-Managed
Provisioning
Security
Maintenance
Road to less Server
Sieht irgendwie kompliziert
aus! Muss ich mich darum
kümmern?
Self-Managed Cloud-Managed
Provisioning
Security
Maintenance
Road to less Server
Self-Managed Cloud-Managed
Elastic
Beanstalk
Elastic
Kubernetes
Elastic
Container
Provisioning
Security
Maintenance
Scaling
Road to less Server
IaaS
(Infrastructure as a Service)
EBS: elastic beanstalk
Road to less Server
IaaS
(Infrastructure as a Service)
ECS : elastic container service
Road to less Server
IaaS
(Infrastructure as a Service)
EKS : elastic container service for kubernetes
IaaS
Road to less Server
IaaSPaaS
Road to less Server
Road to less Server
Self-Managed Cloud-Managed
Provisioning
Security
Maintenance
Scaling
Road to less Server
Self-Managed Cloud-Managed
Provisioning
Security
Backup/Recovery
Scaling
Provisioning
Security
Maintenance
Scaling
Road to less Server
IaaS
(Infrastructure as a Service)
Road to less Server
PaaS
(Platform as a Service)
IaaSPaaS
Road to less Server
Business Logic
(... as a Service)
Das Versprechen
von Serverless
“Run YOUR business
code in the cloud.“
Das klappt niemals!
Das klappt niemals!
Warum nicht?
Das klappt niemals!
Warum nicht?
Na, weil es
DEIN
Business
Code ist!
IaaSPaaS
Road to less Server
PaaS IaaS
Road to less Server
Road to less Server
Self-Managed Cloud-Managed
Provisioning
Security
Backup/Recovery
Scaling
Provisioning
Security
Maintenance
Scaling
Road to less Server
Self-Managed Cloud-Managed
API Key Mgmt
Throtteling
Zero-Downtime
Region Availability
Provisioning
Security
Backup/Recovery
Scaling
Provisioning
Security
Maintenance
Scaling
Road to less Server
PaaS
(Platform as a Service)
Road to less Server
PaaS
(Platform as a Service)
Road to less Server
BaaS
(Backend as a Service)
Road to less Server
BaaS
(Backend as a Service)
Road to less Server
BaaS
(Backend as a Service)
PaaS IaaS
Road to less Server
?
PaaS IaaS
Road to less Server
#WISSENTEILEN
“Run your business code
highly-available
in the cloud in response
to events and scale
without any servers to
manage.“*
* AWS Lambda Advertising
#1:
Run your
business code
#2:
No servers to
provision or manage
#3:
Build in high availability
and disaster recovery
#4:
Scale with usage
by design
Management:
“Hmm, ich bin noch
nicht überzeugt!.”
#5:
Never pay idle
(Management: „Ok, I bin definitiv dabei!“)
„Kein Server ist
einfacher zu
verwalten, als
kein Server.“
(Werner Vogels, CTO Amazon)
out-of-the-box self-scaling
out-of-the-box
self-scaling
cloud-based
super-backend
Remember
„your“ dreams?
My Logic
(... as a Service)
Function
(... as a Service)
Functions als Basis für
Deployment
& Skalierung
Road to less Server
PaaS
(Platform as a Service)
Road to less Server
FaaS
(Function as a Service)
Run Code,
not Server?
No machines, VMs,
or containers.
*... are visible in the programing model
Big
Players?
AWS
Lambda Microsoft
Azure Functions
Oracle Functions
a.k.a. Project FN***
IBM Cloud Functions
a.k.a Apache OpenWhisk**
Google Cloud
Functions
Project Riff
sponsored by Pivotal
Serverless in a Nutshell
Was ist die Idee
von Serverless?
#WISSENTEILEN
Function as self-contained application
Serverless Function: Entwickler schreibt eine Business-
Funktion in einer der unterstützen Programmiersprachen,
„bundled“ diese mit den entsprechenden Abhängigkeiten
(LIBs) und lädt sie in die Cloud.
Serverless Environment: Führt die Funktion bei „Aufruf“ in
der passenden Runtime effizient, flexibel und hoch skalierbar
aus.
“
#WISSENTEILEN
Serverless no need to maintain
Entwickler: Fokussiert sich ausschließlich auf die
Umsetzung der Business-Logik und das Erstellen des
Function-Bundle.
Cloud Provider: liefert und maintained rundum-sorglos
Umgebung für die Serverless Functions, inklusive etwaiger
Cloud Services (z.B. Storage, DB, Streaming, AI).
“
> Hands-On
AWS Cloud
1
trigger
request
Hands-on: Hello World
AWS Cloud
hello world serverless context
1
trigger
request
Hands-on: Hello World
AWS Cloud
hello world serverless context
HelloWorld
Logs
1
trigger
request
2
Hands-on: Hello World
Was passiert da
unter der Haube?
1
trigger
request
Hello World „under the Hood“
AWS Cloud
HelloWorld
ZIP
1
trigger
request
Hello World „under the Hood“
Download
Function Code
ZIP
Cloud Storage
S3
AWS Cloud
2
HelloWorld
ZIP
1
trigger
request
Hello World „under the Hood“
Download
Function Code
Setup
Runtime
ZIP
Cloud Storage
S3
AWS Cloud
2 3
HelloWorld
ZIP
1
trigger
request
Hello World „under the Hood“
Download
Function Code
Setup
Runtime
Init
Function
ZIP
Cloud Storage
S3
AWS Cloud
2 3 4
HelloWorld
ZIP
1
trigger
request
Hello World „under the Hood“
Download
Function Code
Setup
Runtime
Init
Function
ZIP
Cloud Storage
S3
AWS Cloud
2 3 4
COLD START
trigger
request
Hello World „under the Hood“
Download
Function Code
ZIP
AWS Cloud
Setup
Runtime
Init
Function
COLD START
trigger
request
Hello World „under the Hood“
Download
Function Code
ZIP
AWS Cloud
Setup
Runtime
Init
Function
COLD START
Execute
Handler
trigger
request
Hello World „under the Hood“
Download
Function Code
ZIP
AWS Cloud
Setup
Runtime
Init
Function
COLD START
Execute
Handler
Terminate
Function
trigger
request
Hello World „under the Hood“
ZIP
AWS Cloud
COLD START
Terminate
Function
Execute
Handler
trigger
request
Hello World „under the Hood“
ZIP
AWS Cloud
COLD START
Terminate
Function
Execute
Handler
Execute
Handler
trigger
request
trigger
request
Hello World „under the Hood“
ZIP
AWS Cloud
COLD START
Execute
Handler
Terminate
Function
Execute
Handler
Execute
Handler
trigger
request
trigger
request
Serverless
Szenarien
Szenario
#1
Szenario #1: Datei-/Datenbearbeitung
Datei- oder Datenbearbeitung nach Ablage im S3 Storage System
• Bildbearbeitung
• Thumbnail-Erzeugung
• PDF-Generierung
AWS Cloud
Szenario #1: Datei-/Datenbearbeitung
1
upload
image
AWS Cloud
Szenario #1: Datei-/Datenbearbeitung
1 2
upload
image
AWS Cloud
Store raw Image
Szenario #1: Datei-/Datenbearbeitung
StoreImage
Logs
1 2
3
upload
image
AWS Cloud
Store raw Image
Szenario #1: Datei-/Datenbearbeitung
StoreImage
Logs
S3 Object
created1 2
3
4
upload
image
AWS Cloud
Store raw Image
Szenario #1: Datei-/Datenbearbeitung
StoreImage
Logs
S3 Object
created1 2
3
4
upload
image
AWS Cloud
Create ThumbnailStore raw Image
Szenario #1: Datei-/Datenbearbeitung
StoreImage
Logs
CreateThumbnail
Logs
S3 Object
created1 2
3
4
5
upload
image
> File Processing
Szenario #1: Lessons Learned
Was wir bisher gelernt haben …
• S3 ist der Platz zur Ablage von Objekten in AWS
• S3 benötigt spezielle Zugriffsrechte
• S3 triggert automatisch Cloud Events an
• Filter innerhalb der Lambda können S3 Event Trigger gezielt
einschränken, z.B. für
• Buckets
• Prefix / Postfix,
• IAM Nutzer / Rollen
Szenario
#2
Szenario #2: Stream Processing
Regelmäßiges abarbeiten von Streaming Data
• Social Media Trendanalysen
• Sensor Data Monitoring / Anomaly Detection
AWS Cloud
1
sensor data stream is
uploaded to Kinesis
in real-time
Szenario #2: Stream Processing
tons of
very important
sensor data
AWS Cloud
1
sensor data stream is
uploaded to Kinesis
in real-time
Szenario #2: Stream Processing
tons of
very important
sensor data
AWS Cloud
Data Stream Analysis
StreamAnalyzer
Logs
1
sensor data stream is
uploaded to Kinesis
in real-time
2
Lambda runs code to
detect anomalies
Szenario #2: Stream Processing
tons of
very important
sensor data
AWS Cloud
Data Stream Analysis
StreamAnalyzer
Logs
store anomalies
extracted by lambda
function
1
sensor data stream is
uploaded to Kinesis
in real-time
2
3
Lambda runs code to
detect anomalies
Szenario #2: Stream Processing
tons of
very important
sensor data
AWS Cloud
Data Stream Analysis
StreamAnalyzer
Logs
Real-Time Monitoring / Querying
store anomalies
extracted by lambda
function
1
sensor data stream is
uploaded to Kinesis
in real-time
2
3
Lambda runs code to
detect anomalies
4
data immediately
available for interested
parties to query
Szenario #2: Stream Processing
tons of
very important
sensor data
> Stream Processing
Szenario #3: Lessons Learned
Was wir bisher gelernt haben…
• Kinesis erlaubt die Bearbeitung von Data / Media Stream
• Kinesis benötigt spezielle Zugriffsrechte
• Lambdas können Chunks eines Kinesis Streams bearbeiten
• Lambdas in Verbindung mit Kinesis können genutzt werden, um …
• Metriken zu erzeugen
• Fehler / Anomalien zu erkennen
• Media Trends zu analysieren
Szenario
#3
Szenario #3: Web Application
Serverless „all in“ einer Anwendung…
• Ausliefern von statischem Content via CDN
• Authentication / Autorization via BaaS
• Businesslogik via FaaS (unter Verwendung von PaaS)
Szenario #3: Web Application
AWS Cloud
Web Client
region aware
web app
delivery
1
Szenario #3: Web Application
AWS Cloud
Web Client
region aware
web app
delivery
1
login via id/pwd
returns JWT
2
Szenario #3: Web Application
AWS Cloud
Web Client
region aware
web app
delivery
1
login via id/pwd
returns JWT
2
3
REST
call
Szenario #3: Web Application
AWS Cloud
Web Client
region aware
web app
delivery
1
login via id/pwd
returns JWT
2
3
REST
call
4
translated
lambda
trigger
Szenario #3: Web Application
AWS Cloud
Web Client
storage related functions
region aware
web app
delivery
1
login via id/pwd
returns JWT
2
3
REST
call
4
translated
lambda
trigger
5
lambda
@work
Szenario #3: Web Application
AWS Cloud
Web Client
storage related functions
database related functions
region aware
web app
delivery
1
login via id/pwd
returns JWT
2
3
REST
call
4
translated
lambda
trigger
5
lambda
@work
5
lambda
@work
Szenario #3: Web Application
AWS Cloud
Web Client
storage related functions
database related functions
additional functions, e.g.
region aware
web app
delivery
1
login via id/pwd
returns JWT
2
6
3
REST
call
4
translated
lambda
trigger
5
lambda
@work
5
lambda
@work
The Road to the Cloud ...
Der Serverless Showcase
Web Image Gallery
(easy version)
GET ../images/{imageId}
PUT ../images/{imageId}
DELETE ../images/{imageId}
POST ../images/
Web Image Gallery
(not so easy version)
GET ../images/{imageId}
PUT ../images/{imageId}
DELETE ../images/{imageId}
POST ../images/
Web Image Gallery
(real life version)
GET ../images/{imageId}
PUT ../images/{imageId}
DELETE ../images/{imageId}
POST ../images/
Szenario #3: Lessons Learned
Was wir bisher gelernt haben …
• CloudFront und S3 zur Web App Auslieferung (statischer Content)
• Cognito zur User Authentication via JWT
• Ketten von async / lose gekoppelten Lambdas
• Gateway dient als eine Art Function Dispatcher (plus …)
Szenario #3: Lessons Learned
Was wir bisher gelernt haben …
• CloudFront und S3 zur Web App Auslieferung (statischer Content)
• Cognito zur User Authentication via JWT
• Ketten von async / lose gekoppelten Lambdas
• Layer zur Mehrfachnutzung von Libraries in Lambdas
• Gateway dient als eine Art Function Dispatcher (plus …)
?
Szenario
#4
Scenarios
#3
API Gateway
AWS Cloud
Wofür ist ein API Gateway gut?
• Security
• API Key Handling
• Throttling
• Proxying
• Logging / Tracing
• Request / Respons Mapping
• Staging
AWS Cloud
1
Szenario #4: API Gateway
GET ../resources/{resourceId}
PUT ../resources/{resourceId}
DELETE ../resources/{resourceId}
POST ../resources/
AWS Cloud
Szenario #4: API Gateway
21
GET ../resources/{resourceId}
PUT ../resources/{resourceId}
DELETE ../resources/{resourceId}
POST ../resources/
AWS Cloud
read
create
delete
update
21
Szenario #4: API Gateway
3
GET ../resources/{resourceId}
PUT ../resources/{resourceId}
DELETE ../resources/{resourceId}
POST ../resources/
AWS Cloud
read
create
delete
update
Szenario #4: API Gateway
56 4
GET ../resources/{resourceId}
PUT ../resources/{resourceId}
DELETE ../resources/{resourceId}
POST ../resources/
> API Gateway
Szenario #4: Lessons Learned
Was wir bisher gelernt haben ...
• ein API Gateway „schützt“ die Cloud vor der Außenwelt
• HTTP Requests werden in Lambda Trigger überführt
• HTTP Parameter / Payload wird auf Lambda Events gemappt
• Lambda Results werden in HTTP Status Codes überführt
• Lambda Result Objekte werden auf HTTP Payload gemapped
• API Gateways kann ein Staging-Konzpt realisieren
Reality Check
The Road to the Cloud ...
Der Serverless Showcase
AWS Cloud
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
Store raw Image
1
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create ThumbnailStore raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Use-Case: Upload Image
upload image
with additional
information
„Was kann
da schon
schiefgehen?“
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
AWS Cloud
AWS Step Functions workflow: Store Image
Create Thumbnail
Inform Subscribers
Store raw Image
Store Image Information
1
2
Was kann da schon schiefgehen?
• Interne Programmier-/Logikfehler
• Anomalien (z.B. unerwartet/ungültige Calls)
• verlorene oder doppelte Events
• hohe Latenz / Timeouts
• Security-Attacken (z.B. DoS/DDoS)
• Personalisierte SLAs / Usage Plans
• unerwartete Workload Peaks
• …
“Run your business code
highly-available
in the cloud in response
to events and scale
without any servers to
manage.“*
*(AWS Lambda product description)
“Run your business code
highly distributed
and event driven in a non
transparent environment
with no single
point of control.“*
*(my personal interpretation)
Wie teste ich?
meine Serverless Application
Was, wann, wie und wo sollte ich testen, um …
• Vertrauen in meinen Code zu gewinnen
• das Risiko von Fehlern zu minimieren*
* vor allem in Produtktion
Testen in der traditionellen Welt
Testen in der Serverless Welt
„The biggest complexity is not within
the function itself, but in how it interacts
with other functions and services
(a.k.a. cloud components).“
Testen in der Serverless Welt
Ziele des Testens: „Risiko minimieren“
• Risiko Konfiguration
• Risiko technischer Workflow
• Risiko Businesslogik
• Risiko Integration
Testen in der Serverless Welt
Ziele des Testens: „Risiko minimieren“
• Risiko Konfiguration
• Risiko technischer Workflow
• Risiko Businesslogik
• Risiko Integration
Testen in der Serverless Welt
„Don‘t let your users
test your code!“
„Welche Art von ‚Benchmarks‘ wollen wir für unser Testing?“
• funktionale Änderungen schnell/kosteneffizient testen
• integrative Änderungen schnell/kosteneffizient testen
• integrative Änderungen so „real“ wie möglich testen
• Use-Cases und User-Stories so „real“ wie möglich testen
Testing Best Practices
#1 Trennen von Businesslogik und Infrastruktur
Testing Best Practices
AWS CloudOn-Premise
handler
logic
Kandidat für Unit Tests
e
i
u
Kandidat für Integration Tests
Kandidat für End-to-Ende Tests
u
Infrastructure Business Logic
Infrastructure Business Logic
Business Logic Tests
#2 Cloud-Infrastruktur Komponenten mocken
Testing Best Practices
AWS CloudOn-Premise
handler
logic u
um
Kandidat für Unit Tests
e
i
u
Kandidat für Integration Tests
Kandidat für End-to-Ende Tests
Infrastructure
fake infrastructure component (Context)
mock infrastructure component (Context)
#3 Lokale Umgebung für funktionale Tests verwenden (z.B. SAM local)
Testing Best Practices
AWS CloudOn-Premise
handler
logic uvia SAM local
via SAM local
SAM
yaml
TEST
u
u
Kandidat für Unit Tests
e
i
u
Kandidat für Integration Tests
Kandidat für End-to-Ende Tests
$ sam local invoke "Greetings" -e event-greeting.json --env-vars env.json
function name payload for function
$ sam local invoke "Greetings" -e event-greeting.json --env-vars env.json
function name payload for function
#4 Lokale Umgebung zum Triggern von Integration Tests verwenden
Testing Best Practices
AWS CloudOn-Premise
handler
logic uvia SAM local
via SAM local
SAM
yaml
TEST
u
u
i
i
Kandidat für Unit Tests
e
i
u
Kandidat für Integration Tests
Kandidat für End-to-Ende Tests
$ sam local start-api –p 8080
$ sam local start-api –p 8080
$ sam local start-api –p 8080
#5 Lokale Cloud-Komponenten für Integration Tests*
Testing Best Practices
AWS CloudOn-Premise
handler
logic u
via DynamoDB local
via FakeS3 via SAM local
via SAM local
SAM
yaml
TEST
u
u
i
i
i
i
WARNUNG: lokale Cloud
Komponenten können
lediglich funktionale
Korrektheit sicherstellen,
nicht aber infrastrukturelle,
wie z.B. DLQs, Timeouts,
Throttling, SLAs, …
Kandidat für Unit Tests
e
i
u
Kandidat für Integration Tests
Kandidat für End-to-Ende Tests
$ sam local generate-event [SERVICE] [OPTION]
Simulate Component Event to trigger Lambda
$ sam local genarte-event [SERVICE] [OPTION]
Simulate Component Event to trigger Lambda
Simulate Component triggered by Lambda
$ aws –endpoint-url=http://localhost:8000 dynamodb list-tables
$ java –jar DynamoDBLocal.-jar
Simulate Component triggered by Lambda
$ aws –endpoint-url=http://localhost:8000 dynamodb list-tables
Simulate Component triggered by Lambda
$ aws –endpoint-url=http://localhost:8000 dynamodb list-tables
#6 temporäre Integration-Cloud für partielle Integration Tests
Testing Best Practices
AWS CloudOn-Premise
handler
logic uvia SAM local
via SAM local
SAM
yaml
TEST
u
u
via DynamoDB local
via FakeS3
i
i
Temorary Intregration #Dev1
ii
INT
i
i
Kandidat für Unit Tests
e
i
u
Kandidat für Integration Tests
Kandidat für End-to-Ende Tests
#7 permanente Integration-Cloud für End-to-End Tests
Testing Best Practices
AWS CloudOn-Premise
handler
logic uvia SAM local
via SAM local
SAM
yaml
TEST
u
u
via DynamoDB local
via FakeS3
i
i
Permament IntregrationINT
e
e
e
e
i
i
Kandidat für Unit Tests
e
i
u
Kandidat für Integration Tests
Kandidat für End-to-Ende Tests
„Sind wir endlich
fertig?“
Testing endet nicht
in Produktion!
Testing in Produktion
Ziele des Testens: „Vertrauen gewinnen“
• Outages von Cloud & Cloud-Komponenten
• Outages von 3rd Party Apps
• Bugs / Probleme durch Skalierung
Testing in Produktion
Robustes Monitoring und Error Reporting
• Logging
• Tracing
• Metrics
• Alerting
Vorhersagen von Störungen
inklusive automatischer
Regenerierung!
Testing in Produktion
Chaos Engineering
• bewusst kleine “Probleme“ und „Fehler“ in
das System einstreuen!
Wie monitore ich?
meine Serverless Application
Mit einem gut geplantes Monitoring sollten wir in der Lage sein, …
• aufkommende Probleme vorherzusagen
• schnell die Ursache von Problemen zu identifizieren
• automatische Recovery-Prozesse anzustoßen
• notwendige Alarme zu triggern
Real-Life Monitoring
Real-Life Monitoring
Business
KPI
UX
SLA
“Produkte
pro Bestellung”
“Durchschnittlicher
Bestellwert”
“Abbruchrate”
“Erste Darstellung
von Inhalten”
“Erste sinnvolle
Darstellung"
“Erste
Interaktion”
“Verfügbarkeit”
“Latenz”
“Beständigkeit”
“Konsistenz”
Gut geplantes Monitoring berücksichtigt verschiedene Aspekte
• reliability: Komponenten und Kommunikation
• usage: funktional und nicht-funktional
• performance: Dauer, Latenz und Timeouts
• security: Zugriffsrechte, Attacken
• costs: aktuelle Kosten, Kostenentwicklung
Real-Life Monitoring
Die 4 Säulen des Monitorings
3
2 4
1
Tracing Metrics
Alerting
Logging
3
2
Tracing Metrics
4
4
Alerting
Die 4 Säulen des Monitorings
Repräsentiert den State
einer Anwendung.
Wenn etwas schiefläuft
benötigen wir LOGs, um
herauszufinden, welche
Änderungen am State den
Fehler verursacht haben.
1
Logging
Logging
3
Metrics
4
1
Alerting
Logging
Die 4 Säulen des Monitorings
Tracing
2
Repräsentiert eine
einzelne „User‘s Journey“
durch den gesamten
Stack der Anwendung.
Tracing wird oft zur
Optimierung des Systems
genutzt.
Tracing
2
Tracing
4
1
Alerting
Logging
Die 4 Säulen des Monitorings
3
Metrics
Repräsentiert einen über
einen Zeitraum
aggregierten Messpunkt.
Hilft dabei, den aktuellen
„Health-Status“ des
Systems sowie dessen
Entwicklung festzustellen.
Metrics
3
2
Tracing Metrics
1
Logging
Die 4 Säulen des Monitorings
4
Alerting
Die Komponente des
Monitorings, die
basierende auf Metriken,
Aktionen auslöst.
Meist zur automatischen
„Selbstheilung“ verwendet
oder im zuständige
Personen zu informieren.
Alerting
Für ein gut geplantes Monitoring, sollten man daher …
• Events loggen, die eine State Transformation anstoßen
• Standard-Metriken sammeln
• Custom-Metriken definieren und sammeln
• Distributed Tracing ermöglichen
• Alarme auf individuellem und aggregierten Level definieren
Serverless Application Monitoring
Monitoring Strategie
AWS Cloud
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #1: DIY
AWS Cloud
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #1: DIY
AWS Cloud
universal Log
Logging
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #1: DIY
AWS Cloud
universal Log
Logging
DevOps
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #1: DIY
AWS Cloud
universal Log
Archive
Logging
Tracing
DevOps
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #1: DIY
AWS Cloud
universal Log
Archive
Logging Metrics
Tracing
DevOps
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #1: DIY
AWS Cloud
universal Log
Alarm
Archive
Logging Metrics
Tracing
Alerting
DevOps
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #2: Plattform Services
AWS Cloud
Logging
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #2: Plattform Services
AWS Cloud
Logging
Alerting
Metrics
“BASIC ALERTING FOR FREE”
“BASIC METRICS FOR FREE”
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #2: Plattform Services
AWS Cloud
Alarm
Logging
Alerting
Metrics
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #2: Plattform Services
AWS Cloud
Logging
Alerting
Metrics
Tracing (still DIY)
Alarm
Metrics
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #2: Plattform Services
AWS Cloud
Alarm
Logging
Tracing
Alerting
Tracing (DIY)
Metrics
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #2: Plattform Services
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #2: Plattform Services
Logging
Tracing
Metrics
Alerting
Monitoring Strategie #2: Plattform Services
Logging
Tracing
Metrics
Alerting
> Monitoring
Monitoring: Lessons Learned
Was haben wir gelernt …
• ein gut durchdachtes Monitoring besteht aus 4 Säulen
• das Logging zum Festhalten von State Transformation
• das Tracing zum Verfolgen einzelner User Journeys
• die Metriken zur Feststellung des Systemzustands
• das Alerting zum (autom.) Auslösen von „heilenden“ Aktionen
„Logging data is expensive,
so better log wisely!“
„Welche Art von ‚Benchmarks‘ wollen wir für unser Monitoring?“
• Sammeln von umfangreichen System- und Anwendungsmetriken
• Metriken und Logs sollten keine User-facing Latency verursachen
• Metriken und Logs sollten in Real-Time verfügbar sein
• Metriken und Logs sollten granular und korreliert vorliegen
Monitoring Best Practices
#1 User-facing Latency vermeiden
Monitoring Best Practices
AWS Cloud
My Lambda logs
log
stream
log
data
async
sync
Log Aggregator
log
data
1
very fast and cheap
2
3
time consuming and “expensive”
parse
log stream
#2 umfangreiche System-/Anwendungsmetriken sammeln
Monitoring Best Practices
AWS Cloud
My Lambda logs
log
stream
log
data
async
sync
Log Aggregator
metrics
custom
metrics
custom
metrics
log
data
2
3
1
very fast and cheap
parse
log stream
custom
metrics
#3 unnötige Kosten vermeiden
Monitoring Best Practices
AWS Cloud
My Lambda logs
log
stream
log
data
async
sync
Log Aggregator
metrics
custom
metrics
custom
metrics
log
data
archive
logs
1
2
custom
metrics
#4 Logs und Metriken korrelieren / aggregieren
Monitoring Best Practices
AWS Cloud
My Lambda logs
log
stream
log
data
async
sync
Log Aggregator
metrics
custom
metrics
custom
metrics
log
data
archive
logs
1
correlation
ID
custom
metrics
#5 Logging via ENV Vars an Edge Server enablen/disablen
Monitoring Best Practices
AWS Cloud
My Lambda logs
log
stream
log
data
async
sync
Log Aggregator
metrics
custom
metrics
custom
metrics
log
data
archive
logs
DEBUG
on/off
ENV var
1
2
custom
metrics
#WISSENTEILEN
Fazit
Schlussfolgerung: Spaß haben mit
Serverless?
“Find suitable
serverless workload
and apply the correct
integration patterns.”
“Eat your own
serverless dog food
for monitoring
and testing“
? ? ?
Lars Röwekamp, @mobileLarson
Kontakt:
lars.roewekamp@openknowledge.de
kontakt@openknowledge.de
Besten Dank! #WISSENTEILEN
© chanchai howharn – shutterstock.com (Folie 1)
© wavebreaker – shutterstock.com (Folie 4)
© Rich Vintage – iStockphoto.com (Folie 9)
© foxaon1987 - shutterstock.com (Folie 11)
© Guide van Nipsen – wikipedia.com (Folie 19)
© Zeeker2526 - shutterstock.com (Folie 20)
© CandyDuck - shutterstock.com (Folie 80)
© Myvisual - shutterstock.com (Folie 97)
© Rawpixel.com - shutterstock.com (Folie 241)
Alle weiteren Bilder der Präsentation sind entweder von pixabay.com
oder von mir selbst erstellt.
Bildernachweis

Cloud Architekturen - von "less Server" zu Serverless

  • 1.
    #WISSENTEILEN Cloud Architekuren Von „lessServer“ zu Serverless Lars Röwekamp | open knowledge GmbH @_openKnowledge | @mobileLarson
  • 2.
    ÜBER OPEN KNOWLEDGE BranchenneutraleSoftwareentwicklung & IT-Beratung
  • 3.
    ÜBER MICH Wer binich - und wenn ja, wie viele? • CIO New Technologies • Enterprise & Mobile • Autor, Speaker, Coach & Mentor • Snowboard & MTB Enthusiast (a.k.a. “stets bemüht“) Lars Röwekamp (a.k.a. @mobileLarson)
  • 4.
  • 5.
    Mein Server und ich... „The Nightmare“
  • 6.
    #WISSENTEILEN Server Q&A„Dinge, überdie ich mir Gedanken machen sollte!“
  • 7.
    #WISSENTEILEN #Servers: #Customer: #Traffic: #Security: Anzahl? OS? Storage?CPU? Memory? Start small! Grow fast! Die faster? Moderat, aber mit Peaks? OS? Patches? Access Control?
  • 8.
    “We have tobe great at a number of things… operating data centers is not one of those things.”
  • 9.
  • 10.
    #WISSENTEILEN #LaborCost: #Risk: #ResourceCost: #Scaling: #LeadTime: DIY? Nein, danke! Risikoliegt zu 100% beim Provider nur zahlen, was ich nutze on-the-fly Up- und Down-Scaling neue System stehen „sofort“ zur Verfügung
  • 11.
    „Kein Server ist einfacherzu verwalten, als kein Server.“ (Werner Vogels, CTO Amazon) out-of-the-box self-scaling out-of-the-box self-scaling cloud-based super-backend I had a dream ...
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
    “We are ahospitality management organization, not an IT services company.”
  • 18.
    80 Mio Gäste/ 1500 EC2 „We have a 5 person operations team.”
  • 19.
    „Kein Server ist einfacherzu verwalten, als kein Server.“ (Werner Vogels, CTO Amazon) SERVERLESS
  • 20.
  • 21.
    The Road tothe Cloud ... Der Serverless Showcase
  • 22.
  • 23.
  • 24.
    Road to lessServer Self-Managed Cloud-Managed
  • 25.
    Road to lessServer Self-Managed Cloud-Managed Provisioning Security Maintenance
  • 26.
    Road to lessServer Self-Managed Cloud-Managed Provisioning Security Maintenance
  • 27.
    Road to lessServer Sieht irgendwie kompliziert aus! Muss ich mich darum kümmern? Self-Managed Cloud-Managed Provisioning Security Maintenance
  • 28.
    Road to lessServer Self-Managed Cloud-Managed Elastic Beanstalk Elastic Kubernetes Elastic Container Provisioning Security Maintenance Scaling
  • 29.
    Road to lessServer IaaS (Infrastructure as a Service) EBS: elastic beanstalk
  • 30.
    Road to lessServer IaaS (Infrastructure as a Service) ECS : elastic container service
  • 31.
    Road to lessServer IaaS (Infrastructure as a Service) EKS : elastic container service for kubernetes
  • 32.
  • 33.
  • 34.
    Road to lessServer Self-Managed Cloud-Managed Provisioning Security Maintenance Scaling
  • 35.
    Road to lessServer Self-Managed Cloud-Managed Provisioning Security Backup/Recovery Scaling Provisioning Security Maintenance Scaling
  • 36.
    Road to lessServer IaaS (Infrastructure as a Service)
  • 37.
    Road to lessServer PaaS (Platform as a Service)
  • 38.
  • 39.
  • 40.
  • 41.
    “Run YOUR business codein the cloud.“
  • 42.
  • 43.
  • 44.
    Das klappt niemals! Warumnicht? Na, weil es DEIN Business Code ist!
  • 45.
  • 46.
    PaaS IaaS Road toless Server
  • 47.
    Road to lessServer Self-Managed Cloud-Managed Provisioning Security Backup/Recovery Scaling Provisioning Security Maintenance Scaling
  • 48.
    Road to lessServer Self-Managed Cloud-Managed API Key Mgmt Throtteling Zero-Downtime Region Availability Provisioning Security Backup/Recovery Scaling Provisioning Security Maintenance Scaling
  • 49.
    Road to lessServer PaaS (Platform as a Service)
  • 50.
    Road to lessServer PaaS (Platform as a Service)
  • 51.
    Road to lessServer BaaS (Backend as a Service)
  • 52.
    Road to lessServer BaaS (Backend as a Service)
  • 53.
    Road to lessServer BaaS (Backend as a Service)
  • 54.
    PaaS IaaS Road toless Server ?
  • 55.
    PaaS IaaS Road toless Server
  • 56.
    #WISSENTEILEN “Run your businesscode highly-available in the cloud in response to events and scale without any servers to manage.“* * AWS Lambda Advertising
  • 57.
  • 58.
  • 59.
    #3: Build in highavailability and disaster recovery
  • 60.
  • 61.
    Management: “Hmm, ich binnoch nicht überzeugt!.”
  • 62.
    #5: Never pay idle (Management:„Ok, I bin definitiv dabei!“)
  • 63.
    „Kein Server ist einfacherzu verwalten, als kein Server.“ (Werner Vogels, CTO Amazon) out-of-the-box self-scaling out-of-the-box self-scaling cloud-based super-backend Remember „your“ dreams?
  • 64.
    My Logic (... asa Service)
  • 65.
  • 66.
    Functions als Basisfür Deployment & Skalierung
  • 67.
    Road to lessServer PaaS (Platform as a Service)
  • 68.
    Road to lessServer FaaS (Function as a Service)
  • 69.
  • 70.
    No machines, VMs, orcontainers. *... are visible in the programing model
  • 72.
  • 73.
    AWS Lambda Microsoft Azure Functions OracleFunctions a.k.a. Project FN*** IBM Cloud Functions a.k.a Apache OpenWhisk** Google Cloud Functions Project Riff sponsored by Pivotal
  • 76.
  • 77.
    Was ist dieIdee von Serverless?
  • 78.
    #WISSENTEILEN Function as self-containedapplication Serverless Function: Entwickler schreibt eine Business- Funktion in einer der unterstützen Programmiersprachen, „bundled“ diese mit den entsprechenden Abhängigkeiten (LIBs) und lädt sie in die Cloud. Serverless Environment: Führt die Funktion bei „Aufruf“ in der passenden Runtime effizient, flexibel und hoch skalierbar aus. “
  • 79.
    #WISSENTEILEN Serverless no needto maintain Entwickler: Fokussiert sich ausschließlich auf die Umsetzung der Business-Logik und das Erstellen des Function-Bundle. Cloud Provider: liefert und maintained rundum-sorglos Umgebung für die Serverless Functions, inklusive etwaiger Cloud Services (z.B. Storage, DB, Streaming, AI). “
  • 80.
  • 82.
  • 83.
    AWS Cloud hello worldserverless context 1 trigger request Hands-on: Hello World
  • 84.
    AWS Cloud hello worldserverless context HelloWorld Logs 1 trigger request 2 Hands-on: Hello World
  • 85.
  • 86.
  • 87.
    HelloWorld ZIP 1 trigger request Hello World „underthe Hood“ Download Function Code ZIP Cloud Storage S3 AWS Cloud 2
  • 88.
    HelloWorld ZIP 1 trigger request Hello World „underthe Hood“ Download Function Code Setup Runtime ZIP Cloud Storage S3 AWS Cloud 2 3
  • 89.
    HelloWorld ZIP 1 trigger request Hello World „underthe Hood“ Download Function Code Setup Runtime Init Function ZIP Cloud Storage S3 AWS Cloud 2 3 4
  • 90.
    HelloWorld ZIP 1 trigger request Hello World „underthe Hood“ Download Function Code Setup Runtime Init Function ZIP Cloud Storage S3 AWS Cloud 2 3 4 COLD START
  • 91.
    trigger request Hello World „underthe Hood“ Download Function Code ZIP AWS Cloud Setup Runtime Init Function COLD START
  • 92.
    trigger request Hello World „underthe Hood“ Download Function Code ZIP AWS Cloud Setup Runtime Init Function COLD START Execute Handler
  • 93.
    trigger request Hello World „underthe Hood“ Download Function Code ZIP AWS Cloud Setup Runtime Init Function COLD START Execute Handler Terminate Function
  • 94.
    trigger request Hello World „underthe Hood“ ZIP AWS Cloud COLD START Terminate Function Execute Handler
  • 95.
    trigger request Hello World „underthe Hood“ ZIP AWS Cloud COLD START Terminate Function Execute Handler Execute Handler trigger request
  • 96.
    trigger request Hello World „underthe Hood“ ZIP AWS Cloud COLD START Execute Handler Terminate Function Execute Handler Execute Handler trigger request trigger request
  • 97.
  • 98.
  • 99.
    Szenario #1: Datei-/Datenbearbeitung Datei-oder Datenbearbeitung nach Ablage im S3 Storage System • Bildbearbeitung • Thumbnail-Erzeugung • PDF-Generierung
  • 100.
    AWS Cloud Szenario #1:Datei-/Datenbearbeitung 1 upload image
  • 101.
    AWS Cloud Szenario #1:Datei-/Datenbearbeitung 1 2 upload image
  • 102.
    AWS Cloud Store rawImage Szenario #1: Datei-/Datenbearbeitung StoreImage Logs 1 2 3 upload image
  • 103.
    AWS Cloud Store rawImage Szenario #1: Datei-/Datenbearbeitung StoreImage Logs S3 Object created1 2 3 4 upload image
  • 104.
    AWS Cloud Store rawImage Szenario #1: Datei-/Datenbearbeitung StoreImage Logs S3 Object created1 2 3 4 upload image
  • 105.
    AWS Cloud Create ThumbnailStoreraw Image Szenario #1: Datei-/Datenbearbeitung StoreImage Logs CreateThumbnail Logs S3 Object created1 2 3 4 5 upload image
  • 106.
  • 108.
    Szenario #1: LessonsLearned Was wir bisher gelernt haben … • S3 ist der Platz zur Ablage von Objekten in AWS • S3 benötigt spezielle Zugriffsrechte • S3 triggert automatisch Cloud Events an • Filter innerhalb der Lambda können S3 Event Trigger gezielt einschränken, z.B. für • Buckets • Prefix / Postfix, • IAM Nutzer / Rollen
  • 109.
  • 110.
    Szenario #2: StreamProcessing Regelmäßiges abarbeiten von Streaming Data • Social Media Trendanalysen • Sensor Data Monitoring / Anomaly Detection
  • 111.
    AWS Cloud 1 sensor datastream is uploaded to Kinesis in real-time Szenario #2: Stream Processing tons of very important sensor data
  • 112.
    AWS Cloud 1 sensor datastream is uploaded to Kinesis in real-time Szenario #2: Stream Processing tons of very important sensor data
  • 113.
    AWS Cloud Data StreamAnalysis StreamAnalyzer Logs 1 sensor data stream is uploaded to Kinesis in real-time 2 Lambda runs code to detect anomalies Szenario #2: Stream Processing tons of very important sensor data
  • 114.
    AWS Cloud Data StreamAnalysis StreamAnalyzer Logs store anomalies extracted by lambda function 1 sensor data stream is uploaded to Kinesis in real-time 2 3 Lambda runs code to detect anomalies Szenario #2: Stream Processing tons of very important sensor data
  • 115.
    AWS Cloud Data StreamAnalysis StreamAnalyzer Logs Real-Time Monitoring / Querying store anomalies extracted by lambda function 1 sensor data stream is uploaded to Kinesis in real-time 2 3 Lambda runs code to detect anomalies 4 data immediately available for interested parties to query Szenario #2: Stream Processing tons of very important sensor data
  • 116.
  • 118.
    Szenario #3: LessonsLearned Was wir bisher gelernt haben… • Kinesis erlaubt die Bearbeitung von Data / Media Stream • Kinesis benötigt spezielle Zugriffsrechte • Lambdas können Chunks eines Kinesis Streams bearbeiten • Lambdas in Verbindung mit Kinesis können genutzt werden, um … • Metriken zu erzeugen • Fehler / Anomalien zu erkennen • Media Trends zu analysieren
  • 119.
  • 120.
    Szenario #3: WebApplication Serverless „all in“ einer Anwendung… • Ausliefern von statischem Content via CDN • Authentication / Autorization via BaaS • Businesslogik via FaaS (unter Verwendung von PaaS)
  • 121.
    Szenario #3: WebApplication AWS Cloud Web Client region aware web app delivery 1
  • 122.
    Szenario #3: WebApplication AWS Cloud Web Client region aware web app delivery 1 login via id/pwd returns JWT 2
  • 123.
    Szenario #3: WebApplication AWS Cloud Web Client region aware web app delivery 1 login via id/pwd returns JWT 2 3 REST call
  • 124.
    Szenario #3: WebApplication AWS Cloud Web Client region aware web app delivery 1 login via id/pwd returns JWT 2 3 REST call 4 translated lambda trigger
  • 125.
    Szenario #3: WebApplication AWS Cloud Web Client storage related functions region aware web app delivery 1 login via id/pwd returns JWT 2 3 REST call 4 translated lambda trigger 5 lambda @work
  • 126.
    Szenario #3: WebApplication AWS Cloud Web Client storage related functions database related functions region aware web app delivery 1 login via id/pwd returns JWT 2 3 REST call 4 translated lambda trigger 5 lambda @work 5 lambda @work
  • 127.
    Szenario #3: WebApplication AWS Cloud Web Client storage related functions database related functions additional functions, e.g. region aware web app delivery 1 login via id/pwd returns JWT 2 6 3 REST call 4 translated lambda trigger 5 lambda @work 5 lambda @work
  • 129.
    The Road tothe Cloud ... Der Serverless Showcase
  • 130.
    Web Image Gallery (easyversion) GET ../images/{imageId} PUT ../images/{imageId} DELETE ../images/{imageId} POST ../images/
  • 131.
    Web Image Gallery (notso easy version) GET ../images/{imageId} PUT ../images/{imageId} DELETE ../images/{imageId} POST ../images/
  • 132.
    Web Image Gallery (reallife version) GET ../images/{imageId} PUT ../images/{imageId} DELETE ../images/{imageId} POST ../images/
  • 133.
    Szenario #3: LessonsLearned Was wir bisher gelernt haben … • CloudFront und S3 zur Web App Auslieferung (statischer Content) • Cognito zur User Authentication via JWT • Ketten von async / lose gekoppelten Lambdas • Gateway dient als eine Art Function Dispatcher (plus …)
  • 134.
    Szenario #3: LessonsLearned Was wir bisher gelernt haben … • CloudFront und S3 zur Web App Auslieferung (statischer Content) • Cognito zur User Authentication via JWT • Ketten von async / lose gekoppelten Lambdas • Layer zur Mehrfachnutzung von Libraries in Lambdas • Gateway dient als eine Art Function Dispatcher (plus …) ?
  • 135.
  • 136.
  • 137.
    AWS Cloud Wofür istein API Gateway gut? • Security • API Key Handling • Throttling • Proxying • Logging / Tracing • Request / Respons Mapping • Staging
  • 138.
    AWS Cloud 1 Szenario #4:API Gateway GET ../resources/{resourceId} PUT ../resources/{resourceId} DELETE ../resources/{resourceId} POST ../resources/
  • 139.
    AWS Cloud Szenario #4:API Gateway 21 GET ../resources/{resourceId} PUT ../resources/{resourceId} DELETE ../resources/{resourceId} POST ../resources/
  • 140.
    AWS Cloud read create delete update 21 Szenario #4:API Gateway 3 GET ../resources/{resourceId} PUT ../resources/{resourceId} DELETE ../resources/{resourceId} POST ../resources/
  • 141.
    AWS Cloud read create delete update Szenario #4:API Gateway 56 4 GET ../resources/{resourceId} PUT ../resources/{resourceId} DELETE ../resources/{resourceId} POST ../resources/
  • 142.
  • 144.
    Szenario #4: LessonsLearned Was wir bisher gelernt haben ... • ein API Gateway „schützt“ die Cloud vor der Außenwelt • HTTP Requests werden in Lambda Trigger überführt • HTTP Parameter / Payload wird auf Lambda Events gemappt • Lambda Results werden in HTTP Status Codes überführt • Lambda Result Objekte werden auf HTTP Payload gemapped • API Gateways kann ein Staging-Konzpt realisieren
  • 145.
  • 146.
    The Road tothe Cloud ... Der Serverless Showcase
  • 147.
    AWS Cloud Use-Case: UploadImage upload image with additional information
  • 148.
    AWS Cloud Store rawImage 1 Use-Case: Upload Image upload image with additional information
  • 149.
    AWS Cloud Store rawImage Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 150.
    AWS Cloud AWS StepFunctions workflow: Store Image Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 151.
    AWS Cloud AWS StepFunctions workflow: Store Image Create ThumbnailStore raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 152.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 153.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 154.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 155.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 156.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2 Use-Case: Upload Image upload image with additional information
  • 157.
  • 158.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 159.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 160.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 161.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 162.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 163.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 164.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 165.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 166.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 167.
    AWS Cloud AWS StepFunctions workflow: Store Image Create Thumbnail Inform Subscribers Store raw Image Store Image Information 1 2
  • 168.
    Was kann daschon schiefgehen? • Interne Programmier-/Logikfehler • Anomalien (z.B. unerwartet/ungültige Calls) • verlorene oder doppelte Events • hohe Latenz / Timeouts • Security-Attacken (z.B. DoS/DDoS) • Personalisierte SLAs / Usage Plans • unerwartete Workload Peaks • …
  • 169.
    “Run your businesscode highly-available in the cloud in response to events and scale without any servers to manage.“* *(AWS Lambda product description)
  • 170.
    “Run your businesscode highly distributed and event driven in a non transparent environment with no single point of control.“* *(my personal interpretation)
  • 172.
    Wie teste ich? meineServerless Application
  • 173.
    Was, wann, wieund wo sollte ich testen, um … • Vertrauen in meinen Code zu gewinnen • das Risiko von Fehlern zu minimieren* * vor allem in Produtktion
  • 174.
    Testen in dertraditionellen Welt
  • 175.
    Testen in derServerless Welt „The biggest complexity is not within the function itself, but in how it interacts with other functions and services (a.k.a. cloud components).“
  • 176.
    Testen in derServerless Welt Ziele des Testens: „Risiko minimieren“ • Risiko Konfiguration • Risiko technischer Workflow • Risiko Businesslogik • Risiko Integration
  • 177.
    Testen in derServerless Welt Ziele des Testens: „Risiko minimieren“ • Risiko Konfiguration • Risiko technischer Workflow • Risiko Businesslogik • Risiko Integration
  • 178.
    Testen in derServerless Welt
  • 179.
    „Don‘t let yourusers test your code!“
  • 181.
    „Welche Art von‚Benchmarks‘ wollen wir für unser Testing?“ • funktionale Änderungen schnell/kosteneffizient testen • integrative Änderungen schnell/kosteneffizient testen • integrative Änderungen so „real“ wie möglich testen • Use-Cases und User-Stories so „real“ wie möglich testen Testing Best Practices
  • 182.
    #1 Trennen vonBusinesslogik und Infrastruktur Testing Best Practices AWS CloudOn-Premise handler logic Kandidat für Unit Tests e i u Kandidat für Integration Tests Kandidat für End-to-Ende Tests u
  • 183.
  • 184.
  • 185.
  • 186.
    #2 Cloud-Infrastruktur Komponentenmocken Testing Best Practices AWS CloudOn-Premise handler logic u um Kandidat für Unit Tests e i u Kandidat für Integration Tests Kandidat für End-to-Ende Tests
  • 187.
  • 188.
  • 189.
  • 190.
    #3 Lokale Umgebungfür funktionale Tests verwenden (z.B. SAM local) Testing Best Practices AWS CloudOn-Premise handler logic uvia SAM local via SAM local SAM yaml TEST u u Kandidat für Unit Tests e i u Kandidat für Integration Tests Kandidat für End-to-Ende Tests
  • 192.
    $ sam localinvoke "Greetings" -e event-greeting.json --env-vars env.json function name payload for function
  • 193.
    $ sam localinvoke "Greetings" -e event-greeting.json --env-vars env.json function name payload for function
  • 194.
    #4 Lokale Umgebungzum Triggern von Integration Tests verwenden Testing Best Practices AWS CloudOn-Premise handler logic uvia SAM local via SAM local SAM yaml TEST u u i i Kandidat für Unit Tests e i u Kandidat für Integration Tests Kandidat für End-to-Ende Tests
  • 195.
    $ sam localstart-api –p 8080
  • 196.
    $ sam localstart-api –p 8080
  • 197.
    $ sam localstart-api –p 8080
  • 198.
    #5 Lokale Cloud-Komponentenfür Integration Tests* Testing Best Practices AWS CloudOn-Premise handler logic u via DynamoDB local via FakeS3 via SAM local via SAM local SAM yaml TEST u u i i i i WARNUNG: lokale Cloud Komponenten können lediglich funktionale Korrektheit sicherstellen, nicht aber infrastrukturelle, wie z.B. DLQs, Timeouts, Throttling, SLAs, … Kandidat für Unit Tests e i u Kandidat für Integration Tests Kandidat für End-to-Ende Tests
  • 199.
    $ sam localgenerate-event [SERVICE] [OPTION] Simulate Component Event to trigger Lambda
  • 200.
    $ sam localgenarte-event [SERVICE] [OPTION] Simulate Component Event to trigger Lambda
  • 201.
    Simulate Component triggeredby Lambda $ aws –endpoint-url=http://localhost:8000 dynamodb list-tables $ java –jar DynamoDBLocal.-jar
  • 202.
    Simulate Component triggeredby Lambda $ aws –endpoint-url=http://localhost:8000 dynamodb list-tables
  • 203.
    Simulate Component triggeredby Lambda $ aws –endpoint-url=http://localhost:8000 dynamodb list-tables
  • 204.
    #6 temporäre Integration-Cloudfür partielle Integration Tests Testing Best Practices AWS CloudOn-Premise handler logic uvia SAM local via SAM local SAM yaml TEST u u via DynamoDB local via FakeS3 i i Temorary Intregration #Dev1 ii INT i i Kandidat für Unit Tests e i u Kandidat für Integration Tests Kandidat für End-to-Ende Tests
  • 205.
    #7 permanente Integration-Cloudfür End-to-End Tests Testing Best Practices AWS CloudOn-Premise handler logic uvia SAM local via SAM local SAM yaml TEST u u via DynamoDB local via FakeS3 i i Permament IntregrationINT e e e e i i Kandidat für Unit Tests e i u Kandidat für Integration Tests Kandidat für End-to-Ende Tests
  • 206.
  • 208.
  • 209.
    Testing in Produktion Zieledes Testens: „Vertrauen gewinnen“ • Outages von Cloud & Cloud-Komponenten • Outages von 3rd Party Apps • Bugs / Probleme durch Skalierung
  • 210.
    Testing in Produktion RobustesMonitoring und Error Reporting • Logging • Tracing • Metrics • Alerting Vorhersagen von Störungen inklusive automatischer Regenerierung!
  • 211.
    Testing in Produktion ChaosEngineering • bewusst kleine “Probleme“ und „Fehler“ in das System einstreuen!
  • 212.
    Wie monitore ich? meineServerless Application
  • 213.
    Mit einem gutgeplantes Monitoring sollten wir in der Lage sein, … • aufkommende Probleme vorherzusagen • schnell die Ursache von Problemen zu identifizieren • automatische Recovery-Prozesse anzustoßen • notwendige Alarme zu triggern Real-Life Monitoring
  • 214.
    Real-Life Monitoring Business KPI UX SLA “Produkte pro Bestellung” “Durchschnittlicher Bestellwert” “Abbruchrate” “ErsteDarstellung von Inhalten” “Erste sinnvolle Darstellung" “Erste Interaktion” “Verfügbarkeit” “Latenz” “Beständigkeit” “Konsistenz”
  • 215.
    Gut geplantes Monitoringberücksichtigt verschiedene Aspekte • reliability: Komponenten und Kommunikation • usage: funktional und nicht-funktional • performance: Dauer, Latenz und Timeouts • security: Zugriffsrechte, Attacken • costs: aktuelle Kosten, Kostenentwicklung Real-Life Monitoring
  • 216.
    Die 4 Säulendes Monitorings 3 2 4 1 Tracing Metrics Alerting Logging
  • 217.
    3 2 Tracing Metrics 4 4 Alerting Die 4Säulen des Monitorings Repräsentiert den State einer Anwendung. Wenn etwas schiefläuft benötigen wir LOGs, um herauszufinden, welche Änderungen am State den Fehler verursacht haben. 1 Logging Logging
  • 218.
    3 Metrics 4 1 Alerting Logging Die 4 Säulendes Monitorings Tracing 2 Repräsentiert eine einzelne „User‘s Journey“ durch den gesamten Stack der Anwendung. Tracing wird oft zur Optimierung des Systems genutzt. Tracing
  • 219.
    2 Tracing 4 1 Alerting Logging Die 4 Säulendes Monitorings 3 Metrics Repräsentiert einen über einen Zeitraum aggregierten Messpunkt. Hilft dabei, den aktuellen „Health-Status“ des Systems sowie dessen Entwicklung festzustellen. Metrics
  • 220.
    3 2 Tracing Metrics 1 Logging Die 4Säulen des Monitorings 4 Alerting Die Komponente des Monitorings, die basierende auf Metriken, Aktionen auslöst. Meist zur automatischen „Selbstheilung“ verwendet oder im zuständige Personen zu informieren. Alerting
  • 221.
    Für ein gutgeplantes Monitoring, sollten man daher … • Events loggen, die eine State Transformation anstoßen • Standard-Metriken sammeln • Custom-Metriken definieren und sammeln • Distributed Tracing ermöglichen • Alarme auf individuellem und aggregierten Level definieren Serverless Application Monitoring
  • 222.
  • 223.
    Monitoring Strategie #1:DIY AWS Cloud Logging Tracing Metrics Alerting
  • 224.
    Monitoring Strategie #1:DIY AWS Cloud universal Log Logging Logging Tracing Metrics Alerting
  • 225.
    Monitoring Strategie #1:DIY AWS Cloud universal Log Logging DevOps Logging Tracing Metrics Alerting
  • 226.
    Monitoring Strategie #1:DIY AWS Cloud universal Log Archive Logging Tracing DevOps Logging Tracing Metrics Alerting
  • 227.
    Monitoring Strategie #1:DIY AWS Cloud universal Log Archive Logging Metrics Tracing DevOps Logging Tracing Metrics Alerting
  • 228.
    Monitoring Strategie #1:DIY AWS Cloud universal Log Alarm Archive Logging Metrics Tracing Alerting DevOps Logging Tracing Metrics Alerting
  • 229.
    Monitoring Strategie #2:Plattform Services AWS Cloud Logging Logging Tracing Metrics Alerting
  • 230.
    Monitoring Strategie #2:Plattform Services AWS Cloud Logging Alerting Metrics “BASIC ALERTING FOR FREE” “BASIC METRICS FOR FREE” Logging Tracing Metrics Alerting
  • 231.
    Monitoring Strategie #2:Plattform Services AWS Cloud Alarm Logging Alerting Metrics Logging Tracing Metrics Alerting
  • 232.
    Monitoring Strategie #2:Plattform Services AWS Cloud Logging Alerting Metrics Tracing (still DIY) Alarm Metrics Logging Tracing Metrics Alerting
  • 233.
    Monitoring Strategie #2:Plattform Services AWS Cloud Alarm Logging Tracing Alerting Tracing (DIY) Metrics Logging Tracing Metrics Alerting
  • 234.
    Monitoring Strategie #2:Plattform Services Logging Tracing Metrics Alerting
  • 235.
    Monitoring Strategie #2:Plattform Services Logging Tracing Metrics Alerting
  • 236.
    Monitoring Strategie #2:Plattform Services Logging Tracing Metrics Alerting
  • 237.
  • 239.
    Monitoring: Lessons Learned Washaben wir gelernt … • ein gut durchdachtes Monitoring besteht aus 4 Säulen • das Logging zum Festhalten von State Transformation • das Tracing zum Verfolgen einzelner User Journeys • die Metriken zur Feststellung des Systemzustands • das Alerting zum (autom.) Auslösen von „heilenden“ Aktionen
  • 240.
    „Logging data isexpensive, so better log wisely!“
  • 242.
    „Welche Art von‚Benchmarks‘ wollen wir für unser Monitoring?“ • Sammeln von umfangreichen System- und Anwendungsmetriken • Metriken und Logs sollten keine User-facing Latency verursachen • Metriken und Logs sollten in Real-Time verfügbar sein • Metriken und Logs sollten granular und korreliert vorliegen Monitoring Best Practices
  • 243.
    #1 User-facing Latencyvermeiden Monitoring Best Practices AWS Cloud My Lambda logs log stream log data async sync Log Aggregator log data 1 very fast and cheap 2 3 time consuming and “expensive” parse log stream
  • 244.
    #2 umfangreiche System-/Anwendungsmetrikensammeln Monitoring Best Practices AWS Cloud My Lambda logs log stream log data async sync Log Aggregator metrics custom metrics custom metrics log data 2 3 1 very fast and cheap parse log stream custom metrics
  • 245.
    #3 unnötige Kostenvermeiden Monitoring Best Practices AWS Cloud My Lambda logs log stream log data async sync Log Aggregator metrics custom metrics custom metrics log data archive logs 1 2 custom metrics
  • 246.
    #4 Logs undMetriken korrelieren / aggregieren Monitoring Best Practices AWS Cloud My Lambda logs log stream log data async sync Log Aggregator metrics custom metrics custom metrics log data archive logs 1 correlation ID custom metrics
  • 247.
    #5 Logging viaENV Vars an Edge Server enablen/disablen Monitoring Best Practices AWS Cloud My Lambda logs log stream log data async sync Log Aggregator metrics custom metrics custom metrics log data archive logs DEBUG on/off ENV var 1 2 custom metrics
  • 248.
  • 249.
  • 250.
    “Find suitable serverless workload andapply the correct integration patterns.”
  • 251.
    “Eat your own serverlessdog food for monitoring and testing“
  • 253.
  • 254.
  • 255.
    © chanchai howharn– shutterstock.com (Folie 1) © wavebreaker – shutterstock.com (Folie 4) © Rich Vintage – iStockphoto.com (Folie 9) © foxaon1987 - shutterstock.com (Folie 11) © Guide van Nipsen – wikipedia.com (Folie 19) © Zeeker2526 - shutterstock.com (Folie 20) © CandyDuck - shutterstock.com (Folie 80) © Myvisual - shutterstock.com (Folie 97) © Rawpixel.com - shutterstock.com (Folie 241) Alle weiteren Bilder der Präsentation sind entweder von pixabay.com oder von mir selbst erstellt. Bildernachweis