Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Running Swift Code on AWS Lambda (CocoaHeads 01...

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

Claus Höfele

January 18, 2017
Tweet

More Decks by Claus Höfele

Other Decks in Programming

Transcript

  1. 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. '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. 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. 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