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

LDNWebPerf April 2017 - Andy Still

LDNWebPerf April 2017 - Andy Still

Serverless is the latest buzzword sweeping the industry but what is it and more importantly, how does it perform?

More Decks by London Web Performance Group

Other Decks in Technology

Transcript

  1. Digital Performance
    Serverless
    Performance
    By Andy Still

    View Slide

  2. Andy Still : Technical Director & Founder, Intechnica
    Web: www.intechnica.co.uk
    Email: [email protected]
    Twitter: @andy_still / @intechnica
    Blog: http://www.internetperformanceexpert.com/
    http://www.intechnica.co.uk/web-performance-warrior.aspx http://oreil.ly/2cJLxZh http://oreil.ly/2ce2ghE

    View Slide

  3. Digital Performance
    What is Serverless?

    View Slide

  4. History

    View Slide

  5. History

    View Slide

  6. History

    View Slide

  7. History

    View Slide

  8. History – Going Virtual

    View Slide

  9. History – into the cloud

    View Slide

  10. History – into the cloud

    View Slide

  11. Now : Serverless

    View Slide

  12. Digital Performance
    What is AWS Lambda?

    View Slide

  13. Digital Performance
    What it isn’t

    View Slide

  14. A lamb

    View Slide

  15. View Slide

  16. A lamborghini

    View Slide

  17. A C# Lambda Expression
    customers.Where(c => c.City
    == "London");

    View Slide

  18. Digital Performance
    So, what is it then?

    View Slide

  19. Digital Performance
    A standalone piece of code that runs in a shared
    infrastructure

    View Slide

  20. Important Lesson…

    View Slide

  21. It is not Serverless…

    View Slide

  22. It does still run on servers…

    View Slide

  23. You just don’t need to know
    about them

    View Slide

  24. Better name:
    Function-As-A-Service

    View Slide

  25. A standalone piece of code that
    runs in a shared infrastructure
    Code is managed and
    deployed as individual
    functions
    Triggered by external events

    View Slide

  26. A standalone piece of code that
    runs in a shared infrastructure
    You are only responsible for
    your code – the environment
    is outside your control
    No control over compute
    resources used
    You specify the amount of
    memory you want assigned
    to your function

    View Slide

  27. Multiple Supported Languages
    Can develop in 4 supported
    languages
    Java
    Python
    Node
    C#

    View Slide

  28. Digital Performance
    Benefits

    View Slide

  29. Benefits
    No servers to manage
    Code scales to your requirements
    Can execute many times in
    parallel
    Only pay for execution time
    Tracked down to nearest 100ms
    Isolation of functionality

    View Slide

  30. Digital Performance
    How does it work?

    View Slide

  31. View Slide

  32. Digital Performance
    How can it be triggered?

    View Slide

  33. Triggers
    Other AWS services
    S3
    Dynamo DB
    Kinesis
    SNS
    Cloudwatch
    External requests
    Via AWS API Gateway
    E.g. triggered from website
    Scheduled
    Proactive or reactive

    View Slide

  34. Digital Performance
    What’s it for?

    View Slide

  35. Real time file processing

    View Slide

  36. Real time Data Processing

    View Slide

  37. Data Transformation

    View Slide

  38. Deployment tasks
     Plumbing for a deployment pipeline
     Platform transforms
     Backups
     etc

    View Slide

  39. Backends

    View Slide

  40. Digital Performance
    Performance – is it ready for prime time?

    View Slide

  41. Serverless does not mean no
    servers… Just you don’t have
    to worry about servers

    View Slide

  42. Whilst you can simplify the
    management of servers and
    environments…

    View Slide

  43. The requirement to understand
    and analyse performance data
    is as important as ever

    View Slide

  44. Digital Performance
    Performance Challenges

    View Slide

  45. Standard server performance
    metrics are no longer available.
    Only stats available relate to
    external execution times

    View Slide

  46. All functions have to be
    written to be idempotent
    - no cached data or files
    - no connection pooling

    View Slide

  47. Digital Performance
    Overheads

    View Slide

  48. Understand other overheads
    as well as the server side
    request…
    Look at RUM / Synthetic data

    View Slide

  49. Non-server side overhead
    https://blog.newrelic.com/2017/01/11/aws-lambda-cold-start-optimization/

    View Slide

  50. Digital Performance
    Cold Start

    View Slide

  51. Functions have to create
    environment on first use
    Known as a Cold Start

    View Slide

  52. Environment has to be re-
    created after period of no
    activity or if underlying
    infrastructure needs to expand
    under load.

    View Slide

  53. After approx 5 mins of
    inactivity or 2-4 hours
    regardless of activity

    View Slide

  54. Performance of regular v Intermittent Functions
    https://blog.newrelic.com/2017/01/11/aws-lambda-cold-start-optimization/

    View Slide

  55. Each cold start Lambda
    execution adds significant
    overhead

    View Slide

  56. Cold start overhead varies by
    language

    View Slide

  57. Cold start overhead can be
    mitigated by minimising
    amount of packages included in
    the build

    View Slide

  58. Easily mitigated with
    scheduled task

    View Slide

  59. Digital Performance
    Serverless Performance and Economics

    View Slide

  60. Serverless is a perfect
    economic reflection of good
    performance

    View Slide

  61. Serverless is a perfect
    economic reflection of good
    performance
    Dan North

    View Slide

  62. Serverless Cost Model
    • Number of Executions
    • Memory allocated
    • Execution Time
    3 Elements

    View Slide

  63. Execution is charged in 100ms
    blocks – optimise performance
    to meet these block limits

    View Slide

  64. As always… evaluate cost
    savings against cost of
    optimisation

    View Slide

  65. Digital Performance
    Optimising Memory size

    View Slide

  66. Memory is the only dial
    available – adjusting memory
    also adjusts the CPU and other
    server settings

    View Slide

  67. Example: Low memory, High CPU task
    Task:
    In local testing, uses <50mb of memory
    https://serverless.zone/my-accidental-3-5x-speed-increase-of-aws-lambda-functions-6d95351197f3#.q18h6eg9k

    View Slide

  68. Example: Low memory, High CPU task
    REPORT Duration: 2120.67 ms Billed Duration: 2200 ms Memory Size: 128 MB
    REPORT Duration: 2778.51 ms Billed Duration: 2800 ms Memory Size: 128 MB
    REPORT Duration: 2185.11 ms Billed Duration: 2200 ms Memory Size: 128 MB
    REPORT Duration: 1883.18 ms Billed Duration: 1900 ms Memory Size: 128 MB
    REPORT Duration: 353.52 ms Billed Duration: 400 ms Memory Size: 1536 MB
    REPORT Duration: 340.44 ms Billed Duration: 400 ms Memory Size: 1536 MB
    REPORT Duration: 356.91 ms Billed Duration: 400 ms Memory Size: 1536 MB
    REPORT Duration: 280.49 ms Billed Duration: 300 ms Memory Size: 1536 MB
    REPORT Duration: 336.75 ms Billed Duration: 400 ms Memory Size: 1536 MB
    Before:
    After:
    Increasing memory improved performance 7x

    View Slide

  69. Digital Performance
    Consistency of Performance

    View Slide

  70. Lambda functions deliver
    inconsistent performance
    https://blog.symphonia.io/the-occasional-chaos-of-aws-lambda-runtime-performance-880773620a7e#.s1vd0mr6f

    View Slide

  71. Regular executions at varying memory size
    infrastructure

    View Slide

  72. Sorted into response time order

    View Slide

  73. What does this mean?
    Documented performance levels are
    WORST CASE SCENARIO

    View Slide

  74. What does this mean?
    Performance scales *at least*
    proportionally to memory settings

    View Slide

  75. What does this mean?
    Higher memory settings result in higher
    levels of consistency

    View Slide

  76. What does this mean?
    Benchmarking requires long term data
    capture to be sure of reliable
    interpretation

    View Slide

  77. Digital Performance
    Platform Comparison

    View Slide

  78. Response Time Under Load
    Azure Functions
    Google Cloud
    AWS Lambda
    http://cloudacademy.com/blog/microsoft-azure-functions-vs-google-cloud-functions-fight-for-serverless-cloud-domination-continues/

    View Slide

  79. Digital Performance
    Questions

    View Slide

  80. Andy Still : Technical Director & Founder, Intechnica
    Web: www.intechnica.co.uk
    Email: [email protected]
    Twitter: @andy_still / @intechnica
    Blog: http://www.internetperformanceexpert.com/
    http://www.intechnica.co.uk/web-performance-warrior.aspx http://oreil.ly/2cJLxZh http://oreil.ly/2ce2ghE

    View Slide