You can use a child_process (or a cluster of child processes) to do this. 
But I'd actually advise to isolate that logic into a small service (either 
written in node or maybe in something that is more tailored towards CPU 
heavy apps, e.g. C++ or Java) and use for example HTTP to call it. This 
allows you to freely scale the two things (the web application and the 
ranking algorithm) independently.

In any case: out-sourcing the computation itself to C++ is always possible, 
though if you implement it yourself you won't need ffi and you can just use 
a normal node module as your interface. The docs have an example on how to 
build a native node module. Depending on the complexity of the computation 
you may want to consider if you can do some precalculations offline. But if 
you just start out that might just overcomplicate things.

Cheers,
Jan

On Sunday, March 16, 2014 10:47:22 AM UTC-7, Andy Zelinski wrote:
>
> I am hoping for someone to point me in the right direction (examples, 
> info) on how best to handle the need for some processor heavy computations 
> that might best be executed with C++ math libraries.
>
> example scenario pseudocode:
>
> 1. application user clicks "give me 10 movies to watch" button after 
> entering age, iq, time of day,  and how much time he/she has to watch. 
> (some post data needed as calculation parameters)
> 2. application pulls some historical data from database: an array of 
> [person id, age, iq, movie watched, time watched, movie length, rating user 
> gave] -- say a million data points in an array
> 3. application then needs to apply a sophisticated math model to all data 
> points and includes other hard-coded parameters. 
> 4. assume after watching one movie, all the hard-coded parameters change 
> as a side effect, so the algorithm should rank all movies in likelihood 
> loved from 1 to n, choose the top ranked movie for user, and then iterate 
> for the next 9, re-applying the math model
>
> is this best handled by forking a child_process? use node-ffi? wrap a c++ 
> object that can handle the math and pass the parameters?
>
> thanks a million
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to