concurrent issue
Moderator: General Moderators
concurrent issue
Hello all
In my php application, users will enter urls and I have to keep the information such as time hit, url...I
I donot want to store those information directly into my database as there may be a high number of hits per second. So, first, I write those information into a temporary file (in the server). Then each 10 minutes, this whole data will be added(insert) into database (using cron). The problem here is concurrent issue. When I am reading the file to store the data from the file into database, someone may update the file and some information may be lost. What is the best way to avoid losing data in this case.
Many thanks for any help
sho
In my php application, users will enter urls and I have to keep the information such as time hit, url...I
I donot want to store those information directly into my database as there may be a high number of hits per second. So, first, I write those information into a temporary file (in the server). Then each 10 minutes, this whole data will be added(insert) into database (using cron). The problem here is concurrent issue. When I am reading the file to store the data from the file into database, someone may update the file and some information may be lost. What is the best way to avoid losing data in this case.
Many thanks for any help
sho
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
database is postgres
We use postgresql database for a mobile system. 5000 is too many but sometimes it goes to 500-1000 hits/second (when there is promotion). That why we donot want to update/add directly into database
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
Ya, dumping right to a database is what you should do. Concurrency is handled by the database then. ~feyd made a good point in that the file system will have more problems with 1000 accesses/second than the database will.
If you need to store data quickly, use a database. If your database can't handle it, you need to use a different database or have a dedicated database box. There are pretty much no other options.
If you need to store data quickly, use a database. If your database can't handle it, you need to use a different database or have a dedicated database box. There are pretty much no other options.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.