Kwayedza Microservices - Yekutanga Gwaro

Kuedza Microservices kuri kuramba kuchikosha zvakanyanya sezvo akawanda emaapplication matsva ari kuvakwa achishandisa Microservices kuvaka.

Tisati tagona kuona maitiro ekuyedza microservices, isu tinofanirwa kutanga tanzwisisa kuti chii.

Chii chinonzi Microservices?

Microservice inotsanangurwa seyakavakirwa dhizaini, nzira yekuvandudza application imwechete seyeti yemasevhisi. Sevhisi yega yega inotsanangurwa nehunhu hwayo mamwe acho ari:

  • Kumhanya mukuita kwayo.
  • Kutaurirana neyakareruka michina kazhinji neiyo HTTP sosi API.
  • Kuzvimiririra kushandiswa nemuchina wakazara.
  • Uchishandisa akasiyana mitauro mitauro / matekinoroji / DB.
  • Iri kushandisa akasiyana matekinoroji ekuchengetedza data.

Iyo microservice dhizaini yekugadzira inosanganisira kugadzira imwechete maitiro ayo anogona kushanda pamwechete seyeti yezvidiki masevhisi, imwe neimwe inomhanya mune yayo yega maitiro uye nekutaurirana nehuremu nzira senge yeHTTP sosi API. Aya masevhisi anoda mashoma epakati manejimendi manejimendi, shandisa akasiyana data ekuchengetedza matekinoroji, uye anogona kunyorwa mumitauro yakasiyana yekuronga. Aya masevhisi, akavakirwa kutenderedza kugona kwebhizinesi, anogona zvakare kuendeswa zvakazvimiririra nemishini inotsigira yakazara zvoga kuendesa.

Microservices hunhu:

  • Yakarongedzwa kutenderedza kugona kwebhizinesi,
  • Zvoga kutumirwa,
  • Ungwaru muma endpoints pane kuita basa bhazi,
  • Kudzora kwakatemerwa mitauro uye data.

Microservices Yakasiyana Sei neSOA

  • Sevhisi-yakatarisana nekuvakwa (SOA): dhizaini yekuvaka mumacomputer software dhizaini mune izvo zvinoshandiswa zvekushandisa zvinopa masevhisi kune zvimwe zvikamu kuburikidza neprotocol yekutaurirana, kazhinji pamusoro petiweki.
  • Microservices : Software yekushongedza dhizaini umo maitiro akaomarara anoumbwa nediki, akazvimirira maitiro ekutaurirana neumwe neumwe achishandisa mutauro-agnostic APIs

Muenzaniso:



Kana Uber yakavakwa neSOA, masevhisi avo anogona kunge ari:

  • GetPaymentsAndDriverInformationAndMappingDataAPI
  • AuthenticateUsersAndDriversAPI

Dai Uber yakavakwa nema microservices, maAPIs avo angave akafanana neaya:

  • TumiraPaymentsService
  • GetDriverInfoService
  • GetMappingDataService
  • AuthenticateUserService
  • AuthenticateDriverService

Mamwe maAPIs, madiki madiki emabasa.

Maitiro ekuyedza Microservices

Kwayedza Miedzo

Yuniti bvunzo dzinoita zvidimbu zvidiki zve software senge basa mune chishandiso kuona kuti zvinogadzira here chaunoda kuburitsa chakapihwa seti yezvinozivikanwa zvinopinda.

Izvo zvakakosha kuti uzive kuti yuniti kuyedza yega haina kupa vimbiso nezve maitiro ehurongwa. Tinoda mamwe marudzi ekuyedza microservices.

Chikamu Chemiedzo

Kana tangoita kuyedza kwechikwata cheese mashandiro mukati meiyo microservice, saka tinofanirwa kuyedza iyo microservice pachayo tiri tega.

Kazhinji, chishandiso chinogona kuve chakaumbwa neakawanda emicroservices, saka kuti tingoedza tiri tega, tinofanirwa kuseka mamwe ma microservices.

Chikamu chemuyedzo chichaedzawo kudyidzana kwe microservice nekutsamira kwayo senge dhatabhesi, ese seyuniti.

Kubatanidzwa Kuyedza

Mushure mekunge tavimbisa mashandiro eiyo yega microservice, saka tinofanirwa kuyedza iyo yekudyidzana-sevhisi kutaurirana. Chiyero chekubatanidza chinosimbisa nzira dzekutaurirana pamwe nekudyidzana pakati pezvinhu kuti uone kusagadzikana kwehukama

Mafoni ebasa anofanirwa kuitwa pamwe nekubatanidzwa kune ekunze masevhisi, ayo anofanirwa kusanganisira kukanganisa uye kubudirira mitezo, nekudaro, kuyedzwa kwekubatanidza kunovimbisa kuti iyo system iri kushanda pamwe chete musono uye kuti kutsamira pakati pemasevhisi aripo sekutarisirwa.

Chibvumirano Kuyedza

Kontrakiti miedzo inoongorora kudyidzana pamuganho wekunze sevhisi ichisimbisa kuti inosangana nechibvumirano chinotarisirwa nebasa rinodya.

Rudzi urwu rweyedzo runofanira kubata sevhisi yega yega sebhokisi dema uye ese masevhisi anofanira kudaidzwa akasununguka uye mhinduro dzawo dzinofanirwa kuverengerwa.

'Chibvumirano' ndechekuti kufona sevhisi (uko kwakatarwa mhedzisiro kana kuburitswa kune zvimwe zvekushandisa) kunoziviswa neyevatengi kuyedza chibvumirano. Mutengi wese anofanirwa kuwana mhedzisiro yakafanana kubva kusevhisi nekufamba kwenguva, kunyangwe sevhisi ikachinja. Panofanirwa kuve nekuchinjika kwekuwedzera mamwe mashandiro sezvainodiwa kuMhinduro gare gare. Nekudaro, izvi zvinowedzerwa hazvifanirwe kutyora mashandiro ebasa.

End-To-End Miedzo

Basa rekuyedza-kumagumo bvunzo kuona kuti zvese zvinobatana pamwechete uye hapana kusawirirana kwepamusoro pakati pemicroservices.

End-to-end bvunzo dzinoongorora kuti system inosangana neyekunze zvinodiwa uye inozadzisa zvinangwa zvayo, kuyedza iyo sisitimu yese, kubva kumagumo kusvika kumagumo.

Iyo bvunzo inoongorora zvakare kuti maitiro ese uye mushandisi kuyerera kunoshanda nemazvo, kusanganisira yese sevhisi uye DB kusangana. Kunyatso kuyedzwa mashandiro anokanganisa akawanda masevhisi anovimbisa kuti iyo system inoshanda pamwe izere uye inogutsa zvese zvinodiwa.

Muenzaniso weKuedza Microservices

Ngatitorei microservice TO zvinoenderana nemamwe masevhisi maviri B & C . Iwe unofanirwa kuseta nharaunda yakasarudzika uko nyika ye TO , B uye C inotsanangurwa mushe uye inogona kudzokororwa kumisikidzwa.

Semuenzaniso, nyika / kuchengetedza kwe B uye C inofanira kutanga-kutanga. Mushure meizvozvo, iwe unongomhanyisa seti yekuyedza kuyedza APIs ye microservice TO uchishandisa zvakajairwa REST / WebService seti yemathuluzi ekuyedza, i.e. Sipo kana Chakram kana yakapusa xUnit imwe nzira yemutauro wako wechirongwa.

Kuseka chero vezera masevhisi iyo API inoenderana nekushandisa restito. Dzimwe nzira dzinosanganisira zororo-mutyairi, WireMock, uye Mochito.

Dambudziko riri pachena nderekuseka / kunyepedzera bato rechitatu maAPI kana uchiita kuyedzwa kwekubatanidza microservices. Iwe unogona kushandisa chero eanoseka maturusi ataurwa pamusoro, ingo bata izvo zvinoseka sechikamu cheyedu test fixture uye ita shuwa kuti iwe uri kufambirana nerino nyowani API kuburitswa.