Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some examples of running in a background job environment? #2

Open
cheeyeo opened this issue Apr 6, 2014 · 1 comment
Open

Some examples of running in a background job environment? #2

cheeyeo opened this issue Apr 6, 2014 · 1 comment

Comments

@cheeyeo
Copy link

cheeyeo commented Apr 6, 2014

Hi

I have been trying to use webshot in a multi threaded / concurrent environment but phantomjs is producing unexpected results. Sometimes it works but on occassions if multiple background jobs are using webshot to grab the url screenshots, it crashes phantomjs with a fatal error

Is phantomjs not meant to be run in a multi threaded environment or if so can you please provide some form of setup instructions?

thanks

@vitalie
Copy link
Owner

vitalie commented Apr 15, 2014

It's not recommended to start multiple PhantomJS concurrently. You should serialize the access, treat it as unreliable and monitor it with daemontools, god, monit, etc. My current setup:

   S3 <-- CloudFront + 404 handler <-- User Request
    ^
    |
Worker <--> Screenshot Service API (Heroku)
    |
    ^
    |
Queue < -- App

Screenshots are cached on S3 and served through CloudFront CDN. Heroku restarts the service automatically when it crashes and CloudFront serves a default image with a low TTL if the screenshot is not yet ready. Take a look at this gems too:

unicorn-worker-killer
unicorn-soft-timeout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants