![Search icon](https://hackernoon.imgix.net/search-new.png?w=19&h=19)
Nsuku zonke, ngaso sonke isikhathi phakathi nomsebenzi wethu wobunjiniyela, sihlangabezana nezinkinga eziningi ezahlukahlukene zobunkimbinkimbi nezimo lapho sidinga ukuthatha isinqumo noma sihlehlise ngenxa yokuntuleka kwedatha. Noma nini lapho sakha amasevisi amasha, sakha ingqalasizinda, noma sakha izinqubo zokuthuthukisa, sithinta umhlaba omkhulu wezinselelo ezihlukahlukene.
Kuyinselele, futhi mhlawumbe akunakwenzeka ngisho nokubhala zonke izinkinga. Uzohlangabezana nezinye zalezi zinkinga kuphela uma usebenza ku-niche ethile. Ngakolunye uhlangothi, kuningi okumele sonke sikuqonde ukuthi kungaxazululwa kanjani, njengoba kubalulekile ekwakheni izinhlelo ze-IT. Ngamathuba aphezulu, uzohlangana nawo kuwo wonke amaphrojekthi.
Kulesi sihloko, ngizokwabelana ngolwazi lwami ngezinye zezinkinga engihlangabezane nazo ngenkathi ngidala izinhlelo zesofthiwe.
Uma sibheka ku-Wikipedia, sizothola incazelo elandelayo
Ekuthuthukisweni kwesoftware okugxile kuhlangothi, ukukhathazeka okunqamulayo kuyizici zohlelo ezithinta amamojula amaningana, ngaphandle kokuthi kungenzeka ukuthi kuhlanganiswe kunoma iyiphi yazo. Lokhu kukhathazeka ngokuvamile akukwazi ukubola ngokuhlanzekile kusukela kulo lonke uhlelo kukho kokubili ukwakheka nokusebenza, futhi kungaholela ekuhlakazeni (ukuphindaphinda kwekhodi), ukuhlangana (ukuncika okubalulekile phakathi kwezinhlelo), noma kokubili.
Ichaza kakhulu ukuthi iyini, kodwa ngifuna ukuyinweba futhi ngiyenze ibe lula kancane:
Ukukhathazeka okuhlukanisayo umqondo noma ingxenye yesistimu/inhlangano ethinta (noma 'enqamula') ezinye izingxenye eziningi.
Izibonelo ezinhle kakhulu zokukhathazeka okunjalo ukwakhiwa kwesistimu, ukugawulwa kwemithi, ukuphepha, ukuphathwa kokuthengiselana, i-telemetry, i-database design kanye nezinye eziningi. Sizonaba ngeziningi zazo kamuva kulesi sihloko.
Kwileveli yekhodi, ukukhathazeka okunqamulayo kuvame ukusetshenziswa kusetshenziswa amasu afana ne -Aspect-Oriented Programming (AOP) , lapho lokhu kukhathazeka kuguqulwa kube izingxenye ezihlukene ezingasetshenziswa kulo lonke uhlelo lokusebenza. Lokhu kugcina ingqondo yebhizinisi ihlukanisiwe kulokhu kukhathazeka, okwenza ikhodi ifundeke kakhudlwana futhi ilondolozeke.
Ziningi izindlela ezingenzeka zokuthi ungazihlukanisa kanjani izici ngokuzihlukanisa ngezinto ezihlukene ezifana nobubanzi, usayizi, ukusebenza, ukubaluleka, okuqondiwe, nokunye, kodwa kulesi sihloko, ngizosebenzisa ukuhlukaniswa kobubanzi obulula. Ngalokhu, ngiqonde lapho lesi sici siqondiswe khona noma ngabe inhlangano yonke, uhlelo oluthile, noma ingxenye ethile yalolo hlelo.
Ngakho-ke, ngizohlukanisa izici zibe i -Macro ne -Micro .
Ngohlangothi olukhulu ngiqonde ukucatshangelwa esikulandelayo kulo lonke uhlelo njengokwakheka kwesistimu ekhethiwe kanye nomklamo wayo (i-monolithic, ama-microservices, i-architecture egxile kusevisi), isitaki sobuchwepheshe, ukwakheka kwenhlangano, njll. Izici eziningi zihlobene kakhulu namasu kanye nezinga eliphezulu. izinqumo.
Okwamanje, isici se -Micro sisondele kakhulu ezingeni lekhodi nokuthuthuka. Isibonelo, iluphi uhlaka olusetshenziselwa ukusebenzisana nesizindalwazi, isakhiwo sephrojekthi samafolda namakilasi, noma amaphethini edizayini yento ethile.
Yize lokhu kuhlukaniswa kungalungile, kusiza ukuhlela ukuqonda kwezinkinga ezingaba khona kanye nokubaluleka nomthelela wezisombululo esizisebenzisa kuzo.
Kulesi sihloko, ngizogxila kakhulu ezicini ze-macro.
Lapho ngiqala ukufunda nge-software ye-architecture, ngafunda izindatshana eziningi ezithakazelisayo mayelana nomthetho kaConway nomthelela wawo esakhiweni senhlangano. Ikakhulukazi lena . Ngakho, lo mthetho usho lokho
Noma iyiphi inhlangano eklama uhlelo (echazwe kabanzi) izokhiqiza umklamo osakhiwo sayo siyikhophi yesakhiwo sokuxhumana senhlangano.
Bengilokhu ngikholelwa ukuthi lo mbono ngempela usemhlabeni wonke futhi umele uMthetho Wegolide.
Ngabe sengiqala ukufunda indlela ka-Eric Evans's Domain-Driven Design (DDD) yezinhlelo zokumodela. U-Eric Evans ugcizelela ukubaluleka kokuhlonza i-Bounded Context. Lo mqondo uhilela ukuhlukanisa imodeli yesizinda esiyinkimbinkimbi sibe izingxenye ezincane, ezilawulekayo, ngasinye esinolwazi lwaso olulinganiselwe. Le ndlela isiza ekuxhumaneni kweqembu ngempumelelo, njengoba inciphisa isidingo solwazi olubanzi lwaso sonke isizinda futhi inciphisa ukushintsha kokuqukethwe, ngaleyo ndlela yenze izingxoxo ziphumelele. Ukushintsha kokuqukethwe yinto embi kakhulu futhi edla izisetshenziswa kakhulu. Ngisho namakhompyutha athwele kanzima. Nakuba kungenakwenzeka ukuzuza ukungabikho okuphelele kokushintsha umongo, ngicabanga ukuthi yilokho okufanele sikulwele.
Ukubuyela kuMthetho kaConway, ngithole izingqinamba ezimbalwa ngawo.
Udaba lokuqala engihlangabezane nalo ngoMthetho kaConway, ophakamisa ukuthi ukwakheka kwesistimu kufanekisela ukwakheka kwenhlangano, amandla okwakha Izimo Ezihlanganisiwe Eziyinkimbinkimbi futhi ezibanzi. Lobu bunzima buvela lapho ukwakheka kwenhlangano kungahambelani nemingcele yesizinda, okuholela Ezimeni Ezihlanganisiwe ezincikene kakhulu futhi ezilayishwe ulwazi. Kuholela ekuguquleni umongo okuvamile kwethimba lokuthuthukisa.
Olunye udaba ukuthi amatemu enhlangano avuza ezingeni lekhodi. Lapho izinhlaka zenhlangano zishintsha, kudinga ukulungiswa kwe-codebase, kudle izinsiza ezibalulekile.
Ngakho-ke, ukulandela i-Inverse Conway Maneuver kusiza ekwakheni isistimu nenhlangano ekhuthaza ukwakhiwa kwesofthiwe oyifunayo. Kodwa-ke, kuyaphawuleka ukusho ukuthi le ndlela ngeke isebenze kahle kakhulu ekwakhiweni kwezakhiwo esezakhiwe kakade njengoba izinguquko kulesi sigaba zithatha isikhathi eside, kodwa zisebenza kahle kakhulu eziqalweni njengoba ziyashesha ukwethula noma yiziphi izinguquko.
Le phethini noma "i-anti-pattern" ishayela ukwakha isistimu ngaphandle kwanoma iyiphi i-architecture. Ayikho imithetho, akukho mingcele, futhi alikho isu lendlela yokulawula inkimbinkimbi ekhulayo engenakugwemeka. Inkimbinkimbi yisitha esesabekayo kakhulu ohambweni lokwakha izinhlelo zesoftware.
Ukuze sigweme ukwakha uhlobo olunjalo lwesistimu, kudingeka silandele imithetho ethile kanye nemingcele.
Kunezinkulungwane zezincazelo ze-Software Architecture. Ngiyabathanda abaningi babo ngoba bahlanganisa izici ezahlukene. Nokho, ukuze sikwazi ukucabanga mayelana nezakhiwo, sidinga ngokwemvelo ukwakha ezinye zazo ezingqondweni zethu. Futhi kuyaphawuleka ukusho ukuthi le ncazelo ingase iguquke. Ngakho-ke, okungenani okwamanje, nginencazelo elandelayo kimina.
I-Software Architecture imayelana nezinqumo nokukhetha okwenzayo nsuku zonke okunomthelela ohlelweni olwakhiwe.
Ukuze wenze izinqumo okudingeka ube nazo “esikhwameni” sakho imigomo namaphethini okuxazulula izinkinga eziphakamayo, kubalulekile futhi ukusho ukuthi ukuqonda izidingo kuyisihluthulelo sokwakha lokho okudingwa yibhizinisi. Kodwa-ke, ngezinye izikhathi izidingo azibonakali noma azichazwanga, kulokhu, kungcono ukulinda ukuze uthole ukucaciswa okwengeziwe noma ukuthembela kokuhlangenwe nakho kwakho futhi uthembele intuition yakho. Kodwa noma kunjalo, awukwazi ukwenza izinqumo ngendlela efanele uma ungenayo imigomo namaphethini ongathembela kuwo. Yilapho ngiza khona encazelweni ye -Software Architecture Style.
I-Software Architecture Style iyisethi yezimiso namaphethini achaza indlela yokwakha isofthiwe.
Kunezitayela eziningi ezahlukene zezakhiwo ezigxile ezinhlangothini ezihlukahlukene zezakhiwo ezihleliwe, futhi ukusebenzisa eziningi zazo ngesikhathi esisodwa kuyisimo esivamile.
Ngokwesibonelo, njengokuthi:
Izakhiwo ze-Monolithic
Idizayini eqhutshwa yisizinda
Kususelwa kungxenye
Ama-Microservices
Ipayipi nezihlungi
Kuqhutshwa umcimbi
I-Microkernel
Okuqondiswe kusevisi
njalo njalo…
Yebo, banezinzuzo zabo kanye nokubi, kodwa into ebaluleke kakhulu engiyifundile ukuthi izakhiwo zishintsha kancane kancane ngenkathi kuya ngezinkinga zangempela. Ukuqala ngesakhiwo se-monolithic kuyisinqumo esihle kakhulu sokunciphisa ubunzima bokusebenza, kungenzeka ukuthi le zakhiwo zizofanela izidingo zakho ngisho nangemva kokufinyelela esigabeni se-Product-market Fit (PMI) sokwakha umkhiqizo. Esikalini, ungase ucabange ukuya endleleni eqhutshwa umcimbi kanye nama-microservices ukuze uthole ukuthunyelwa okuzimele, imvelo yezitaki ze-tech ehlukile, kanye nezakhiwo ezihlanganiswe kancane (futhi kungabikho sobala okwamanje ngenxa yemvelo yezindlela eziqhutshwa umcimbi kanye ne-pub-sub uma lezi ziyamukelwa). Ubulula nokusebenza kahle kuseduze futhi kunomthelela omkhulu komunye nomunye. Ngokuvamile, izakhiwo eziyinkimbinkimbi zithinta isivinini sokuthuthukiswa kwezici ezintsha, zisekela futhi zigcine ezikhona kakade, futhi ziphonse inselelo ukuvela kwemvelo kwesistimu.
Kodwa-ke, izinhlelo eziyinkimbinkimbi ngokuvamile zidinga izakhiwo eziyinkimbinkimbi futhi ezibanzi, okuyinto engenakugwemeka.
Ngokufanelekile, lesi yisihloko esibanzi kakhulu, futhi kunemibono eminingi emihle mayelana nendlela yokuhlela nokwakha izinhlelo zokuziphendukela kwemvelo. Ngokusekelwe kokuhlangenwe nakho kwami, ngisebenzise le ndlela elandelayo:
Kubalulekile futhi ukuqonda izinombolo namamethrikhi afana ne -DAU (Daily Active Users), MAU (Monthly Active Users), RPC (Request Per Second), kanye ne -TPC (Transaction Per Second) ngoba ingakusiza ukuba wenze ukukhetha ngoba Abasebenzisi abasebenzayo abangu-100 kanye nabasebenzisi abasebenzayo abayizigidi ezingu-100 bahlukile.
Njengenothi lokugcina, ngingasho ukuthi izakhiwo zinomthelela omkhulu empumelelweni yomkhiqizo. Izakhiwo eziklanywe kabi zemikhiqizo ziyadingeka ekulinganisweni, okungenzeka kakhulu kuholele ekuhlulekeni njengoba amakhasimende engeke alinde ngenkathi ukala isistimu, azokhetha esiqhudelana naye, ngakho-ke sidinga ukuba ngaphambi kwesikali esingaba khona. Nakuba ngivuma ukuthi ngezinye izikhathi bekungeke kube indlela ethambile, umqondo uwukuba nesistimu ehlanjululwayo kodwa engasenasikali kakade. Ngakolunye uhlangothi, ukuba nesistimu eyinkimbinkimbi kakhulu futhi esevele inezikali engenawo amakhasimende noma izinhlelo zokuthola amaningi kuzokulahlekisela imali ebhizinisini lakho mahhala.
Ukukhetha isitaki sobuchwepheshe futhi kuyisinqumo sezinga elikhulu njengoba kuthonya ukuqashwa, imibono yokuvela kwemvelo yesistimu, ukuqina, nokusebenza kwesistimu.
Lolu uhlu lokucatshangelwa okuyisisekelo kokukhetha isitaki sobuchwepheshe:
Ukuba nezitaki eziningi zobuchwepheshe kungathinta kanjani ukukhula kwebhizinisi?
Ngokombono owodwa, ukwethula isitaki esisodwa kungase kukhulise ukuqasha kwakho, kodwa ngakolunye uhlangothi, kuletha izindleko ezengeziwe zokulungisa njengoba udinga ukusekela zombili izitaki. Ngakho-ke, njengoba ngishilo ngaphambili, ngokombono wami, isidingo esengeziwe kuphela okufanele kube ingxabano yokuhlanganisa izitaki eziningi zobuchwepheshe.
Kodwa kuthiwani ngesimiso sokukhetha ithuluzi elingcono kakhulu lenkinga ethile?
Ngezinye izikhathi awunayo enye inketho ngaphandle kokuletha amathuluzi amasha okuxazulula inkinga ethile ngokusekelwe ekucatshangelweni okufanayo okukhulunywe ngenhla, ezimweni ezinjalo, kunengqondo ukukhetha isisombululo esingcono kakhulu.
Ukwakhiwa kwamasistimu ngaphandle kokuhlanganiswa okuphezulu kubuchwepheshe obuthile kungaba inselele. Noma kunjalo, kuyasiza ukulwela isimo lapho uhlelo lungaxhunywanga ngokuqinile nobuchwepheshe, futhi ngeke lufe uma kusasa, uhlaka oluthile noma ithuluzi liba sengozini noma lihoxiswe.
Okunye okucatshangelwayo okubalulekile kuhlobene nokuncika kwesoftware yomthombo ovulekile kanye nokuphathelene. Isoftware yobunikazi ikunikeza ukuguquguquka okuncane kanye nethuba lokwenziwa ngendlela oyifisayo. Noma kunjalo, into eyingozi kakhulu ukukhiya komthengisi, lapho uncika emikhiqizweni yomthengisi, izintengo, imigomo, nemephu yomgwaqo. Lokhu kungaba yingozi uma umthengisi eshintsha indlela, enyusa izintengo, noma eyeka umkhiqizo. Isofthiwe yomthombo ovulekile inciphisa lobu bungozi, njengoba ibhizinisi elilodwa lingayilawuli. Ukuqeda iphuzu elilodwa lokwehluleka kuwo wonke amazinga kuyisihluthulelo sokwakha izinhlelo ezithembekile zokukhula.
Iphuzu elilodwa lokuhluleka (SPOF) libhekisela kunoma iyiphi ingxenye yesistimu okuthi, uma yehluleka, ibangele lonke uhlelo ukuthi luyeke ukusebenza. Ukuqeda ama-SPOF kuwo wonke amazinga kubalulekile kunoma iyiphi isistimu edinga ukutholakala okuphezulu. Konke, okuhlanganisa ulwazi, abasebenzi, izingxenye zesistimu, abahlinzeki bamafu, nezintambo ze-inthanethi, kungahluleka.
Kunezindlela ezimbalwa eziyisisekelo esingazisebenzisa ukuze sisuse iphuzu elilodwa lokwehluleka:
Kulesi sihloko, sihlanganise izici ezimbalwa ezibalulekile zeMacro nokuthi singabhekana kanjani nobunzima bazo.
Siyabonga ngokufunda! Sobonana ngokuzayo!