Creating a connection pool for Snowflake

  1. Installing the necessary libraries
~ npm install --save snowflake-sdk
~ npm install --save generic-pool
  • We have first created a factory object. Inside which we are initializing create, destroy and validate functions that will be responsible to create, destroy and validate the Snowflake connection
  • Then we have created an opts object. Here we have configured the connections pool as per our needs. You can read more about the configuration options here
  • The query function first acquires a connection from the connection pool
  • Then it executes the query which is passed to the query function
  1. Does creating new connections start the warehouse?
    According to our testing, the warehouse didn’t start when we create a new connection (It only starts when we query the warehouse). That means creating new connections will not add extra credits to the warehouse.
  2. Does keeping the connections alive will cost you?
    The cost for creating and maintaining the Snowflake connections depends on the service layer which handles most of the metadata operations. The cost for the services layer depends on your subscription and it is very little or free.
  3. How long should you keep the connections alive?
    There is an option called clientSessionKeepAlive which probably could be used to keep the connection alive forever. But since it queries the warehouse after a certain interval this option could cost you extra to keep the connections alive.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Abhijeet Pandhe

Abhijeet Pandhe

Full Stack Web Developer and a tech enthusiast XD