SlideShare a Scribd company logo
1 of 31
Download to read offline
Plaλ!
Running the Play! framework in AWS Lambda
@sihil
Simon Hildrew
Lead Software Developer
The Guardian
@sihil
simon.hildrew@theguardian.com
@sihil
+
@sihil
@sihil
HTTP JSON
@sihil
Plaλ wrapper
appHTTP JSON
Will this work?
@sihil
Plaλ wrapper
app
Let's try!
@sihil
@sihil
topLevelDirectory in Universal := None
Baby steps
@sihil
class LambdaEntrypoint {
def run(event: JMap[String, Object], lambdaContext: Context): Unit = {
// Start a play application
val application: Application = {
val environment = Environment(new File("/"),
getClass.getClassLoader, Mode.Prod)
val context = ApplicationLoader.createContext(environment)
val loader = ApplicationLoader(context)
loader.load(context)
}
Play.start(application)
context.logger.log("AWS Lambda has started your Play application")
}
}
@sihil
https://www.flickr.com/photos/

jarld/14374126748
@sihil
val request = FakeRequest("GET", "/management/healthcheck")
// actually call the router
val maybeResult = Helpers.route(app, request)
maybeResult.map(Helpers.contentAsString).foreach{result =>
context.getLogger.log(result)
}
@sihil
def transform(request: LambdaRequest): FakeRequest[AnyContentAsEmpty.type] = {
val queryString = for {
queryMap <- request.queryStringParameters.toList
(name, value) <- queryMap
} yield s"$name=$value"
val pathWithQueryString =
if (queryString.isEmpty) request.path
else queryString.mkString(s"${request.path}?", "&", "")
FakeRequest(
method = request.httpMethod,
uri = pathWithQueryString,
headers = FakeHeaders(request.headers.map(_.toList).getOrElse(Nil)),
body = AnyContentAsEmpty
)
}
Limitations
• Strictly defined request and response mappings
• Multiple Set-Cookie headers
• Binary data
• Performance
@sihil
@sihil
Limitations
• Strictly defined request and response mappings
• Multiple Set-Cookie headers
• Binary data
• Performance
@sihil
@sihil
@sihil
Plaλ wrapper
appJSON
Set-Cookie & Redirect for nextcookie
/auth
/plambda/moreCookies?c=xxx&r=XXX
Set-Cookie & Redirect to final dest
Limitations
• Strictly defined request and response mappings
• Multiple Set-Cookie headers
• Binary data
• Performance
@sihil
UTF8 💩
@sihil
$ curl -s https://<plambda-url>/assets/images/fav-versions-32.png | md5
d17aec342d33ae61c775c118d605fa10
$ md5 public/images/fav-versions-32.png
38f8b0476d6beef91350c79f76b88210
@sihil
Plaλ wrapper
appJSON
Redirect to S3
/asset/binary-data.png
s3://plambda-data/asset/binary-data.png?signature=???
Binary data response
PutObject
Limitations
• Strictly defined request and response mappings
• Multiple Set-Cookie headers
• Binary data
• Performance
@sihil
¯_( )_/¯
@sihil
@sihil
CMS
snapshot restore
@sihil
Server Plaλ (Cold-ish)
@sihil
@sihil
Server Plaλ (Warm)
@sihil
$0.02 - $0.50 / mo
@sihil
@sihil
Plaλ (Play!)
https://github.com/sihil/plambda
AWS Serverless Express (Node Express)
https://github.com/awslabs/aws-serverless-express
Zappa (Python WSGI)
https://www.zappa.io/
Quaich (Scala)
https://github.com/bwmcadams/quaich
Serverless (Node)
https://serverless.com/
Chalice (Python)
https://github.com/awslabs/chalice
Thanks!
@sihil

More Related Content

What's hot

What's hot (20)

AWS Community Day Bangkok 2019 - DevOps Cost Reduction using Jenkins & AWS Sp...
AWS Community Day Bangkok 2019 - DevOps Cost Reduction using Jenkins & AWS Sp...AWS Community Day Bangkok 2019 - DevOps Cost Reduction using Jenkins & AWS Sp...
AWS Community Day Bangkok 2019 - DevOps Cost Reduction using Jenkins & AWS Sp...
 
Tensorflow in production with AWS Lambda
Tensorflow in production with AWS LambdaTensorflow in production with AWS Lambda
Tensorflow in production with AWS Lambda
 
Application & Account Monitoring in AWS
Application & Account Monitoring in AWSApplication & Account Monitoring in AWS
Application & Account Monitoring in AWS
 
Building a Python Serverless Applications with AWS Chalice - AWS Online Tech...
 Building a Python Serverless Applications with AWS Chalice - AWS Online Tech... Building a Python Serverless Applications with AWS Chalice - AWS Online Tech...
Building a Python Serverless Applications with AWS Chalice - AWS Online Tech...
 
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
CI CD using AWS Developer Tools @ AWS Community Day Bengaluru 2018
 
AWS Cloud Formation
AWS Cloud FormationAWS Cloud Formation
AWS Cloud Formation
 
Serverless haskell
Serverless haskellServerless haskell
Serverless haskell
 
Practical Cloud
Practical CloudPractical Cloud
Practical Cloud
 
Cloud Academy's AWS Hands on-labs
Cloud Academy's AWS Hands on-labsCloud Academy's AWS Hands on-labs
Cloud Academy's AWS Hands on-labs
 
Exploring Serverless Architectures: AWS Lambda
Exploring Serverless Architectures: AWS LambdaExploring Serverless Architectures: AWS Lambda
Exploring Serverless Architectures: AWS Lambda
 
Graphs: Fabric of DevOps
Graphs: Fabric of DevOpsGraphs: Fabric of DevOps
Graphs: Fabric of DevOps
 
Apex Liberation - the evolution of Flex Queue (DF15)
Apex Liberation - the evolution of Flex Queue (DF15)Apex Liberation - the evolution of Flex Queue (DF15)
Apex Liberation - the evolution of Flex Queue (DF15)
 
Intro to js august 31
Intro to js august 31Intro to js august 31
Intro to js august 31
 
Where is my scalable api?
Where is my scalable api?Where is my scalable api?
Where is my scalable api?
 
JCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop LabsJCConf 2016 - Dataflow Workshop Labs
JCConf 2016 - Dataflow Workshop Labs
 
Serverless Workshop - Tomato Restaurant Rating App
Serverless Workshop - Tomato Restaurant Rating AppServerless Workshop - Tomato Restaurant Rating App
Serverless Workshop - Tomato Restaurant Rating App
 
Analyzing Mixpanel Data into Amazon Redshift
Analyzing Mixpanel Data into Amazon RedshiftAnalyzing Mixpanel Data into Amazon Redshift
Analyzing Mixpanel Data into Amazon Redshift
 
Introduction to the Serverless paradigm
Introduction to the Serverless paradigmIntroduction to the Serverless paradigm
Introduction to the Serverless paradigm
 
Deploying .Net Core Application to AWS ECS Fargate
Deploying .Net Core Application to AWS ECS FargateDeploying .Net Core Application to AWS ECS Fargate
Deploying .Net Core Application to AWS ECS Fargate
 
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
 

Similar to Plaλ!

The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
Amazon Web Services
 
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resourcesJavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
Corley S.r.l.
 

Similar to Plaλ! (20)

Building Serverless Applications with AWS Chalice
Building Serverless Applications with AWS ChaliceBuilding Serverless Applications with AWS Chalice
Building Serverless Applications with AWS Chalice
 
Serverless archtiectures
Serverless archtiecturesServerless archtiectures
Serverless archtiectures
 
Going Serverless
Going ServerlessGoing Serverless
Going Serverless
 
A Crash Course on Serverless Applications in Python
A Crash Course on Serverless Applications in PythonA Crash Course on Serverless Applications in Python
A Crash Course on Serverless Applications in Python
 
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
 
Into The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api'sInto The Box | Alexa and ColdBox Api's
Into The Box | Alexa and ColdBox Api's
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
So how do I test my Sling application?
 So how do I test my Sling application? So how do I test my Sling application?
So how do I test my Sling application?
 
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
The Best Practices and Hard Lessons Learned of Serverless Applications - AWS ...
 
AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...
AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...
AWS Startup Day - Boston 2018 - The Best Practices and Hard Lessons Learned o...
 
Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020Aws Lambda in Swift - NSLondon - 3rd December 2020
Aws Lambda in Swift - NSLondon - 3rd December 2020
 
AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...
AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...
AWS18 Startup Day Toronto- The Best Practices and Hard Lessons Learned of Ser...
 
About Node.js
About Node.jsAbout Node.js
About Node.js
 
Creating a modern web application using Symfony API Platform Atlanta
Creating a modern web application using  Symfony API Platform AtlantaCreating a modern web application using  Symfony API Platform Atlanta
Creating a modern web application using Symfony API Platform Atlanta
 
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resourcesJavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
JavaScript & Cloud: the AWS JS SDK and how to work with cloud resources
 
Building Serverless APIs on AWS
Building Serverless APIs on AWSBuilding Serverless APIs on AWS
Building Serverless APIs on AWS
 
Developing and deploying serverless applications (February 2017)
Developing and deploying serverless applications (February 2017)Developing and deploying serverless applications (February 2017)
Developing and deploying serverless applications (February 2017)
 
JavaScript Misunderstood
JavaScript MisunderstoodJavaScript Misunderstood
JavaScript Misunderstood
 
Arquitecturas de microservicios - Medianet Software
Arquitecturas de microservicios   -  Medianet SoftwareArquitecturas de microservicios   -  Medianet Software
Arquitecturas de microservicios - Medianet Software
 
Serverless Beyond Functions - CTO Club Made in JLM
Serverless Beyond Functions - CTO Club Made in JLMServerless Beyond Functions - CTO Club Made in JLM
Serverless Beyond Functions - CTO Club Made in JLM
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 

Recently uploaded (20)

8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 

Plaλ!