You probably already know this, but oh well in case you don't.
To optimize mysql queries, use explain on your queries and modify your database or change your queries to see if you can improve it.
Use ab (apache benchmark utility) to benchmark your script on the server.