Open girafferiel opened 3 years ago
same question
With 10k users it would definitely be very resource intensive to use devtool.New
and rpcc.Dial
for each request. If you're looking to use only one Chrome instance with many connections, I'd recommend taking a look at using the session
package. This package allows all tabs to be controlled via a single websocket connection.
For a complete example where the session
package is utilized, check out Example (Incognito).
But keep in mind it's not necessary to use CreateBrowserContext
, this all depends on your use-case and what level of isolation you want. I recommend reading up on what it entails. But essentially you could use one context per tab, or one context for a group of tabs, or just rely on the default context.
With this, devtool.New + rpcc.Dial
is essentially replaced by bc.Target.CreateTarget + sess.Dial
, and that's how you'd create more tabs.
Hi, apologize if its in the docs. I would like to create a link preview rpc API so that client can send a URL and get the title, desc, etc. Should I call devtool.New inside the RPC handler or only once when the service is initialized? How many connections to the devtool can be managed at a time ? I'm planning to use the docker as described here: https://stackoverflow.com/questions/59110235/how-to-run-chromedp-in-docker I am confused if 10k users call my RPC, that means 10k connections to the devtool and how is it going to be handled by the chromedriver thank you