Autosurf script that is written on PHP and runs on MySQL server. After using the script for a couple of months with more than 5,000 users, realised that the script is not very efficient in utilizing my server's resources. Have a dedicated 2.6 Xeon and 2GB of RAMS, yet my script is hitting the limits. Causing page time outs, MySql service to stop/hang.
Urgently need to optimize the script to reduce the server load. Think the script is poorly written and not closing sql connections as I'm not a programmer myself. Attached is the entire script for those interested in taking up this project.
Description of the autosurf script:
Users sign up as a user. Users have to surf up to 50 sites a day to earn credits to advertise their own sites and also earn some money.
Users run '[login to view URL]'. There's a 20 sec timer (javascript) that will rotate randomly to the next site on the database. What happens here is each time the timer runs out to 0, it will update the database that the user have surfed 1 site, credits the user by 1 credit, reads the database to pull out a new site for the user to view, and deduct the site owner's credits by 1. This goes on until the user hits 50 credits, then the script will compute the user's earnings for that day and updates the appropriate table fields.
Thinking to change the script to updates the database once every 5 or 10 sites (configurable by me). Also to store sites to be viewed on a local cache or cookie so that it will read from the local machine instead of the database every 20 seconds.
Feel free to comment or ask me any questions.
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
Runs on apache web server, PHP and MySql with a bit of javascript.