Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Demo project: How to run pgbouncer (client-side) with a Django-app on Heroku

Notifications You must be signed in to change notification settings

steuke/heroku-pgbouncer-django-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Please note: This project is not suitable for production use.

This project demonstrates how to use the Heroku pgbouncer buildpack together with Django for client-side connection pooling.

Usage

To get up and running, clone this repo and cd into the folder containing this README-file.

Then:

# create app
$ heroku apps:create ${HEROKU_APP_NAME}

# add postgres
$ heroku addons:create heroku-postgresql:hobby-dev --name=${HEROKU_APP_NAME}

# add pgbouncer buildpack
$ heroku buildpacks:add heroku/pgbouncer

# add python buildpack
$ heroku buildpacks:add heroku/python3

# deploy the app
$ git push heroku master

# run Django migrations
$ heroku run python manage.py migrate

Open https://${HEROKU_APP_NAME}/blocking-transaction?sleep=2 in your browser.

You should see something like this (but not as nicely formatted):

{
    "seconds_delay": 2.0,
    "total_item_count": 120,
    "pgbouncer_stats": [
        {
            "database": "db1",
            "total_xact_count": 24,
            "total_query_count": 288,
            "total_received": 32580,
            "total_sent": 17915,
            "total_xact_time": 14320888,
            "total_query_time": 8179707,
            "total_wait_time": 7903285,
            "avg_xact_count": 0,
            "avg_query_count": 3,
            "avg_recv": 377,
            "avg_sent": 207,
            "avg_xact_time": 661640,
            "avg_query_time": 33823,
            "avg_wait_time": 109654
        },
        {
            "database": "pgbouncer",
            "total_xact_count": 12,
            "total_query_count": 12,
            "total_received": 0,
            "total_sent": 0,
            "total_xact_time": 0,
            "total_query_time": 0,
            "total_wait_time": 0,
            "avg_xact_count": 0,
            "avg_query_count": 0,
            "avg_recv": 0,
            "avg_sent": 0,
            "avg_xact_time": 0,
            "avg_query_time": 0,
            "avg_wait_time": 0
        }
    ]
}

About

Demo project: How to run pgbouncer (client-side) with a Django-app on Heroku

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages