On Aug 11, 2010, at 11:24 PM, Ohad wrote:
> I have few processes of Node,
> What is the best practice of sharing memory between those processes ?
>
> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
On Aug 12, 2010, at 8:24 AM, Ohad wrote:
> I have few processes of Node,
> What is the best practice of sharing memory between those processes ?
>
man 7 svipc
You'll have to write node.js bindings for it, though. And learn to
live with the fact that SysV shared memory segments are of a fixed
size. POSIX IPC is an alternative but it's not as widely supported as
SysV IPC.
Shared memory is better until your system exceeds the capacity of the
machine, or any available machine. You then have two options: use
memcache, or another similar system, or spend lots and lots of money
on a ridiculous machine.
All of the top sites on the web use memcache or memcache-like tools.
They all rely on "slow" TCP connections across many machines. Unless
you're sure that your software will never need to scale beyond a
single machine, do yourself a favour and start with the scalable
option.
b.
Not available on OS X (for instance).
Ohad, may I ask what you are doing (in a greater sense)? If local tcp
sockets are too slow, you might be on the wrong foot to begin with
(using Nodejs). You should be aware that v8 and thus Nodejs is not at
all thread safe, which mean that the memory your processes would share
could never be touched by v8 or Nodejs, thus you would need to copy
any data back and fourth between the shared memory segment and each
process local memory, which in turn is almost as "slow" as talking
over local sockets.
>
> You'll have to write node.js bindings for it, though. And learn to
> live with the fact that SysV shared memory segments are of a fixed
> size. POSIX IPC is an alternative but it's not as widely supported as
> SysV IPC.
>
> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
>
--
Rasmus Andersson
By serializing it and using a UNIX socket.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
Don't. It hurts scalability.
Sorry, missed this post.
Rasmus, I think you are wrong on this one. An Apache module I wrote
uses SysV IPC[1] and it runs just fine on OS X.
[1] This was before the advent of apr_shm.h
Ah. You might be correct. I just did some shallow digging (like
looking up dev manuals). I don't think sharing memory between node
processes is a very good idea in general though.
>
> [1] This was before the advent of apr_shm.h
>
That's another matter and one we agree on. :-)
Before settling on memcache/memcached try taking a look at Redis and see if its supported data types are a better fit for session data than plain strings.
On Aug 12, 2010 1:55 PM, "Ohad" <mro...@gmail.com> wrote:
Excellent, so it seems like I'll go for memcached,
Which NodeJs-Memcached impl' do you suggest? how about
http://github.com/jketterl/memcachejs?
A new question, how do you recommend implementing affinity session?
which mean that the same user will get redirected to the same Node
instance
(btw that will solve the problem above regarding session but not
regarding application scope which is still needed)
On Aug 12, 8:30 pm, Arnout Kazemier <i...@3rd-eden.com> wrote:
> Same here, I don't see a reason t...
> > On Thu, Aug 12, 2010 at 1:04 PM, Ohad <mro...@gmail.com> wrote:
> > so there are many options
>
...
> > For more options, visit this group athttp://groups.google.com/group/nodejs?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups "nodejs" grou...
> > For more options, visit this group athttp://groups.google.com/group/nodejs?hl=en.
>
> Arnout Kazemier
> i...@3rd-Eden.com
--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To po...
Because it's easy to introduce concurrency bugs, which are awesomely
hard to debug.
> what would you do?
Pick the easiest, most maintainable solution. Probably memcached.
If it's for storing sessions, you could (and probably should) apply
the provider pattern and start out with a simple implementation.
On Fri, Aug 27, 2010 at 2:13 PM, Don Park <supe...@gmail.com> wrote:
> I could see shared memory being useful with add-ons that pass large
> media objects, like images, sounds, or video between processes.
>
Resurrecting this topic ...I think there is a real use case for node for shared memory. Because TCP connections are great but will always be slower than direct access to memory.To avoid any concurrency issue shared memory should be writable only by one process. When using the cluster module, the shared memory should be writable only by the master for example. If you want to write from a worker, just send a message, and the master will do it.
On Thursday, August 12, 2010 8:24:30 AM UTC+2, Ohad wrote:I have few processes of Node,
What is the best practice of sharing memory between those processes ?
I wrote a C/C++ binding of shared memory access from nodejs. https://github.com/supipd/node-shmStill work in progress (but working for me), maybe usefull, if bug or suggestion, inform me.Exactly like a Simon wrote, already are here real cases for using shared memory from node.js.And potential concurrency issues (solvable) aren't reason to not use shared memory.Maybe bigger problem is "eventable" shared memory, something like "inform me, when someting is changed".In case of one process as central-shared-memory-manager can be there some form of sending very small ((-:TCP packet "Hey You, signed ChangeOfValue subscriptor, somebody changed Your area of interest in SharedMemoryControlledByMe",as source of change event, on which COV client read shared memory to accept changes.Instead of TCP sending potentially large amount of bytes, this event system simple MUST be (and is) faster.
--
--
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 nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
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 nodejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.