FaaS

THE

S

erverless

AND THE

Simon MacDonald
@macdonst

How I saved myself some 💰 by converting  from

to

What do the Fast & the Furious movies have to do with Serverless?

Planning

Punching

Mechanic

Comic Relief

Characters

Functions

Fetch

Process

Transform

UI

Characters

  • Have their own agency
  • Internally consistent
  • Do one thing well

Functions

  • Stateless
  • Pure
  • One task per function

How does this relate to Functions?

function queryLegacyAPI(query) {
    return fetch(api.getData(query))
        .then(response => response.text())
        .then(xmlString => parseXML(xmlString))
        .then(xml => { return xml; })
    );
}
function formatResponse(data) {
    const template = await loadTemplate();
    const html = json2html.transform(data, t);
    return html;
}
function paulWalker(data) {
    const xslt = await loadXslt();
    const parser = new DOMParser();
    const doc = parser.parseFromString(data, "application/xml");
    const json = doc.transformNode(xslt)
    return json;
}

Composing Functions

function queryLegacyAndFormat() {
    return compose(
            formatResponse,
            paulWalker,
            queryLegacyAPI
    )(query);
}

Accomplishments

  • Brought down drug lords (multiple times)
  • Apprehend rouge secret agents (twice)
  • Prevent nuclear war

Plot Points

  • Car Thefts
  • Blackmail
  • Jailbreaks
  • Kidnappings
  • Murders!

Events

  • Git commit
  • Database action
  • Cron job
  • Blob storage
  • Analytics trigger
  • etc, etc, etc

What about Serverless?

On Premises

IaaS

PaaS

SaaS

Faas

It's about the Cars…

…and the Roads.

Furious…

  • Characters
  • Cars
  • Roads
     
  • Infinite possiblities

Serverless

  • Code (Faas)
  • Containers (SaaS/PaaS)
  • Other folks Infrastructure (IaaS)
  • Unbounded Scaling

Why?

🤔

Translation

Query

Static Assets

Translation

Query

Static Assets

Translation

Query

Static Assets

FaaS

Translation

Query

Static Assets

FaaS

đź’°

No more hosting fees!

Thanks Linda Nichols (@lynnaloo)!

Check out her great talk on Serverless called

Not so FaaS…What's under the hood?

Summary

  • Functions should only do one thing
  • Everything a function needs should be passed in as input
  • The same input should produce the same output every time
  • Compose multiple small functions to make more complicated actions
  • Use events to fire off sequences of functions
  • Take advantage of other people's infrastructure so you can focus on the code