nodejs-shm (WORK IN PROGRESS)
Node.js native addon for using shared memory compatible with PHP shmop
Working on bigger project with several autonomous long-running processes I need communication between them. This processes ( workers, drivers ) need share relatively huge amount of data ( 10k - 100k bytes ) and I feel, that communication through TCP sockets is not so fast, as I want.
I have PHP workers with shared memory used with shmop_XXXX commands as "data sources", and another workers, based on node.js, which I need connect with them - that's why I started this work.
Working with shared memory need some discipline, my solution of potential concurrency and race condition problem is simple (not included in sources, only for imagination) :
My shm system is based on one big (10 MB) allocated shared memory block, divided to sections, where can write only exactly one worker. Information about sections (addressOffset, sectionSize, owner) are readed from database and saved in first - header section. SHM creates one process - centralManager, which writes header section. Workers connects to SHM with well-known KEY, reads header section, finds info, where they have memory space (offset and size) and where are spaces of another workers, whose data they maybe need.
And communication between processes can start.
TODO: simple SHM manager.
The module is currently build on windows, linux not already tested.
Because a newbie in nodejs, this native addon is maybe not very pretty ... any help invited
You can install with
$ npm install -g nodejs-shm
How to Use
var shm = ;console;var shmkey = 1236;var shmid = shm;console;var bubu = "1234567890";console; //10xxxx = shm;console;console;var timerD =;
Copyright (c) 2013 Jan Supuka sbmintegral.sk
The MIT License