<?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: Anshul Attri</title>
    <description>The latest articles on DEV Community by Anshul Attri (@anshul_attri_d0fa9feedb79).</description>
    <link>https://dev.to/anshul_attri_d0fa9feedb79</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%2F3772524%2Fb2c23bf2-0fc5-4e46-b8fc-7ce539af9212.png</url>
      <title>DEV Community: Anshul Attri</title>
      <link>https://dev.to/anshul_attri_d0fa9feedb79</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anshul_attri_d0fa9feedb79"/>
    <language>en</language>
    <item>
      <title>Hi everyone, I need some help.</title>
      <dc:creator>Anshul Attri</dc:creator>
      <pubDate>Sat, 14 Feb 2026 11:07:31 +0000</pubDate>
      <link>https://dev.to/anshul_attri_d0fa9feedb79/hi-everyone-i-need-some-help-6ia</link>
      <guid>https://dev.to/anshul_attri_d0fa9feedb79/hi-everyone-i-need-some-help-6ia</guid>
      <description>&lt;p&gt;All of my microservices need to access these databases.&lt;/p&gt;

&lt;p&gt;To manage this, I created a shared npm package that handles MongoDB/Mongoose connections, and I import and call it in every service inside the index.ts file.&lt;/p&gt;

&lt;p&gt;The problem is: every time a service starts, it creates multiple MongoDB connections, and after some time I can see a lot of open connections in MongoDB, which is not efficient.&lt;/p&gt;

&lt;p&gt;I want to handle this in a professional way, like:&lt;/p&gt;

&lt;p&gt;reusing the same connection (singleton)&lt;/p&gt;

&lt;p&gt;preventing duplicate connections&lt;/p&gt;

&lt;p&gt;handling reconnect logic properly&lt;/p&gt;

&lt;p&gt;managing multiple DBs with one connection&lt;/p&gt;

&lt;p&gt;Can someone guide me on the best practice for managing MongoDB/Mongoose connections in a microservice architecture?&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>microservices</category>
      <category>mongodb</category>
      <category>node</category>
    </item>
  </channel>
</rss>
