Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb & max connections

Tags:

i am going to have a website with 20k+ concurrent users.

i am going to use mongodb using one management node and 3 or more nodes for data sharding.

now my problem is maximum connections. if i have that many users accessing the database, how can i make sure they don't reach the maximum limit? also do i have to change anything maybe on the kernel to increase the connections?

basically the database will be used to keep hold of connected users to the site, so there are going to be heavy read/write operations.

thank you in advance.

like image 481
carmelo arena Avatar asked Dec 09 '11 00:12

carmelo arena


People also ask

What MongoDB used for?

MongoDB is an open source NoSQL database management program. NoSQL is used as an alternative to traditional relational databases. NoSQL databases are quite useful for working with large sets of distributed data. MongoDB is a tool that can manage document-oriented information, store or retrieve information.

Which is better SQL or MongoDB?

While MongoDB is more flexible and ensures high and diverse data availability, a SQL Database operates with the ACID (Atomicity, Consistency, Isolation, and Durability) properties and ensures greater reliability of transactions.

What is MongoDB?

MongoDB is a popular, open source, scale-out NoSQL database that provides high throughput for your data-driven applications. Unlike relational databases such as SQL Server, Oracle, and MySQL, which store data in tables according to a rigid schema, MongoDB stores data in documents with flexible schema.

Is MongoDB a database or DBMS?

MongoDB (link resides outside IBM) is an open source, nonrelational database management system (DBMS) that uses flexible documents instead of tables and rows to process and store various forms of data.


1 Answers

You don't want to open a new database connection each time a new user connects. I don't know if you'll be able to scale to 20k+ concurrent users easily, since MongoDB uses a new thread for each new connection. You want your web app backend to have just one to a few database connections open and just use those in a pool, particularly since web usage is very asynchronous and event driven.

see: http://www.mongodb.org/display/DOCS/Connections

The server will use one thread per TCP connection, therefore it is highly recomended that your application use some sort of connection pooling. Luckily, most drivers handle this for you behind the scenes. One notable exception is setups where your app spawns a new process for each request, such as CGI and some configurations of PHP.

Whatever driver you're using, you'll have to find out how they handle connections and if they pool or not. For instance, Node's Mongoose is non-blocking and so you use one connection per app usually. This is the kind of thing you probably want.

like image 98
EhevuTov Avatar answered Sep 20 '22 16:09

EhevuTov