title: Firestore - Handling documents with >1 writes per second
body: <p>In my database schema, I have documents that, in theory, could exceed the soft limit of one write per second. For example, users can post images and other users can comment on those images. I have all the comments stored on a single document so they can be retrieved in a single query, rather than a document for each individual comment.</p>
  <p>Is this going to cause issues if I have many users writing comments to the &quot;comments&quot; map on the same document at the same time? What can I do to prevent contention. I was already planning to use the dot notation to only update a single nested comment within the comments map at once.</p>
  <pre><code>//firestore schema    
  postTitle: &quot;Test Post&quot;,
  imageLink: &quot;https...&quot;
  comments: {
          {uuid}: {
                   &quot;userId&quot;: &quot;user12321321&quot;
                   &quot;createdDate&quot;: &quot;2022-07-06T10:13:14&quot;
                   &quot;comment&quot;: &quot;lorem ipsum...&quot;
          }
          {uuid}: {
                   &quot;userId&quot;: &quot;user32902394&quot;
                   &quot;createdDate&quot;: &quot;2022-07-06T10:13:14&quot;
                   &quot;comment&quot;: &quot;lorem ipsum...&quot;
          }
          ...
      }
  
  //javascript
  //(I didn't write the JS code below in an IDE or test it so there might be syntax issues with 
  // it)
  const res = await db.collection('posts').doc('randomPostId').update({
        'comments.{uuid}': {
            &quot;userId&quot;: &quot;user12213214&quot;
            &quot;createdDate&quot;: &quot;2022-07-06T10:13:14&quot;
            &quot;comment&quot;: &quot;New comment created here...&quot;
        }
      });
  </code></pre>