polleverywhere/phantom-cluster-webfonts

Name: phantom-cluster-webfonts

Owner: Poll Everywhere

Description: This fork is deprecated. Provides a cluster of phantomjs-backed workers

Created: 2015-05-27 18:36:41.0

Updated: 2017-10-04 05:43:24.0

Pushed: 2015-06-04 00:56:37.0

Homepage:

Size: 143

Language: CoffeeScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

phantom-cluster

Phantom-cluster is a cluster of node.js workers for processing requests with phantomjs instances.

Because you can spawn multiple workers, requests can be processed in parallel. At the same time, the limited number of workers prevents you from spinning up too many memory-intensive phantomjs instances. Further, there's some added logic to automatically restart workers after a few iterations to prevent memory leaks.

For a full example, see example.coffee.

Communication-agnostic engines

If you want to use a custom communication mechanism, or do not wish to use a FIFO queue, you can use the communication-agnostic engines, represented with PhantomClusterServer and PhantomClusterClient. In this mode, the server spins up workers, and workers coordinate access to the phantomjs process, but that's it. It's up to you to figure out how to get the server to send requests to clients.

Spin up new instances of these classes via create(), i.e.:

var phantomCluster = require("phantom-cluster");
var engine = phantomCluster.create({ ...options... });
...

The options for create:

If the process is a worker, you'll be returned an instance of PhantomClusterClient. Otherwise you'll be returned an instance of PhantomClusterServer.

PhantomClusterServer
Methods Events Properties
PhantomClusterClient
Methods Events Properties
Queued engines

phantom-cluster exposes a server/client setup that builds on the communication-agnostic server/client that processes requests via a FIFO queue. Communication between the server and workers is facilitated via node.js' built-in IPC mechanism. This should suit most needs and is the default setup.

In this setup, requests should be idempotent - that is, multiple executions of the request should yield the same result. This is because requests have a built-in timeout. This is to prevent lost requests from, e.g. workers that suddenly die.

Spin up new instances of these classes via createQueued(), i.e.:

var phantomCluster = require("phantom-cluster");
var engine = phantomCluster.createQueued({ ...options... });
...

The options for createQueued including all of the options for create, and additionally:

PhantomQueuedClusterServer

This extends PhantomClusterServer, so it includes all of their methods/events/properties.

Methods Properties
PhantomQueuedClusterClient

This extends PhantomClusterClient, so it includes all of their methods/events/properties.

Methods Events
QueueItem

This is the object returned by PhantomQueuedClusterServer's enqueue method.

Events Properties

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.