SlideShare a Scribd company logo
Serverless and React
(It's Just Sleight Of Hand)
Photo by Alex Block
Marina Miranovich
@obnoxious_mari
2
Nice to meet you!
3
Solution Architect in
Agenda
Part 1. Exposition
Part 2. Main story
Part 3. Resolution
4
5
Part 1.
Exposition
Services I used
S3 Assets storage
IAM Manages access rights
API Gateway URL for the site
CloudFormation Deployment
AWS Lambda
6
7
Important!
I highly encourage you to attempt all demos yourself at home.*
And it’s
free!
7
What is AWS Lambda?
8
Scaling
9
Part 2.
Main story
https://github.com/Marina-Miranovich/lambda-react
http://bit.ly/react-lambda
11
1212
How it works?
http://foo.com GET foo.com/
Lambda renders
the page
API Gateway
triggers Lambda
GET bundle.js
S3: Bundle.js,
main.css, fonst,
etc.
User
Browser
13
lambda-react
├── README.md
├── config
├── package.json
├── public
├── scripts
├── serverless.yml
├── src
└── yarn.lock
Project structure
config
package.json
serverless.yml
src
14
Project structure
lambda-react
├── README.md
├── config
├── package.json
├── public
├── scripts
├── serverless.yml
├── src
└── yarn.lock
config
├── env.js
├── jest
├── paths.js
├── polyfills.js
├── webpack.config.dev.js
├── webpack.config.lambda.js
├── webpack.config.prod.js
└── webpackDevServer.config.js
webpack.config.lambda.js
15
Lambda Webpack config
1 module.exports = {
2 entry: slsw.lib.entries,
3 target: 'node',
4 module: {
5 loaders: [
6 { test: /.js$/, loaders: ['babel-loader'], include: path.resolve(__dirname, '../src'), exclude:
/node_modules/ },
7 { test: /.css$/, loaders: ['node-style-loader','css-loader?importLoaders=1'], exclude: /node_modules/ },
8 { test: [/.png$/, /.jpg$/], loader: 'url-loader', options: { limit: 10000, mimetype: 'image/png' } }
9 ],
10 },
11 output: {
12 libraryTarget: 'commonjs',
13 path: path.join(__dirname, '../.webpack'),
14 filename: '[name].js',
15 },
16 };
target: 'node',
entry: slsw.lib.entries,
libraryTarget: 'commonjs',
16
Project structure
lambda-react
├── README.md
├── config
├── package.json
├── public
├── scripts
├── serverless.yml
├── src
└── yarn.lock
config
package.json
serverless.yml
src
17
package.json
1 {
2 "name": "lambda-react-demo",
3 "version": "1.0.0",
4 "scripts": {
5 "start": "node scripts/start.js",
6 "build": "node scripts/build.js",
7 "lambda": "sls offline --port 8000 start",
8 "deploy:lambda": "sls deploy"
9 },
10 "dependencies": {
...
"lambda": "sls offline --port 8000 start"
"deploy:lambda": "sls deploy"
18
Project structure
lambda-react
├── README.md
├── config
├── package.json
├── public
├── scripts
├── serverless.yml
├── src
└── yarn.lock
19
serverless.yml
1 service:
2 name: lambda-react-demo
3 plugins:
4 - serverless-webpack
5 - serverless-offline
6 provider:
7 name: aws
8 runtime: nodejs6.10
9 functions:
10 renderPage:
11 handler: src/lambda/handler.renderPage
12 events:
13 - http:
14 method: GET
15 path: /
16 custom:
17 webpack: "./config/webpack.config.lambda.js"
handler: src/lambda/handler.renderPage
webpack: "./config/webpack.config.lambda.js"20
Project structure
lambda-react
├── README.md
├── config
├── package.json
├── public
├── scripts
├── serverless.yml
├── src
└── yarn.lock
config
package.json
serverless.yml
src
21
Project structure
lambda-react
├── README.md
├── config
├── package.json
├── public
├── scripts
├── serverless.yml
├── src
└── yarn.lock
src
├── actions
├── apis
├── components
├── index.css
├── index.js
├── lambda
├── reducers
└── sagas
lambda
22
Project structure
lambda-react
├── README.md
├── config
├── package.json
├── public
├── scripts
├── serverless.yml
├── src
│ ├── actions
│ ├── apis
│ ├── components
│ ├── index.css
│ ├── index.js
│ ├── lambda
│ ├── reducers
│ └── sagas
└── yarn.lock
lambda
├── handler.js
└── renderer.jsrenderer.js
handler.js
23
Lambda handler src/lambda/handler.js
1 import render from './renderer';
2
3 const createResponse = (html) => {
4 return {
5 statusCode: 200,
6 headers: {
7 "Content-Type": "text/html; charset=utf-8"
8 },
9 body: html
10 };
11 };
12
13 export const renderPage = (event, context, cb) => {
14 render()
15 .then((html) => cb(null, createResponse(html)))
16 .catch(e => cb(e));
17 };
13 export const renderPage = (event, context, cb) => {
14 render()
15 .then((html) => cb(null, createResponse(html)))
16 .catch(e => cb(e));.catch(e => cb(e));
createResponse(html)
24
Lambda handler src/lambda/handler.js
1 import render from './renderer';
2
3 const createResponse = (html) => {
4 return {
5 statusCode: 200,
6 headers: {
7 "Content-Type": "text/html; charset=utf-8"
8 },
9 body: html
10 };
11 };
12
13 export const renderPage = (event, context, cb) => {
14 render()
15 .then((html) => cb(null, createResponse(html)))
16 .catch(e => cb(e));
17 };
statusCode: 200,
"Content-Type": "text/html; charset=utf-8"
25
Lambda handler src/lambda/handler.js
1 import render from './renderer';
2
3 const createResponse = (html) => {
4 return {
5 statusCode: 200,
6 headers: {
7 "Content-Type": "text/html; charset=utf-8"
8 },
9 body: html
10 };
11 };
12
13 export const renderPage = (event, context, cb) => {
14 render()
15 .then((html) => cb(null, createResponse(html)))
16 .catch(e => cb(e));
17 };
14 render()
15 .then((html) => cb(null, createResponse(html)))
16 .catch(e => cb(e));
render()
1 import render from './renderer';
26
Project structure
lambda-react
├── README.md
├── config
├── package.json
├── public
├── scripts
├── serverless.yml
├── src
│ ├── actions
│ ├── apis
│ ├── components
│ ├── index.css
│ ├── index.js
│ ├── lambda
│ ├── reducers
│ └── sagas
└── yarn.lock
lambda
├── handler.js
└── renderer.jsrenderer.js
handler.js
27
Inside src/lambda/renderer.js
1. Isomorphic application
2828
Inside src/lambda/renderer.js
1. Isomorphic application
2. Error handling
2929
Error handling src/lambda/renderer.js
1 const render = () => {
2 return new Promise((resolve, reject) => {
30
Inside src/lambda/renderer.js
1. Isomorphic application
2. Error handling
3. Local environment vs. AWS
3131
JS Bundle src/lambda/renderer.js
const bundleUrl = process.env.NODE_ENV === 'AWS' ?
AWS_URL : LOCAL_URL;
...
<script type="text/javascript" src="${bundleUrl}"></script>
32
JS Bundle serverless.yml
...
1 functions:
2 renderPage:
3 handler: src/lambda/handler.renderPage
4 environment:
5 NODE_ENV: "AWS"
...
NODE_ENV: "AWS"
33
34
Part 3.
Resolution
Serverless: advantages and pitfalls
35
Serverless: advantages and pitfalls
https://serverless.com/blog/when-why-not-use-serverless/35
What else you can do with
cloud functions?
37
Anything
you’d
like*
36 * If it’s within cloud functions limitations
What else you can do with cloud functions?
HTTP
services
IoT Chat Bots
Image/Video
conversions
Machine
Learning
Batch Jobs
37
If not AWS
then what?
39
Google
Azure
IBM
Twillio
38
Open Source!
• Iron functions
• Fnproject
• Openfaas
• Apache OpenWhisk
• Kubeless
• Fission
• Funktion
4039
Thank you!
@obnoxious_mariMarina-Miranovich obnoxious_marie

More Related Content

What's hot (20)

PDF
Using React with Grails 3
Zachary Klein
 
PPTX
Orchestration with Kubernetes
Kunal Kerkar
 
PPTX
GvaScript Library
Mona Remlawi
 
PDF
MongoDB World 2016: Implementing Async Networking in MongoDB 3.2
MongoDB
 
PDF
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
LINAGORA
 
PDF
Advanced Node.JS Meetup
LINAGORA
 
PDF
API First with Connexion - PyConWeb 2018
Henning Jacobs
 
PPTX
Jenkins' shared libraries in action
Lohika_Odessa_TechTalks
 
PDF
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
Shengyou Fan
 
PDF
Scalable Angular 2 Application Architecture
FDConf
 
PDF
Tdc 2013 - Ecossistema Ruby
Fabio Akita
 
PPTX
Игорь Фесенко "Web Apps Performance & JavaScript Compilers"
Fwdays
 
PDF
Convox introduction by Matt Manning
jasnow
 
PDF
Server Side Swift
Jens Ravens
 
PDF
The Architecture of PicCollage Server
Lin Jen-Shin
 
PDF
V8 javascript engine for フロントエンドデベロッパー
Taketoshi 青野健利
 
PDF
Grunt.js introduction
Claudio Mignanti
 
PDF
Node.js cluster
Derek Willian Stavis
 
KEY
GPerf Using Jesque
ctoestreich
 
PDF
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
KAI CHU CHUNG
 
Using React with Grails 3
Zachary Klein
 
Orchestration with Kubernetes
Kunal Kerkar
 
GvaScript Library
Mona Remlawi
 
MongoDB World 2016: Implementing Async Networking in MongoDB 3.2
MongoDB
 
[UDS] Cloud Computing "pour les nuls" (Exemple avec LinShare)
LINAGORA
 
Advanced Node.JS Meetup
LINAGORA
 
API First with Connexion - PyConWeb 2018
Henning Jacobs
 
Jenkins' shared libraries in action
Lohika_Odessa_TechTalks
 
[JCConf 2020] 用 Kotlin 跨入 Serverless 世代
Shengyou Fan
 
Scalable Angular 2 Application Architecture
FDConf
 
Tdc 2013 - Ecossistema Ruby
Fabio Akita
 
Игорь Фесенко "Web Apps Performance & JavaScript Compilers"
Fwdays
 
Convox introduction by Matt Manning
jasnow
 
Server Side Swift
Jens Ravens
 
The Architecture of PicCollage Server
Lin Jen-Shin
 
V8 javascript engine for フロントエンドデベロッパー
Taketoshi 青野健利
 
Grunt.js introduction
Claudio Mignanti
 
Node.js cluster
Derek Willian Stavis
 
GPerf Using Jesque
ctoestreich
 
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
KAI CHU CHUNG
 

Similar to Serverless and React (20)

PDF
Building Serverless APIs (January 2017)
Julien SIMON
 
PDF
AWS Lambda and Serverless framework: lessons learned while building a serverl...
Luciano Mammino
 
PPTX
Peeling back the Lambda layers
Patrick McCaffrey
 
PPTX
Introduction to Aws lambda and build first application | Namespace IT
namespaceit
 
PDF
Building a Serverless company with Node.js, React and the Serverless Framewor...
Luciano Mammino
 
PDF
AWS Lambda
Alexander Savchuk
 
PDF
Run Code, Not Servers: AWS Lambda
Özgür Çiçek
 
PDF
Building applications with Serverless Framework and AWS Lambda - JavaZone 2019
Fredrik Vraalsen
 
PDF
Aws Lambda for Java Architects - JavaOne -2016-09-19
Derek Ashmore
 
PDF
Aws Lambda for Java Architects CJug-Chicago 2016-08-30
Derek Ashmore
 
PDF
AWS Lambda Deployments: Best Practices and Common Mistakes O'Reilly Software...
Derek Ashmore
 
PDF
Serverless APIs with JavaScript - Matt Searle - ChocPanda
Paul Dykes
 
PPTX
Amazon Web Services (AWS) that enables developers to build applications with ...
Chandravathi Dittakavi
 
PDF
Serverless workshop with Amazon Web Services
TheFamily
 
PPTX
The family - presentation on AWS Serverless
Alexandre Pinhel
 
PDF
Going Serverless on AWS with Golang and SAM
George Tourkas
 
PDF
locize tech stack
Adriano Raiano
 
PPTX
AWS Serverless Computing Introduction Session 2.pptx
krnaween
 
PDF
AWS Lambda for Architects - Chicago Coder Conference -2016-06-07
Derek Ashmore
 
PPTX
AWS Serverless with Chalice
Suman Debnath
 
Building Serverless APIs (January 2017)
Julien SIMON
 
AWS Lambda and Serverless framework: lessons learned while building a serverl...
Luciano Mammino
 
Peeling back the Lambda layers
Patrick McCaffrey
 
Introduction to Aws lambda and build first application | Namespace IT
namespaceit
 
Building a Serverless company with Node.js, React and the Serverless Framewor...
Luciano Mammino
 
AWS Lambda
Alexander Savchuk
 
Run Code, Not Servers: AWS Lambda
Özgür Çiçek
 
Building applications with Serverless Framework and AWS Lambda - JavaZone 2019
Fredrik Vraalsen
 
Aws Lambda for Java Architects - JavaOne -2016-09-19
Derek Ashmore
 
Aws Lambda for Java Architects CJug-Chicago 2016-08-30
Derek Ashmore
 
AWS Lambda Deployments: Best Practices and Common Mistakes O'Reilly Software...
Derek Ashmore
 
Serverless APIs with JavaScript - Matt Searle - ChocPanda
Paul Dykes
 
Amazon Web Services (AWS) that enables developers to build applications with ...
Chandravathi Dittakavi
 
Serverless workshop with Amazon Web Services
TheFamily
 
The family - presentation on AWS Serverless
Alexandre Pinhel
 
Going Serverless on AWS with Golang and SAM
George Tourkas
 
locize tech stack
Adriano Raiano
 
AWS Serverless Computing Introduction Session 2.pptx
krnaween
 
AWS Lambda for Architects - Chicago Coder Conference -2016-06-07
Derek Ashmore
 
AWS Serverless with Chalice
Suman Debnath
 
Ad

Recently uploaded (20)

PDF
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
PPTX
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PDF
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
PPTX
Top Managed Service Providers in Los Angeles
Captain IT
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PPTX
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
PDF
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Ampere Offers Energy-Efficient Future For AI And Cloud
ShapeBlue
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
Building and Operating a Private Cloud with CloudStack and LINBIT CloudStack ...
ShapeBlue
 
Building a Production-Ready Barts Health Secure Data Environment Tooling, Acc...
Barts Health
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Persuasive AI: risks and opportunities in the age of digital debate
Speck&Tech
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
Rethinking Security Operations - SOC Evolution Journey.pdf
Haris Chughtai
 
Top Managed Service Providers in Los Angeles
Captain IT
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
✨Unleashing Collaboration: Salesforce Channels & Community Power in Patna!✨
SanjeetMishra29
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
Top iOS App Development Company in the USA for Innovative Apps
SynapseIndia
 
Wojciech Ciemski for Top Cyber News MAGAZINE. June 2025
Dr. Ludmila Morozova-Buss
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
SFWelly Summer 25 Release Highlights July 2025
Anna Loughnan Colquhoun
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Ad

Serverless and React