0

I have a Rails application that allows users to buy and use phone numbers (via Twilio) for marketing campaigns.

Currently, when they navigate to the 'calls' section of the app, I'm making live API calls to Twilio to retrieve all their call data for a specific number (to, from, duration,etc.). While this works ok for 20 or so users, I know its not a long term solution.

I'd like to grab the necessary data from a callback once each phone call ends and store it in a model or use a worker to go out and pull down all the call info at the end of each day and save it to a model.

What would be the best way to store this data? Let's assume a number gets 200 calls a day (they range from 20-400+ calls/day).

I don't think I should create a separate record for each of those 200 calls each day (please correct me if I'm wrong in thinking that).

I was thinking of creating a serialized text column in a table that would store a hash of hashes with all the calls and call info for each number but is that ok to have a hash of hashes that large?

Ex.

calls = {:"800-123-6798"=>{:to=>415-111-0000, :from=>415-111-2222, :duration=>240}, :"800-123-6798"=>{:to=>415-222-0000, :from=>415-222-3456, :duration=>345}

Am I missing a better solution?

macoughl
  • 591
  • 2
  • 5
  • 17
  • How do you need to *access* the data? Is not clear what info you actually need to store, and how data relates to other data. – Dave Newton Mar 06 '15 at 23:35
  • I need to store the 'to, from, duration' data. That data will only need to be called up by a controller for the view to get the hash for a table – macoughl Mar 06 '15 at 23:38
  • How many users are we talking about? 200 records/day is not that much. Why do you want to avoid creating one record per call? This seems to me to be the most straight forward method. MYSQL can handle quite large data sets: http://stackoverflow.com/questions/1276/how-big-can-a-mysql-database-get-before-performance-starts-to-degrade – Albin Mar 09 '15 at 15:32
  • Thanks Albin. It is a postgres DB (not sure if that changes how you think about it). Right now, its 263 users that get an avg of 200 calls/day each. That is over 1.5m records/month which is why I am concerned. I'm also looking to grow that user base significantly. – macoughl Mar 09 '15 at 18:21

0 Answers0