<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>andre2x</title><link>https://andre2x.com/</link><description>Recent content on andre2x</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Sat, 17 Oct 2026 00:00:00 +0700</lastBuildDate><atom:link href="https://andre2x.com/index.xml" rel="self" type="application/rss+xml"/><item><title>How To Make Your Database Connection Deadlocked in Golang</title><link>https://andre2x.com/posts/how-to-make-your-database-connection-deadlocked-in-golang/</link><pubDate>Sat, 17 Oct 2026 00:00:00 +0700</pubDate><guid>https://andre2x.com/posts/how-to-make-your-database-connection-deadlocked-in-golang/</guid><description>&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://engineering.idn.media/how-to-make-your-database-connection-deadlocked-in-golang-ed1573d3ebe2"&gt;IDN Media Engineering&lt;/a&gt; on July 30, 2024.&lt;/em&gt;&lt;/p&gt;
&lt;figure&gt;&lt;img src="https://andre2x.com/posts/how-to-make-your-database-connection-deadlocked-in-golang/cover.jpg"
alt="Photo by TopSphere Media on Unsplash"&gt;&lt;figcaption&gt;
&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@zvessels55?utm_source=medium&amp;amp;utm_medium=referral"&gt;TopSphere Media&lt;/a&gt; on &lt;a href="https://unsplash.com?utm_source=medium&amp;amp;utm_medium=referral"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;h2 id="prologue"&gt;Prologue&lt;/h2&gt;
&lt;p&gt;What if every request for your API will open a new database connection and closed the connection after request was finished? In small application maybe it’s okay to do that, but when your API scale up and handle so many request, open and close the connection on every request will be expensive. One of the solution to handle this, is using &lt;em&gt;database connection pool&lt;/em&gt;. Database connection pool is like a “cache” of all database connection, so for every request it doesn’t need to create new connection, just use the available connection. The connection can be reused in the future database operation. For example, on first request in API it will using database connection number 1, second until fourth request will using database connection number 2–4, then on fifth request it will used database connection number 1, no need to create new connection for every request. &lt;strong&gt;Golang&lt;/strong&gt; has already provide built-in &lt;strong&gt;database connection pool&lt;/strong&gt; which can be used to keep connection open for a while and not open/close database connection on every request.&lt;/p&gt;</description></item></channel></rss>