[{"data":1,"prerenderedAt":73},["ShallowReactive",2],{"content-svc-lambda-guides-cost-optimization-8-emf":3},{"markdown":4,"frontMatterAttributes":5,"bodyRaw":8,"menu":9,"menuType":64,"isCollapseableMenu":12,"nextDocItem":65,"previousDocItem":54,"contributorPaths":66,"contentName":72,"slug":63,"readingTime":31},"\u003Cp>Many applications benefit from the publication of custom metrics. These metrics may include business performance indicators, technical performance indicators, or other key information requiring measurement. Publishing custom metrics to CloudWatch is frequently used to accomplish this task. The CloudWatch PutMetricData API call from an AWS SDK is a synchronous request. In other words, if you make this call inside your Lambda function, your function will be blocked while it waits for a response, increasing your function duration and consequently your function cost. There is a better and cheaper way to get this data. \u003C\u002Fp>\n\u003Cp>The \u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudWatch\u002Flatest\u002Fmonitoring\u002FCloudWatch_Embedded_Metric_Format_Specification.html\">CloudWatch embedded metric format\u003C\u002Fa> enables you to embed JSON metrics into your structured log events. After the logs are shipped at the end of each invocation they are processed to find data in EMF format. These data are then published as custom metrics to CloudWatch metrics.\u003C\u002Fp>\n",{"title":6,"order":7},"8. Use CloudWatch embedded metric format",8,"Many applications benefit from the publication of custom metrics. These metrics may include business performance indicators, technical performance indicators, or other key information requiring measurement. Publishing custom metrics to CloudWatch is frequently used to accomplish this task. The CloudWatch PutMetricData API call from an AWS SDK is a synchronous request. In other words, if you make this call inside your Lambda function, your function will be blocked while it waits for a response, increasing your function duration and consequently your function cost. There is a better and cheaper way to get this data. \n\nThe [CloudWatch embedded metric format](https:\u002F\u002Fdocs.aws.amazon.com\u002FAmazonCloudWatch\u002Flatest\u002Fmonitoring\u002FCloudWatch_Embedded_Metric_Format_Specification.html) enables you to embed JSON metrics into your structured log events. After the logs are shipped at the end of each invocation they are processed to find data in EMF format. These data are then published as custom metrics to CloudWatch metrics.\n",[10],{"title":11,"collapsible":12,"isCollapsed":12,"content":13},"Top 8 Optimizations",false,[14,21,28,35,42,48,54,60],{"title":15,"order":16,"time":17,"path":18,"id":19,"link":20},"1. Fine-tune Lambda power",1,"4 min","1-fine-tuning","1-fine-tuning.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fguides\u002Fcost-optimization\u002F1-fine-tuning",{"title":22,"order":23,"time":24,"path":25,"id":26,"link":27},"2. Switch to Graviton2",2,"2 min","2-graviton","2-graviton.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fguides\u002Fcost-optimization\u002F2-graviton",{"title":29,"order":30,"time":31,"path":32,"id":33,"link":34},"3. Fine-tune CloudWatch Logs",3,"1 min","3-cloudwatch","3-cloudwatch.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fguides\u002Fcost-optimization\u002F3-cloudwatch",{"title":36,"order":37,"time":38,"path":39,"id":40,"link":41},"4. Don't pay for idle",4,"3 min","4-avoid-idle","4-avoid-idle.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fguides\u002Fcost-optimization\u002F4-avoid-idle",{"title":43,"order":44,"time":17,"path":45,"id":46,"link":47},"5. Filter and batch events",5,"5-filter-and-batch","5-filter-and-batch.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fguides\u002Fcost-optimization\u002F5-filter-and-batch",{"title":49,"order":50,"time":38,"path":51,"id":52,"link":53},"6. Set realistic timeouts",6,"6-set-timeouts","6-set-timeouts.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fguides\u002Fcost-optimization\u002F6-set-timeouts",{"title":55,"order":56,"time":31,"path":57,"id":58,"link":59},"7. Use direct integrations",7,"7-direct-integrations","7-direct-integrations.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fguides\u002Fcost-optimization\u002F7-direct-integrations",{"title":6,"order":7,"time":31,"path":61,"id":62,"link":63},"8-emf","8-emf.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fguides\u002Fcost-optimization\u002F8-emf","LIST",null,[67,68,69,70,71],"content\u002Fcontributors\u002Fdan-fox.json","content\u002Fcontributors\u002Fanton-aleksandrov.json","content\u002Fcontributors\u002Fjosh-kahn.json","content\u002Fcontributors\u002Fdhiraj-mahapatro.json","content\u002Fcontributors\u002Fvamsi-vikash-ankam.json","Cost Optimization for AWS Lambda",1792665272268]