It is hard to believe that after 6 years or so, I still find a bugs in legacy code. In this case, a database connection is not closed after finishing the request. To make a long story short, forgetting to close the connection really slows down the application, and performance goes to the toilet. Who would’ve thunk that?
The interesting fact is that I have been in the code a couple years ago to fix another issue, I missed the blatantly obvious flaw back then. As I think back, the reason that I missed it basically boils down to priority. I was not looking for a fix for a performance issue, but a bug in domain logic. The primary driver to address issues is usually something tangible or visible.
In these past few years, scalability takes a back seat to business needs. That is, until the application performance sinks to the point were users start to notice. That tends to put everyone under the gun and brings scalability immediately to the forefront. Suddenly, people start to pay attention to these issues and new initiatives start.
What I learned: always consider performance and scalability in mind as you start developing your application, no matter how much resistance you get.