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

Try to use chromeless on AWS Lambda

Try to use chromeless on AWS Lambda

Ryo Shibayama

October 25, 2017
Tweet

More Decks by Ryo Shibayama

Other Decks in Technology

Transcript

  1. Who am I? Ryo Shibayama Server Side Engineer Working at

    GameWith Inc. (We're hiring! ) Twitter / GitHub : @serima
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. 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
  8. 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