MongoDB database connection pool

Source: Internet
Author: User
Tags time in milliseconds

Reprinted: View Original

Keywords: COM. MongoDB. dbportpool $ semaphoresout: Out of semaphores to get DB


I did a MongoDB concurrency test today and reported the above error. The reason is that the number of database connections is too small and the resources are exhausted. View the source code of COM. MongoDB. mongooptions, including connectionsperhost and threadsallowedtoblockforconnectionmultiplier.

Connectionsperhost: Number of connections per host

Threadsallowedtoblockforconnectionmultiplier: Number of thread queues. The result of multiplying the connectionsperhost value above is the maximum value of the thread queue. If the connection thread is full, the error "out of semaphores to get DB" will be thrown.

The default value of connectionsperhost is 10, and that of threadsallowedtoblockforconnectionmultiplier is 5, that is, the thread pool has 50 connections. Therefore, you only need to increase the value of this attribute to avoid the above errors.

 

Other property settings:

Maxwaittime: Maximum thread blocking time waiting for connection

Connecttimeout: the connection timeout time in milliseconds. 0 is the default and unlimited

Sockettimeout: Socket timeout. 0 is the default and unlimited

Autoconnectretry

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.