Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue - too many TCP connections #335

Open
lprhodes opened this issue May 26, 2017 · 1 comment
Open

Performance issue - too many TCP connections #335

lprhodes opened this issue May 26, 2017 · 1 comment
Labels

Comments

@lprhodes
Copy link

Hi,

I'm at a bit of a dead end with a performance issue.

I started out with a connection pool but it kept running out and I ended up needing 10k connections in the pool.

I then changed the code to create a single connection with rethinkdbdash (pool turned off) then I pass the connection too any bit of code that runs a query on rethinkDB. Unfortunately running the command lsof -i -n | wc -l on the rethinkdb server is showing that it still has 1300 open connections with barely anyone using the application. It seems that a TCP connection is being opened for every query but then not being closed.

I had hoped to just open a single connection and then query everything through that.

Here's how I have things setup:

  host: process.env.RDB_HOST || '127.0.0.1',
  port: process.env.RDB_PORT || 28015,
  password: process.env.RDB_PASSWORD,
  pool: false
}


export default rethinkdbdash({
  servers: [ server ],
  db: process.env.RDB_DB_NAME || 'database'
})```

const rDBConnection = await rDB.connect(server)

async function doSomething (rDBConnection) {
const a = await rDB.table('comment').getAll(activity.id, { index: 'activity' }).run(rDBConnection)
const b = await rDB.table('taskQueue').insert(task).run(rDBConnection)
const c = await rDB.table('device').getAll(user.id, { index: 'user' }).run(rDBConnection)
}

doSomething(rDBConnection)


Any ideas?

Thanks!
@neumino
Copy link
Owner

neumino commented May 28, 2017

Rethinkdbdash is using one connection per query. By default it will open up to 1000 connections per server - that is if you have at some time in the past 1000 concurrent queries.

I would need a bit more detail to understand your problem. What's the actual problem? Having thousands of TCP connections on a server is fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants