# How Does the Apache Cassandra GoCQL Driver Function?

When you connect to Cassandra, you need to initialize a `Session` . This session will create a 2 connection pools to C\*

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1748685981468/c2f4b749-ceda-4c5f-8f76-86872e00581c.png align="center")

`Session` will try to discover hosts for control connection pool first by resolving the provided hosts with DNS lookup. It will then use this host to discover other members in the cluster by querying `system.peers` and `system.local` for host info. ([https://github.com/apache/cassandra-gocql-driver/blob/7279756d7311211939f1466d20d1a029ab69f4a4/host\_source.go#L711](https://github.com/apache/cassandra-gocql-driver/blob/7279756d7311211939f1466d20d1a029ab69f4a4/host_source.go#L711))

Control connection pool also maintains a go routine to periodically heartbeat the connected host and reinitialize the connection when the heartbeat fails. ([https://github.com/apache/cassandra-gocql-driver/blob/7279756d7311211939f1466d20d1a029ab69f4a4/control.go#L125](https://github.com/apache/cassandra-gocql-driver/blob/7279756d7311211939f1466d20d1a029ab69f4a4/control.go#L125))

When a node join/leave the cluster, Cassandra will send a corresponding event to the connected client via the mentioned above control connection. The driver when then issue a ring refresh request for a new host list. ([https://github.com/apache/cassandra-gocql-driver/blob/7279756d7311211939f1466d20d1a029ab69f4a4/events.go#L166](https://github.com/apache/cassandra-gocql-driver/blob/7279756d7311211939f1466d20d1a029ab69f4a4/events.go#L166))
