Running Swift Code on AWS Lambda (CocoaHeads 01/2017)

Running Swift Code on AWS Lambda (CocoaHeads 01/2017)

Ae2cc3279f2c24525c0dcae7063834d3?s=128

Claus Höfele

January 18, 2017
Tweet

Transcript

  1. 2.

    AWS Lambda • Function as a Service, “Serverless” Architecture •

    ThoughtWorks: “event-triggered, ephemeral (may only last for one invocation), and fully managed by a 3rd party” • Competitors • Google Cloud Functions • MS Azure Functions • IBM OpenWhisk
  2. 5.

    'use strict'; const exec = require('child_process').exec; exports.handler = (event, context,

    callback) => { if (!event.cmd) { return callback('Please specify a command to run as event.cmd'); } const child = exec(event.cmd, (error) => { // Resolve with result of process callback(error, 'Process complete!'); }); // Log process stdout and stderr child.stdout.on('data', console.log); child.stderr.on('data', console.error); };
  3. 6.

    Create Swift Package Build Swift executable Capture library dependencies Run

    
 integration tests with Node.js shim zip everything together Swift exec *.so zip Amazon Linux Ubuntu Ubuntu
  4. 8.
  5. 9.

    Pros/Cons • AWS Lambda • Limited time (5m) • Latency

    • Tools • Vendor lock-in • No server management • Swift on Lambda • Large file size • Logging • Ecosystem • Memory/compute efficiency