I will make my question very simple.
I have a ruby on rails app, backed with mysql.
I will click a button in page-1, it will goto page-2 and list a table of 10 company's name.
Now, this list of ten companies are randomly generated(based on the logic behind that clicked button in page-1) from COMPANIES table which has 10k company names.
How do I calculate the count of the number of times a COMPANY name being displayed on page-2, for a day.
Examaple: At the end of day - 1
COMPANY_NAME | COUNT
A | 2300
B | 100
C | 500
D | 10000
Now, from the research I have done, raw inserts will be costly and I learned there are 2 common ways to do it.
Open an unix file, write into it. At the end of the day, INSERT the content to the database. Negative : File system if accessed concurrently, it will lead to lock issues.
Memcache the count and bulk insert into the DB.