SlideShare a Scribd company logo
AWS Lambda for Java Architects
Given by Derek C. Ashmore
Sept 19, 2016
©2016 Derek C. Ashmore, All Rights Reserved 1
Who am I?
• Professional Geek
since 1987
• Java/J2EE/Java EE
since 1999
• Roles include:
• Developer
• Architect
• Project Manager
• DBA
• System Admin
©2016 Derek C. Ashmore, All Rights Reserved 2
Discussion Resources
• This slide deck
– http://www.slideshare.net/derekashmore
• Sample code on my Github
– https://github.com/Derek-Ashmore/
• Sample Java AWS Lambda Source
– https://github.com/Derek-Ashmore/AWSLambdaExamples
• Slide deck has hyper-links!
– Don’t bother writing down URLs
©2016 Derek C. Ashmore, All Rights Reserved 3
Agenda
The “What”
and “Why” of
AWS Lambda
Developing
Lambda
Supporting
Lambda
Lambda and
Microservices
Summary /
Q&A
©2016 Derek C. Ashmore, All Rights Reserved 4
What are AWS Lambdas?
• You provide custom code -> AWS runs it
– Java, Node.js, Python
• Computing power with less management
– AWS manages the hardware
– AWS autoscales that hardware
– AWS maintains that hardware
• Lambdas are event driven
– API Gateway (e.g. RESTful Web Service call)
– Many more
• Lambdas are stateless
• Not to be confused with “Lambda Expressions” in Java 8
©2016 Derek C. Ashmore, All Rights Reserved 5
Lambda Event Sources
• API Gateway
• SNS Messaging
Subscriptions
• Schedule
• Storage writes
– S3, DynamoDB, Kenesis
©2016 Derek C. Ashmore, All Rights Reserved 6
• SES Email receipt
• Cloudwatch
– Schedule, Events, log entries
• Cognito (Security)
• CloudFormation
– Creation script
What’s the Business Benefit
• Less Maintenance Hassle
• Unlimited Parallelism
• Current cost advantage
– Don’t pay for idle
– CPU cost currently lower
• Free tier
– 1 M executions and 400K compute seconds per month
– Memory allocated determines allowed free-tier runtime
• 20 cents per 1 M executions + memory/runtime cost
– Administration cost
• No O/S upgrades, server backups, etc.
©2016 Derek C. Ashmore, All Rights Reserved 7
There’s no free lunch
• Less control over environment
– Harder to tune
– Memory and time limits on execution
• No Java EE amenities
– No connection pooling, session support, caching
• Proprietary Interface
– Potential Technical Lock-in
• No Guarantee that AWS cost will be constant
– Potential Business Risk
• Modern version of CGI
©2016 Derek C. Ashmore, All Rights Reserved 8
Agenda
The “What”
and “Why” of
AWS Lambda
Developing
Lambda
Supporting
Lambda
Lambda and
Microservices
Summary /
Q&A
©2016 Derek C. Ashmore, All Rights Reserved 9
Lambda Java API
• RequestHandler interface
• JSON marshalling of Request and Response
• Execution Context
• Deployment Zip Artifact
– Typically one RequestHandler per Zip artifact
©2016 Derek C. Ashmore, All Rights Reserved 10
Lambda Request / Response Sample
• Expose REST API that collects email addresses
for a mailing list
– https://scrubbed/prod/EmailCollector
• Sample request/response
©2016 Derek C. Ashmore, All Rights Reserved 11
Implementing a RequestHandler
• RequestHandler interface is generic.
– POJOs represent the request and response
– POJOs determine JSON request/response format
– Execution Context class provided by AWS
• This class specified when Lambda defined
• Note the wrapping try/catch
– Portion of the Context provided by AWS -> need more
– AWS Does marshalling
– ContextedRuntimeException from Apache Commons Lang3
• Note that the Lambda is thin -> Business logic is elsewhere
• Sample is on GitHub (here)
©2016 Derek C. Ashmore, All Rights Reserved 12
Implementing a RequestHandler
• RequestHandler interface is generic.
– POJOs represent the request and response
– POJOs determine JSON request/response format
– Execution Context class provided by AWS
• This class specified when Lambda defined
• Note the wrapping try/catch
– Portion of the Context provided by AWS -> need more
– AWS Does marshalling
– ContextedRuntimeException from Apache Commons Lang3
• Note that the Lambda is thin -> Business logic is elsewhere
• Sample is on GitHub (here)
©2016 Derek C. Ashmore, All Rights Reserved 13
Implementing a RequestHandler
• RequestHandler interface is generic.
– POJOs represent the request and response
– POJOs determine JSON request/response format
– Execution Context class provided by AWS
• This class specified when Lambda defined
• Note the wrapping try/catch
– Portion of the Context provided by AWS -> need more
– AWS Does marshalling
– ContextedRuntimeException from Apache Commons Lang3
• Note that the Lambda is thin -> Business logic is elsewhere
• Sample is on GitHub (here)
©2016 Derek C. Ashmore, All Rights Reserved 14
What’s in the Context?
• Execution Context provided by AWS
• Contains:
– AWS Request ID -> Get logs for specific request
– Function name, version, arn
– Cognito identity
– Remaining time/memory
– Mobile client information (AWS Mobile SDK)
• Environment name/value map
• Custom name/value map
©2016 Derek C. Ashmore, All Rights Reserved 15
Resource Support
• Java 8 Runtime ->
– you can configure memory available
• Log4J logging available
– Viewable/searchable in Cloudwatch logs
– Custom Log4J Appender provided
• Third party jars can be included
– Including AWS SDK for AWS Tasks (executing other Lambdas)
– JDBC Drivers
– HttpClient or Apache CXF
• Keep in Mind
– You create/destroy all database connections
• No connection pooling (Lambdas are stateless)
– Caching APIs have limited benefit (Lambdas are stateless)
– No Remote Debug capability
©2016 Derek C. Ashmore, All Rights Reserved 16
Lambda Deployment Package
• Zip Organization
– Root is in the classpath
– Lib contains 3rd party jars
• Maven example here
– Need maven-dependency-plugin, maven-antrun-plugin
©2016 Derek C. Ashmore, All Rights Reserved 17
API Gateway
• Exposes Lambdas as a RESTful Web Service
– Can be publicly available or part of a secured
private microservice library
©2016 Derek C. Ashmore, All Rights Reserved 18
Gateway Lambda Integration
©2016 Derek C. Ashmore, All Rights Reserved 19
• Integrations do basic transformations
– Map headers and parameters to Lambda request
fields
Gateway Integration Example
©2016 Derek C. Ashmore, All Rights Reserved 20
Gateway Models
©2016 Derek C. Ashmore, All Rights Reserved 21
Gateway Models (con’t)
• Jackson can generate the Json schema needed as
a Model
– No Mavin plugin for this
– Example Java code to generate (here)
– Example Mavin pom generating on build (here)
©2016 Derek C. Ashmore, All Rights Reserved 22
Lambdas and SNS Topics
• Lambdas can subscribe to SNS Publish/subscribe
topics
• Request Message is type SNSEvent
©2016 Derek C. Ashmore, All Rights Reserved 23
Lambdas can be scheduled
• Lambda executions can be scheduled through
CloudWatch
– Cron expressions supported
©2016 Derek C. Ashmore, All Rights Reserved 24
Tooling Gotchas
• API Gateway requires client with Server Name
Indication (SNI) support
– Most recent SoapUI does not (reference)
– Had to write my own test client using Httpclient
4.2 or above
©2016 Derek C. Ashmore, All Rights Reserved 25
Agenda
The “What”
and “Why” of
AWS Lambda
Developing
Lambda
Supporting
Lambda
Lambda and
Microservices
Summary /
Q&A
©2016 Derek C. Ashmore, All Rights Reserved 26
Versioning Support
• Lambda versioning and aliases
– Aliases are labels (e.g. PROD, TEST, DEV) that can be
reassigned to different versions.
– Versions are unique an can’t be changed.
• S3 versioning possible for Lambda Zip artifacts
• You need a correlation between source control
and Lambda version
– Possibilities
• Tag all Lambda versions in source control and include the
Lambda version number
• Breadcrumbs in the deployed Zip that describe the specific
source control change number used for the build
©2016 Derek C. Ashmore, All Rights Reserved 27
Lifecycle Environment Support
• Configuration Support
– Baked into the deployment zip
• You can’t just move the zips from environment to
environment
• Spring profiles not an option as you don’t control JVM
parms
– API Gateway does have staging variables
• No Remote Debug Support
©2016 Derek C. Ashmore, All Rights Reserved 28
Automated Deployment Options
• Nothing out of the box
• One possibility
– Load Lambda function from S3 bucket
– Jenkins plugin to load build artifacts to S3
• https://wiki.jenkins-ci.org/display/JENKINS/S3+Plugin
– Use AWS CLI to Manage lambda publishing and
aliases
©2016 Derek C. Ashmore, All Rights Reserved 29
Performance
• Start-up Time – Python, Node.js, Java
– Berezovsky performance test
• Throughput – Java and Node.js
– Both have a JIT
– DZone comparison here
– Close enough that other factors would likely guide
your language choice
©2016 Derek C. Ashmore, All Rights Reserved 30
Agenda
The “What”
and “Why” of
AWS Lambda
Developing
Lambda
Supporting
Lambda
Lambda and
Microservices
Summary /
Q&A
©2016 Derek C. Ashmore, All Rights Reserved 31
Lambdas and Microservices
©2016 Derek C. Ashmore, All Rights Reserved 32
Using Lambdas as Microservices
• Lambda / API Gateway is a deployment option for microservices
– No differences in design principles
• Single purpose
• Self-contained
– Still design for failure
• Don’t “assume” that Lambda outages can’t happen
– A Lambda might need external resources that aren’t available
• Off Limits: Coding patterns that use state
– Lambdas must be stateless
– Fail fast patterns
• Service Call Mediator
• Circuit Breaker
– Performance Patterns
• Expiring Cache (API Gateway allows request caching)
©2016 Derek C. Ashmore, All Rights Reserved 33
Back-ends for Front-ends
©2015 Derek C. Ashmore, All Rights Reserved 34
Retry Pattern
©2015 Derek C. Ashmore, All Rights Reserved 35
• Best for asynchronous tasks
• Limit the number of tries
• You must stay under your Lambda execution time limit!
• Use sleep interval between tries
• Only addresses temporary outages
• Sample Retry Pattern implementation here.
• Tooling Support:
– Apache CXF supports Retry
– Spring Batch RetryTemplate
– Apache HttpClient (Example here)
Dispatch via Messaging
©2015 Derek C. Ashmore, All Rights Reserved 36
• Place work instruction on persistent queue
• If receivers are down, work stacks in queue
• Work throttled by number of receivers
• Queue can be SES, JMS or AMQP
• Tooling Support:
– JMS Api (easy API – many use natively)
– Spring JMSTemplate or RabbitTemplate (producer)
Custom Rollback
©2015 Derek C. Ashmore, All Rights Reserved 37
Custom Rollback (continued)
• Reverses a transaction previously posted
• Only use this for multi-service transactions
– Keeping the transaction within one service is
preferred
• This pattern is completely custom
– No special product support available
• More information here
©2015 Derek C. Ashmore, All Rights Reserved 38
Contract Testing
• Critical for MS architectures
– Contract changes can break other services
– Bulkhead for rogue developers
– Makes individual services more disposable
• Consumer-based testing
• Tooling support
– Apache HttpClient (4.2 or above)
©2015 Derek C. Ashmore, All Rights Reserved 39
Agenda
The “What”
and “Why” of
AWS Lambda
Developing
Lambda
Supporting
Lambda
Lambda and
Microservices
Summary /
Q&A
©2016 Derek C. Ashmore, All Rights Reserved 40
Chief Complaints
• Documentation leaves a lot to be desired
– This is an understatement.
– For Java Lambdas, you are almost on your own.
• Lambda start-up time not consistent
– Sometimes long start-up time for JVM
– Python is the fastest
• Optimizations that depend on state aren’t as easy
– You would have to persist that state
• This would have it’s own concurrency and performance
issues
©2016 Derek C. Ashmore, All Rights Reserved 41
Implementation Tips
• Separation of Concerns
– Keep Lambda code separate from business logic
• Might want to change vendors someday
– Keep AWS SDK code separate from business logic
• Same reason
– Invoke other Lambdas through the API Gateway, not directly through the AWS
SDK
• Same reason
– Keep Business Logic locally runnable/debuggable
• Remote debug isn’t yet possible
• Ensure you can always tie AWS Request Id to your business transaction
– Need a way to gather logs from a complete business transactions and the
many services it might use
– All invocations get unique AWS request Ids
• For example, lambda invokes other lambdas
– Configure log4j layout to include AWS Request Id (example)
©2016 Derek C. Ashmore, All Rights Reserved 42
Lambda and the Gartner Hype Cycle
©2016 Derek C. Ashmore, All Rights Reserved 43
Further Reading
• This slide deck
– http://www.slideshare.net/derekashmore
• AWS Lambda Reading List
– http://www.derekashmore.com/2016/04/aws-lambda-reading-list.html
©2016 Derek C. Ashmore, All Rights Reserved 44
Questions?
• Derek Ashmore:
– Blog: www.derekashmore.com
– LinkedIn: www.linkedin.com/in/derekashmore
– Twitter: https://twitter.com/Derek_Ashmore
– GitHub: https://github.com/Derek-Ashmore
– Book: http://dvtpress.com/
©2016 Derek C. Ashmore, All Rights Reserved 45

More Related Content

What's hot

Writing microservices in Java -- Chicago-2015-11-10
Writing microservices in Java -- Chicago-2015-11-10Writing microservices in Java -- Chicago-2015-11-10
Writing microservices in Java -- Chicago-2015-11-10
Derek Ashmore
 
Writing microservices in java java one-2015-10-28
Writing microservices in java java one-2015-10-28Writing microservices in java java one-2015-10-28
Writing microservices in java java one-2015-10-28
Derek Ashmore
 
Refactoring Into Microservices. Chicago Coders Conference 2017-06-26
Refactoring Into Microservices. Chicago Coders Conference 2017-06-26Refactoring Into Microservices. Chicago Coders Conference 2017-06-26
Refactoring Into Microservices. Chicago Coders Conference 2017-06-26
Derek Ashmore
 
Microservices with Terraform, Docker and the Cloud. DevOps Wet 2018
Microservices with Terraform, Docker and the Cloud. DevOps Wet 2018Microservices with Terraform, Docker and the Cloud. DevOps Wet 2018
Microservices with Terraform, Docker and the Cloud. DevOps Wet 2018
Derek Ashmore
 
Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15
Derek Ashmore
 
Serverless in Java Lessons learnt
Serverless in Java Lessons learntServerless in Java Lessons learnt
Serverless in Java Lessons learnt
Krzysztof Pawlowski
 
Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02
Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02
Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02
Derek Ashmore
 
Microservices for java architects schamburg-2015-05-19
Microservices for java architects schamburg-2015-05-19Microservices for java architects schamburg-2015-05-19
Microservices for java architects schamburg-2015-05-19
Derek Ashmore
 
High Availability Perl DBI + MySQL
High Availability Perl DBI + MySQLHigh Availability Perl DBI + MySQL
High Availability Perl DBI + MySQL
Steve Purkis
 
Sas 2015 event_driven
Sas 2015 event_drivenSas 2015 event_driven
Sas 2015 event_driven
Sascha Möllering
 
DevOpsCon Cloud Workshop
DevOpsCon Cloud Workshop DevOpsCon Cloud Workshop
DevOpsCon Cloud Workshop
Sascha Möllering
 
Docker in the Cloud
Docker in the CloudDocker in the Cloud
Docker in the Cloud
Sascha Möllering
 
Peeling back the Lambda layers
Peeling back the Lambda layersPeeling back the Lambda layers
Peeling back the Lambda layers
Patrick McCaffrey
 
Scala in the Wild
Scala in the WildScala in the Wild
Scala in the Wild
Tomer Gabel
 
Why akka
Why akkaWhy akka
Why akka
Sapardi Sapardi
 
Journey towards serverless infrastructure
Journey towards serverless infrastructureJourney towards serverless infrastructure
Journey towards serverless infrastructure
Ville Seppänen
 
AWS Re:Invent - High Availability Architecture at Netflix
AWS Re:Invent - High Availability Architecture at NetflixAWS Re:Invent - High Availability Architecture at Netflix
AWS Re:Invent - High Availability Architecture at Netflix
Adrian Cockcroft
 
RESTing in the ALPS Mike Amundsen's Presentation from QCon London 2013
RESTing in the ALPS Mike Amundsen's Presentation from QCon London 2013RESTing in the ALPS Mike Amundsen's Presentation from QCon London 2013
RESTing in the ALPS Mike Amundsen's Presentation from QCon London 2013
CA API Management
 
Performance architecture for cloud connect
Performance architecture for cloud connectPerformance architecture for cloud connect
Performance architecture for cloud connect
Adrian Cockcroft
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web Applications
Achievers Tech
 

What's hot (20)

Writing microservices in Java -- Chicago-2015-11-10
Writing microservices in Java -- Chicago-2015-11-10Writing microservices in Java -- Chicago-2015-11-10
Writing microservices in Java -- Chicago-2015-11-10
 
Writing microservices in java java one-2015-10-28
Writing microservices in java java one-2015-10-28Writing microservices in java java one-2015-10-28
Writing microservices in java java one-2015-10-28
 
Refactoring Into Microservices. Chicago Coders Conference 2017-06-26
Refactoring Into Microservices. Chicago Coders Conference 2017-06-26Refactoring Into Microservices. Chicago Coders Conference 2017-06-26
Refactoring Into Microservices. Chicago Coders Conference 2017-06-26
 
Microservices with Terraform, Docker and the Cloud. DevOps Wet 2018
Microservices with Terraform, Docker and the Cloud. DevOps Wet 2018Microservices with Terraform, Docker and the Cloud. DevOps Wet 2018
Microservices with Terraform, Docker and the Cloud. DevOps Wet 2018
 
Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15Microservices for java architects it-symposium-2015-09-15
Microservices for java architects it-symposium-2015-09-15
 
Serverless in Java Lessons learnt
Serverless in Java Lessons learntServerless in Java Lessons learnt
Serverless in Java Lessons learnt
 
Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02
Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02
Microservices with Terraform, Docker and the Cloud. JavaOne 2017 2017-10-02
 
Microservices for java architects schamburg-2015-05-19
Microservices for java architects schamburg-2015-05-19Microservices for java architects schamburg-2015-05-19
Microservices for java architects schamburg-2015-05-19
 
High Availability Perl DBI + MySQL
High Availability Perl DBI + MySQLHigh Availability Perl DBI + MySQL
High Availability Perl DBI + MySQL
 
Sas 2015 event_driven
Sas 2015 event_drivenSas 2015 event_driven
Sas 2015 event_driven
 
DevOpsCon Cloud Workshop
DevOpsCon Cloud Workshop DevOpsCon Cloud Workshop
DevOpsCon Cloud Workshop
 
Docker in the Cloud
Docker in the CloudDocker in the Cloud
Docker in the Cloud
 
Peeling back the Lambda layers
Peeling back the Lambda layersPeeling back the Lambda layers
Peeling back the Lambda layers
 
Scala in the Wild
Scala in the WildScala in the Wild
Scala in the Wild
 
Why akka
Why akkaWhy akka
Why akka
 
Journey towards serverless infrastructure
Journey towards serverless infrastructureJourney towards serverless infrastructure
Journey towards serverless infrastructure
 
AWS Re:Invent - High Availability Architecture at Netflix
AWS Re:Invent - High Availability Architecture at NetflixAWS Re:Invent - High Availability Architecture at Netflix
AWS Re:Invent - High Availability Architecture at Netflix
 
RESTing in the ALPS Mike Amundsen's Presentation from QCon London 2013
RESTing in the ALPS Mike Amundsen's Presentation from QCon London 2013RESTing in the ALPS Mike Amundsen's Presentation from QCon London 2013
RESTing in the ALPS Mike Amundsen's Presentation from QCon London 2013
 
Performance architecture for cloud connect
Performance architecture for cloud connectPerformance architecture for cloud connect
Performance architecture for cloud connect
 
Scaling High Traffic Web Applications
Scaling High Traffic Web ApplicationsScaling High Traffic Web Applications
Scaling High Traffic Web Applications
 

Similar to Aws Lambda for Java Architects - JavaOne -2016-09-19

AWS Lambda: Best Practices and Common Mistakes - Dev Ops West 2019
AWS Lambda: Best Practices and Common Mistakes - Dev Ops West 2019AWS Lambda: Best Practices and Common Mistakes - Dev Ops West 2019
AWS Lambda: Best Practices and Common Mistakes - Dev Ops West 2019
Derek Ashmore
 
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2019
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2019AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2019
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2019
Derek Ashmore
 
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
Derek Ashmore
 
AWS Lambda: Best Practices and Common Mistakes - DevOps East 2019
AWS Lambda: Best Practices and Common Mistakes - DevOps East 2019AWS Lambda: Best Practices and Common Mistakes - DevOps East 2019
AWS Lambda: Best Practices and Common Mistakes - DevOps East 2019
Derek Ashmore
 
AWS Lambda: Best Practices and Common Mistakes - AWS Community Days 2019
AWS Lambda: Best Practices and Common Mistakes - AWS Community Days 2019AWS Lambda: Best Practices and Common Mistakes - AWS Community Days 2019
AWS Lambda: Best Practices and Common Mistakes - AWS Community Days 2019
Derek Ashmore
 
AWS Community Day - Derek C. Ashmore - AWS Lambda: Best Practices
AWS Community Day  - Derek C. Ashmore - AWS Lambda: Best Practices AWS Community Day  - Derek C. Ashmore - AWS Lambda: Best Practices
AWS Community Day - Derek C. Ashmore - AWS Lambda: Best Practices
AWS Chicago
 
What's New in AWS Serverless and Containers
What's New in AWS Serverless and ContainersWhat's New in AWS Serverless and Containers
What's New in AWS Serverless and Containers
Amazon Web Services
 
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech TalksDeep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Amazon Web Services
 
SMC302 Building Serverless Web Applications
SMC302 Building Serverless Web ApplicationsSMC302 Building Serverless Web Applications
SMC302 Building Serverless Web Applications
Amazon Web Services
 
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB AtlasWebinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
MongoDB
 
Serverless design considerations for Cloud Native workloads
Serverless design considerations for Cloud Native workloadsServerless design considerations for Cloud Native workloads
Serverless design considerations for Cloud Native workloads
Tensult
 
Serverless Architecture Patterns
Serverless Architecture PatternsServerless Architecture Patterns
Serverless Architecture Patterns
Amazon Web Services
 
Building Serverless Web Applications
Building Serverless Web Applications Building Serverless Web Applications
Building Serverless Web Applications
Amazon Web Services
 
Lambdaless and AWS CDK
Lambdaless and AWS CDKLambdaless and AWS CDK
Lambdaless and AWS CDK
MooYeol Lee
 
What's New with AWS Lambda
What's New with AWS LambdaWhat's New with AWS Lambda
What's New with AWS Lambda
Amazon Web Services
 
以AWS Lambda與Amazon API Gateway打造無伺服器後端
以AWS Lambda與Amazon API Gateway打造無伺服器後端以AWS Lambda與Amazon API Gateway打造無伺服器後端
以AWS Lambda與Amazon API Gateway打造無伺服器後端
Amazon Web Services
 
Deep Dive on AWS Lambda
Deep Dive on AWS LambdaDeep Dive on AWS Lambda
Deep Dive on AWS Lambda
Amazon Web Services
 
Aws lambda best practices - ignite - dev opsdays-charlotte
Aws lambda   best practices - ignite - dev opsdays-charlotteAws lambda   best practices - ignite - dev opsdays-charlotte
Aws lambda best practices - ignite - dev opsdays-charlotte
Derek Ashmore
 
Building Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API GatewayBuilding Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API Gateway
Amazon Web Services
 
What's New with AWS Lambda
What's New with AWS LambdaWhat's New with AWS Lambda
What's New with AWS Lambda
Amazon Web Services
 

Similar to Aws Lambda for Java Architects - JavaOne -2016-09-19 (20)

AWS Lambda: Best Practices and Common Mistakes - Dev Ops West 2019
AWS Lambda: Best Practices and Common Mistakes - Dev Ops West 2019AWS Lambda: Best Practices and Common Mistakes - Dev Ops West 2019
AWS Lambda: Best Practices and Common Mistakes - Dev Ops West 2019
 
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2019
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2019AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2019
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2019
 
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
AWS Lambda: Best Practices and Common Mistakes - Chicago Cloud Conference 2020
 
AWS Lambda: Best Practices and Common Mistakes - DevOps East 2019
AWS Lambda: Best Practices and Common Mistakes - DevOps East 2019AWS Lambda: Best Practices and Common Mistakes - DevOps East 2019
AWS Lambda: Best Practices and Common Mistakes - DevOps East 2019
 
AWS Lambda: Best Practices and Common Mistakes - AWS Community Days 2019
AWS Lambda: Best Practices and Common Mistakes - AWS Community Days 2019AWS Lambda: Best Practices and Common Mistakes - AWS Community Days 2019
AWS Lambda: Best Practices and Common Mistakes - AWS Community Days 2019
 
AWS Community Day - Derek C. Ashmore - AWS Lambda: Best Practices
AWS Community Day  - Derek C. Ashmore - AWS Lambda: Best Practices AWS Community Day  - Derek C. Ashmore - AWS Lambda: Best Practices
AWS Community Day - Derek C. Ashmore - AWS Lambda: Best Practices
 
What's New in AWS Serverless and Containers
What's New in AWS Serverless and ContainersWhat's New in AWS Serverless and Containers
What's New in AWS Serverless and Containers
 
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech TalksDeep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
Deep Dive on AWS Lambda - January 2017 AWS Online Tech Talks
 
SMC302 Building Serverless Web Applications
SMC302 Building Serverless Web ApplicationsSMC302 Building Serverless Web Applications
SMC302 Building Serverless Web Applications
 
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB AtlasWebinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
 
Serverless design considerations for Cloud Native workloads
Serverless design considerations for Cloud Native workloadsServerless design considerations for Cloud Native workloads
Serverless design considerations for Cloud Native workloads
 
Serverless Architecture Patterns
Serverless Architecture PatternsServerless Architecture Patterns
Serverless Architecture Patterns
 
Building Serverless Web Applications
Building Serverless Web Applications Building Serverless Web Applications
Building Serverless Web Applications
 
Lambdaless and AWS CDK
Lambdaless and AWS CDKLambdaless and AWS CDK
Lambdaless and AWS CDK
 
What's New with AWS Lambda
What's New with AWS LambdaWhat's New with AWS Lambda
What's New with AWS Lambda
 
以AWS Lambda與Amazon API Gateway打造無伺服器後端
以AWS Lambda與Amazon API Gateway打造無伺服器後端以AWS Lambda與Amazon API Gateway打造無伺服器後端
以AWS Lambda與Amazon API Gateway打造無伺服器後端
 
Deep Dive on AWS Lambda
Deep Dive on AWS LambdaDeep Dive on AWS Lambda
Deep Dive on AWS Lambda
 
Aws lambda best practices - ignite - dev opsdays-charlotte
Aws lambda   best practices - ignite - dev opsdays-charlotteAws lambda   best practices - ignite - dev opsdays-charlotte
Aws lambda best practices - ignite - dev opsdays-charlotte
 
Building Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API GatewayBuilding Serverless Backends with AWS Lambda and Amazon API Gateway
Building Serverless Backends with AWS Lambda and Amazon API Gateway
 
What's New with AWS Lambda
What's New with AWS LambdaWhat's New with AWS Lambda
What's New with AWS Lambda
 

Recently uploaded

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
UiPathCommunity
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 

Recently uploaded (20)

Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 

Aws Lambda for Java Architects - JavaOne -2016-09-19

  • 1. AWS Lambda for Java Architects Given by Derek C. Ashmore Sept 19, 2016 ©2016 Derek C. Ashmore, All Rights Reserved 1
  • 2. Who am I? • Professional Geek since 1987 • Java/J2EE/Java EE since 1999 • Roles include: • Developer • Architect • Project Manager • DBA • System Admin ©2016 Derek C. Ashmore, All Rights Reserved 2
  • 3. Discussion Resources • This slide deck – http://www.slideshare.net/derekashmore • Sample code on my Github – https://github.com/Derek-Ashmore/ • Sample Java AWS Lambda Source – https://github.com/Derek-Ashmore/AWSLambdaExamples • Slide deck has hyper-links! – Don’t bother writing down URLs ©2016 Derek C. Ashmore, All Rights Reserved 3
  • 4. Agenda The “What” and “Why” of AWS Lambda Developing Lambda Supporting Lambda Lambda and Microservices Summary / Q&A ©2016 Derek C. Ashmore, All Rights Reserved 4
  • 5. What are AWS Lambdas? • You provide custom code -> AWS runs it – Java, Node.js, Python • Computing power with less management – AWS manages the hardware – AWS autoscales that hardware – AWS maintains that hardware • Lambdas are event driven – API Gateway (e.g. RESTful Web Service call) – Many more • Lambdas are stateless • Not to be confused with “Lambda Expressions” in Java 8 ©2016 Derek C. Ashmore, All Rights Reserved 5
  • 6. Lambda Event Sources • API Gateway • SNS Messaging Subscriptions • Schedule • Storage writes – S3, DynamoDB, Kenesis ©2016 Derek C. Ashmore, All Rights Reserved 6 • SES Email receipt • Cloudwatch – Schedule, Events, log entries • Cognito (Security) • CloudFormation – Creation script
  • 7. What’s the Business Benefit • Less Maintenance Hassle • Unlimited Parallelism • Current cost advantage – Don’t pay for idle – CPU cost currently lower • Free tier – 1 M executions and 400K compute seconds per month – Memory allocated determines allowed free-tier runtime • 20 cents per 1 M executions + memory/runtime cost – Administration cost • No O/S upgrades, server backups, etc. ©2016 Derek C. Ashmore, All Rights Reserved 7
  • 8. There’s no free lunch • Less control over environment – Harder to tune – Memory and time limits on execution • No Java EE amenities – No connection pooling, session support, caching • Proprietary Interface – Potential Technical Lock-in • No Guarantee that AWS cost will be constant – Potential Business Risk • Modern version of CGI ©2016 Derek C. Ashmore, All Rights Reserved 8
  • 9. Agenda The “What” and “Why” of AWS Lambda Developing Lambda Supporting Lambda Lambda and Microservices Summary / Q&A ©2016 Derek C. Ashmore, All Rights Reserved 9
  • 10. Lambda Java API • RequestHandler interface • JSON marshalling of Request and Response • Execution Context • Deployment Zip Artifact – Typically one RequestHandler per Zip artifact ©2016 Derek C. Ashmore, All Rights Reserved 10
  • 11. Lambda Request / Response Sample • Expose REST API that collects email addresses for a mailing list – https://scrubbed/prod/EmailCollector • Sample request/response ©2016 Derek C. Ashmore, All Rights Reserved 11
  • 12. Implementing a RequestHandler • RequestHandler interface is generic. – POJOs represent the request and response – POJOs determine JSON request/response format – Execution Context class provided by AWS • This class specified when Lambda defined • Note the wrapping try/catch – Portion of the Context provided by AWS -> need more – AWS Does marshalling – ContextedRuntimeException from Apache Commons Lang3 • Note that the Lambda is thin -> Business logic is elsewhere • Sample is on GitHub (here) ©2016 Derek C. Ashmore, All Rights Reserved 12
  • 13. Implementing a RequestHandler • RequestHandler interface is generic. – POJOs represent the request and response – POJOs determine JSON request/response format – Execution Context class provided by AWS • This class specified when Lambda defined • Note the wrapping try/catch – Portion of the Context provided by AWS -> need more – AWS Does marshalling – ContextedRuntimeException from Apache Commons Lang3 • Note that the Lambda is thin -> Business logic is elsewhere • Sample is on GitHub (here) ©2016 Derek C. Ashmore, All Rights Reserved 13
  • 14. Implementing a RequestHandler • RequestHandler interface is generic. – POJOs represent the request and response – POJOs determine JSON request/response format – Execution Context class provided by AWS • This class specified when Lambda defined • Note the wrapping try/catch – Portion of the Context provided by AWS -> need more – AWS Does marshalling – ContextedRuntimeException from Apache Commons Lang3 • Note that the Lambda is thin -> Business logic is elsewhere • Sample is on GitHub (here) ©2016 Derek C. Ashmore, All Rights Reserved 14
  • 15. What’s in the Context? • Execution Context provided by AWS • Contains: – AWS Request ID -> Get logs for specific request – Function name, version, arn – Cognito identity – Remaining time/memory – Mobile client information (AWS Mobile SDK) • Environment name/value map • Custom name/value map ©2016 Derek C. Ashmore, All Rights Reserved 15
  • 16. Resource Support • Java 8 Runtime -> – you can configure memory available • Log4J logging available – Viewable/searchable in Cloudwatch logs – Custom Log4J Appender provided • Third party jars can be included – Including AWS SDK for AWS Tasks (executing other Lambdas) – JDBC Drivers – HttpClient or Apache CXF • Keep in Mind – You create/destroy all database connections • No connection pooling (Lambdas are stateless) – Caching APIs have limited benefit (Lambdas are stateless) – No Remote Debug capability ©2016 Derek C. Ashmore, All Rights Reserved 16
  • 17. Lambda Deployment Package • Zip Organization – Root is in the classpath – Lib contains 3rd party jars • Maven example here – Need maven-dependency-plugin, maven-antrun-plugin ©2016 Derek C. Ashmore, All Rights Reserved 17
  • 18. API Gateway • Exposes Lambdas as a RESTful Web Service – Can be publicly available or part of a secured private microservice library ©2016 Derek C. Ashmore, All Rights Reserved 18
  • 19. Gateway Lambda Integration ©2016 Derek C. Ashmore, All Rights Reserved 19 • Integrations do basic transformations – Map headers and parameters to Lambda request fields
  • 20. Gateway Integration Example ©2016 Derek C. Ashmore, All Rights Reserved 20
  • 21. Gateway Models ©2016 Derek C. Ashmore, All Rights Reserved 21
  • 22. Gateway Models (con’t) • Jackson can generate the Json schema needed as a Model – No Mavin plugin for this – Example Java code to generate (here) – Example Mavin pom generating on build (here) ©2016 Derek C. Ashmore, All Rights Reserved 22
  • 23. Lambdas and SNS Topics • Lambdas can subscribe to SNS Publish/subscribe topics • Request Message is type SNSEvent ©2016 Derek C. Ashmore, All Rights Reserved 23
  • 24. Lambdas can be scheduled • Lambda executions can be scheduled through CloudWatch – Cron expressions supported ©2016 Derek C. Ashmore, All Rights Reserved 24
  • 25. Tooling Gotchas • API Gateway requires client with Server Name Indication (SNI) support – Most recent SoapUI does not (reference) – Had to write my own test client using Httpclient 4.2 or above ©2016 Derek C. Ashmore, All Rights Reserved 25
  • 26. Agenda The “What” and “Why” of AWS Lambda Developing Lambda Supporting Lambda Lambda and Microservices Summary / Q&A ©2016 Derek C. Ashmore, All Rights Reserved 26
  • 27. Versioning Support • Lambda versioning and aliases – Aliases are labels (e.g. PROD, TEST, DEV) that can be reassigned to different versions. – Versions are unique an can’t be changed. • S3 versioning possible for Lambda Zip artifacts • You need a correlation between source control and Lambda version – Possibilities • Tag all Lambda versions in source control and include the Lambda version number • Breadcrumbs in the deployed Zip that describe the specific source control change number used for the build ©2016 Derek C. Ashmore, All Rights Reserved 27
  • 28. Lifecycle Environment Support • Configuration Support – Baked into the deployment zip • You can’t just move the zips from environment to environment • Spring profiles not an option as you don’t control JVM parms – API Gateway does have staging variables • No Remote Debug Support ©2016 Derek C. Ashmore, All Rights Reserved 28
  • 29. Automated Deployment Options • Nothing out of the box • One possibility – Load Lambda function from S3 bucket – Jenkins plugin to load build artifacts to S3 • https://wiki.jenkins-ci.org/display/JENKINS/S3+Plugin – Use AWS CLI to Manage lambda publishing and aliases ©2016 Derek C. Ashmore, All Rights Reserved 29
  • 30. Performance • Start-up Time – Python, Node.js, Java – Berezovsky performance test • Throughput – Java and Node.js – Both have a JIT – DZone comparison here – Close enough that other factors would likely guide your language choice ©2016 Derek C. Ashmore, All Rights Reserved 30
  • 31. Agenda The “What” and “Why” of AWS Lambda Developing Lambda Supporting Lambda Lambda and Microservices Summary / Q&A ©2016 Derek C. Ashmore, All Rights Reserved 31
  • 32. Lambdas and Microservices ©2016 Derek C. Ashmore, All Rights Reserved 32
  • 33. Using Lambdas as Microservices • Lambda / API Gateway is a deployment option for microservices – No differences in design principles • Single purpose • Self-contained – Still design for failure • Don’t “assume” that Lambda outages can’t happen – A Lambda might need external resources that aren’t available • Off Limits: Coding patterns that use state – Lambdas must be stateless – Fail fast patterns • Service Call Mediator • Circuit Breaker – Performance Patterns • Expiring Cache (API Gateway allows request caching) ©2016 Derek C. Ashmore, All Rights Reserved 33
  • 34. Back-ends for Front-ends ©2015 Derek C. Ashmore, All Rights Reserved 34
  • 35. Retry Pattern ©2015 Derek C. Ashmore, All Rights Reserved 35 • Best for asynchronous tasks • Limit the number of tries • You must stay under your Lambda execution time limit! • Use sleep interval between tries • Only addresses temporary outages • Sample Retry Pattern implementation here. • Tooling Support: – Apache CXF supports Retry – Spring Batch RetryTemplate – Apache HttpClient (Example here)
  • 36. Dispatch via Messaging ©2015 Derek C. Ashmore, All Rights Reserved 36 • Place work instruction on persistent queue • If receivers are down, work stacks in queue • Work throttled by number of receivers • Queue can be SES, JMS or AMQP • Tooling Support: – JMS Api (easy API – many use natively) – Spring JMSTemplate or RabbitTemplate (producer)
  • 37. Custom Rollback ©2015 Derek C. Ashmore, All Rights Reserved 37
  • 38. Custom Rollback (continued) • Reverses a transaction previously posted • Only use this for multi-service transactions – Keeping the transaction within one service is preferred • This pattern is completely custom – No special product support available • More information here ©2015 Derek C. Ashmore, All Rights Reserved 38
  • 39. Contract Testing • Critical for MS architectures – Contract changes can break other services – Bulkhead for rogue developers – Makes individual services more disposable • Consumer-based testing • Tooling support – Apache HttpClient (4.2 or above) ©2015 Derek C. Ashmore, All Rights Reserved 39
  • 40. Agenda The “What” and “Why” of AWS Lambda Developing Lambda Supporting Lambda Lambda and Microservices Summary / Q&A ©2016 Derek C. Ashmore, All Rights Reserved 40
  • 41. Chief Complaints • Documentation leaves a lot to be desired – This is an understatement. – For Java Lambdas, you are almost on your own. • Lambda start-up time not consistent – Sometimes long start-up time for JVM – Python is the fastest • Optimizations that depend on state aren’t as easy – You would have to persist that state • This would have it’s own concurrency and performance issues ©2016 Derek C. Ashmore, All Rights Reserved 41
  • 42. Implementation Tips • Separation of Concerns – Keep Lambda code separate from business logic • Might want to change vendors someday – Keep AWS SDK code separate from business logic • Same reason – Invoke other Lambdas through the API Gateway, not directly through the AWS SDK • Same reason – Keep Business Logic locally runnable/debuggable • Remote debug isn’t yet possible • Ensure you can always tie AWS Request Id to your business transaction – Need a way to gather logs from a complete business transactions and the many services it might use – All invocations get unique AWS request Ids • For example, lambda invokes other lambdas – Configure log4j layout to include AWS Request Id (example) ©2016 Derek C. Ashmore, All Rights Reserved 42
  • 43. Lambda and the Gartner Hype Cycle ©2016 Derek C. Ashmore, All Rights Reserved 43
  • 44. Further Reading • This slide deck – http://www.slideshare.net/derekashmore • AWS Lambda Reading List – http://www.derekashmore.com/2016/04/aws-lambda-reading-list.html ©2016 Derek C. Ashmore, All Rights Reserved 44
  • 45. Questions? • Derek Ashmore: – Blog: www.derekashmore.com – LinkedIn: www.linkedin.com/in/derekashmore – Twitter: https://twitter.com/Derek_Ashmore – GitHub: https://github.com/Derek-Ashmore – Book: http://dvtpress.com/ ©2016 Derek C. Ashmore, All Rights Reserved 45