Node.js applications often use relational databases such as MySQL or MariaDB for persistent data.
Use a connection pool for web applications so connections can be reused efficiently. Keep database credentials in environment variables.
Deep dive
Why connection pools matter
Opening a new database connection for every HTTP request is inefficient. A pool maintains a controlled set of reusable connections and helps handle concurrent requests.
Database failure planning
Applications should handle connection failures, query timeouts, unavailable databases, and transient errors without exposing internal database details to users.