현재 MongoDB Connection Pool을 만들기 위해서 이것저것 찾아보고 있다.



그래서 찾아낸 것이 


API 문서 중 ClientURI 문서에서 Connection Pool Setting에 관한 문서가 있었다.



Connection Configuration:

  • ssl=true|false: Whether to connect using SSL.
  • sslInvalidHostNameAllowed=true|false: Whether to allow invalid host names for SSL connections.
  • connectTimeoutMS=ms: How long a connection can take to be opened before timing out.
  • socketTimeoutMS=ms: How long a send or receive on a socket can take before timing out.
  • maxIdleTimeMS=ms: Maximum idle time of a pooled connection. A connection that exceeds this limit will be closed
  • maxLifeTimeMS=ms: Maximum life time of a pooled connection. A connection that exceeds this limit will be closed

Connection pool configuration:

  • maxPoolSize=n: The maximum number of connections in the connection pool.
  • waitQueueMultiple=n : this multiplier, multiplied with the maxPoolSize setting, gives the maximum number of threads that may be waiting for a connection to become available from the pool. All further threads will get an exception right away.
  • waitQueueTimeoutMS=ms: The maximum wait time in milliseconds that a thread may wait for a connection to become available.


즉 , URI 패턴에 맞게 설정한다면



mongodb://localhost:27017/?maxPoolSize=50



이렇게 만들어진다는 말인데 이건 초기값이 50이라는 게 아니라 풀의 최대 크기가 50이다.

실제 MongoDB와 연결하는 명령 프롬프트에서도 커넥션을 실행하면 1 connection  -> 0 connection으로만 나오고 

여러개가 생성되었다는 정보는 얻을 수 없었다.


아파치에서 제공하는 common-dbcp2에도 들어가봤지만 NoSQL의 DBCP에 관한 정보는 없었다.

인터넷에 나와있는 자료는 전부 Node.js에서 초기값을 설정하는 방법이고 Java에서 설정하는 방법은 오로지 저 URI패턴 밖에 없다.

답답한 마음에 MongoDB 3.6 API에서 ConnectionPool에 관한 ConnectionPoolSetting도 찾아서 봤지만 init값에 대한 이야기는 없었다.

그나마 가장 비슷해 보인 건 addConnectionPoolListener()정도였는데 


public Builder addConnectionPoolListener(final ConnectionPoolListener connectionPoolListener) {

            

connectionPoolListeners.add(notNull("connectionPoolListener", connectionPoolListener));

      return this;

      }


이런 형태라 아닌 것 같다.


Node.js가 가능하니 Java에서도 가능할 것 같은데 조금 더 찾아봐야겠다.

+ Recent posts