吴生涛
吴生涛

Reputation: 11

why curator does not use the connection pool to manager the connection

I'm new in using curator,i found that some framework use the connection pool to manage the connections like jdbc,redis. but i don't find the connection pool in curator.why curator does not provide the connection pool to reduce the resource which each connection consumes.

Upvotes: 1

Views: 382

Answers (1)

Jingguo Yao
Jingguo Yao

Reputation: 7986

One CuratorFramework instance wraps a ZooKeeper instance which in turn maintains a connection to a ZooKeeper node.

ZooKeeper provides the following ordering guarantees:

  • Linearizable writes: all requests that update the state of ZooKeeper are serializable and respect precedence;
  • FIFO client order: all requests from a given client are executed in the order that they were sent by the client.

Assume there is connection pool with two CuratorFramework instances A and B. We issue a write request to A to create a znode /a and return A to the connection pool. Then we get another CuratorFramework instance from the connection pool. This time we get B. We issue a read request to B to read /a. It is possible that we can't get /a since there is no guarantee that the read request will be placed after the write request. Only with the same connction, we can ensure the order. So the connection pool has this data inconsistency problem.

Another problem is ephemeral znodes. Ephemeral znodes created with one CuratorFramework instance is only visible to itself. With a connection pool, we can read ephemeral znodes only when using the same CuratorFramework instance which creates them.

Upvotes: 1

Related Questions