Skip to main content

What are the Serverless Best Practices in Cloud Computing

Page 1


What are the Serverless Best Practices in Cloud Computing?

Serverlesscomputingisgenerallymeanttobeacomputingsystemwhereyouwritethecode,upload thisanditrunswithoutmanaginganyoftheservers.Therewillbenoneedofoperatingsystemto configure.Justyourcodedoingitsjob.Whenyouworkwithserverlessforalongtime,yourealizethatit alsohasitsownbenefitsandchallenges,whichcancauseproblemsifyouarenotpreparedforthem.

Inthisarticle,wewilldiscussindetailtheserverlessbestpracticesincloudcomputingindetail.Ifyou arelookingtolearnthis,applyin Cloud Computing Course Online. Hereyoucanlearneverything aboutcloudcomputingbyyourself.Sothisguideisvaluableforbeginnerswhoarethinkingofadvancing theircareerinthisfield.

Serverless Best Practices in Cloud Computing: Thesearesomeofthebestpracticesincloudcomputingthatoneneedstounderstand.Well,peoplewho applyforthe Cloud Computing Course in Gurgaon canlearnthemandimplementtheminpractice:

Write Small Functions That Do One Thing

Itcouldbethemostimportantrule.Sodon’twritethefunctionsthatarebigandtrytodoeverything. Well,eachofthefunctionsshouldhandleonespecialtaskandnothingelse.Sowhenyouputtoomuch intoonefunction,debuggingbecomeshard.Itmayresultinbreakingandyouarediggingthrough hundredsoflinesfortryingtofindtheproblem.

Coldstartshappenwhenyourfunctionhasn'truninawhile,andthecloudproviderneedstoloadit fromscratch.Smallerfunctionswakeupfaster,thathelpusersgettheirresponsesquicker.People studyingin Cloud Computing Training in Bangalore spendahugeamountoftimelearningabouthow todesignfunctionsproperlybecauseitmakessuchahugedifference.

Deal with Cold Starts

Coldstartswillfrustrateyouatsomepoint.There'snomagicfixthateliminatesthem.Butyoucan reducetheirimpactquiteabit.

First,keepyourcodelean.Don'timportlibrariesyou'renotusing.Everyextramegabyteofcodemeans moretimetoload.Stripouttheunnecessarystuff.Somepeoplepingtheirfunctionseveryfewminutes tokeepthemwarm.Thismaywork,butyouhavetopayforthepings.Alsoyouneedtodecidewhether thefastresponseisworththeadditionalcost.

Forthemostimportantfunctionsthatneedtorespondfast,mostcloudprovidersoffersomethingcalled provisionedconcurrency.Youbasicallypaytokeepsomefunctioninstancesalwaysrunningandready. Itcostsmoremoney.

Set Timeouts and Memory Correctly

Don'tjustacceptwhateverdefaultsettingsyourcloudprovidergivesyou.Actually,thinkaboutwhat eachfunctiondoesandconfigureitproperly.Afunctionthatvalidatesanemailaddressprobablyonly needsafewseconds.Afunctionthatprocessesalargevideofilemightneedseveralminutes.Settingthe righttimeoutpreventsrunawayfunctionsfromeatingyourbudget.

Memoryistrickier.Serverlessplatformschargebasedonbothmemoryandhowlongthefunctionruns. Morememorymakesyourfunctionfasterbutcostsmorepersecond.Lessmemoryischeaperper second,butthefunctionrunslonger.Youhavetotestdifferentsettingstofindthebalancethatactually coststheleastoverall.Youcanlearnabouthowtomanagethesecostsbytakingthe Cloud Computing Certification Course becausegettingitwrongwastesseriousmoney.

Expect Things to Fail

Yourfunctionswillfailsometimes.Networksgodown.Databasestimeout.APIsyou'recallinghave outages.Yourcodeneedstohandlethisreality.

Buildinretrylogic.Ifsomethingfails,waitamomentandtryagain.Ifitfailsagain,waitabitlongerand tryoncemore.Don'timmediatelygiveuponthefirstfailure.

Whensomethingfailsrepeatedlyandretriesaren'tworking,youneedadeadletterqueue.Thisis basicallyaholdingareaformessagesthatcouldn'tbeprocessed.Youcancheckitlatertoseewhatwent wrongandfixtheunderlyingissue.Withoutthis,failedmessagesjustdisappear,andyoulosedata.

Lock Down Security

NeverputpasswordsorAPIkeysdirectlyinyourcode.Anyonewhoseesyourcodeseesthose credentials.Useenvironmentvariablesorthesecretmanagementtoolsyourcloudprovideroffers.

Giveeachfunctiontheminimumpermissionsitneedstodoitsjob.Afunctionthatreadsdatafroma databasedoesn'tneedpermissiontodeletedata.Afunctionthatuploadsfilesdoesn'tneedpermission towipeoutyourentirestoragebucket.

Checkeverythingthatcomesintoyourfunction.Don'ttrustanyinput.Validateitall.Badinputcancrash yourfunctionor,worse,createsecurityholes.

Conclusion

Serverlessispowerful,butthisisnotautopilot.Youstillneedtodesigncarefully,monitorclosely,and optimizethisconstantly.Whenyoufollowthesepracticesitcansaveyoufromthepainfuldebugging sessionsandbudgetoverruns.Whateverthecourseyoutakeorlearnthroughtheexperience,these basicsgetappliedeverywhere.

Turn static files into dynamic content formats.

Create a flipbook
What are the Serverless Best Practices in Cloud Computing by Laxmikant Mishra - Issuu