title: Can I design a mongo collection which will be updated by many clients?
body: <p>Please see my questions very carefully, thanks.</p>
  
  <p>I designed a collection to store monitor information. The data stored in the collection will be like below:</p>
  
  <pre><code>{
      metric_name: 'physical_memory_used',
      server_name: 'server_a',
      time: timestamp,
      value: 2000
      tag1: value1,
      tag2: value2,
      ...
  }
  </code></pre>
  
  <p><strong>metric_name</strong> is the name of the monitored items like 'physical_memory_used', 'process_count' .. . This is an mandatory field for every document.</p>
  
  <p><strong>server_name</strong> indicate which server did this data comes from. So it is also a mandatory field.</p>
  
  <p><strong>time</strong> stores  the timestamp when the data collected. Also mandatory. But the value of this fields will change frequently. Because I only store the latest data, and I store them every 5 seconds.</p>
  
  <p><strong>value</strong> store the collected value for this monitored item so also mandatory. And it also change very frequently. same reason as the time filed.</p>
  
  <p>Other fields like tag1:value1, tag2:value2 is not mandatory. Because different monitored items may have different attributes. For example: NIC may have a tag:value pair like 'nic_name:eth0' to indicate the nic name.</p>
  
  <p>I create a index on </p>
  
  <pre><code>metric_name
  server_name
  </code></pre>
  
  <p>since this two are the mandatory fields (which means every document have them) and the are not updated frequently like time and value field.</p>
  
  <p><strong>This index is not a unique index since one metric of one server may have multiple documents. For example: The metric nic_io_per_seconds for one server may generate several documents since there may be multiple nics. We use tag:value pairs like nic_name=eth0 to seperate them</strong></p>
  
  <p>Now below are my concern </p>
  
  <pre><code>The collection may be update thousands of servers each seconds.
  
  I will have another system querying the collection every seconds. 
  </code></pre>
  
  <p>The update and query will always use the index i created. </p>
  
  <p>Is this a bad design?</p>
  
  <p>I did a few search and study, think it is ok. Because although the collection will be updated tens of thousands of time every seconds. these updates will be happened on different documents. (different server, different monitored items) so no competition. Also the indexed columns "metric_name", "server_name" will always remain the same value, the are not updated. So should not cause any update on index, so it should be OK.</p>
  
  <p>Regarding the search. although the collection may be very big. but though the index (metric_name, server)we can always get a very little data set.  so performance should be OK</p>
  
  <p>The above are only my guess. I am not sure so ask here. Please give some advice if you have</p>