Wednesday, December 9, 2009

Coding Plays a Big Role in Site Speed

Ok, one of my larger site which receives around 4000 unique visitors per day is having problems again recently, this time it's caused by Mysql database. My website have a large user base, it has around 150,000 members and it's increasing daily. In all honest, I have no idea if the slowness of my site was caused by the constant mysql connection or the VPS hosting I'm with is just slow. If you have been keeping track of my blog, you know I just moved from shared hosting to VPS a month ago. At first, the server was fast and I'm happy with it, but recently it's taking longer and longer to load. The average of the site speed was 13 seconds, and sometime it can be as long as 30 seconds plus! The recommend loading speed of a site should be less than 4 seconds on a 10mbps connection or visitors might just click back and go to other sites. It'll take longer to load if the visitors are on DSL or dial-up connection. So if you sites are slow, it's something you should be worried about.

Anyway I asked my hosting about the issues and I was told it was caused by high loads of Mysql database. Some of the processes are not dying off and it's eating up a lot of CPU resources. After numerous communication and fixing the database, it does seems to be improving but the average speed of the server still stay at around 8 seconds which is extremely slow for a VPS server. Hey I pay 4.99 per month on a shared hosting and it even run faster than my current Vps which I pay 49.90 per month. If there isn't any concurrent limitation on a shared hosting, I'd definitely considered going back. In the end, I still haven't figure it out what is really causing the slowness of the site, I attempt to close a few more function on the site to test the speed. Every time I send a new ticket to the support, they always come back with new excuses. Even picking on queries that don't run very often. I'm not a programmer or expert in these hosting thing, so I'm not sure if what they are telling is truth or not. Maybe it's possible that my site coding is causing the problem, but is it enough to make a VPS server this slow? I have already killed off a lot of unnecessary queries in the database, but it's not helping a lot. What baffled me was it run fine before and I haven't change anything, why so slow all of a sudden. I can understand If it was slow on peak hours, but the server seems to be slow all of the time. That just doesn't make sense.

I have thought about moving to another provider, if it wasn't for the huge files I have, I think I've already moved. As for now, all I can do is try to optimize my script and database and hope it'll get better soon. Worst come to worst I can just find another hosting and move, that's really the last resort I'd want to take. I'll let you know if I find the real causes of this slowness.

What I want you to know is that coding plays a major role when you have huge database and visitors. One bad line of code could affect the speed of your site. Remember to close Mysql process at the end of the code, and set a timeout to kill off processes running in the background.

No comments:

Post a Comment