1 00:00:00,170 --> 00:00:02,090 ‫So we have learned a lot on Lambda 2 00:00:02,090 --> 00:00:02,923 ‫in this section 3 00:00:02,923 --> 00:00:04,350 ‫and that was necessary going to the exam. 4 00:00:04,350 --> 00:00:08,190 ‫So just some final words of wisdom before we leave you. 5 00:00:08,190 --> 00:00:09,620 ‫So best practices. 6 00:00:09,620 --> 00:00:11,180 ‫You need to perform heavy duty work 7 00:00:11,180 --> 00:00:12,720 ‫outside of your function handler 8 00:00:12,720 --> 00:00:16,170 ‫to minimize the amount of time your handler will run for. 9 00:00:16,170 --> 00:00:18,030 ‫So that means that you need to connect your databases 10 00:00:18,030 --> 00:00:19,650 ‫outside of your function handler, 11 00:00:19,650 --> 00:00:22,860 ‫initialize the AWS SDK outside of your handler again 12 00:00:22,860 --> 00:00:24,780 ‫and building any dependencies or datasets, 13 00:00:24,780 --> 00:00:27,210 ‫again, outside of your function handler. 14 00:00:27,210 --> 00:00:28,880 ‫You should use environment variables 15 00:00:28,880 --> 00:00:31,430 ‫for anything that is going to be changing over time. 16 00:00:31,430 --> 00:00:32,960 ‫So your database connection strings, 17 00:00:32,960 --> 00:00:35,060 ‫your S3 bucket name, et cetera, et cetera. 18 00:00:35,060 --> 00:00:37,090 ‫Do not put these values in your code. 19 00:00:37,090 --> 00:00:38,980 ‫And for password and sensitive values, 20 00:00:38,980 --> 00:00:42,430 ‫you can encrypt these environment variables with KMS. 21 00:00:42,430 --> 00:00:45,040 ‫Next, you should minimize your deployment package size 22 00:00:45,040 --> 00:00:46,750 ‫to its runtime necessities. 23 00:00:46,750 --> 00:00:48,950 ‫So that means that if your function is too big, 24 00:00:48,950 --> 00:00:50,200 ‫please break it down. 25 00:00:50,200 --> 00:00:51,990 ‫Also, remember the Lamda limits 26 00:00:51,990 --> 00:00:53,920 ‫for your package size and so on. 27 00:00:53,920 --> 00:00:56,360 ‫And if you need to reuse some libraries, 28 00:00:56,360 --> 00:00:58,910 ‫think of leveraging Lambda layers. 29 00:00:58,910 --> 00:01:01,040 ‫And finally, avoid recursing code. 30 00:01:01,040 --> 00:01:04,100 ‫Okay, never have a Lambda function call itself. 31 00:01:04,100 --> 00:01:05,270 ‫That is going to be a disaster 32 00:01:05,270 --> 00:01:07,680 ‫and is going to be very expensive for you. 33 00:01:07,680 --> 00:01:09,570 ‫Okay, so that's it for this lecture. 34 00:01:09,570 --> 00:01:12,503 ‫I hope you liked it and I will see you in the next lecture.