Share
Embed
Serverless: Less is more
Answering what, why, why not of Serverless and explaining basics of AWS Lambda by showing some use-cases at the end.
Serhat Can
July 18, 2018
Transcript
52 slides
-
@srhtcn Who am I? Remote worker in Istanbul after 7
years in Ankara Software Engineer to Technical Evangelist @OpsGenie Writes, talks, and speaks about DevOps and Serverless - So far: London (x5), Amsterdam (x3), Barcelona (x2), Kiev (x2), Warsaw, Zurich - Soon: Boston, NYC, Berlin, Paris, Nuremberg, Las Vegas Organizer - Serverless Turkey meetup - DevOps Turkey meetup - DevOpsDays Istanbul -
@srhtcn 3000+ customers from all around the world 10M$ from
Battery Ventures in mid 2016 From 15 people in 2016 to 90 Ankara, 87 Boston, 7 Washington DC. within 2.5 years Learn more (Turkish - otherwise visit opsgenie.com): https://medium.com/@serhatcan/opsgenie-nedir-ne-yapar-b688eaf724f1 -
@srhtcn • Always-on • Don’t react, RESPOND! • Reliable and
flexible alerting • Reporting and analytics • 200+ integration -
@srhtcn You want to run code on cloud. Your options:
Bare metal IaaS (VM) CaaS (container) PaaS (app) Serverless (function) More control, more code Less control, less code -
@srhtcn Making thoughtful decisions about tools and architecture can help;
well-considered constraints can free us from the decisions that aren't bringing us distinguishable benefit. Bridget Kromhout https://queue.acm.org/detail.cfm?id=3185224 -
@srhtcn What is wrong with lower level abstractions? aka. VMs,
Containers, Apps -
@srhtcn Nothing Use where and when it makes sense Just
be aware that hidden costs are bigger than service costs -
@srhtcn Defining Serverless Serverless is an event driven, utility based,
stateless, code execution environment. Simon Wardley @swardley -
@srhtcn Defining Serverless Event driven: Code is initiated and run
after an event like HTTP request or storage of a file triggers. -
@srhtcn Defining Serverless Event driven: Code is initiated and run
after an event like HTTP request or storage of a file triggers. Utility based: No payment for idle time or hosting. You pay for the resources you use when your code is triggered. -
@srhtcn Defining Serverless Event driven: Code is initiated and run
after an event like HTTP request or storage of a file triggers. Utility based: No payment for idle time or hosting. You pay for the resources you use when your code is triggered. Stateless: Code execution environment is deconstructed after sometime. No information is guaranteed to stay in the environment after function execution is completed. -
@srhtcn Defining Serverless Event driven: Code is initiated and run
after an event like HTTP request or storage of a file triggers. Utility based: No payment for idle time or hosting. You pay for the resources you use when your code is triggered. Stateless: Code execution environment is deconstructed after sometime. No information is guaranteed to stay in the environment after function execution is completed. Code execution: Just code, not servers / VMs / containers etc. -
@srhtcn Less is more Less code to maintain, less ops,
less toil (work tied to running a production service that tends to be manual, repetitive) - Scaling - Provisioning - OS or Language updates - Resource utilization - Network monitoring - Fault tolerance - Shipping logs https://landing.google.com/sre/book/chapters/eliminating-toil.html -
@srhtcn Economics - No payment for idle time or hosting
- Easy to get started - Faster time to market -
@srhtcn Which services are Serverless? AWS Lambda Azure Functions IBM
Cloud Functions Google Cloud Functions -
@srhtcn Serverless vs. Easy to use Inexpensive Low maintenance Event
driven apps working best with other cloud services Containers More suitable for complex apps with enterprise roots More control over the environment Long running apps More mature tooling -
@srhtcn Language support Node.js (JavaScript) Python, Java (Java 8 compatible),
C# (.NET Core) Golang -
@srhtcn Pricing You choose memory size % of CPU core
and network capacity increases proportionally with memory More memory doesn’t always mean you pay more -
@srhtcn Supported event sources 20 different services can trigger AWS
Lambda functions including. Event sources that aren't stream-based: Synchronous invocation: AWS SDK, Cognito, Alexa, API Gateway Asynchronous invocation: S3, SNS, CloudWatch logs, CloudWatch events Poll-based (or pull model) event sources that are stream-based: Kinesis, DynamoDB Streams, Poll-based event sources that are not stream-based: SQS -
@srhtcn Scaling Most of the time, no need to deal
with scalability There are two limits you need to be aware of: - Concurrent execution limit - Function level execution limit Set proper timeouts to your functions -
@srhtcn Deployment Zip and upload Use tools like SAM, Serverless.js
Blue-green or canary releases are easy -
@srhtcn Logging Easy to write logs to CloudWatch just write
console log Log group per function and log stream per container under log group Consider CloudWatch cost Stream logs to other services such as Elasticsearch for more advanced capabilities -
@srhtcn Monitoring Metrics like invocations, errors, throttles, ConcurrentExecutions etc. Cloudwatch
logs for custom monitoring data X-Ray for distributed tracing Thundra!!! -
@srhtcn Determine the latency in different levels Automatic instrumentation GC,
Thread counts & durations, CPU usage details Get the stack trace in case of an error and drill down See logs, traces, and metrics in one view What we needed was -
@srhtcn Config Management Environment variables are easy to use For
secrets encrypt with KMS Centralized config management with SSM Parameter Store -
@srhtcn Testing Write unit tests as always More focus on
integration tests Test locally with SAM CLI (Public Beta) -
@srhtcn Security Functions are in isolated environment, with its own
resources and file system view Code is in Amazon S3 and encrypted at rest Leverage full power of IAM roles Not recommended but you put your functions in a VPC -
@srhtcn Handling errors Depends on the trigger type. Sync: handle
on client side Async: Non-stream: retry a few times with delays. If doesn’t work, put data in DLQ Stream: retry until succeeded or data expires -
@srhtcn Toolkit around AWS Lambda Orchestration: Step Functions Deployment: SAM,
Serverless.js, CloudFormation, Apex, Terraform Monitoring: X-Ray, Thundra Marketplace: AWS Serverless Application Repository -
@srhtcn AWS Lambda at OpsGenie AWS Lambda with Java 8
DynamoDB SQS SNS VPC Serverless.js -
@srhtcn Follow these awesome folks and blogs engineering.opsgenie.com opsgenie.com/resources @swardley
@chrismunns @theburningmonk