Good people,
Instead of blaming the poor techie over at KNEC for the slow app, lets give him/her some practical tips...
High Performance Website/Webapplication 101
1. Server
- Get the fastest server you can with the budget you have, fastest processor, as many cores as you can get
- Make sure the hard disk RPM is the highest you can get, let 7200 be the minimum
- Get bucketloads of RAM, we talking about 8GB minimum here.
- Separate the web server from the database server, let each be on its own superfast, kick ass server (see first three points above)
- Connect the database server directly to the webserver via a factory made cross over cable; this will save you a few micro seconds per request
- If possible, rent several extra servers; maybe three for Apache (yes, I know you use Apache with ServerSignature On) and three for the database, then use appropriate load balancing apps to distribute load over the other servers
- If more servers are not an option, then when the time for releasing results comes, give 98% of the staff at KNEC compulsory leave and take their PCs, then make all of them act like one big nasty swarm.
- Optimize the CentOS for speed
- ...
2. Webserver
- Let Apache sit on its own server, maybe two servers, maybe three. If more than one, use a load balancer.
- Deactivate modules you dont need, like support for perl, python and etc
- Oh yeah, you might want to change ServerSignature to something less "revealing" to the casual browser
- ...
3. Database
- I am guessing you are using MySQL, if not, ignore this section.
- IMHO, MySQL is happiest when swimming in an ocean of RAM on a superfast HDD.
- Make sure to test the options in my.cnf coz the defaults may not always be the best.
- Let EXPLAIN query_here be your close friend. Explain each and every query and make the necessary changes. There is a ka-column called "rows scanned" or sth like that, let this be as low as possible, 1 being the magical number
- Explain will reveal unused indices or missing indices. The philosophy is use is that most columns used in WHERE clauses should have indices
- Make sure you have enabled the slow query log, set it to something low like 5 seconds, then monitor it like a baby. Any query which shows up in the slow query log is your enemy and you need to fix it ASAP.
- If you have the skill, setup replication across several servers and modify your application to take advantage of your replication. I am guessing since you dont have much writes to the database after the results have been released, setup one server as the Master, then several servers as the slaves and direct all your reads to the slaves.
- Head over to quest software and download Spotlight on MySQL/SQL Server/Linux and use it to watch your database and the underlying OS. Not only does it make the data easy to ingest, but it also looks amazingly cool!
- ...
4. PHP
- Be frugal, dont create variables unless you really need to, it might save you a bit of RAM
- Profile your code, remove dead sections.
- Run PageSpeen against each page, and fix the issues it points out.
- Test test test!
- ...
5. Others
- Now, as skunk Phares will tell you, you dont really need many servers, you can get like 2 behemoths and virtualize the hell out of them!
- The skunk Odhiambo will tell you, FreeBSD has the fastest TCP/IP stack this side of the Universe, so you might want to run your Apache off that
- Some other better placed skunks will also tell you how to make your network super fast
- And most def some other skunk will tell you how to make your non-mysql database even faster.
- ....
6. ....