title: Does AWS Lambda charge for the time spent initializing code?
body: <p>If my Lambda function written in Python takes 1.8 seconds to initialize (during a cold start) and 400 ms to execute, am I charged for the 400 ms execution time or the entire 2.2 seconds of initialization + execution time?</p>
  
  <p>From X-Ray, I see:</p>
  
  <p><a href="https://i.stack.imgur.com/T3FSQ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/T3FSQ.png" alt="AWS X-Ray trace"></a></p>
  
  <p>From CloudWatch logs, I see:</p>
  
  <pre><code>Duration: 404.42 ms Billed Duration: 500 ms Memory Size: 448 MB Max Memory Used: 113 MB
  </code></pre>
  
  <p>What I understand from this is that I was billed for 500ms of execution time, so does that mean code initialization (e.g. importing stuff) is free?</p>