Is there a limit on number of phantomJS instances that can be alunched

2,835 views
Skip to first unread message

lavesh bhandari

unread,
Nov 6, 2013, 1:16:14 AM11/6/13
to phan...@googlegroups.com
I am using a scraping script which uses casperJS and phantomJS. I am launching 100 parallel phantomJS instances.On monitoring it via task manager i find that only 10-12 phantomjs are active. Rest all looks to be idle with 0 cpu usage and constant RAM usage. Obviously the 10-12 active are not same at a time.

Is there something that can choke phantomJS at this level

Tom M

unread,
Nov 7, 2013, 5:45:36 AM11/7/13
to phan...@googlegroups.com
This quite interesting question,
I would like to add: Is there a way to re-use the same instance of Phantomjs that is already loaded in memory ?
For example you start an instance in another/same machine and connect to the ip-address and port to execute the job ? is it possible ? 

Jason Swearingen

unread,
Nov 9, 2013, 8:55:46 PM11/9/13
to phan...@googlegroups.com
you can reuse, but due to a memory bug, you should only expect 50 or so reuses before it crashes.   the related issue is here, which includes an example showing how to reuse pjs instances: https://github.com/ariya/phantomjs/issues/11390

because of this issue, I had to setup a pjs cloud service provider (as I need to scrape about 100 pages/sec)  so i have experience trying to do what the OP is saying:   generally i can fit 10 pjs instances per machine, with the main bottleneck being CPU, not ram.       even on a big developer pc, i was only able to run about 15.   so 100 per machine is going to be pretty impossible i think.

you can try out my pjs cloud service at http://PhantomJsCloud.com, but it's only for scraping right now (the awesome automation / test features of phantomjs are not implemented yet)    If you want to roll your own cloud, there are a lot of great npm packages that help integrating pjs with node,   so check that out (even if you don't use node, seeing how they do pjs<-->node communication would tell you how to implement it in your own language)

-Jason
Reply all
Reply to author
Forward
0 new messages