[{"data":1,"prerenderedAt":151},["ShallowReactive",2],{"content-svc-lambda-paved-path-java-replatforming-performance":3},{"markdown":4,"frontMatterAttributes":5,"bodyRaw":20,"menu":21,"menuType":147,"isCollapseableMenu":24,"nextDocItem":104,"previousDocItem":65,"contributorPaths":148,"contentName":150,"slug":100,"readingTime":97},"\u003Cp>\u003Cstrong>Function Memory\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>The CPU allocation is directly linked to the memory allocation of the function. Java uses CPU disproportionately at \nstartup to compile classes from byte-code to native machine code. This means that if a Lambda function is starved of CPU\nit will dramatically decrease first invoke latency. If you are unsure of the amount of memory to allocate, start with \n2048MB and test values above and below. The open source project \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Falexcasalboni\u002Faws-lambda-power-tuning\">aws-lambda-power-tuning\u003C\u002Fa> \ncan help you visualize and fine-tune the memory configuration of Lambda functions.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>JVM Options\u003C\u002Fstrong>\u003C\u002Fp>\n\u003Cp>You can set JVM configuration using the environment variable JAVA_TOOL_OPTIONS as described in the \u003Ca href=\"https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Fruntimes-modify.html\">modifying the runtime environment\u003C\u002Fa>. \nFor the vast majority of applications you will want to change the default tiered compilation behavior.\u003C\u002Fp>\n\u003Cpre>\u003Ccode>JAVA_TOOL_OPTIONS=&quot;-XX:+TieredCompilation -XX:TieredStopAtLevel=1&quot;\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cp>For an in-depth explanation of tiered compilation, you can read the blog \u003Ca href=\"https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Foptimizing-aws-lambda-function-performance-for-java\u002F\">Optimizing AWS Lambda function performance for Java\u003C\u002Fa>.\u003C\u002Fp>\n\u003Cp>This optimization may not be suitable if a Lambda function is running for minutes or is repeating the same piece of code\nthousands of times within the same execution. An example would be running Monte Carlo simulations.\u003C\u002Fp>\n",{"title":6,"youtubeVideoID":7,"order":8,"callout":9,"resources":13,"learningGoals":18},"Performance","sVJOJUD0fhQ",2,{"title":10,"description":11,"link":12},"Workshop","Learn how to optimize Java Lambda functions.","https:\u002F\u002Fcatalog.workshops.aws\u002Fjava-on-aws-lambda\u002Fen-US\u002F01-migration",[14],{"link":15,"type":16,"text":17},"https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Foptimizing-aws-lambda-function-performance-for-java\u002F?ref=serverlessland","Blog","Optimizing AWS Lambda function performance for Java",[19],"How to optimization your Java function","**Function Memory**\n\nThe CPU allocation is directly linked to the memory allocation of the function. Java uses CPU disproportionately at \nstartup to compile classes from byte-code to native machine code. This means that if a Lambda function is starved of CPU\nit will dramatically decrease first invoke latency. If you are unsure of the amount of memory to allocate, start with \n2048MB and test values above and below. The open source project [aws-lambda-power-tuning](https:\u002F\u002Fgithub.com\u002Falexcasalboni\u002Faws-lambda-power-tuning) \ncan help you visualize and fine-tune the memory configuration of Lambda functions.\n\n**JVM Options**\n\nYou can set JVM configuration using the environment variable JAVA_TOOL_OPTIONS as described in the [modifying the runtime environment](https:\u002F\u002Fdocs.aws.amazon.com\u002Flambda\u002Flatest\u002Fdg\u002Fruntimes-modify.html). \nFor the vast majority of applications you will want to change the default tiered compilation behavior.\n\n```\nJAVA_TOOL_OPTIONS=\"-XX:+TieredCompilation -XX:TieredStopAtLevel=1\"\n```\n\nFor an in-depth explanation of tiered compilation, you can read the blog [Optimizing AWS Lambda function performance for Java](https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Foptimizing-aws-lambda-function-performance-for-java\u002F).\n\nThis optimization may not be suitable if a Lambda function is running for minutes or is repeating the same piece of code\nthousands of times within the same execution. An example would be running Monte Carlo simulations.",[22,43,62,90,101,113,137],{"title":23,"collapsible":24,"isCollapsed":25,"content":26},"Introduction",false,true,[27],{"title":23,"order":28,"callout":29,"prerequisite":31,"resources":34,"time":39,"path":40,"id":41,"link":42},1,{"title":10,"description":30,"link":12},"The workshop gives you a step-by-step guide of how to migrate a Spring Boot application to Lambda using the AWS Serverless Java Container library.",[32,33],"Some understanding of Java","Some Understanding of AWS Lambda",[35],{"link":36,"text":37,"type":38},"https:\u002F\u002Faws.amazon.com\u002Flambda\u002F","Learn more about Lambda","text","2 min","introduction","introduction.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fintroduction",{"title":44,"collapsible":24,"isCollapsed":25,"content":45},"Access patterns",[46],{"title":47,"order":8,"callout":48,"resources":49,"learningGoals":57,"time":39,"path":59,"id":60,"link":61},"Access Patterns",{"title":10,"description":30,"link":12},[50,54],{"link":51,"type":52,"text":53},"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Faws-lambda-web-adapter","Repo","AWS Lambda Web Adapter",{"link":55,"text":56,"type":52},"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Faws-serverless-java-container","AWS Serverless Java Container",[58],"To learn the different approaches to replatforming REST APIs on Lambda","access-patterns","access-patterns.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Faccess-patterns",{"title":63,"collapsible":24,"isCollapsed":25,"content":64},"SnapStart",[65],{"title":66,"youtubeVideoID":67,"order":8,"callout":68,"resources":71,"learningGoals":85,"time":39,"path":87,"id":88,"link":89},"Performance - SnapStart","ZbnAithBNYY",{"title":10,"description":69,"link":70},"Learn how SnapStart addresses Java function performance, how to enable SnapStart with IaC, and how to customize your SnapStart behavior with runtime hooks.","https:\u002F\u002Fcatalog.workshops.aws\u002Fjava-on-aws-lambda\u002Fen-US\u002F03-snapstart",[72,76,79,82],{"link":73,"text":74,"type":75},"https:\u002F\u002Fserverlessland.com\u002Fpatterns\u002Fapigw-lambda-snapstart","API Gateway to Lambda with SnapStart","Pattern",{"link":77,"type":75,"text":78},"https:\u002F\u002Fserverlessland.com\u002Fpatterns\u002Fapigw-lambda-rds-snapstart","REST API with Amazon API Gateway, Amazon RDS and AWS Lambda with SnapStart",{"link":80,"type":16,"text":81},"https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Fstarting-up-faster-with-aws-lambda-snapstart\u002F?ref=serverlessland","Starting up faster with AWS Lambda SnapStart",{"link":83,"type":16,"text":84},"https:\u002F\u002Faws.amazon.com\u002Fblogs\u002Fcompute\u002Freducing-java-cold-starts-on-aws-lambda-functions-with-snapstart\u002F?ref=serverlessland","Reducing Java cold starts on AWS Lambda functions with SnapStart",[86],"Learn how Lambda SnapStart improves first invoke latency","snapstart","snapstart.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fsnapstart",{"title":6,"collapsible":24,"isCollapsed":24,"content":91},[92],{"title":6,"youtubeVideoID":7,"order":8,"callout":93,"resources":94,"learningGoals":96,"time":97,"path":98,"id":99,"link":100},{"title":10,"description":11,"link":12},[95],{"link":15,"type":16,"text":17},[19],"1 min","performance","performance.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fperformance",{"title":102,"collapsible":24,"isCollapsed":25,"content":103},"Observability - Logging ",[104],{"title":105,"order":8,"callout":106,"learningGoals":107,"time":109,"path":110,"id":111,"link":112},"Observability - Logging",{"title":10,"description":30,"link":12},[108],"How to meet your logging requirements with Lambda","4 min","observability-and-logging","observability-and-logging.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fobservability-and-logging",{"title":114,"collapsible":24,"isCollapsed":25,"content":115},"Observability - Metrics",[116],{"title":114,"order":8,"callout":117,"resources":121,"learningGoals":131,"time":133,"path":134,"id":135,"link":136},{"title":118,"description":119,"link":120},"Watch the video","AWS Lambda Powertools: Lessons from the road to 10 million downloads.","https:\u002F\u002Fwww.youtube.com\u002Fwatch?v=dH2GP6Lydj8",[122,125,128],{"link":123,"text":124,"type":52},"https:\u002F\u002Fawslabs.github.io\u002Faws-lambda-powertools-java\u002Fcore\u002Fmetrics\u002F","Lambda Powertools for Java - Metrics",{"link":126,"text":127,"type":52},"https:\u002F\u002Fawslabs.github.io\u002Faws-lambda-powertools-java\u002F","Lambda Powertools for Java",{"link":129,"text":130,"type":52},"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Faws-embedded-metrics-java","EMF Client Library",[132],"How to efficiently write metrics with Lambda","3 min","metrics","metrics.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fmetrics",{"title":138,"collapsible":24,"isCollapsed":25,"content":139},"Health checks",[140],{"title":141,"order":8,"learningGoals":142,"time":97,"path":144,"id":145,"link":146},"Health Checks",[143],"To understand when to use health checks with Lambda","health-checks","health-checks.md","\u002Fcontent\u002Fservice\u002Flambda\u002Fpaved-path\u002Fjava-replatforming\u002Fhealth-checks","LESSON",[149],"content\u002Fcontributors\u002Fmark-sailes.json","Java Replatforming",1792578874764]