title: Storing large amount of data in Redis / NoSQL or Relational db?
body: <p>I need to store and access financial market candle stick information.</p>
  
  <p>The amount of candles sticks that I will need to store is beginning to looking staggering (huge). There are 1000s of markets and each one has many trading pairs, and each pair has many time frames, and each time frame is an array of candles like the below. The array below could be for hourly price data or daily price data for example.</p>
  
  <p>I need to make this information available to multiple users at any given time, so need to store it and make it available somehow.</p>
  
  <p>The data looks something like this:</p>
  
  <pre><code>[
      {
          time: 1528761600,
          openPrice: 100,
          closePrice: 20,
          highestPrice: 120,
          lowesetPrice:10 
      },
      {
          time: 1528761610,
          openPrice: 100,
          closePrice: 20,
          highestPrice: 120,
          lowesetPrice:10 
      },
      {
          time: 1528761630,
          openPrice: 100,
          closePrice: 20,
          highestPrice: 120,
          lowesetPrice:10 
      }
  ]
  </code></pre>
  
  <p>Consumers of the data will mostly be a complex Javascript based charting app, but other consumers will be node code, and perhaps other backend code.</p>
  
  <p>My current best idea is to put save the candlesticks in Redis, though I have also considered a noSQL database. I'm not super experienced in either, so I'm not 100% sure Redis is the right choice. It seems to be the most performant option though, but perhaps harder to work with, since I am having to learn a lot, and I'm not convinced that the method of saving and retrieval used by Redis is going to make this very easy since, I will need to continually add candles to each array.</p>
  
  <p>I'm currently thinking something like:</p>
  
  <p>Do an initial fetch from the candle stick api and either:</p>
  
  <ol>
  <li>Create a Redis hash with a suitable label and stingify the whole array of candles into the hash, so that it back be parsed by Javascript etc</li>
  </ol>
  
  <p>Drawbacks of this approach: </p>
  
  <p>Every time a new candle is created, I have to parse the json, add any new candles sticks and stringify and save it.</p>
  
  <p>Pros of this approach:</p>
  
  <p>I can use Javascript to manage the array and make sure it's sorted etc</p>
  
  <ol start="2">
  <li>Create a Redis list of time stamps, which allows me to just push new candles onto the list and trust it to be in the right order. I can then do a Redis SCAN? to return time stamps between the specific dates and then use the time stamps to pull the data out of a Redis hash. After retriveng all of this, then building a json object similar to above to pass to Javascript.</li>
  </ol>
  
  <p>I have to say that both of these approaches feels way more painfull to me putting the data in a relational database. I imagine that a no-SQL database could also be way easier, but I'm not experienced with them, so I can't say for sure.</p>
  
  <p>I'm a bit lost and out of my experience here, as you can tell, and would love any advice anyone can give me.</p>
  
  <p>Thanks :)</p>