Are you being servered? — Exploring a “serverless” web

A presentation at DotJS in December 2019 in Paris, France by Phil Hawksworth

Slide 1

Slide 1

ARE YOU BEING SERVERED? EXPLORING A SERVERLESS WEB PHIL HAWKSWORTH

Slide 2

Slide 2

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 3 5 : 7 1

Slide 3

Slide 3

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 4

Slide 4

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 5

Slide 5

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 6

Slide 6

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 7

Slide 7

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 8

Slide 8

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 WIRELESS

Slide 9

Slide 9

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 SERVERLESS

Slide 10

Slide 10

netlify Are you being servered? @philhawksworth s s e l r e v r se dotJS, Paris, December 2019 ⚡ ⚡ k c a t s jam

Slide 11

Slide 11

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 CAN WE REALLY TAKE SERVERS OUT OF THE EQUATION?

Slide 12

Slide 12

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 FOCUSSING ON THE THINGS YOU CARE ABOUT

Slide 13

Slide 13

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 d e t a r e b li TO FOCUS ON WHAT MATTERS

Slide 14

Slide 14

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 r p e h t h it w m e l ob DOING BIG PROJECTS

Slide 15

Slide 15

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 CONSTRAINTS AND COMPLEXITY AND INFRASTRUCTURE ! y m oh

Slide 16

Slide 16

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 WHERE TO FOCUS OUR EFFORTS?

Slide 17

Slide 17

netlify Are you being servered? LINES AND BOXES @philhawksworth dotJS, Paris, December 2019

Slide 18

Slide 18

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 @ PHIL HAWKSWORTH HE / HIM DEVELOPER EXPERIENCE NETLIFY

Slide 19

Slide 19

ARE YOU BEING SERVERED? EXPLORING A SERVERLESS WEB PHIL HAWKSWORTH

Slide 20

Slide 20

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 FUNCTIONS AS A SERVICE

Slide 21

Slide 21

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 SERVING WEBSITES WITHOUT WEBSERVERS

Slide 22

Slide 22

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 23

Slide 23

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 k c a t s m ja JAVASCRIPT / API / MARKUP

Slide 24

Slide 24

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 STACKS FOR DAYZ AN / LAMP / MAMP / XAMP / ROR / WISA / MEA WISA / MEAN / LAMP / MAMP / XAMP / ROR /

Slide 25

Slide 25

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 k c a t s m a j A modern architecture — Create fast and secure sites and dynamic apps with JavaScript, APIs, and pre-rendered Markup, served without web servers

Slide 26

Slide 26

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 BAKE, DON’T FRY – Aaron Swartz http://www.aaronsw.com/weblog/000404

Slide 27

Slide 27

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 I CARE ABOUT NOT HAVING TO MAINTAIN CRANKY AOLSERVER, POSTGRES AND ORACLE INSTALLS AARON SWARTZ, 2002 http://www.aaronsw.com/weblog/000404

Slide 28

Slide 28

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 TOOLS & ECOSYSTEM

Slide 29

Slide 29

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 SO… WHAT CAN A STATIC SITE EVEN BE?

Slide 30

Slide 30

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 REACTJS.ORG REACTJS.ORG STATIC

Slide 31

Slide 31

netlify Are you being servered? @philhawksworth VUEJS.ORG REACTJS.ORG dotJS, Paris, December 2019

Slide 32

Slide 32

netlify Are you being servered? @philhawksworth SMASHINGMAGAZINE.COM SMASHINGMAGAZINE.COM dotJS, Paris, December 2019

Slide 33

Slide 33

netlify Are you being servered? @philhawksworth JUSTDOIT.NIKE.COM REACTJS.ORG dotJS, Paris, December 2019

Slide 34

Slide 34

netlify Are you being servered? @philhawksworth SQUOOSH.APP REACTJS.ORG dotJS, Paris, December 2019

Slide 35

Slide 35

netlify Are you being servered? @philhawksworth SQUOOSH.APP REACTJS.ORG dotJS, Paris, December 2019

Slide 36

Slide 36

Slide 37

Slide 37

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 38

Slide 38

netlify Are you being servered? @philhawksworth REDUCING DEPLOYMENT FRICTION dotJS, Paris, December 2019 INCREASES PERCEIVED DYNAMISM

Slide 39

Slide 39

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 PHILIP GOT COCKY

Slide 40

Slide 40

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 SOME PEOPLE ON THE INTERNET NOTICED

Slide 41

Slide 41

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 😳

Slide 42

Slide 42

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 43

Slide 43

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 44

Slide 44

netlify Are you being servered? @philhawksworth FINDTHAT.AT/TIME https://setyourwatchby.netlify.com dotJS, Paris, December 2019

Slide 45

Slide 45

netlify Are you being servered? @philhawksworth FINDTHAT.AT/TIME https://setyourwatchby.netlify.com dotJS, Paris, December 2019

Slide 46

Slide 46

netlify Are you being servered? @philhawksworth FINDTHAT.AT/TIME https://setyourwatchby.netlify.com dotJS, Paris, December 2019

Slide 47

Slide 47

netlify Are you being servered? @philhawksworth FINDTHAT.AT/TIME https://setyourwatchby.netlify.com dotJS, Paris, December 2019

Slide 48

Slide 48

netlify Are you being servered? WEBTASK.IO @philhawksworth dotJS, Paris, December 2019

Slide 49

Slide 49

netlify Are you being servered? WEBTASK.IO @philhawksworth dotJS, Paris, December 2019

Slide 50

Slide 50

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 ( DON’T DO THIS )

Slide 51

Slide 51

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 a r t s u l il … t n i o p a g tin VERY LOW DEPLOYMENT FRICTION

Slide 52

Slide 52

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 a r t s u l il … t n i o p a g tin EVENTS AND AUTOMATION

Slide 53

Slide 53

netlify Are you being servered? @philhawksworth a dotJS, Paris, December 2019 t a k o o l k c i u q TWO PRINCIPLES

Slide 54

Slide 54

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 PRE-RENDERING

Slide 55

Slide 55

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 PRE-RENDERING SERVERLESS RENDERING

Slide 56

Slide 56

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 r o f s e v i t o m PRE-RENDERING

Slide 57

Slide 57

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 DOING THE WORK NOW, SO YOUR SERVERS DON’T HAVE TO LATER

Slide 58

Slide 58

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 PUT DISTANCE BETWEEN THE COMPLEXITY AND THE USER

Slide 59

Slide 59

netlify Are you being servered? l a n o i it d a r t k c a t s m ja @philhawksworth CDN dotJS, Paris, December 2019 LOAD BALANCER WEB SERVERS DB SERVERS

Slide 60

Slide 60

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 JAMSTACK ADVANTAGES SECURITY PERFORMANCE SCALE

Slide 61

Slide 61

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 DECOUPLING

Slide 62

Slide 62

netlify Are you being servered? l a n o i it d a r t k c a t s m ja @philhawksworth CDN dotJS, Paris, December 2019 LOAD BALANCER WEB SERVERS DB SERVERS

Slide 63

Slide 63

netlify Are you being servered? @philhawksworth k c a t s m ja REQUEST TIME BULD TIME BUILD dotJS, Paris, December 2019

Slide 64

Slide 64

netlify Are you being servered? GET TO THE CHOPPER CDN @philhawksworth dotJS, Paris, December 2019

Slide 65

Slide 65

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 PRE-RENDERING SERVERLESS RENDERING

Slide 66

Slide 66

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 PRE-RENDERING SERVERLESS RENDERING

Slide 67

Slide 67

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 k c a t s m a j A modern architecture — Create fast and secure sites and dynamic apps with JavaScript, APIs, and pre-rendered Markup, served without web servers

Slide 68

Slide 68

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 I ABSOLUTELY POSITIVELY NEED A LITTLE LOGIC ON A SERVER SOME OF US, SOMETIMES

Slide 69

Slide 69

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 SERVERLESS TO THE RESCUE

Slide 70

Slide 70

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 AUGMENTATION

Slide 71

Slide 71

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 ENHANCEMENT

Slide 72

Slide 72

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 STATIC FIRST MARKUS SCHORK, UNILEVER

Slide 73

Slide 73

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 AN EXAMPLE

Slide 74

Slide 74

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 AN EXAMPLE

Slide 75

Slide 75

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 USER GENERATED CONTENT

Slide 76

Slide 76

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 VLOLLY.NET/LOLLY/3hmtt2r3b AN EXAMPLE

Slide 77

Slide 77

netlify Are you being servered? @philhawksworth m e r i u q re dotJS, Paris, December 2019 s l o o t & s t n e

Slide 78

Slide 78

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 PRE-GENERATED PAGES WITH REAL URLS (EVEN FOR THE USER GENERATED CONTENT) DATA STORED IN A DATABASE (BUT DON’T MAKE ME A DBA) INSTANT ACCESS TO NEW CONTENT (WITHOUT WAITING FOR A REBUILD)

Slide 79

Slide 79

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 PRE-GENERATED PAGES WITH REAL URLS ELEVENTY (EVEN FOR THE USER GENERATED CONTENT) DATA STORED IN A DATABASE FAUNADB (BUT DON’T MAKE ME A DBA) INSTANT ACCESS TO NEW CONTENT NETLIFY FUNCTIONS (WITHOUT WAITING FOR A REBUILD)

Slide 80

Slide 80

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 81

Slide 81

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 82

Slide 82

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 const faunadb = require(‘faunadb’); const q = faunadb.query; const client = new faunadb.Client({ secret: process.env.FAUNADB_SERVER_SECRET }); module.exports = () !=> { return new Promise((resolve, reject) !=> { client.query( q.Paginate(q.Match(q.Ref(“indexes/all_lollies”))) ).then((response) !=> { const lollies = response.data; const getAllDataQuery = lollies.map((ref) !=> { return q.Get(ref); }); return client.query(getAllDataQuery).then((ret) !=> { resolve(ret); }); }).catch((error) !=> { reject(error); }); }) } Authenticate with the DB query for all d n a . .. s ie l l o l e h t their data resolve the s ie l l o l f o e is prom s r o r r e y n a h c cat

Slide 83

Slide 83

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 84

Slide 84

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 85

Slide 85

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 86

Slide 86

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 87

Slide 87

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 88

Slide 88

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 404

Slide 89

Slide 89

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 TRIGGERS AND AUTOMATION

Slide 90

Slide 90

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 AN EXAMPLE

Slide 91

Slide 91

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 92

Slide 92

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 const faunadb = require(‘faunadb’); const shortid = require(‘shortid’); const querystring = require(‘querystring’); const axios = require(‘axios’); const q = faunadb.query const client = new faunadb.Client({ secret: process.env.FAUNADB_SERVER_SECRET }) exports.handler = (event, context, callback) !=> { const data = querystring.parse(event.body); const uniquePath = shortid.generate(); data.lollyPath = uniquePath; const lolly = { data: data }; client.query(q.Create(q.Ref(‘classes/lollies’), lolly)) .then((response) !=> { axios.post(‘https:!//api.netlify.com/build_hooks/5d46fa20da4a1b70047f2f04’) .then(function (response) { console.log(response); }) .catch(function (error) { console.log(error); }); return callback(null, { body: JSON.stringify(response), statusCode: 302, headers: { Location: /lolly/${uniquePath}, } }); }).catch((error) !=> { return callback(null, { statusCode: 400, body: JSON.stringify(error) }); }); } Authenticate with the DB a t a d e h t t s o P rebuild r e s u e h t d n e S To check the freezer FOR A LOLLY

Slide 93

Slide 93

netlify Are you being servered? CHECK FOR A PRE-GENERATED LOLLY PAGE @philhawksworth 200 dotJS, Paris, December 2019 SERVE THE STATIC PAGE 404 RENDER A DYNAMIC VIEW

Slide 94

Slide 94

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 95

Slide 95

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 96

Slide 96

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 const faunadb = require(‘faunadb’); const pageTemplate = require(‘./lollyTemplate.js’); const q = faunadb.query; const client = new faunadb.Client({ secret: process.env.FAUNADB_SERVER_SECRET }); exports.handler = (event, context, callback) !=> { const path = event.queryStringParameters.id.replace(“/”, “”); client.query( q.Get(q.Match(q.Index(“lolly_by_path”), path)) ).then((response) !=> { return callback(null, { statusCode: 200, body: pageTemplate(response.data) }); }).catch((error) !=> { return callback(null, { body: JSON.stringify(error), statusCode: 301, headers: { Location: /melted/index.html, } }); }); } Get page as a javascript l a r e it l e t a l p tem Authenticate with the DB Get the lolly data w ie v y l l o l e v r e S k a e r B . y l l o L o N the bad news

Slide 97

Slide 97

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 98

Slide 98

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 99

Slide 99

Slide 100

Slide 100

netlify Are you being servered? @philhawksworth FINDTHAT.AT/LOLLYTRICKS dotJS, Paris, December 2019 https://css-tricks.com/static-first-pre-generated-jamstack-sites-with-serverless-rendering-as-a-fallback/

Slide 101

Slide 101

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 WHY SAY JAMSTACK, AND NOT STATIC?

Slide 102

Slide 102

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 TOOLS & ECOSYSTEM

Slide 103

Slide 103

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 PRE-RENDERING SERVERLESS RENDERING

Slide 104

Slide 104

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 A SHIFT

Slide 105

Slide 105

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 m o r f SEEKING TO OPTIMIZE BY ADDING STATIC LAYERS

Slide 106

Slide 106

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 to STATIC FIRST ENHANCING IF REQUIRED

Slide 107

Slide 107

netlify Are you being servered? l a n o i it d a r t k c a t s m ja @philhawksworth CDN dotJS, Paris, December 2019 LOAD BALANCER WEB SERVERS DB SERVERS

Slide 108

Slide 108

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 SIMPLIFYING IS NOT DUMBING DOWN

Slide 109

Slide 109

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 SIMPLIFYING IS NOT DUMBING DOWN IT LETS US FOCUS ON WHAT REALLY IS IMPORTANT

Slide 110

Slide 110

netlify Are you being servered? @philhawksworth EASIER TO REASON ABOUT dotJS, Paris, December 2019

Slide 111

Slide 111

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019

Slide 112

Slide 112

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 STATIC SITE GENERATORS staticgen.com NETLIFY www.netlify.com STATIC VARIOUS RELATED RESOURCES FROM CHRIS COYIER https://serverless.css-tricks.com/ CITRIX PRESENTATION FROM JAMSTACKCONF NYC youtube.com/watch?v=kvS5h5domf0

Slide 113

Slide 113

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 JAMSTACK CONFERENCE jamstackconf.com HEADLESS / DECOUPLED CMS headlesscms.org STATIC ABOUT THE JAMSTACK / COMMUNITY jamstack.org BUILDING A URL SHORTENER WITH NETLIFY REDIRECTS findthat.at

Slide 114

Slide 114

netlify Are you being servered? @philhawksworth dotJS, Paris, December 2019 SO I GUESS WE’RE FULL STACK NOW? https://www.youtube.com/watch?v=lFOfQsi5ye0 MODERN WEB DEVELOPMENT ON THE JAMSTACK netlify.com/oreilly-jamstack/ JAMSTACK WHITEPAPER findthat.at/jamstack-whitepaper JAMSTACK COMMENTS EXAMPLE jamstack-comments.netlify.com STATIC

Slide 115

Slide 115

FINDTHAT.AT / SERVERED THANKS @PHILHAWKSWORTH