Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>For object persistence, I added Redis support using node_redis. Then I replaced the client.send loop on the array of channels with Redis pub/sub as a layer of abstraction. But I noticed that I needed to create a new Redis client for each user that made a subscription. And I still needed to store socket.io client information to send messages to on publish. How scalable is that? Are there other (better) implementations or further optimizations I could make? What would you do?</p> </blockquote> <p>Yes, you have to create a new redis client for every io request. It is heavy and not scalable. But creating a new redis client connection does not consume much memory. So if your system user count is not more than 5000 then it is ok. To scale you can add in slave redis server to resolve the heavy publish and subscribe and if you are concerned about creating a lot of connections then you can increase your OS uLIMIT.</p> <p>You don't need to store socket.io client in message sent. Once redis received subscribed channel message. It will send message to particular io client.</p> <pre><code>subscribe.on("message",function(channel,message) { var msg = { message: [client.sessionId, message] }; buffer.push(msg); if (buffer.length 15) buffer.shift(); client.send(msg); &gt; }); </code></pre> <p>To subscribe multi channel. I suggest you to pre-store all user with more than one channel(You can use storage Mongodb or redis). </p> <pre><code>var store = redis.createClient(); var subscriber= redis.createClient() store.hgetall(UID, function(e, obj){ subscriber.subscribe(obj.ChannelArray.toArray()); }) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload