Slide 1

Slide 1 text

Try to use chromeless on AWS Lambda @serima 25 Oct. 2018

Slide 2

Slide 2 text

Who am I? Ryo Shibayama Server Side Engineer Working at GameWith Inc. (We're hiring! ) Twitter / GitHub : @serima

Slide 3

Slide 3 text

What's GameWith?

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Let's get on track

Slide 6

Slide 6 text

chromeless Runs locally or headless on AWS Lambda It can be used to Run 1000s of browser integration tests in parallel Crawl the web & automate screenshots Write bots that require a real browser https://github.com/graphcool/chromeless

Slide 7

Slide 7 text

Two operation modes This time I will introduce Remote Proxy mode

Slide 8

Slide 8 text

Setup ow 1. Clone chromeless repo, npm install in proxy service directory 2. Con gure AWS's access key and secret 3. Deploy to own infrastructure with dedicated command( npm run deploy ) 4. Request to the proxy using issued endpoint, API key Notice: Use the same region between AWS services chromeless uses

Slide 9

Slide 9 text

Deployed Lambda Functions We can see that the four functions have been deployed

Slide 10

Slide 10 text

Then Let's request to Lambda functions!

Slide 11

Slide 11 text

const Chromeless = require('chromeless').default async function run(url) { const chromeless = new Chromeless({ remote: { endpointUrl: 'https://xxxxx.execute-api.ap-northeast-1.ama apiKey: 'xxxxxxxxxxxx' }, }) const screenshot = await chromeless .setUserAgent('Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like M .setViewport({width: 640, height: 1136, scale: 1}) .goto(url) .screenshot() console.log(url) console.log(screenshot) // prints S3 url await chromeless.end() } run('https://www.yahoo.co.jp').catch(console.error.bind(console run('https://www.facebook.com').catch(console.error.bind(console

Slide 12

Slide 12 text

Run % node test.js https://www.yahoo.co.jp https://xxxxx-ap-northeast-1-chromeless.s3.amazonaws.com/cj946gj https://www.facebook.com https://xxxxx-ap-northeast-1-chromeless.s3.amazonaws.com/cj946gk Retured S3 urls(they are screen captures)

Slide 13

Slide 13 text

uh-oh

Slide 14

Slide 14 text

Why □? chromeless depends on severless-chrome By default, some fonts are not installed in serverless-chrome #49 Include Chinese/Japanese/Korean/more fonts in headless Chrome binary

Slide 15

Slide 15 text

Rendered successfully Because yahoo.com only uses English

Slide 16

Slide 16 text

Missing fonts... But we can resolve this issue to re-archive serverless-chrome with fontcon g bundled My former senior was writing a blog about this issue

Slide 17

Slide 17 text

Hmm It's better to wait for serverless-chrome supports multi fonts con guration Because chromeless depends on it... If we use serverless-chrome as standalone, I think we should install and use our own fonts

Slide 18

Slide 18 text

Conclusion The approach of explosively increasing the number of parallels using Lambda is very interesting Keep watching these repos More in details on my blog serima.co/blog

Slide 19

Slide 19 text

Bonus PhantomJS: Stepping down as maintainer https://news.ycombinator.com/item? id=14105489 We should choose headless chrome as an e2e test tool from now on

Slide 20

Slide 20 text

Thank you for listening