<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Stefan Ukena</title>
    <description>The latest articles on DEV Community by Stefan Ukena (@stefanukena).</description>
    <link>https://dev.to/stefanukena</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F400239%2Feb51a539-f1ca-4bc5-a66c-4ba3f4b5dc44.jpg</url>
      <title>DEV Community: Stefan Ukena</title>
      <link>https://dev.to/stefanukena</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stefanukena"/>
    <language>en</language>
    <item>
      <title>Debugging postgres: List all connections</title>
      <dc:creator>Stefan Ukena</dc:creator>
      <pubDate>Fri, 20 Feb 2026 07:00:00 +0000</pubDate>
      <link>https://dev.to/stefanukena/debugging-postgres-list-all-connections-3o55</link>
      <guid>https://dev.to/stefanukena/debugging-postgres-list-all-connections-3o55</guid>
      <description>&lt;p&gt;Sometimes want a list of all connections to your postgres database. Postgres maintains this list in an internal datastructure that you simply query like this: SELECT * FROM pg_stat_activity; This will give you something like this (I have removed many columns to make it more readable here): state application_name client_addr wait_event NULL NULL AutoVacuumMain NULL NULL LogicalLauncherMain idle test.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>quicktip</category>
    </item>
    <item>
      <title>Debugging postgres: Showing recent queries</title>
      <dc:creator>Stefan Ukena</dc:creator>
      <pubDate>Sun, 01 Feb 2026 07:00:00 +0000</pubDate>
      <link>https://dev.to/stefanukena/debugging-postgres-showing-recent-queries-26p9</link>
      <guid>https://dev.to/stefanukena/debugging-postgres-showing-recent-queries-26p9</guid>
      <description>&lt;p&gt;Postgres’ built-in pg_stat_activity-view shows the list of all open connections, including the current query from that connection in the query-column. What if that is not enough? How can you see not only the current query, but a list of recent queries? That is what the pg_stat_statements extension is for. Enabling the pg_stat_statements-extension Unlike pg_stat_activity, which is active by default, pg_stat_statements needs to be enabled on the postgres server. There are two steps:&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>quicktip</category>
    </item>
    <item>
      <title>Google's knowledge sharing process</title>
      <dc:creator>Stefan Ukena</dc:creator>
      <pubDate>Wed, 17 Nov 2021 07:00:00 +0000</pubDate>
      <link>https://dev.to/stefanukena/googles-knowledge-sharing-process-5461</link>
      <guid>https://dev.to/stefanukena/googles-knowledge-sharing-process-5461</guid>
      <description>&lt;p&gt;Today I learned how Google facilitates (developer) knowledge sharing across their teams. Internally, Google calls this the readability process, a form of standardized mentorship through code review. “Code-review?”, you may ask, “What’s so special about that? Don’t all successful technology companies practice code-reviews?” You are right, and Google also has these regular code-reviews. But the readability process, is different in some key ways. Here is how I understand it: readability reviews are mandatory for all code commits (not on the commit-level, of source, but for a set of commits) readability reviews are performed by qualified individuals, who are well versed in the companies’ software development guidelines and best practices the process of becoming a qualified readability reviewer is set up in such a way that it ensures knowledge-sharing across teams, essentially across the whole company Anyone can become a qualified readability reviewer.&lt;/p&gt;

</description>
      <category>quicktip</category>
    </item>
    <item>
      <title>Scaling Django/Postgres with PgBouncer on Heroku</title>
      <dc:creator>Stefan Ukena</dc:creator>
      <pubDate>Tue, 09 Jun 2020 09:40:53 +0000</pubDate>
      <link>https://dev.to/stefanukena/scaling-django-postgres-with-pgbouncer-on-heroku-1lb5</link>
      <guid>https://dev.to/stefanukena/scaling-django-postgres-with-pgbouncer-on-heroku-1lb5</guid>
      <description>&lt;p&gt;Do you have an app on Heroku using Postgres? Are you running out of database connections? Maybe you've already tried setting &lt;a href="https://docs.djangoproject.com/en/3.0/ref/settings/#conn-max-age" rel="noopener noreferrer"&gt;CONN_MAX_AGE&lt;/a&gt;, but that only helped for a while. It’s time for PgBouncer, the de facto standard for Postgres connection pooling.&lt;br&gt;
In this article, we'll look at how to use PgBouncer to scale your app on Heroku. We'll use Django, a popular python web framework, as an example for the settings. The installation steps for PgBouncer and the concepts, however, should work for any app on Heroku.&lt;/p&gt;
&lt;h2&gt;
  
  
  What You Will Learn
&lt;/h2&gt;

&lt;p&gt;Although setting up PgBouncer is straight forward, finding the right settings for your particular use case can be a challenge. There is no one-size-fits-all solution for a PgBouncer configuration.&lt;/p&gt;

&lt;p&gt;This article will show you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how to select a PgBouncer pool mode and deployment type&lt;/li&gt;
&lt;li&gt;how to install PgBouncer on Heroku by adding the &lt;a href="https://github.com/heroku/heroku-buildpack-pgbouncer" rel="noopener noreferrer"&gt;pgbouncer buildpack&lt;/a&gt; to your existing Django app&lt;/li&gt;
&lt;li&gt;how to monitor PgBouncer runtime statistics to help fine-tune your settings&lt;/li&gt;
&lt;li&gt;common errors and things to watch out for&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can find a sample project on GitHub at &lt;a href="https://github.com/steuke/heroku-pgbouncer-django-demo" rel="noopener noreferrer"&gt;https://github.com/steuke/heroku-pgbouncer-django-demo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note: to use this guide, your app must use the &lt;code&gt;DATABASE_URL&lt;/code&gt; environment variable to configure its database-connection. This is important. If you configure your database manually, you will first need to switch to using &lt;code&gt;DATABASE_URL&lt;/code&gt;. For Django, have a look at &lt;a href="https://github.com/jacobian/dj-database-url" rel="noopener noreferrer"&gt;dj-database-url&lt;/a&gt; and the &lt;a href="https://github.com/steuke/heroku-pgbouncer-django-demo/blob/7d20aff9b051995a8f1f8b07083512e695b59df7/pgbouncer_client_demo/settings.py#L10-L11" rel="noopener noreferrer"&gt;sample project&lt;/a&gt;, which makes this very easy. You can check out the sample project to better understand how this can be done.&lt;/p&gt;
&lt;h2&gt;
  
  
  What to Consider Before You Start
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Choosing the right PgBouncer deployment type
&lt;/h3&gt;

&lt;p&gt;PgBouncer can be deployed in different ways. Heroku supports both server-side and client-side deployments. The server-side implementation on Heroku is still in beta, is somewhat restricted on configuration options, and only supports transaction-mode (see next section). Therefore, this guide uses the client-side approach, which deploys PgBouncer on the same dyno as your Django app and gives you more control over each setting.&lt;/p&gt;

&lt;p&gt;If you are unsure which deployment type to use, the &lt;a href="https://devcenter.heroku.com/articles/best-practices-pgbouncer-configuration" rel="noopener noreferrer"&gt;official Heroku documentation will help you decide if client-side deployment is right for you&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Choosing the right PgBouncer pool mode and Django settings
&lt;/h3&gt;

&lt;p&gt;PgBouncer has &lt;a href="http://www.pgbouncer.org/features.html" rel="noopener noreferrer"&gt;three types of connection pool modes&lt;/a&gt;, listed here from most polite to most aggressive connection sharing: session, transaction, and statement mode.&lt;/p&gt;

&lt;p&gt;Here is what you need to know when considering different pool modes for use with your Django app:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Session-mode&lt;/strong&gt; (the connection is returned to the pool only when the user session is closed): This mode is the most conservative. If you use this mode, you do not need to change anything in your Django app. If the other modes do not work with your app, this mode might fix the issues. This mode supports all Postgres features.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Transaction-mode&lt;/strong&gt; (the connection is returned to the pool as soon as the transaction is complete): This is the default mode of the Heroku PgBouncer buildpack. This mode requires you to disable the use of server-side cursors. In Django, disable them by setting &lt;a href="https://docs.djangoproject.com/en/3.0/ref/settings/#disable-server-side-cursors" rel="noopener noreferrer"&gt;DISABLE_SERVER_SIDE_CURSORS = True&lt;/a&gt;. This mode should work with the majority of apps, but note that some important Postgres features, such as prepared statements, listen/notify, &lt;a href="http://www.pgbouncer.org/features.html" rel="noopener noreferrer"&gt;and others&lt;/a&gt;, are not supported. If you use any of those features (or you rely on a library that uses these features), you'll risk breaking your app or straining the performance of some queries.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Statement-mode&lt;/strong&gt; (the connection is returned to the pool as soon as the statement is executed): This is even more aggressive than transaction mode. In this mode, you cannot use multi-statement transactions. Multi-state transactions will result in an error ("server closed the connection unexpectedly"). If you need this mode for certain use cases, consider setting up multiple PgBouncer pools with different settings.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a best practice, start by using transaction-mode and verify that your app still works. After that, feel free to experiment with the other modes and their impact on performance and resource usage. For example, if you experience errors because your app uses features that are not supported, try switching to session-mode. If you don't experience errors, and you want to push your app's performance further, you could try to use statement-mode. &lt;a href="https://devcenter.heroku.com/articles/best-practices-pgbouncer-configuration#pgbouncer-s-connection-pooling-modes" rel="noopener noreferrer"&gt;More details can be found in the Heroku documentation.&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Installing PgBouncer on Heroku Using a Buildpack
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A word of advice: Use a staging environment to follow this guide. Roll this change out to production only after testing your app in a staging environment. Incorrect steps might prevent your app from working until you fix the problem. (You have been warned!)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;OK, let's get started. Follow these five steps to add PgBouncer to your app (in this article, we'll use the &lt;a href="https://devcenter.heroku.com/articles/heroku-cli" rel="noopener noreferrer"&gt;Heroku CLI&lt;/a&gt; for commands):&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Disable use of server-side cursors
&lt;/h3&gt;

&lt;p&gt;In a Django app, simply add &lt;a href="https://github.com/steuke/heroku-pgbouncer-django-demo/blob/01de2fd2af0d4933cabed782066d0d2790bd3e1d/pgbouncer_client_demo/settings.py#L13" rel="noopener noreferrer"&gt;this line&lt;/a&gt; to your settings.py:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DISABLE_SERVER_SIDE_CURSORS = True  # required when using pgbouncer's pool_mode=transaction
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Add the PgBouncer buildpack
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku buildpacks:add heroku/pgbouncer 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Add the python buildpack
&lt;/h3&gt;

&lt;p&gt;In some cases, you have to manually add the python buildpack (or the buildpack for the language you are using). Since there is no harm in doing this, let's do it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku buildpacks:add heroku/python 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4. Change your Procfile so that PgBouncer is launched at startup
&lt;/h3&gt;

&lt;p&gt;If you are using python/Django, then before this change, your Procfile will look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;web: gunicorn your_django_project.wsgi 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change it to something &lt;a href="https://github.com/steuke/heroku-pgbouncer-django-demo/blob/01de2fd2af0d4933cabed782066d0d2790bd3e1d/Procfile#L1" rel="noopener noreferrer"&gt;like this&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;web: bin/start-pgbouncer gunicorn your_django_project.wsgi 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This change will pass your original startup command to the bin/start-pgbouncer script. The script is part of the PgBouncer buildpack. Its main purpose is to change the DATABASE_URL environment variable to point to the local PgBouncer connection pool instead of the original Postgres database.&lt;/p&gt;

&lt;p&gt;This is the reason your Django app must use the DATABASE_URL environment variable to configure the database connection. If you do not use DATABASE_URL, your app will still work, but it won’t be connecting via PgBouncer to your Postgres.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Commit the changes and deploy them to Heroku
&lt;/h3&gt;

&lt;p&gt;Use your favorite git client to commit the changes, and push them to Heroku. Then start looking at the logs with &lt;code&gt;heroku logs -t --source app | grep pgbouncer&lt;/code&gt; while running tests on your app. You should see a series of log-entries similar to these:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2020-04-30T18:59:48.918478+00:00 app[web.1]: 2020-04-30 18:59:48.918 53 LOG C-0x56211ba01900: pgbouncer/pgbouncer@unix(63):6000 login attempt: db=pgbouncer user=pgbouncer tls=no
2020-04-30T18:59:48.919044+00:00 app[web.1]: 2020-04-30 18:59:48.919 53 LOG C-0x56211ba01900: pgbouncer/pgbouncer@unix(63):6000 closing because: client close request (age=0)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations! This indicates that your app is successfully configured and using PgBouncer to connect to Postgres.&lt;/p&gt;

&lt;h3&gt;
  
  
  What did you just achieve?
&lt;/h3&gt;

&lt;p&gt;Your web dyno is now running a PgBouncer instance, which is providing a connection pool to your Django app (running on the same dyno). Your Django app is connecting to this local PgBouncer connection pool instead of directly to the Postgres database.&lt;/p&gt;

&lt;p&gt;In the next section, you'll learn how to monitor PgBouncer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Monitoring PgBouncer
&lt;/h2&gt;

&lt;p&gt;There are several ways to monitor PgBouncer. One common way is to &lt;a href="https://devcenter.heroku.com/articles/postgres-connection-pooling#viewing-connection-pool-stats" rel="noopener noreferrer"&gt;connect to the PgBouncer admin-console using psql&lt;/a&gt;. This section demonstrates two other ways: using Heroku logs and querying the stats from within your Django app.&lt;/p&gt;

&lt;h3&gt;
  
  
  Using Heroku logs
&lt;/h3&gt;

&lt;p&gt;The PgBouncer buildpack is configured to log the PgBouncer stats in one minute intervals. Running the following command shows the most recent stats:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ heroku logs --source app | grep "LOG Stats"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will look similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2020-04-30T19:11:25.720304+00:00 app[web.1]: 2020-04-30 19:11:25.720 54 LOG Stats: 5 xacts/s, 46 queries/s, in 5401 B/s, out 2756 B/s, xact 45640 us, query 992 us wait time 1396 us
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Querying the PgBouncer database from your Django app using SHOW STATS
&lt;/h3&gt;

&lt;p&gt;PgBouncer provides a virtual database containing its stats. This is also referred to as the &lt;a href="http://www.pgbouncer.org/usage.html#admin-console" rel="noopener noreferrer"&gt;Admin Console&lt;/a&gt;. The PgBouncer buildpack provides access to this virtual database via a Unix socket named /tmp, using the username "PgBouncer" and no password.&lt;/p&gt;

&lt;p&gt;Using these credentials, you can retrieve the PgBouncer stats from within your Django app by using the low-level psycopg2 database API. Here is an example function pgbouncer_stats() that retrieves the stats using that API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def pgbouncer_stats() -&amp;gt; List[Dict]:
    try:
        connection = psycopg2.connect(host="/tmp/", port=6000, dbname="pgbouncer", user="pgbouncer",
                                      cursor_factory=extras.DictCursor)
        connection.autocommit = True  # must enable autocommit when querying pgbouncer stats
        cursor = connection.cursor()
        cursor.execute('SHOW STATS')
        pgbouncer_stats = [dict(row) for row in cursor]
        return pgbouncer_stats
    except Exception as e:
        return [{'error': True, 'description': 'Could not query pgbouncer stats.', 'reason': f'{e}'}]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The return value of pgbouncer_stats() is a list of dictionaries, with one dictionary for each database that PgBouncer is pooling:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"pgbouncer_stats":[
  {
    "database":"db1",
    "total_xact_count":220,
    "total_query_count":2750,
    "total_received":330110,
    "total_sent":168517,
    "total_xact_time":15062895,
    "total_query_time":2837299,
    "total_wait_time":84837,
    "avg_xact_count":2,
    "avg_query_count":29,
    "avg_recv":3519,
    "avg_sent":1796,
    "avg_xact_time":68467,
    "avg_query_time":1031,
    "avg_wait_time":904
  },
  {
    "database":"pgbouncer",
    "total_xact_count":110,
    "total_query_count":110,
    "total_received":0,
    "total_sent":0,
    "total_xact_time":0,
    "total_query_time":0,
    "total_wait_time":0,
    "avg_xact_count":1,
    "avg_query_count":1,
    "avg_recv":0,
    "avg_sent":0,
    "avg_xact_time":0,
    "avg_query_time":0,
    "avg_wait_time":0
  }
] 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see that the “db1” database has  a total_xact_count of 220. This indicates that a total of 220 transactions have been processed. &lt;a href="http://www.pgbouncer.org/usage.html#admin-console" rel="noopener noreferrer"&gt;The PgBouncer documentation has the full list of stats and their meaning.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Errors and Things to Watch Out For
&lt;/h2&gt;

&lt;p&gt;How to fix some common problems when starting to use PgBouncer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"FATAL: database 'pgbouncer' does not exist:" The server you are connecting to does not seem to be a PgBouncer-server. Did you add the Heroku buildpack for PgBouncer? Are you using DATABASE_URL to configure your connection? Did you change the Procfile to start PgBouncer?&lt;/li&gt;
&lt;li&gt;"ERROR: no such user: username." This shouldn't happen if you are using the Heroku buildpack. Make sure you are connecting via the Unix socket as user "pgbouncer" without a password. See the &lt;a href="https://www.pgbouncer.org/config.html#authentication-file-format" rel="noopener noreferrer"&gt;pgbouncer-documentation on authentication&lt;/a&gt; for more details.&lt;/li&gt;
&lt;li&gt;You need to disable SSL in Django's database options, i.e. remove any 'sslmode': 'require'. Since you are using the client-side installation, traffic does not leave your machine and should be safe. Alternatively, see the &lt;a href="https://www.pgbouncer.org/config.html" rel="noopener noreferrer"&gt;PgBouncer docs for enabling TLS-support&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;If you connect to multiple Postgres databases, you need to set the PGBOUNCER_URLS environment variable to let PgBouncer know which environment variables it should use for connection pooling. For example, this command tells PgBouncer to create connection pools for DATABASE_URL and EVENT_DATABASE_URL: heroku config:add PGBOUNCER_URLS="DATABASE_URL EVENT_DATABASE_URL"&lt;/li&gt;
&lt;li&gt;If you have requests that need to access large tables with many rows, your app's performance can suffer when you have to disable server-side-cursors. One solution is to use multiple connection pools. You could have one pool in session mode for these large-table requests, while using a second pool in transaction mode for others.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Next Steps: Monitor, Benchmark, and Fine-Tune PgBouncer
&lt;/h2&gt;

&lt;p&gt;At this point, PgBouncer is up and running on your dyno, providing connection pooling to your Django app.&lt;/p&gt;

&lt;p&gt;What should you do next?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure that your app performance is solid. Monitor the PgBouncer stats, keeping an eye on user-facing stats like avg_wait_time, which indicates the time that your app is waiting for connections.&lt;/li&gt;
&lt;li&gt;Perform benchmarks and experiment with the PgBouncer settings, as well as pool-types. One way to do this is by using a load-testing tool that puts your app under increasing load. While the load is increasing, watch PgBouncer's maxwait-stat. If that number is increasingly dramatically, then the pool is not handling client requests quickly enough. You could try increasing &lt;a href="https://github.com/heroku/heroku-buildpack-pgbouncer#tweak-settings" rel="noopener noreferrer"&gt;PGBOUNCER_DEFAULT_POOL_SIZE, reducing PGBOUNCER_RESERVE_POOL_TIMEOUT&lt;/a&gt; or try using a more aggressive pool mode. If none of this helps, maybe the server is running out of resources, which could mean you need to upgrade the Postgres server.&lt;/li&gt;
&lt;li&gt;Familiarize yourself with PgBouncer settings like max_client_conn, default_pool_size, and max_db_connections to tweak your connection pooling.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;PgBouncer is the right tool to help scale your Postgres app when the number of database connections becomes an issue. Keep in mind that while adding PgBouncer to your setup will result in additional complexity for you and your team, taking the time to carefully setup, monitor, and tune your configuration should improve your app's performance.&lt;/p&gt;

</description>
      <category>python</category>
      <category>heroku</category>
      <category>pgbouncer</category>
      <category>django</category>
    </item>
    <item>
      <title>Just a couple of tiny recipes for pipenv</title>
      <dc:creator>Stefan Ukena</dc:creator>
      <pubDate>Sun, 08 Mar 2020 00:00:00 +0000</pubDate>
      <link>https://dev.to/stefanukena/just-a-couple-of-tiny-recipes-for-pipenv-3i3e</link>
      <guid>https://dev.to/stefanukena/just-a-couple-of-tiny-recipes-for-pipenv-3i3e</guid>
      <description>&lt;h2&gt;
  
  
  How to migrate an existing project from requirements.txt to a pipenv Pipfile
&lt;/h2&gt;

&lt;p&gt;This will create a new virtual environment for your current folder and install all requirements from requirements.txt. Put another way: This will "convert" your &lt;code&gt;requirements.txt&lt;/code&gt; into a &lt;code&gt;Pipfile&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run this from the project folder containing the &lt;code&gt;requirements.txt&lt;/code&gt; file.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ touch Pipfile
$ pipenv install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Creating a Pipfile &lt;span class="k"&gt;for &lt;/span&gt;this project…
Requirements file provided! Importing into Pipfile…
Pipfile.lock not found, creating…
Locking &lt;span class="o"&gt;[&lt;/span&gt;dev-packages] dependencies…
Locking &lt;span class="o"&gt;[&lt;/span&gt;packages] dependencies…
✔ Success! 
Updated Pipfile.lock &lt;span class="o"&gt;(&lt;/span&gt;037725&lt;span class="o"&gt;)!&lt;/span&gt;
Installing dependencies from Pipfile.lock &lt;span class="o"&gt;(&lt;/span&gt;037725&lt;span class="o"&gt;)&lt;/span&gt;…
  🐍   ▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉▉ 42/42 — 00:00:07
To activate this project&lt;span class="s1"&gt;'s virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next step: verify that the generated &lt;code&gt;Pipfile&lt;/code&gt; contains all your requirements. &lt;/p&gt;

&lt;p&gt;Feel free to delete the requirements.txt. You can always create a new one by calling &lt;code&gt;pipenv run pip freeze &amp;gt; requirements.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Caveats
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If your &lt;code&gt;requirements.txt&lt;/code&gt; contains &lt;code&gt;-e .&lt;/code&gt; this will be converted to an absolute path in the generated &lt;code&gt;Pipefile&lt;/code&gt;. You probably do not want this, because it will break on other machines with different paths. &lt;em&gt;To fix:&lt;/em&gt; Open your Pipfile and change the absolute path from  &lt;code&gt;file = "file:///Users/..."&lt;/code&gt; simply to &lt;code&gt;file = "."&lt;/code&gt;. (&lt;a href="https://github.com/pypa/pipfile/issues/50" rel="noopener noreferrer"&gt;Source&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Note
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;touch&lt;/code&gt;ing the Pipfile is important, in case you already have a Pipfile in a parent-folder of your current path. &lt;em&gt;This has tripped me up so many times.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to create a virtual environment for a specific version of Python
&lt;/h2&gt;

&lt;p&gt;Obviously, the specified version should be installed on your system first. Pipenv will not handle that for you.&lt;/p&gt;

&lt;p&gt;To use any python 3 version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ touch Pipfile
$ pipenv --python 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use python version 3.8.1:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ touch Pipfile
$ pipenv --python 3.8.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>python</category>
      <category>pipenv</category>
    </item>
  </channel>
</rss>
