Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web site performance - what is it about? Readability and ignorance Vs. Performance

Let me cut to the chase...
On one hand, many of the programming advices given (here and on other places) emphasize the notion that code should always be as readable and as clear as possible, at (almost?!) any pefromance cost. On the other hand there are SO many slow web sites (at least one of whom, I know from personal experience).
Obviously round trips and DB access, are issues a web developer should always keep in mind. But the trade-off between readability and what not to do because it slows things down, for me is very unclear.
Question are-
1.What else?
2.Is there a rule (preferably simple, but probably quite general) one should adhere to in order to make sure his code does not slow things down too much?
General best practices as well as specific advices would be much appreciated. Advices based on experience would be especially appreciated.

Thanks.

Edit: A little clarification: General peformance advices aren't hard to find. That's not what I'm looking for. I'm asking about two things- 1. While trying to make my code as readable as possible, when should I stop and say: "Now I'm hurting performance too much".
2. Little, less known things like- is selecting just one column faster than selecting all (Thanks Otávio)...

Thanks again!

like image 537
Oren A Avatar asked Jan 21 '23 12:01

Oren A


1 Answers

See the Stack Overflow discussion here:

What is the most important effect on performance in a database-backed web application?

The top voted answer was, "write it clean, and use a profiler to identify real problems and address them."

In my experience, the biggest mistake (using C#/asp.net/linq) is over-querying due to LINQ's ease-of-use. One huge query is usually much faster than 10000 small ones.

The other ASP.NET gotcha I see a lot is when the viewstate gets extremely fat and bloated. EnableViewState=false is your best friend, start every new project with it!

like image 177
Scott Stafford Avatar answered Feb 16 '23 02:02

Scott Stafford