rethinkdb / rethinkdb/docs

Socket.io change feed help (performance)

Open
#1,230 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
CSS
Stars
118
Forks
161
PR merge metrics
No merged PRs in 30d

Description

Hello, im setting up a change feed that pushes to a socket io connection.

Im worried that setting up a new change feed for each io connection is gonna be a bit intensive.

Can rethink handle 100-1000 change feeds OK ?

Ill post my code below and any advice or feedback would be amazing, this is my first time using change feeds.

Also so i need to 'unsubscribe' from the change feed ?

Here is my current code :

    startSocket() {
        this.io.sockets.on('connection', socket => {
            console.log(' %s sockets connected', this.io.engine.clientsCount)

            socket.on('new_connection', target => {
                rethink
                    .table(target)
                    .changes({ includeInitial: true })
                    .run((err, cursor) => {
                        cursor.each((err, item) => {
                            socket.emit(target, item.new_val)
                        })
                    })
            })

            socket.on('disconnect', function() {
                console.log('disconnect: ', socket.id)
            })
        })
    }

Thanks
Luke

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The only entry point shown is startSocket(), including the new_connection and disconnect handlers; begin by reviewing the changefeed cursor lifecycle alongside the Socket.io connection lifecycle. Determine whether per-socket feeds and cleanup are supported for this setup, then document a confirmed recommendation and clear completion criteria.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend, databases, networking
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.