Elastic APIs: Are microservices the answer? by Orlando Kalossakas

Elastic APIs: Are microservices the answer? by Orlando Kalossakas

Transcript

  1. Elastic APIs Are microservices the answer? orlando@bigballershotcaller.gq 
 @orliesaurus

  2. My name is.. • Im here to help you build

    stuff
  3. Microservices Everyone is talking about this topic, everyone is trying

    to take a bite.
 P.S. They have their own instagram.com/microservices account
  4. The inspiration • Driven From Blueprints • Isolated Resources •

    Run Anywhere LOL
  5. Containers are A THING • Have been around since `chroot`

    • Became a global trend shortly after the release of Docker the 2013-03-23
  6. Docker interest over time

  7. –Every engineer in a social situation “Oh yeah.. we’re using

    containers…”
  8. Independence === pizza:

  9. Qualities of microservices • Deal with problems inside their scope

    • Data sharing per service • Available • Versioning • Auto-deployable
  10. //Assume you have an .env file
 var express = require('express');

    var http = require('http'); var mongo = require('mongodb').MongoClient; var app = express(); app.set('port', process.env.PORT || 8080); var mongodb; if(process.env.MONGO_URL) { mongo.connect(process.env.MONGO_URL, null, function(err, mongodb_) { if(err) { console.log(err); } else { mongodb = mongodb_; } }); } app.get('/users', function(req, res, next) { var collection = db.collection('users'); collection.find().toArray(function(err, result) { if(err) { res.sendStatus(500); return; } res.json(result); }); }); app.listen(app.get('port')); Retrieve all users
  11. INTRODUCING: THE GATEWAY…

  12. • Authentication

  13. • Security (transport layer)

  14. • Load Balancing

  15. • Request Dispatching

  16. Example: You wanna buy some

  17. None
  18. ⚠ ALL THAT! BAY LIFE

  19. λ

  20. λ!

  21. • Own code + Libraries • Native SDK • Timeouts

    and Memory • Use external storage, there’s no root access! • Debug via cloudwatch
  22. • Invoke through Gateway, or other services

  23. λ G
 A
 T
 E
 W
 A
 Y /route λ

    λ λ λ GET PUT POST DELETE PATCH
  24. https://github.com/awslabs/aws-apigateway- importer

  25. console.log('Loading function'); exports.handler = function(event, context) { //YOUR CODE GOES

    HERE context.succeed(“Hurray”); context.fail(‘oh no :( :(‘); };
  26. swagger: '2.0' info: version: '1.0.0' title: Swagger Petstore description: A

    sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification termsOfService: http://helloreverb.com/terms/ contact: name: Swagger API team email: foo@example.com
  27. – Startup guy “2easy4me” ./aws-api-import.sh --create path/to/swagger.json

  28. –Johnny Appleseed “Type a quote here.”

  29. None
  30. None
  31. – (Maybe) A guy employed by Amazon who worked on

    Lambda It’s Superfast, like Rambo driving a Lambo TEST IT: squirrelbin.com
  32. TRY, FAIL, LEARN, DISCUSS orlando@bigballershotcaller.gq 
 @orliesaurus