title: How to store real time data in an iOS Swift App
body: <p>the following problem just arised:</p>
  
  <p>A sensor gathers real time temperature values with 5 Hz.
  It sends the values via publish/subscribe to a broker.
  The backend subscribes to the values and stores them in a MongoDB.
  The iOS App subscribes to the values aswell and displays these values in a nice zoomable,scrollable graph.</p>
  
  <p>The iOS App now should provide historical values of that real time data. But I am not sure how to store those data?</p>
  
  <p>Right now I am only storing a fixed amount of values and that works fine so far.</p>
  
  <p>Yes, I could for example provide a REST Api which just gathers the information, BUT scaling this to 30 sensors, this is approximately ~50Mb of Data for 30 minutes.</p>
  
  <p>So I am wondering if I can just store those values somehow. 
  The MongoDB REST answer is 50Mb because of the other Document properties. Storing them in an array should use MUCH less space. (could also change the REST call to only give 1 document back which already has that array).
  Maybe a 3D Array: Minutes X Seconds X Hz ?</p>
  
  <p>Is an array suited for this? Lets say, 150Hz, so for 30 minutes we have 270,000 entries in that array.</p>
  
  <p>Should I maybe provide "5 minutes" Intervals through REST? And when you scroll left in the graph it loads the other data?</p>
  
  <p>Thanks for your help!</p>