SlideShare a Scribd company logo
1 of 24
Download to read offline
About
Numeract LLC
● Data Science and Economics / Finance consulting services,
open source projects
● Technology Stack: (Postgre)SQL, R, Python, Docker, AWS
Contributors
● Mike Badescu, PhD Economics, Lehigh University
● Ana Niculescu, Msc Statistics for Smart Data, ENSAI, Rennes
● Teodor Ciuraru
github.com/numeract/aws-lambda-r
Agenda
Motivation
APIs
AWS
Running R on Amazon Lambda
Conclusions
Motivation
Deploying R in production is not very easy but it is a
good problem to have.
There are diverse approaches towards creating deployment
packages for AWS Lambda and creating an API but which one is
the best fit for R? This presentation aims to compare currently
available approaches and to present a custom solution.
Overview
Motivation
● Shiny Dashboard for data visualisation and model
validation
● In the backend, the Shiny App was also:
○ reading the data
○ performing data cleaning
○ computing features
○ building prediction models
● Client also needed to access to only the calculation
process to use it outside (and independent from)
the Shiny App
Our use case
Motivation
● Rewriting the code in another programming
language is not efficient
● Certain algorithms may not be available in
other programming languages
● Even though certain algorithms may be available
in other programming languages, they may not
render the same results as in R
Why not rewrite the needed code?
The answer to our problem
● Modularize the application
● Programming language independent
● Common concept: programmers know how to
work with APIs
● Common "data language": JSON (but not the
only one)
APIs
Of R and APIs
● Not directly, as R is not a web server
● We need a wrapper / server that:
● receives requests and hands them to R
● passes any response from R to the client
Candidate approaches
● Web server: plumber and OpenCPU
● Serverless: running R on AWS Lambda -> wrap R
functions inside FasS
Can we serve API requests from R?
Wrapping up the requirements
Getting ready to roll our sleeves
The App task engine should:
● get a request id
● read data from DB
● process data for 5-20 seconds
● return the results
Our challenge: How to use this code in
production?
● needs to be triggered
● uncertain and irregular future demand
● R code still in development
● clicking through an interface to re-deploy
the code every time we needed it was not
an option
Amazon Web Services
Bref
AWS is a collection of pay-as-you-go cloud services.
The services we needed:
● IAM (Identity and Access Management) - for security
● VPC - a logically isolated virtual network
● EC2 - a virtual machine
● API Gateway
● S3 - storage
● Lambda - serverless application service
Amazon Web Services
Lambda: Function as a Service
AWS Lambda is a serverless compute service that
launches and executes code when it is explicitly triggered
by an event (API), and stays up ONLY as long as the code
runs.
● Helps you build apps while minimizing infrastructure
maintenance
● Keep the focus on what’s important: data
engineering/analysis, not DevOps
● Pay only for what you use: supports ad-hoc requests
● Horizontally scalable
Image source:
https://dwdraju.medium.com/python-function-on-aws-lambda-with-api
-gateway-endpoint-288eae7617cb
R on Lambda
How difficult can it be?
Turns out, it is not as intuitive to directly run R in AWS Lambda.
Since December 2018, Amazon introduced
custom runtimes for AWS Lambda. This allows
us to use almost any programming language,
including R.
R on Lambda
Solutions
Our new approach:
● Use a Base R custom runtime provided by Bakdata
● Copy the additional R packages we need inside the deployment
package provided to Lambda
Other approaches:
● Previously we used package rpy2 to run R code from Python)
● R package lambda.r: triggers a Lambda function from R
AWS-Lambda-R
The architecture
Looks simple, but you don’t want to click through all that
every time you want to re-deploy the code...especially
when you have multiple releases
AWS-Lambda-R
Let’s not forget about security
Image source: https://aws.amazon.com/security/
Automation
aws-lambda-r scripts
We needed a fast way to launch the infrastructure entirely.
Our approach: a series of shell scripts that launch the entire AWS
infrastructure needed to run R on AWS Lambda.
Top view:
Deploy R function on AWS Lambda
Configure access to AWS Lambda
Automation
aws-lambda-r implementation details
The scripts:
1. use your settings to create a VPC, S3, authorization
policies
2. install and compile R packages
3. create the zip file to load in AWS Lambda and save it to
S3
4. create Lambda function and deploy the zip file
5. configure AWS API Gateway to allow accessing the
code over the web
The scripts use AWS CLI through (Git)Bash => available on
all platforms
R example
A simple function that runs in Lambda
Command Line
Running the scripts...
Command Line
API requests
Pros
At the end of the setup, you will have the entire infrastructure to
run R on AWS Lambda, without worrying about EC2 instances or
scalability issues.
● use AWS Command Line Interface - no need for clicks anymore
● pay-as-you go
● fast deployment after each release
● easy to adapt to automatically deploy code written in Python or
JavaScript (if needed in the future)
Limitations
● Lambda function memory allocation: 128 MB to 10,240 MB
● Function timeout: 15 minutes
● Maximum zip file size: 250MB
● this is the most important limitation as it prevents using large R
packages
Finally
Where Data Science stops and Data
Engineering begins...
● Each project has unique requirements and constraints
● AWS was great for our needs, Lambda too, especially
since it became more flexible through custom
execution environments and layers
● Scripts still run in production, making the client happy
● It is worth automating something in order to be able
to focus in what’s more important
github.com/numeract/aws-lambda-r
anamaria.niculescu@numeract.com
linkedin.com/in/anamarianiculescu/
github.com/AnaNiculescu36
Thank you!

More Related Content

Similar to Running R on AWS Lambda by Ana-Maria Niculescu

State of serverless
State of serverlessState of serverless
State of serverlessAnurag Saran
 
Write less (code) and build more with serverless
Write less (code) and build more with serverlessWrite less (code) and build more with serverless
Write less (code) and build more with serverlessDhaval Nagar
 
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
Skillenza Build with Serverless Challenge -  Advanced Serverless ConceptsSkillenza Build with Serverless Challenge -  Advanced Serverless Concepts
Skillenza Build with Serverless Challenge - Advanced Serverless ConceptsDhaval Nagar
 
AWS re:Invent 2020 Serverless Recap
AWS re:Invent 2020 Serverless RecapAWS re:Invent 2020 Serverless Recap
AWS re:Invent 2020 Serverless RecapDaniel Zivkovic
 
API workshop by AWS and 3scale
API workshop by AWS and 3scaleAPI workshop by AWS and 3scale
API workshop by AWS and 3scale3scale
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applicationsCesar Cardenas Desales
 
Go lambda-presentation
Go lambda-presentationGo lambda-presentation
Go lambda-presentationSteven White
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsCesar Cardenas Desales
 
Introduction To AWS & AWS Lambda
Introduction To AWS & AWS LambdaIntroduction To AWS & AWS Lambda
Introduction To AWS & AWS LambdaAn Nguyen
 
AWS Lambda Documentation
AWS Lambda DocumentationAWS Lambda Documentation
AWS Lambda DocumentationWhizlabs
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudAmazon Web Services
 
Building A Serverless Web Application With AWS Lambda: A Step-By-Step Guide
Building A Serverless Web Application With AWS Lambda: A Step-By-Step GuideBuilding A Serverless Web Application With AWS Lambda: A Step-By-Step Guide
Building A Serverless Web Application With AWS Lambda: A Step-By-Step GuideSynergyTop Inc.
 
Building Linked Data Platform with AWS
Building Linked Data Platform with AWSBuilding Linked Data Platform with AWS
Building Linked Data Platform with AWSEugeneMorozov
 
Migrating your .NET Applications to the AWS Serverless Platform
Migrating your .NET Applications to the AWS Serverless PlatformMigrating your .NET Applications to the AWS Serverless Platform
Migrating your .NET Applications to the AWS Serverless PlatformAmazon Web Services
 
Serverless Computing, AWS Way by SourceFuse Technologies
Serverless Computing, AWS Way by SourceFuse Technologies Serverless Computing, AWS Way by SourceFuse Technologies
Serverless Computing, AWS Way by SourceFuse Technologies SourceFuse
 
Serverless Computing, AWS Way: SourceFuse Technologies
Serverless Computing, AWS Way: SourceFuse Technologies Serverless Computing, AWS Way: SourceFuse Technologies
Serverless Computing, AWS Way: SourceFuse Technologies Sarmishtha Sinha
 
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017Amazon Web Services
 
Jak nie zwariować z architekturą Serverless?
Jak nie zwariować z architekturą Serverless?Jak nie zwariować z architekturą Serverless?
Jak nie zwariować z architekturą Serverless?The Software House
 
Serverless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about serversServerless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about serversAmazon Web Services
 

Similar to Running R on AWS Lambda by Ana-Maria Niculescu (20)

State of serverless
State of serverlessState of serverless
State of serverless
 
Write less (code) and build more with serverless
Write less (code) and build more with serverlessWrite less (code) and build more with serverless
Write less (code) and build more with serverless
 
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
Skillenza Build with Serverless Challenge -  Advanced Serverless ConceptsSkillenza Build with Serverless Challenge -  Advanced Serverless Concepts
Skillenza Build with Serverless Challenge - Advanced Serverless Concepts
 
AWS re:Invent 2020 Serverless Recap
AWS re:Invent 2020 Serverless RecapAWS re:Invent 2020 Serverless Recap
AWS re:Invent 2020 Serverless Recap
 
API workshop by AWS and 3scale
API workshop by AWS and 3scaleAPI workshop by AWS and 3scale
API workshop by AWS and 3scale
 
Writing and deploying serverless python applications
Writing and deploying serverless python applicationsWriting and deploying serverless python applications
Writing and deploying serverless python applications
 
Go lambda-presentation
Go lambda-presentationGo lambda-presentation
Go lambda-presentation
 
PyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applicationsPyConIE 2017 Writing and deploying serverless python applications
PyConIE 2017 Writing and deploying serverless python applications
 
Introduction To AWS & AWS Lambda
Introduction To AWS & AWS LambdaIntroduction To AWS & AWS Lambda
Introduction To AWS & AWS Lambda
 
AWS Lambda Documentation
AWS Lambda DocumentationAWS Lambda Documentation
AWS Lambda Documentation
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Building A Serverless Web Application With AWS Lambda: A Step-By-Step Guide
Building A Serverless Web Application With AWS Lambda: A Step-By-Step GuideBuilding A Serverless Web Application With AWS Lambda: A Step-By-Step Guide
Building A Serverless Web Application With AWS Lambda: A Step-By-Step Guide
 
Building Linked Data Platform with AWS
Building Linked Data Platform with AWSBuilding Linked Data Platform with AWS
Building Linked Data Platform with AWS
 
AWS Lambda and Serverless Cloud
AWS Lambda and Serverless CloudAWS Lambda and Serverless Cloud
AWS Lambda and Serverless Cloud
 
Migrating your .NET Applications to the AWS Serverless Platform
Migrating your .NET Applications to the AWS Serverless PlatformMigrating your .NET Applications to the AWS Serverless Platform
Migrating your .NET Applications to the AWS Serverless Platform
 
Serverless Computing, AWS Way by SourceFuse Technologies
Serverless Computing, AWS Way by SourceFuse Technologies Serverless Computing, AWS Way by SourceFuse Technologies
Serverless Computing, AWS Way by SourceFuse Technologies
 
Serverless Computing, AWS Way: SourceFuse Technologies
Serverless Computing, AWS Way: SourceFuse Technologies Serverless Computing, AWS Way: SourceFuse Technologies
Serverless Computing, AWS Way: SourceFuse Technologies
 
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
Serverless DevOps to the Rescue - SRV330 - re:Invent 2017
 
Jak nie zwariować z architekturą Serverless?
Jak nie zwariować z architekturą Serverless?Jak nie zwariować z architekturą Serverless?
Jak nie zwariować z architekturą Serverless?
 
Serverless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about serversServerless computing - Build and run applications without thinking about servers
Serverless computing - Build and run applications without thinking about servers
 

More from Paris Women in Machine Learning and Data Science

More from Paris Women in Machine Learning and Data Science (20)

Anomaly detection and data imputation within time series
Anomaly detection and data imputation within time seriesAnomaly detection and data imputation within time series
Anomaly detection and data imputation within time series
 
Managing international tech teams, by Natasha Dimban
Managing international tech teams, by Natasha DimbanManaging international tech teams, by Natasha Dimban
Managing international tech teams, by Natasha Dimban
 
Optimizing GenAI apps, by N. El Mawass and Maria Knorps
Optimizing GenAI apps, by N. El Mawass and Maria KnorpsOptimizing GenAI apps, by N. El Mawass and Maria Knorps
Optimizing GenAI apps, by N. El Mawass and Maria Knorps
 
Perspectives, by M. Pannegeon
Perspectives, by M. PannegeonPerspectives, by M. Pannegeon
Perspectives, by M. Pannegeon
 
Evaluation strategies for dealing with partially labelled or unlabelled data
Evaluation strategies for dealing with partially labelled or unlabelled dataEvaluation strategies for dealing with partially labelled or unlabelled data
Evaluation strategies for dealing with partially labelled or unlabelled data
 
Combinatorial Optimisation with Policy Adaptation using latent Space Search, ...
Combinatorial Optimisation with Policy Adaptation using latent Space Search, ...Combinatorial Optimisation with Policy Adaptation using latent Space Search, ...
Combinatorial Optimisation with Policy Adaptation using latent Space Search, ...
 
An age-old question, by Caroline Jean-Pierre
An age-old question, by Caroline Jean-PierreAn age-old question, by Caroline Jean-Pierre
An age-old question, by Caroline Jean-Pierre
 
Applying Churn Prediction Approaches to the Telecom Industry, by Joëlle Lautré
Applying Churn Prediction Approaches to the Telecom Industry, by Joëlle LautréApplying Churn Prediction Approaches to the Telecom Industry, by Joëlle Lautré
Applying Churn Prediction Approaches to the Telecom Industry, by Joëlle Lautré
 
How to supervise a thesis in NLP in the ChatGPT era? By Laure Soulier
How to supervise a thesis in NLP in the ChatGPT era? By Laure SoulierHow to supervise a thesis in NLP in the ChatGPT era? By Laure Soulier
How to supervise a thesis in NLP in the ChatGPT era? By Laure Soulier
 
Global Ambitions Local Realities, by Anna Abreu
Global Ambitions Local Realities, by Anna AbreuGlobal Ambitions Local Realities, by Anna Abreu
Global Ambitions Local Realities, by Anna Abreu
 
Plug-and-Play methods for inverse problems in imagine, by Julie Delon
Plug-and-Play methods for inverse problems in imagine, by Julie DelonPlug-and-Play methods for inverse problems in imagine, by Julie Delon
Plug-and-Play methods for inverse problems in imagine, by Julie Delon
 
Sales Forecasting as a Data Product by Francesca Iannuzzi
Sales Forecasting as a Data Product by Francesca IannuzziSales Forecasting as a Data Product by Francesca Iannuzzi
Sales Forecasting as a Data Product by Francesca Iannuzzi
 
Identifying and mitigating bias in machine learning, by Ruta Binkyte
Identifying and mitigating bias in machine learning, by Ruta BinkyteIdentifying and mitigating bias in machine learning, by Ruta Binkyte
Identifying and mitigating bias in machine learning, by Ruta Binkyte
 
“Turning your ML algorithms into full web apps in no time with Python" by Mar...
“Turning your ML algorithms into full web apps in no time with Python" by Mar...“Turning your ML algorithms into full web apps in no time with Python" by Mar...
“Turning your ML algorithms into full web apps in no time with Python" by Mar...
 
Nature Language Processing for proteins by Amélie Héliou, Software Engineer @...
Nature Language Processing for proteins by Amélie Héliou, Software Engineer @...Nature Language Processing for proteins by Amélie Héliou, Software Engineer @...
Nature Language Processing for proteins by Amélie Héliou, Software Engineer @...
 
Sandrine Henry presents the BechdelAI project
Sandrine Henry presents the BechdelAI projectSandrine Henry presents the BechdelAI project
Sandrine Henry presents the BechdelAI project
 
Anastasiia Tryputen_War in Ukraine or how extraordinary courage reshapes geop...
Anastasiia Tryputen_War in Ukraine or how extraordinary courage reshapes geop...Anastasiia Tryputen_War in Ukraine or how extraordinary courage reshapes geop...
Anastasiia Tryputen_War in Ukraine or how extraordinary courage reshapes geop...
 
Khrystyna Grynko WiMLDS - From marketing to Tech.pdf
Khrystyna Grynko WiMLDS - From marketing to Tech.pdfKhrystyna Grynko WiMLDS - From marketing to Tech.pdf
Khrystyna Grynko WiMLDS - From marketing to Tech.pdf
 
Iana Iatsun_ML in production_20Dec2022.pdf
Iana Iatsun_ML in production_20Dec2022.pdfIana Iatsun_ML in production_20Dec2022.pdf
Iana Iatsun_ML in production_20Dec2022.pdf
 
41 WiMLDS Kyiv Paris Poznan.pdf
41 WiMLDS Kyiv Paris Poznan.pdf41 WiMLDS Kyiv Paris Poznan.pdf
41 WiMLDS Kyiv Paris Poznan.pdf
 

Recently uploaded

Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxEmmanuel Dauda
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts ServiceSapana Sha
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
Predicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project PresentationPredicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project PresentationBoston Institute of Analytics
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Delhi Call girls
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystSamantha Rae Coolbeth
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...Florian Roscheck
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...Suhani Kapoor
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfRachmat Ramadhan H
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsappssapnasaifi408
 

Recently uploaded (20)

Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
Customer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptxCustomer Service Analytics - Make Sense of All Your Data.pptx
Customer Service Analytics - Make Sense of All Your Data.pptx
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
Call Girls In Mahipalpur O9654467111 Escorts Service
Call Girls In Mahipalpur O9654467111  Escorts ServiceCall Girls In Mahipalpur O9654467111  Escorts Service
Call Girls In Mahipalpur O9654467111 Escorts Service
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
Predicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project PresentationPredicting Employee Churn: A Data-Driven Approach Project Presentation
Predicting Employee Churn: A Data-Driven Approach Project Presentation
 
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
Best VIP Call Girls Noida Sector 39 Call Me: 8448380779
 
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
VIP Call Girls Service Miyapur Hyderabad Call +91-8250192130
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 
Unveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data AnalystUnveiling Insights: The Role of a Data Analyst
Unveiling Insights: The Role of a Data Analyst
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...From idea to production in a day – Leveraging Azure ML and Streamlit to build...
From idea to production in a day – Leveraging Azure ML and Streamlit to build...
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
VIP High Class Call Girls Bikaner Anushka 8250192130 Independent Escort Servi...
 
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdfMarket Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
Market Analysis in the 5 Largest Economic Countries in Southeast Asia.pdf
 
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /WhatsappsBeautiful Sapna Vip  Call Girls Hauz Khas 9711199012 Call /Whatsapps
Beautiful Sapna Vip Call Girls Hauz Khas 9711199012 Call /Whatsapps
 

Running R on AWS Lambda by Ana-Maria Niculescu

  • 1.
  • 2. About Numeract LLC ● Data Science and Economics / Finance consulting services, open source projects ● Technology Stack: (Postgre)SQL, R, Python, Docker, AWS Contributors ● Mike Badescu, PhD Economics, Lehigh University ● Ana Niculescu, Msc Statistics for Smart Data, ENSAI, Rennes ● Teodor Ciuraru github.com/numeract/aws-lambda-r
  • 3. Agenda Motivation APIs AWS Running R on Amazon Lambda Conclusions
  • 4. Motivation Deploying R in production is not very easy but it is a good problem to have. There are diverse approaches towards creating deployment packages for AWS Lambda and creating an API but which one is the best fit for R? This presentation aims to compare currently available approaches and to present a custom solution. Overview
  • 5. Motivation ● Shiny Dashboard for data visualisation and model validation ● In the backend, the Shiny App was also: ○ reading the data ○ performing data cleaning ○ computing features ○ building prediction models ● Client also needed to access to only the calculation process to use it outside (and independent from) the Shiny App Our use case
  • 6. Motivation ● Rewriting the code in another programming language is not efficient ● Certain algorithms may not be available in other programming languages ● Even though certain algorithms may be available in other programming languages, they may not render the same results as in R Why not rewrite the needed code?
  • 7. The answer to our problem ● Modularize the application ● Programming language independent ● Common concept: programmers know how to work with APIs ● Common "data language": JSON (but not the only one) APIs
  • 8. Of R and APIs ● Not directly, as R is not a web server ● We need a wrapper / server that: ● receives requests and hands them to R ● passes any response from R to the client Candidate approaches ● Web server: plumber and OpenCPU ● Serverless: running R on AWS Lambda -> wrap R functions inside FasS Can we serve API requests from R?
  • 9. Wrapping up the requirements Getting ready to roll our sleeves The App task engine should: ● get a request id ● read data from DB ● process data for 5-20 seconds ● return the results Our challenge: How to use this code in production? ● needs to be triggered ● uncertain and irregular future demand ● R code still in development ● clicking through an interface to re-deploy the code every time we needed it was not an option
  • 10. Amazon Web Services Bref AWS is a collection of pay-as-you-go cloud services. The services we needed: ● IAM (Identity and Access Management) - for security ● VPC - a logically isolated virtual network ● EC2 - a virtual machine ● API Gateway ● S3 - storage ● Lambda - serverless application service
  • 11. Amazon Web Services Lambda: Function as a Service AWS Lambda is a serverless compute service that launches and executes code when it is explicitly triggered by an event (API), and stays up ONLY as long as the code runs. ● Helps you build apps while minimizing infrastructure maintenance ● Keep the focus on what’s important: data engineering/analysis, not DevOps ● Pay only for what you use: supports ad-hoc requests ● Horizontally scalable Image source: https://dwdraju.medium.com/python-function-on-aws-lambda-with-api -gateway-endpoint-288eae7617cb
  • 12. R on Lambda How difficult can it be? Turns out, it is not as intuitive to directly run R in AWS Lambda. Since December 2018, Amazon introduced custom runtimes for AWS Lambda. This allows us to use almost any programming language, including R.
  • 13. R on Lambda Solutions Our new approach: ● Use a Base R custom runtime provided by Bakdata ● Copy the additional R packages we need inside the deployment package provided to Lambda Other approaches: ● Previously we used package rpy2 to run R code from Python) ● R package lambda.r: triggers a Lambda function from R
  • 14. AWS-Lambda-R The architecture Looks simple, but you don’t want to click through all that every time you want to re-deploy the code...especially when you have multiple releases
  • 15. AWS-Lambda-R Let’s not forget about security Image source: https://aws.amazon.com/security/
  • 16. Automation aws-lambda-r scripts We needed a fast way to launch the infrastructure entirely. Our approach: a series of shell scripts that launch the entire AWS infrastructure needed to run R on AWS Lambda. Top view: Deploy R function on AWS Lambda Configure access to AWS Lambda
  • 17. Automation aws-lambda-r implementation details The scripts: 1. use your settings to create a VPC, S3, authorization policies 2. install and compile R packages 3. create the zip file to load in AWS Lambda and save it to S3 4. create Lambda function and deploy the zip file 5. configure AWS API Gateway to allow accessing the code over the web The scripts use AWS CLI through (Git)Bash => available on all platforms
  • 18. R example A simple function that runs in Lambda
  • 21. Pros At the end of the setup, you will have the entire infrastructure to run R on AWS Lambda, without worrying about EC2 instances or scalability issues. ● use AWS Command Line Interface - no need for clicks anymore ● pay-as-you go ● fast deployment after each release ● easy to adapt to automatically deploy code written in Python or JavaScript (if needed in the future)
  • 22. Limitations ● Lambda function memory allocation: 128 MB to 10,240 MB ● Function timeout: 15 minutes ● Maximum zip file size: 250MB ● this is the most important limitation as it prevents using large R packages
  • 23. Finally Where Data Science stops and Data Engineering begins... ● Each project has unique requirements and constraints ● AWS was great for our needs, Lambda too, especially since it became more flexible through custom execution environments and layers ● Scripts still run in production, making the client happy ● It is worth automating something in order to be able to focus in what’s more important