nodejs/node-addon-examples

Possible to pass master initiated addon function pointer to forks?

hasnat opened this issue · 2 comments

First of all thanks for great set of examples. I have tried most of them and work great with in detail comments.

I couldn't find an example relating to my use case.
Where a c++ addon instance takes about 2-3 gb of RAM. functions as simple as ping pong.
Is supposed to stay alive for the duration of web server. Nodejs forks will be querying this addon providing it headers from request and getting back some insights.

I have around 32 forks in nodejs serving http port. I cannot have c++ addon on all the forks that would take around a lot of RAM.

I wanted to initialise the addon on master and somehow pass master initialized addon function pointer to forks for them to do queries to addon not sure if I can use v8::External here or some other way ( https://nodejs.org/api/all.html#addons_context_aware_addons ).

For now only way I see this possible is nodejs forks sending messages to master and master replies back after querying with addon.

@hasnat message passing is definitely a way to go. You can also use shared memory but that's UNIX-specific, and might vary in implementation from UNIX to UNIX.

Thanks for the pointers @gabrielschulhof , I'll close the issue.