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
Reminder: Architectural patterns for modular monoliths that enable fast flow
Thursday, September 12, 2024
You are receiving this email because you subscribed to microservices.io This month, I'm teaching an online public workshop Architecting for fast, sustainable flow: enabling DevOps and Team
💎 Issue 434 - NextJS to Rails: The code that powers our new marketing site
Thursday, September 12, 2024
This week's Awesome Ruby Newsletter Read this email on the Web The Awesome Ruby Newsletter Issue » 434 Release Date Sep 12, 2024 Your weekly report of the most popular Ruby news, articles and
💻 Issue 434 - PHP is the new JavaScript?
Thursday, September 12, 2024
This week's Awesome JavaScript Weekly Read this email on the Web The Awesome JavaScript Weekly Issue » 434 Release Date Sep 12, 2024 Your weekly report of the most popular JavaScript news, articles
📱 Issue 428 - Apple's new AI is magically mediocre
Thursday, September 12, 2024
This week's Awesome iOS Weekly Read this email on the Web The Awesome iOS Weekly Issue » 428 Release Date Sep 12, 2024 Your weekly report of the most popular iOS news, articles and projects Popular
💻 Issue 427 - Full .NET 9 support coming in UWP
Thursday, September 12, 2024
This week's Awesome .NET Weekly Read this email on the Web The Awesome .NET Weekly Issue » 427 Release Date Sep 12, 2024 Your weekly report of the most popular .NET news, articles and projects
💻 Issue 434 - How to make your Express.js APIs 9x faster with Encore.ts
Thursday, September 12, 2024
This week's Awesome Node.js Weekly Read this email on the Web The Awesome Node.js Weekly Issue » 434 Release Date Sep 12, 2024 Your weekly report of the most popular Node.js news, articles and
📱 Issue 431 - Swift is a more convenient Rust
Thursday, September 12, 2024
This week's Awesome Swift Weekly Read this email on the Web The Awesome Swift Weekly Issue » 431 Release Date Sep 12, 2024 Your weekly report of the most popular Swift news, articles and projects
💻 Issue 429 - Swift is a more convenient Rust
Thursday, September 12, 2024
This week's Awesome Rust Weekly Read this email on the Web The Awesome Rust Weekly Issue » 429 Release Date Sep 12, 2024 Your weekly report of the most popular Rust news, articles and projects
💻 Issue 352 - Frontend Dev + Data Structures & Algorithms: How DSA Can Power Your React App ⚡
Thursday, September 12, 2024
This week's Awesome React Weekly Read this email on the Web The Awesome React Weekly Issue » 352 Release Date Sep 12, 2024 Your weekly report of the most popular React news, articles and projects
🧑🏻💻 You're Training Your Social Media Algorithm Every Day — What Are Spatial Videos
Thursday, September 12, 2024
Also: Should You Wait for the iPhone 17?, and More! How-To Geek Logo September 12, 2024 Did You Know There is no official definition for the building term "skyscraper," and the term is