Performance, like any other feature, doesn’t just “happen”; it has to be designed and built. To do performance well, you have to think about it, study it, write extra code for it, test it, and support it.
…
Since you can’t know how your application is going to perform in production, you need to write your application so that it’s easy to fix performance in production.
From one of my favorite papers on performance: Thinking Clearly About Performance, by Cary Millsap.