title: AWS Lambda Sporadic "No space left on device" error
body: <p>Amazon Lambda function invocations sporadically fail with <strong>no space left on device</strong> when downloading 20M file to <code>/tmp</code>. The lambda limits page clearly says that the limit for Ephemeral disk capacity (“/tmp” space) is 512M, presumably per lambda invocation, not per lambda function across all its invocation. </p>
  
  <p>Below are the details:</p>
  
  <p>A lambda function (java 8 runtime, role "lambda_basic_execution") is called concurrently (40 concurrent invocations). Each invocation downloads data from s3 (in all cases the data is LESS than the 512M limit). Randomly, 4 to 5 of these invocation fail with <strong>no left space on device</strong> error. I believe some of these invocation end up in the same machine and the same JVM, sharing their limit of 512M ephemeral disk. Sounds like a bug to me. </p>
  
  <p>Here is the stack trace:</p>
  
  <pre><code>.....Caused by: java.io.IOException: No space left on device at java.io.FileOutputStream.writeBytes(Native Method) at java.io.FileOutputStream.write(FileOutputStream.java:326) at java.io.BufferedOutputStream.write(BufferedOutputStream.java:122) at com.amazonaws.services.s3.internal.ServiceUtils.downloadToFile(ServiceUtils.java:295) ... 5 more
  </code></pre>
  
  <p>Any advice or workarounds will be greatly appreciated.</p>
  
  <p>Cross posted here: <a href="https://forums.aws.amazon.com/thread.jspa?threadID=209428" rel="noreferrer">https://forums.aws.amazon.com/thread.jspa?threadID=209428</a></p>