@TMCLAUGHBOS
WHAT DO WE DO WHEN THE SERVER
GOES AWAY?
SERVERLESS OPS
@TMCLAUGHBOSSERVERLESS OPS
SERVERLESS!!!
@TMCLAUGHBOSSERVERLESS OPS
SERVERLESS!!!
WHO IS THIS GUY UP
HERE?
@TMCLAUGHBOSSERVERLESS OPS
TOM MCLAUGHLIN: COMMUNITY ENGINEER CLOUD ZERO
BACKGROUND & BIASES
@TMCLAUGHBOSSERVERLESS OPS
I LIKE STARTUPS
@TMCLAUGHBOSSERVERLESS OPS
MY PROBLEMS MAY BE SMALLER OR DIFFERENT THAN YOURS
HOW DID I COME TO
ASK THIS QUESTION?
“WOW! LAMBDA IS
PRETTY COOL!”
“THAT DUDE IS A
WALKING BILLING ALERT”
IT ALL CAME TOGETHER!…
AND THEN FEAR SET IN.
"IF YOU DON’T CODE THEN
YOU’RE JUST AN I.T. PERSON”
WHAT IS SERVERLESS?
@TMCLAUGHBOSSERVERLESS OPS
2007: THE CLOUD IS JUST SOMEONE ELSE’S COMPUTER
@TMCLAUGHBOSSERVERLESS OPS
2017: SERVERLESS STILL USES SERVERS
@TMCLAUGHBOS
TL;DR: A SERVERLESS SOLUTION IS ONE THAT
COSTS YOU NOTHING TO RUN IF NOBODY IS
USING IT (EXCLUDING DATA STORAGE)
Paul Johnston / @PaulDJohnston
SERVERLESS OPS
@TMCLAUGHBOSSERVERLESS OPS
CHARACTERISTICS OF SERVERLESS
▸ Little to no maintenance (no “servers” to maintain)
▸ Everything is a system
▸ Event driven
▸ Consumption (not capacity) priced
▸ You scale systems, the component pieces auto-scale
@TMCLAUGHBOSSERVERLESS OPS
SERVERLESS COMPONENTS
▸ Functions-as-a-service (FaaS)
▸ AWS Lambda
▸ Public cloud services
▸ AWS SNS
▸ AWS SQS
▸ AWS DynamoDB
▸ AWS S3
@TMCLAUGHBOS
“SERVERLESS” IS JUST A NAME. WE COULD
HAVE CALLED IT “JEFF”
Paul Johnston / @PaulDJohnston
SERVERLESS OPS
WHERE DOES OPS FIT
INTO THIS WORLD?
OPS WILL GO AWAY AS MUCH AS IT
DID WITH THE ADOPTION OF PUBLIC
CLOUD
MEANING IT WONT. BUT
IT WILL CHANGE.
@TMCLAUGHBOSSERVERLESS OPS
WHAT EXISTING SKILLS ARE REALLY VALUABLE?
▸ Systems engineering
▸ Building
▸ Operating
▸ Understanding
▸ Scaling
▸ Debugging
▸ Knowing how things work
▸ AWS service limits, performance, etc.
▸ Tooling
▸ Understanding how things fail
@TMCLAUGHBOSSERVERLESS OPS
HOW WILL WE NEED TO CHANGE?
▸ YOU WILL HAVE TO CODE!
@TMCLAUGHBOSSERVERLESS OPS
HOW THIS MIGHT PLAY OUT?
▸ New team formations
▸ Becoming a “utility player” employee
@TMCLAUGHBOSSERVERLESS OPS
DEFINING THE OPS ROLE ON THE TEAM
▸ Developing system standards and best practices
▸ Knowing the build, deploy, and management tooling
▸ Reliability of systems
▸ Code review
▸ Performance tuning systems
▸ Evaluating costs of systems
DEVELOPING SYSTEM STANDARDS
AND BEST PRACTICES
@TMCLAUGHBOSSERVERLESS OPS
AWS RESOURCE PATTERNS: WEB REQUESTS
@TMCLAUGHBOSSERVERLESS OPS
AWS RESOURCE PATTERNS: MESSAGE PASSING (SNS)
▸ Pros
▸ Extensible
▸ Guaranteed delivery
▸ Cons
▸ If subscriber fails… Oh well.
▸ Questions
▸ How many messages will be passed; how
many Lambda subscriber invocations?
@TMCLAUGHBOSSERVERLESS OPS
AWS RESOURCE PATTERNS: MESSAGE PASSING (SQS)
▸ Pros
▸ Message druability
▸ Cons
▸ SQS is not a Lambda event source
▸ Questions
▸ How do you trigger Lambda?
▸ What is your consumer profile?
@TMCLAUGHBOSSERVERLESS OPS
AWS RESOURCE PATTERNS: MESSAGE PASSING (SNS -> SQS)
▸ Pros
▸ Durable
▸ Reliable
▸ Cons
▸ SQS cons
▸ Added cost
▸ Questions
▸ Same as SNS and SQS
@TMCLAUGHBOSSERVERLESS OPS
AWS RESOURCE PATTERNS: MESSAGE PASSING (KINESIS)
▸ Pros
▸ Fast
▸ Reliable
▸ Cons
▸ Expensive
▸ Questions
▸ Can I afford this?
@TMCLAUGHBOSSERVERLESS OPS
AWS RESOURCE PATTERNS: MESSAGE PASSING (LAMBDA FANOUT)
▸ Pros
▸ Fast!
▸ Cons
▸ Caller Lambda needs to handle errors
▸ Hidden service dependencies
▸ Questions
▸ How confident am I this is the best
idea?
KNOWING THE BUILD, DEPLOY,
AND MANAGEMENT TOOLING
@TMCLAUGHBOSSERVERLESS OPS
CLOUDFORMATION / SERVERLESS FRAMEWORK / ETC.
@TMCLAUGHBOSSERVERLESS OPS
CLOUDFORMATION / SERVERLESS FRAMEWORK / ETC.
# Should be replaced by https://www.npmjs.com/package/serverless-sqs-alarms-plugin
ArchiveSqsQueueAlarmStart:
Type: AWS::CloudWatch::Alarm
Properties:
AlarmActions:
- Ref: ArchiveSnsNotify
AlarmName:
- Fn::GetAtt:
- ArchiveSqsQueueAlarmStart
- QueueName
AlarmDescription: 'Queue has messages'
ComparisonOperator: GreaterThanThreshold
Dimensions:
- Name: QueueName
Value: ArchiveSqsQueue
EvaluationPeriods: 1
MetricName: ApproximateNumberOfMessagesVisible
Namespace: AWS/SQS
Period: 60
Statistic: Sum
Threshold: 1
@TMCLAUGHBOSSERVERLESS OPS
CLOUDFORMATION / SERVERLESS FRAMEWORK / ETC.class Plugin {
constructor (serverless, options) {
this.serverless = serverless
this.hooks = {
'package:compileEvents': this.beforeDeployResources.bind(this)
}
}
beforeDeployResources () {
if (!this.serverless.service.custom || !this.serverless.service.custom['sqs-alarms']) {
return
}
const alarms = this.serverless.service.custom['sqs-alarms'].map(
data => new Alarm(data, this.serverless.getProvider('aws').getRegion())
)
alarms.forEach(
alarm => alarm.ressources().forEach(
ressource => {
_.merge(
this.serverless.service.provider.compiledCloudFormationTemplate.Resources,
ressource
)
}
)
)
}
}
module.exports = Plugin
@TMCLAUGHBOSSERVERLESS OPS
CLOUDFORMATION / SERVERLESS FRAMEWORK / ETC.
custom:
sqs-alarms:
- queue: ArchiveSqsQueue
topic: ArchiveSnsNotify
name: ArchiveSqsQueueAlarmStart # optional parameter
thresholds:
- 1
- 50
- 100
- 500
treatMissingData: string | array[] # optional parameter
RELIABILITY OF
SYSTEMS
@TMCLAUGHBOSSERVERLESS OPS
SOMEONE WILL TRY AND SHIP THIS
@TMCLAUGHBOSSERVERLESS OPS
SOMEONE WILL TRY AND SHIP THIS
@TMCLAUGHBOSSERVERLESS OPS
YOU SHOULD BE SEEING THIS IN YOUR HEAD
@TMCLAUGHBOSSERVERLESS OPS
SECURITY
CODE REVIEW
@TMCLAUGHBOSSERVERLESS OPS
LAMBDA CODE BEST PRACTICES
import boto3
import logging
import os
_logger = logging.getLogger(__name__)
# Initialize objects outside of handler to make use of container reuse
s3_client = boto3.client('s3')
def handler(event, context):
# Do one thing and do it well.
'''Archive a a message to S3.'''
# The S3 bucket name is set by deployment
# framework referencing the S3 bucket resource it creates.
s3_bucket_name = os.environ.get('S3_BUCKET')
resp = s3_client.put_object(
Body=event.get(‘Records')[0].get('Sns').get('Message').encode(),
Bucket=s3_bucket_name,
Key=event.get('Records')[0].get('Sns').get('Subject')
)
return resp
@TMCLAUGHBOSSERVERLESS OPS
CODE ORGANIZATION
@TMCLAUGHBOSSERVERLESS OPS
CODE ORGANIZATION
PERFORMANCE TUNING
SYSTEMS
@TMCLAUGHBOSSERVERLESS OPS
SCALING AND OPTIMIZING PERFORMANCE
1,000 Users 100,000 Users
@TMCLAUGHBOSSERVERLESS OPS
AWS X-RAY
EVALUATING COSTS OF
SYSTEMS
@TMCLAUGHBOSSERVERLESS OPS
APPLICATION DOLLAR MONITORING
WE HAVE ADAPTED BEFORE
AND WE WILL ADAPT AGAIN!
THANK YOU!
HTTP://STRAYC.AT/
SERVERLESSOPS-FEEDBACK

Serverless Ops: What do we do when the server goes away?