Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Serverless London - Lambda@Edge (Serverless & O...

Serverless London - Lambda@Edge (Serverless & Originless on AWS)

What can you do with AWS Lambda@Edge? Learn how to execute serverless functions on CloudFront Edge locations in response to CloudFront events to optimize network latency.

Alex Casalboni

April 05, 2017
Tweet

More Decks by Alex Casalboni

Other Decks in Technology

Transcript

  1. About  Me @alex_casalboni clda.co/lambda-­‐edge-­‐london Computer  Science  Background Master  in  Sound

     &  Music  Engineering Sr.  SoEware  Engineer  &  Web  Developer Cloud  Evangelist  @  Cloud  Academy
  2. Agenda What  is  Lambda@Edge? Benefits  and  use  cases Preview  limitaKons

    My  personal  experiment clda.co/lambda-­‐edge-­‐london
  3. What  is  Lambda@Edge? How  does  it  work  and  how’s  it

     different  from  AWS  Lambda? clda.co/lambda-­‐edge-­‐london
  4. Amazon  CloudFront StaKc  content  (web  assets,  videos,  etc.) Dynamic  content

     (cache) 70+  Edge  LocaKons Custom  SSL  &  domain  name Cache  InvalidaKon AnalyKcs  dashboard Custom  origins  (e.g.  EC2) Supports  cookies  &  querystrings clda.co/lambda-­‐edge-­‐london
  5. CloudFront  Triggers Viewer  Request Viewer  Response Origin  Request Origin  Response

    Before  cache  hit/miss A8er  cache  hit/miss Only  if  cache  miss,  before  forwarding Only  if  cache  miss,  a8er  forwarding clda.co/lambda-­‐edge-­‐london
  6. 1.  Request/Response  manipulaQon Custom  HTTP  headers Adapt  to  client  capabiliKes

    Add  Kmezone-­‐related  info A/B  tesKng URL  rewriKng  /  redirects Cookies  manipulaKon clda.co/lambda-­‐edge-­‐london
  7. 2.  Dynamic  content  generaQon  * Custom  error  pages Custom  signup

     forms Opzimized  JS  code  (Polyfill.io) Dynamic  HTML *  Never  hit  the  origin! clda.co/lambda-­‐edge-­‐london
  8. 3.  Pure  latency  opQmizaQon  * 401  errors  if  missing  auth

    Custom  edge-­‐based  logging Custom  data  validaKon Custom  data  transformaKon *  Assuming  dynamic  origin clda.co/lambda-­‐edge-­‐london
  9. LimitaQons  (preview  only) Max  50ms Only  128MB  (RAM) Only  1MB

     of  code Only  Node.js  4.3 clda.co/lambda-­‐edge-­‐london Slightly  different   programming  model Manual  handling  of  HTTP   convenKons  (OPTIONS,  204,  etc.)
  10. LimitaQons  (permanent) No  HTTP  calls No  AWS  SDK No  VPC/DLQ

     config No  real-­‐Kme  logging No  3rd-­‐party  monitoring Slow  deploy  (up  to  15min) clda.co/lambda-­‐edge-­‐london