geek and proud archives |
Friday, November 12, 2004
Speedup
I noticed my site being very slow to load lately. After messing around with it a bit, I came to the conclusion that it was the actual page generation that was being slow, and not the web server or connection. Digging a bit more, I found that most of the slowdown was because of the script I was using to track how many hits my page was getting. It was storing a whole lot more data than necessary, and filling up a MySQL table with far too many records (it was at over 73,000). That’s been fixed. I also cleaned up the database I’m using for the newsfeeds on my sidebars so it deletes old data, and only keeps what it needs to. The boingboing and slashdot tables were at around 2000 lines each. That produced some speedup as well. The page generation time has gone from 2.5-4 seconds to generally under 0.3 seconds. At some point, I’m going to see if I can cut down on the number of database queries I do. That should help bring that number down even lower. [Note: If you’re interested, you can view the source of the page, and see how long it took to get to various points of generation in comments in the HTML.] |
||||
|
It loaded just fine just now!
Y wood u use MySql when the far more robust and efficent MSDE is free? I wood knot use it:)
As a former web project director for many sites my advice to you is to cache, cache, cache. My directive to all web developers was always the same. If you cannot keep your page rendering under 100ms then redo it or cache the data because the site will not scale. Keep you page counts out of the database directly. Cache the counts in memory and persist them at some hit intervals (such as every 5 or 10 hits).
http://dev.mysql.com/doc/mysql/en/INSERT_DELAYED.html
would help you even more