{"action":"created","issue":{"url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/3120","repository_url":"https://api.github.com/repos/GoogleChrome/puppeteer","labels_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/3120/labels{/name}","comments_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/3120/comments","events_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/3120/events","html_url":"https://github.com/GoogleChrome/puppeteer/issues/3120","id":352854660,"node_id":"MDU6SXNzdWUzNTI4NTQ2NjA=","number":3120,"title":"Puppeteer slow execution on Cloud Functions","user":{"login":"lpellegr","id":128898,"node_id":"MDQ6VXNlcjEyODg5OA==","avatar_url":"https://avatars0.githubusercontent.com/u/128898?v=4","gravatar_id":"","url":"https://api.github.com/users/lpellegr","html_url":"https://github.com/lpellegr","followers_url":"https://api.github.com/users/lpellegr/followers","following_url":"https://api.github.com/users/lpellegr/following{/other_user}","gists_url":"https://api.github.com/users/lpellegr/gists{/gist_id}","starred_url":"https://api.github.com/users/lpellegr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpellegr/subscriptions","organizations_url":"https://api.github.com/users/lpellegr/orgs","repos_url":"https://api.github.com/users/lpellegr/repos","events_url":"https://api.github.com/users/lpellegr/events{/privacy}","received_events_url":"https://api.github.com/users/lpellegr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":21,"created_at":"2018-08-22T08:37:02Z","updated_at":"2018-09-27T15:59:16Z","closed_at":null,"author_association":"NONE","body":"I am experimenting Puppeteer on Cloud Functions. \r\n\r\nAfter a few tests, I noticed that taking a page screenshot of _https://google.com_ takes about 5 seconds on average when deployed on Google Cloud Functions infrastructure, while the same function tested locally (using `firebase serve`) takes only 2 seconds.\r\n\r\nAt first sight, I was thinking about a classical cold start issue. Unfortunately, after several consecutive calls, the results remain the same.\r\n\r\nIs Puppeteer (transitively Chrome headless) so CPU-intensive that the best '2GB' Cloud Functions class is not powerful enough to achieve the same performance as a middle-class desktop? \r\n\r\nCould something else explain the results I am getting? Are there any options that could help to get an execution time that is close to the local test?\r\n\r\nHere is the code I use:\r\n\r\n```typescript\r\nimport * as functions from 'firebase-functions';\r\nimport * as puppeteer from 'puppeteer';\r\n\r\nexport const capture =\r\n    functions.runWith({memory: '2GB', timeoutSeconds: 60})\r\n        .https.onRequest(async (req, res) => {\r\n\r\n    const browser = await puppeteer.launch({\r\n        args: ['--no-sandbox']\r\n    });\r\n\r\n    const url = req.query.url;\r\n\r\n    if (!url) {\r\n        res.status(400).send(\r\n            'Please provide a URL. Example: ?url=https://example.com');\r\n    }\r\n\r\n    try {\r\n        const page = await browser.newPage();\r\n        await page.goto(url, {waitUntil: 'networkidle2'});\r\n        const buffer = await page.screenshot({fullPage: true});\r\n        await browser.close();\r\n        res.type('image/png').send(buffer);\r\n    } catch (e) {\r\n        await browser.close();\r\n        res.status(500).send(e.toString());\r\n    }\r\n});\r\n```\r\n\r\nDeployed with Firebase Functions using NodeJS 8."},"comment":{"url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/comments/425147806","html_url":"https://github.com/GoogleChrome/puppeteer/issues/3120#issuecomment-425147806","issue_url":"https://api.github.com/repos/GoogleChrome/puppeteer/issues/3120","id":425147806,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTE0NzgwNg==","user":{"login":"ebidel","id":238208,"node_id":"MDQ6VXNlcjIzODIwOA==","avatar_url":"https://avatars2.githubusercontent.com/u/238208?v=4","gravatar_id":"","url":"https://api.github.com/users/ebidel","html_url":"https://github.com/ebidel","followers_url":"https://api.github.com/users/ebidel/followers","following_url":"https://api.github.com/users/ebidel/following{/other_user}","gists_url":"https://api.github.com/users/ebidel/gists{/gist_id}","starred_url":"https://api.github.com/users/ebidel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebidel/subscriptions","organizations_url":"https://api.github.com/users/ebidel/orgs","repos_url":"https://api.github.com/users/ebidel/repos","events_url":"https://api.github.com/users/ebidel/events{/privacy}","received_events_url":"https://api.github.com/users/ebidel/received_events","type":"User","site_admin":false},"created_at":"2018-09-27T15:59:16Z","updated_at":"2018-09-27T15:59:16Z","author_association":"MEMBER","body":"@DimaFromCanada none that I've seen. To be clear, are you talking about total time (cold start + execution) or just running your handler code?"}}
{"actor":{"display_login":"ebidel"}}