Sorry to say that, but if you’re dealing with connection pools and prepared statements at this stage, maybe Go isn’t a good choice for you. Try something with more built-in solutions, like SpringBoot or even NodeJS. Those already have best practices built in, and you don’t need to invent the wheel, as you had to.

And you’re running out of connections simply because your architecture is wrong. You should have a small amount of constantly running workers consuming the same channel, and preferably writing to DB in batches.

Solutions Architect @Depop, author of “Hands-on Design Patterns with Kotlin” book and “Web Development with Kotlin” course

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store