Ukuvavanya iMicroservices-Isikhokelo saBaqalayo

Ukuvavanya iiMicroservices kuya kusiba ngakumbi kwaye kubaluleke ngakumbi njengoko uninzi lwezicelo ezitsha zakhiwa kusetyenziswa uyilo lweMicroservices.

Ngaphambi kokuba sikwazi ukubona ukuba sivavanya njani ii-microservices, kufuneka kuqala siziqonde ukuba ziyintoni na.



Yintoni iMicroservices?

I-Microservice ichazwa njengesitayile sokwakha, indlela yokuphuhlisa isicelo esinye njengesixhobo seenkonzo. Inkonzo nganye ichazwa ziimpawu zayo ezinye zezi:


  • Ibaleka kwinkqubo yayo.
  • Ukunxibelelana ngesixhobo esingasindi rhoqo ngesixhobo se-HTTP API.
  • Ukuzimela ngokuzimeleyo ngoomatshini abazenzekelayo.
  • Sebenzisa iilwimi ezahlukeneyo zenkqubo / iitekhnoloji / i-DB.
  • Usebenzisa iitekhnoloji ezahlukeneyo zokugcina idatha.

Isitayile se-microservice yoyilo kubandakanya ukuphuhlisa usetyenziso olunye olunokuthi lusebenze kunye njengeseti yeenkonzo ezincinci, nganye isebenza kwinkqubo yayo kunye nokunxibelelana neendlela ezingasindi ezifana ne-API yezixhobo ze-HTTP. Ezi nkonzo zifuna ulawulo olungenanto olusisiseko, sebenzisa ubuchwepheshe bokugcina idatha eyahlukeneyo, kwaye inokubhalwa kwiilwimi ezahlukeneyo zenkqubo. Ezi nkonzo, ezakhelwe kubuchule beshishini, zinokuhanjiswa ngokuzimeleyo ngoomatshini abaxhasa ukuthunyelwa okuzenzekelayo.

Iimpawu zeMicroservices:


  • Uququzelelwe malunga nokukwazi ukuqhuba ishishini,
  • Ukuthunyelwa ngokuzenzekelayo,
  • Ubukrelekrele kwiindawo zokuphela kunakwibhasi yenkonzo,
  • Ulawulo olusasazwayo lweelwimi kunye nedatha.


Yahluke njani iMicroservices kwi-SOA

  • Uyilo olujolise kwinkonzo (SOA): ipateni yoyilo kuyilo lwekhompyuter apho izinto zesicelo zibonelela ngeenkonzo kwamanye amacandelo ngomgaqo wonxibelelwano, ubukhulu becala ngaphezulu kwenethiwekhi.
  • IiMicroservices Isitayile sokwakha isoftware apho izicelo ezintsonkothileyo zenziwe ziinkqubo ezincinci, ezizimeleyo ezinxibelelana nabanye zisebenzisa ii-API zolwimi

Umzekelo:

Ukuba u-Uber wakhiwe nge-SOA, iinkonzo zabo zinokuba:

  • GetPaymentsAndDriverInformationAndMappingDataAPI
  • UqinisekisoUsersAndDriversAPI

Ukuba i-Uber yakhiwe ngee-microservices, ii-API zazo zinokufana ngakumbi:

  • NgenisaIinkonzo zeeNtlawulo
  • GetDriverInfoService
  • GetMappingDataService
  • Iinkonzo zoQinisekiso
  • UkuQiniseka kweDriveService

Ii-API ezininzi, iiseti ezincinci zoxanduva.




Uyivavanya njani iMicroservices

Uvavanyo lweyunithi

Uvavanyo lweyunithi lusebenzisa amaqhekeza amancinci esoftware njengomsebenzi kwisicelo ukumisela ukuba ngaba zivelisa imveliso oyifunayo enikezwe iseti yegalelo elaziwayo.

Kubalulekile ukuba uqaphele ukuba ukuvavanywa kweyunithi kukodwa akuniki ziqinisekiso malunga nokuziphatha kwenkqubo. Sifuna ezinye iintlobo zokuvavanya ii-microservices.

Uvavanyo lwecandelo

Nje ukuba sivavanye iyunithi yonke imisebenzi ngaphakathi kwemicroservice, kuya kufuneka siyivavanye imicroservice uqobo.

Ngokwesiqhelo, isicelo siyakwenziwa ngenani lee-microservices, ke ukuze sivavanye sodwa, kufuneka sihlekise ngezinye ii-microservices.


Uvavanyo lwecandelo luza kuvavanya ukusebenzisana kwemicroservice kunye nokuxhomekeka kwayo kwisiseko sedatha, konke njengeyunithi enye.

Uvavanyo lokudibanisa

Emva kokuba sikuqinisekisile ukusebenza kwemicroservice nganye, emva koko kufuneka sivavanye unxibelelwano lwangaphakathi kwenkonzo. Uvavanyo lokudityaniswa luqinisekisa iindlela zonxibelelwano kunye nonxibelelwano phakathi kwamacandelo ukufumanisa iziphene zomsebenzi

Iifowuni zenkonzo kufuneka zenziwe ngokudityaniswa kweenkonzo zangaphandle, ekufuneka zibandakanye iimpazamo kunye neemeko zempumelelo, kungoko uvavanyo lokudityaniswa luqinisekisa ukuba le nkqubo isebenza ngokudibeneyo kwaye ukuxhomekeka phakathi kweenkonzo kukhona njengoko kulindelwe.

Uvavanyo lwekhontrakthi

Uvavanyo lwekhontrakthi luqinisekisa unxibelelwano kumda wenkonzo yangaphandle lubanga ukuba luyahlangabezana nekhontrakthi elindelwe yinkonzo edlayo.


Olu hlobo lovavanyo kufuneka luphathe inkonzo nganye njengebhokisi emnyama kwaye zonke iinkonzo kufuneka zibizwe ngokuzimeleyo kwaye iimpendulo zazo kufuneka ziqinisekiswe.

'Ikhontrakthi' yindlela umnxeba wenkonzo (apho iziphumo ezithile kulindeleke ukuba zingeniswe) kubhekiswa kuzo kuvavanyo lwekhontrakthi yomthengi. Wonke umsebenzisi kufuneka afumane iziphumo ezifanayo kwinkonzo ekuhambeni kwexesha, nokuba inkonzo iyatshintsha. Kufuneka kubekho ubhetyebhetye ukongeza ukusebenza ngakumbi njengoko kufuneka kwiimpendulo kamva. Nangona kunjalo, ezi zongezo mazingaphuli ukusebenza kwenkonzo.

Ukuphela kovavanyo

Indima yeemvavanyo zokuphela kokuphela kukuqinisekisa ukuba yonke into iyadibana kwaye akukho kungavisisani kwinqanaba eliphezulu phakathi kwemicroservices.

Ukuvavanywa kokuphela kokuqinisekisa ukuba inkqubo ihlangabezana neemfuno zangaphandle kwaye ifezekisa iinjongo zayo, kuvavanywa inkqubo yonke, ukusuka esiphelweni kuye esiphelweni.


Olu vavanyo lukwaqinisekisa ukuba yonke inkqubo kunye nokuhamba komsebenzisi kusebenza ngokuchanekileyo, kubandakanya yonke inkonzo kunye nokudityaniswa kwe-DB. Ukuvavanywa ngokupheleleyo kwemisebenzi echaphazela iinkonzo ezininzi kuqinisekisa ukuba inkqubo isebenza ngokudibeneyo kwaye iyazanelisa zonke iimfuno.



Umzekelo wovavanyo lweMicroservices

Masithathe i-microservice UKUYA oko kuxhomekeke kwezinye iinkonzo ezimbini B & C . Kuya kufuneka ukuba useke imeko ekude apho ilizwe lase UKUYA , B kwaye C ichazwe kakuhle kwaye inokusetwa kwakhona.

Umzekelo, imeko / ukugcinwa kwe B kwaye C kufuneka ilungiselelwe kwangaphambili. Emva koko, vele usebenze iseti yovavanyo lwee-API ze-microservice UKUYA usebenzisa REST / WebService yesiqhelo iseti yezixhobo zovavanyo, o.k.t. Isepha okanye Chakram okanye enye indlela elula ye-xUnit kulwimi lwakho lwenkqubo.

Ukuhlekisa ngazo naziphi na iinkonzo zontanga i-API exhomekeke ekusebenziseni i-restito. Ezinye iindlela zibandakanya umqhubi wokuphumla, iWireMock, kunye neMochito.

Umceli mngeni ocacileyo kukuhlekisa / ukwenza inkohliso kwiqela lesithathu APIs xa usenza uvavanyo lokudityaniswa kwemicroservices. Ungazisebenzisa naziphi na izixhobo ezihlekisayo ezikhankanywe apha ngasentla, vele uphathe ukugculelwa njengenxalenye yovavanyo lwethu kwaye uqiniseke ukuba usesikhathini kunye nokukhutshwa kwe-API entsha.