Slide 1

Slide 1 text

SERVERLESS PERFORMANCE LESSONS WITH HEADLESS CHOME @smithclay ServerlessConf NY, Oct 2017

Slide 2

Slide 2 text

SERVERLESS PERF STRATEGY ƛ ƛ is it fast? ƛ ƛ is it fast concurrently? ƛ ƛ what's the worst case? why?

Slide 3

Slide 3 text

AWS Lambda Function index.handler (node.js runtime) ./bin/chromedriver process.exec https://medium.com/clog/running-selenium-and-headless-chrome-on-aws-lambda-fb350458e4df ./bin/headless_chrome BIG BROWSER, LITTLE FUNCTION + Simple Selenium Script

Slide 4

Slide 4 text

AWS LAMBDA: BATTERIES INCLUDED DATA SOURCES Amazon Cloudwatch Logs Amazon Cloudwatch Metrics AWS X-Ray Traces

Slide 5

Slide 5 text

DISTRIBUTED TRACE VISUALIZTION 1200ms 400ms 370ms Service A Service B Service C Time

Slide 6

Slide 6 text

HELLO, COLD START AWS X-Ray Trace: AWS Function invoked from the Developer Console

Slide 7

Slide 7 text

COLD VS WARM START Notice: Function gets called almost immediately after the service receives the trigger.

Slide 8

Slide 8 text

COLD STARTS: MORE ANALYSIS NEEDED Aggregate function latencies from X-Ray to understand trends

Slide 9

Slide 9 text

VISUALIATING TRACES IN AGGREGATE 1) How long does it take for my function to initialize? 2) Where is time generally being spent?

Slide 10

Slide 10 text

FOR THIS FUNCTION, COLD STARTS ARE RARE Over a 24 hour period, the function rarely experiences cold starts.

Slide 11

Slide 11 text

AWS LAMBDA: COMMON SETTINGS TO MODIFY Language Runtime "Memory" Dropdown Function size (mb)

Slide 12

Slide 12 text

DURATION: BEFORE AND AFTER INCREASING MEMORY 768mb 1152mb Chromium needed more memory!

Slide 13

Slide 13 text

WRAP UP • Collect data for several days for many function runs. • Consider enabling x-ray traces for non-trivial functions • Test scenarios where your function has many concurrent executions (i.e. large spike in the number of requests) • Don't be afraid to increase memory: it might end up costing less. •Measure and share!

Slide 14

Slide 14 text

THANKS! slides: @smithclay + speakerdeck.com Original blog post: https://blog.newrelic.com/2017/06/20/lambda- functions-xray-traces-custom-serverless-metrics/