title: DynamoDB: How to distribute workload over the month?
body: <p><strong>TL;DR</strong></p>
  
  <p>I have a table with about 2 million WRITEs <strong>over</strong> the month and 0 READs. Every 1st day of a month, I need to read all the rows written on the previous month and generate CSVs + statistics.</p>
  
  <p>How to work with DynamoDB in this scenario? How to choose the READ throughput capacity?</p>
  
  <p><strong>Long description</strong></p>
  
  <p>I have an application that logs client requests. It has about 200 clients. The clients need to receive on every 1st day of a month a CSV with all the requests they've made. They also need to be billed, and for that we need to calculate some stats with the requests they've made, grouping by type of request.</p>
  
  <p>So in the end of the month, a client receives a report like:</p>
  
  <p><img src="https://i.stack.imgur.com/J6EK1.png" alt="Full list of requests"></p>
  
  <p><img src="https://i.stack.imgur.com/XXPUX.png" alt="Billing Summary"></p>
  
  <p>I've already come to <strong>two solutions</strong>, but I'm not still <em>convinced</em> on any of them.</p>
  
  <p><strong>1st solution</strong>: ok, every last day of the month I increase the READ throughput capacity and then I run a map reduce job. When the job is done, I decrease the capacity back to the original value.</p>
  
  <p><strong>Cons</strong>: not fully automated, risk of the DynamoDB capacity not being available when the job starts.</p>
  
  <p><strong>2nd solution:</strong> I can break the generation of CSVs + statistics to small jobs in a daily or hourly routine. I could store partial CSVs on S3 and on every 1st day of a month I could join those files and generate a new one. The statistics would be much easier to generate, just some calculations derived from the daily/hourly statistics.</p>
  
  <p><strong>Cons</strong>: I feel like I'm turning something simple into something complex.</p>
  
  <p>Do you have a better solution? If not, what solution would you choose? Why?</p>