Skip to content

❓ Experiment with PostgreSQL Connection Pool (Multiple HTTP Requests should not create multiple pg connections)

Notifications You must be signed in to change notification settings

dwyl/postgres-connection-pool-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postgres-connection-pool-test

Background

While attempting to use PostgreSQL in our Node (Hapi) application, we were experiencing an issue when multiple connections were made.

This issue is described in: brianc/node-postgres#725 and a potential solution was suggested: brianc/node-postgres#725 (comment)

The code in server.js is copied from: https://github.com/brianc/node-postgres/wiki/Example (with a few minor heroku-specific modifications made)

Findings

Each HTTP request is inserting two records into the visit table, where we expect only one to be inserted ...

Try it!

We pushed the example up to Heroku: https://node-postgres-example.herokuapp.com/

When you refresh the page you see that the visit count goes up by two each time...!

This is obviously not the desired behaviour ...

About

❓ Experiment with PostgreSQL Connection Pool (Multiple HTTP Requests should not create multiple pg connections)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published