MongoDB database Connection Pool __ Database

Source: Internet
Author: User
Tags mongodb

Reprint: View Original

Keywords: com.mongodb.dbportpool$semaphoresout:out of semaphores to get DB


Do MongoDB concurrency test today to report the above error. The reason is that the number of database connections is too small, the resources are exhausted. View the Com.mongodb.MongoOptions source code, which has the connectionsperhost and threadsallowedtoblockforconnectionmultiplier two important properties.

Connectionsperhost: Number of connections per host

Threadsallowedtoblockforconnectionmultiplier: The number of thread queues, the result of which is multiplied by the above Connectionsperhost value is the maximum thread queue value. The "out of semaphores to get DB" error is thrown if the connection thread is fully queued.

Connectionsperhost default is 10,threadsallowedtoblockforconnectionmultiplier default is 5, that is, the thread pool has 50 connections to use. Therefore, the above error can be avoided as long as the value of this property is increased.

Other property settings:

Maxwaittime: The maximum waiting time for a connected thread to block

ConnectTimeout: The milliseconds that the connection timed out. 0 is the default and unlimited

Sockettimeout:socket timeout. 0 is the default and unlimited

Autoconnectretry: If this control is in a connection, the system will automatically retry

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.