0

I will make my question very simple.

I have a ruby on rails app, backed with mysql.

  1. I will click a button in page-1, it will goto page-2 and list a table of 10 company's name.

  2. 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.

  3. 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.

  1. 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.

  2. Memcache the count and bulk insert into the DB.

What is the best way to do it in rails?

Are there any other ways to do this?

beck03076
  • 3,268
  • 2
  • 27
  • 37
  • Can you give me any links which explains how to implement it and discusses its advantages as well..? – beck03076 May 10 '12 at 14:51
  • How many times will page-2 be displayed on a day? Seems you are looking for optimizations that are probably not necessary. I doubt your load will be so high that just using the database will be a problem. – Mischa May 27 '12 at 02:34

1 Answers1

1

use redis. redis is good for maintaining in-memory data. It has atomic increment (an other data structures)

deepak
  • 7,230
  • 5
  • 24
  • 26