Architecture Weekly #189 - Mastering Database Connection Pooling
Welcome to the new week! This edition is the first one in a new newsletter format! What does that mean?
I know this can be a big change for you; I understand if you won’t like it and unsubscribe, but I genuinely hope you’ll stay with me and appreciate the new way. As I wrote in the previous release, I want to make this newsletter engaging, interesting, and filled with unique content. That takes time. I hope changing the format will help me free up more space to provide you with deep dives into Software Architecture. I think this will benefit you and make working on Architecture Weekly more sustainable for me. A paid subscription also gives you access to exclusive Discord community monthly webinars with access to recordings of all past ones (currently 20 with over 30 hours of content). Check them out here. I want to be fair, so I'm offering you a free month's trial. Here’s the link: https://www.architecture-weekly.com/b3b7d64d. You can check it out and decide if you like it and want to stay. I hope that you will! Feel invited to respond or comment! Still, off we go to Software Architecture! Efficiently managing database connections is crucial for any application that handles multiple requests. Without proper connection management, your application can quickly become slow, unreliable, and costly to maintain. Database connection pooling offers a smarter way to handle database connections. However, connection pooling isn't always ideal, especially in serverless architectures. Let's explore the mechanics of connection pooling, understand its importance, discuss when it might not be suitable, and explore how modern serverless solutions redefine connection management. Life without connection poolingImagine you're building a new e-commerce platform that helps small and medium-sized businesses create and manage their online stores. It provides features like product listings, inventory management, order processing, and customer analytics. Initially, the focus is on delivering basic functionalities like product management and checkout processes. You start with a simple architecture. The backend is written in Node.js and PostgreSQL database. The naive version of your database access code could look as: Each HTTP request opens a new database connection. This can work well for local development or small deployment, but setup quickly hits a wall as your user base grows. Users start complaining about slow load times, and your database server gets overwhelmed by too many open connections. Why does that become a problem? Opening a new database connection for every request involves a time-consuming process involving authentication, network setup, and session establishment. This adds significant latency, especially in high-traffic applications. Your database has a finite limit on how many concurrent connections it can handle. Without pooling, you risk overwhelming the database, leading to resource exhaustion and potential downtime. What is Connection Pooling?Database connection pooling is a technique that allows applications to manage database connections more efficiently by reusing a set of established connections. Instead of creating a new connection for each database request, the application maintains a pool of open connections that can be reused, significantly reducing the time and resources needed to establish connections repeatedly. How Connection Pooling WorksHere's a breakdown of how connection pooling operates in a technical environment:
Do you prefer visuals? There you have it! Connection pooling can significantly enhance performance and reduce latency by eliminating the latency added by setting up a connection each time. Implementing Connection PoolingEach mature development environment has a built-in connection pooling. For instance, for PostgreSQL:
We’ll use the last one to address our connection management-related performance bottlenecks. The code could look as follows:... Unlock this post for free, courtesy of Oskar Dudycz.A subscription gets you:
|
Older messages
Architecture Weekly #188 - 29th July 2024
Monday, July 29, 2024
This time in an unusual edition, we focused on the underestimated aspect of Software Design: resting. We discussed the typical mistakes we do and why repeating them will not help you in making right
Architecture Weekly #187 - 8th July 2024
Monday, July 8, 2024
This week, we discussed the challenges of finding the right architecture strategy and pivoting it when needed. We brought and discussed a few insightful articles on how/when/why to move to serverless,
Architecture Weekly #186 - 1st July 2024
Monday, July 1, 2024
This week, we covered the Polyfill JS supply chain attack that potentially touched 4% of the Internet. We also checked the DataDog report on the state of Cloud Spendings. We discussed whether it's
Architecture Weekly #185 - 24th June 2024
Monday, June 24, 2024
This edition is 50 shaded of coupling! Yeah, I know how that sounds, but we discussed why coupling is not an end goal but a metric to evaluate tradeoffs. We also discussed how to actually make
Architecture Weekly #184 - 17th June 2024
Monday, June 17, 2024
It's a new Monday, the right time for the new set of software architecture materials! This time, we started with visualisations that were made right for great explanations of queuing concepts. I
You Might Also Like
BetterDev #271 - Memory: The Forgotten History and Why did Windows 95 setup use three operating systems?
Wednesday, November 27, 2024
Better Dev #271 Nov 26, 2024 Hi all, Welcome to thanksgiving issue of BetterDev. Hope everyone had a safe and warm thanksgiving. It's getting so cold these days. If you are in warzone such as
Mapped | Unemployment Rate By U.S. State in 2024 💼
Tuesday, November 26, 2024
As of October 2024, DC and Nevada tied for the highest unemployment rate in the US at 5.7%. Which states saw the lowest rates? View Online | Subscribe | Download Our App FINAL CHANCE - ENDS TONIGHT!
🔊 7 DIY Tips for Soundproofing a Room — Why I Switched to Xfce for Linux Mint
Tuesday, November 26, 2024
Also: Home Theater Sound Terms Explained, and More! How-To Geek Logo November 26, 2024 Did You Know The shiny layer of a CD doesn't contain the data; the plastic polycarbonate layer does. The shiny
JSK Daily for Nov 26, 2024
Tuesday, November 26, 2024
JSK Daily for Nov 26, 2024 View this email in your browser A community curated daily e-mail of JavaScript news JavaScript Certification Black Friday Offer – Up to 54% Off! Certificates.dev, the trusted
NumPy, Loop Targets, Vector Animation, and More
Tuesday, November 26, 2024
NumPy Practical Examples: Useful Techniques #657 – NOVEMBER 26, 2024 VIEW IN BROWSER The PyCoder's Weekly Logo NumPy Practical Examples: Useful Techniques In this tutorial, you'll learn how to
Your Games Quarterly newsletter has arrived
Tuesday, November 26, 2024
What's new for games in Google Play and Android Email not displaying correctly? View it online November 2024 The First Developer Preview of Android 16 The First Developer Preview of Android 16
Daily Coding Problem: Problem #1620 [Hard]
Tuesday, November 26, 2024
Daily Coding Problem Good morning! Here's your coding interview problem for today. This problem was asked by Dropbox. Sudoku is a puzzle where you're given a partially-filled 9 by 9 grid with
Final Hours: Help Save "The Art of Data" From Falling Short 🙏
Tuesday, November 26, 2024
Will Visual Capitalist end up revealing the secrets behind data storytelling? There are 12 hours left to change the fate of "The Art of Data". View Online | Subscribe | Download Our App Help
Spyglass Dispatch: Meta's Bluesky • Apple's China AI Problem • Apple's Chinese iPhone Problem • Perplexity Voice Pin • Susan's Message on Lung Cancer
Tuesday, November 26, 2024
Meta's Bluesky • Apple's China AI Problem • Apple's Chinese iPhone Problem • Perplexity Voice Pin • Susan's Message on Lung Cancer The Spyglass Dispatch is a free newsletter sent out
🎁 Say Goodbye to Adobe and Hello to UPDF's Universal PDF Editor— 50% Off This Black Friday!
Tuesday, November 26, 2024
Promoted by UPDF How-To Geek Logo November 26, 2024 This email is sponsored by UPDF. Product choices and opinions expressed are from the sponsor and do not necessarily reflect the views of the How-To