Save 37% off PRO during our Black Friday Sale! »

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

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


  1.­‐edge-­‐london AWS  Lambda@Edge  (Preview) Serverless  &  Originless  on  AWS 4/5/2017

  2. About  Me @alex_casalboni­‐edge-­‐london Computer  Science  Background Master  in  Sound

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

    My  personal  experiment­‐edge-­‐london
  4. What  is  Lambda@Edge? How  does  it  work  and  how’s  it

     different  from  AWS  Lambda?­‐edge-­‐london
  5. AWS  Lambda  &  Regions us-­‐east-­‐1­‐edge-­‐london

  6. AWS  Lambda  &  Regions us-­‐east-­‐1 eu-­‐west-­‐1­‐edge-­‐london

  7. AWS’s  CDN  &  PoPs 70+  PoPs­‐edge-­‐london

  8. 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­‐edge-­‐london
  9. Hits/Misses/Errors­‐edge-­‐london

  10. Lambda@Edge  Architecture­‐edge-­‐london

  11. 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­‐edge-­‐london
  12. Benefits  and  use  cases Use  cases  categorisa@on  and  analysis­‐edge-­‐london

  13. AWS  Lambda@Edge  Use  cases Request/Response  manipulaKon Dynamic  content  generaKon Pure

     latency  opKmizaKon­‐edge-­‐london
  14. 1.  Request/Response  manipulaQon Custom  HTTP  headers Adapt  to  client  capabiliKes

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

     forms Opzimized  JS  code  ( Dynamic  HTML *  Never  hit  the  origin!­‐edge-­‐london
  16. 3.  Pure  latency  opQmizaQon  * 401  errors  if  missing  auth

    Custom  edge-­‐based  logging Custom  data  validaKon Custom  data  transformaKon *  Assuming  dynamic  origin­‐edge-­‐london
  17. Preview  limitaKons What  restric@ons  do  you  encounter  during  the  preview

  18. LimitaQons  (preview  only) Max  50ms Only  128MB  (RAM) Only  1MB

     of  code Only  Node.js  4.3­‐edge-­‐london Slightly  different   programming  model Manual  handling  of  HTTP   convenKons  (OPTIONS,  204,  etc.)
  19. 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)­‐edge-­‐london
  20. My  personal  experiment Finally  some  code  :)­‐edge-­‐london

  21. Render  dynamic  HTML  with  Lambda@Edge <  origin-­‐less  demo  >­‐edge-­‐london­‐edge-­‐gist­‐edge-­‐demo
  22. Thank  you  =)­‐edge-­‐london Q  &  A 4/5/2017