1

I'm developing a Django app that makes a lot of similar queries in different views, and I'm planning on using Redis to speed things up by querying Redis instead of the database.

I was reading the question: How can I use redis with Django? to get started, and at the end of the best voted answer I see the advice: "Don't start using Redis or any other cache until you need the speed - don't prematurely optimize.", and I thought maybe I'm doing things wrong, what does he mean by "don't prematurely optimize"? Is prematurely optimizing going to hurt my app or the developing process? if it does, what should I look for? what metric can I use to decide when it's a good time to use Redis or any other cache?

Community
  • 1
  • 1
chitty
  • 317
  • 1
  • 5
  • 18
  • 1
    Do you understand that, by definition, "premature optimization" means you're spending optimizing code before you should? Therefore, _by definition_ you should not optimize prematurely. There is no need for a "why." – Matt Ball Sep 05 '12 at 19:00
  • @cch - this question is better suited to Programmers.StackExchange.com – Sripathi Krishnan Sep 06 '12 at 04:21

2 Answers2

3

what does he mean by "don't prematurely optimize"?

By prematurely optimizing your solving problems you don't have.

what metric can I use to decide when it's a good time to use Redis or any other cache?

When the UX is impacted because of load times. Or when the UX is impacted in any way it is probably time to start looking.

Adding more technologies could make your build/deployment process more complicated when there is no need for it to be. People (myself included) always think about how many millions of visitors our apps will support and how we will be writing millions of entries everyday to the db, how to efficiently manage all the data and keep queries fast for all our future ghost users. While it is excellent to think about how an app is goign to scale and grow, there is certainly no reason to scale it before necessary. Using django and a trad RDBMS with a well thought out db schema, and correct indexing will probably support your app to larger than it will be.

dm03514
  • 54,664
  • 18
  • 108
  • 145
1

Premature optimization is for the development process, it is considered bad practice to start optimizing early in the development process;

Donald Knuth made the following two statements on optimization:

"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil"

Source Program Optimization see "When to optimize" section

Reinbach
  • 761
  • 4
  • 7