Schrödinger's miv tsis muaj lub thawv: qhov teeb meem ntawm kev pom zoo hauv kev faib khoom

Yog li, cia peb xav txog. Muaj 5 tus miv xauv hauv chav, thiab txhawm rau mus tsa tus tswv, lawv txhua tus yuav tsum pom zoo rau qhov no ntawm lawv tus kheej, vim tias lawv tuaj yeem qhib qhov rooj nrog XNUMX tus ntawm lawv sawv ntsug. Yog tias ib tus miv yog Schrödinger tus miv, thiab lwm tus miv tsis paub txog nws qhov kev txiav txim siab, cov lus nug tshwm sim: "Yuav ua li cas lawv ua tau?"

Hauv tsab xov xwm no, kuv yuav qhia rau koj hauv cov ntsiab lus yooj yim txog cov theoretical feem ntawm lub ntiaj teb ntawm kev faib tshuab thiab cov hauv paus ntsiab lus ntawm lawv txoj haujlwm. Kuv tseem yuav tshuaj xyuas lub tswv yim tseem ceeb hauv Paxos.

Schrödinger's miv tsis muaj lub thawv: qhov teeb meem ntawm kev pom zoo hauv kev faib khoom

Thaum cov neeg tsim khoom siv huab kev tsim kho vaj tse, ntau yam databases, thiab ua haujlwm hauv pawg ntawm ntau cov nodes, lawv ntseeg siab tias cov ntaub ntawv yuav ua tiav, ruaj ntseg, thiab ib txwm muaj. Tab sis qhov twg yog qhov guarantees?

Qhov tseem ceeb, qhov kev lees paub peb muaj yog cov khoom siv lav. Lawv tau piav qhia hauv cov ntaub ntawv raws li hauv qab no: "Qhov kev pabcuam no muaj kev ntseeg siab heev, nws tau muab SLA, tsis txhob txhawj, txhua yam yuav ua haujlwm faib raws li koj xav tau."

Peb nyiam ntseeg qhov zoo tshaj plaws, vim tias cov neeg txawj ntse los ntawm cov tuam txhab loj tau lees paub peb tias txhua yam yuav zoo. Peb tsis nug cov lus nug: yog vim li cas, qhov tseeb, qhov no tuaj yeem ua haujlwm tag nrho? Puas muaj ib qho kev ncaj ncees rau kev ua haujlwm raug ntawm cov tshuab no?

Kuv nyuam qhuav mus Lub Tsev Kawm Ntawv ntawm Distributed Computing thiab tau txais kev tshoov siab los ntawm lub ncauj lus no. Cov lus qhuab qhia hauv tsev kawm tau zoo li cov chav kawm suav lej ntau dua li qee yam cuam tshuam nrog lub tshuab computer. Tab sis qhov no yog raws nraim li cas qhov tseem ceeb tshaj plaws algorithms uas peb siv txhua hnub, tsis paub nws, tau raug pov thawj ib zaug.

Feem ntau niaj hnub faib tshuab siv Paxos kev pom zoo algorithm thiab nws cov kev hloov pauv ntau yam. Qhov txias tshaj plaws yog qhov siv tau thiab, hauv txoj cai, qhov muaj peev xwm ntawm qhov muaj nyob ntawm no algorithm tuaj yeem ua pov thawj yooj yim nrog tus cwj mem thiab ntawv. Nyob rau hauv kev xyaum, lub algorithm yog siv nyob rau hauv loj systems khiav ntawm ib tug lossis loj tus naj npawb ntawm cov nodes nyob rau hauv cov huab.

Ib qho piv txwv ntawm qhov yuav tau tham ntxiv tom ntej: txoj haujlwm ntawm ob tus thawj cojCia wb mus saib kom sov txoj hauj lwm ntawm ob tug generals.

Peb muaj ob pab tub rog - liab thiab dawb. Cov tub rog dawb yog nyob rau hauv lub nroog besieged. Cov tub rog liab coj los ntawm cov thawj coj A1 thiab A2 nyob ntawm ob sab ntawm lub nroog. Redheads txoj hauj lwm yog mus tua lub nroog dawb thiab yeej. Txawm li cas los xij, cov tub rog ntawm txhua tus tub rog liab ib leeg yog me dua li cov tub rog dawb.

Schrödinger's miv tsis muaj lub thawv: qhov teeb meem ntawm kev pom zoo hauv kev faib khoom

Cov xwm txheej yeej rau cov liab: ob tus thawj coj yuav tsum tawm tsam tib lub sijhawm txhawm rau kom muaj txiaj ntsig zoo ntawm cov neeg dawb. Txhawm rau ua qhov no, cov thawj coj A1 thiab A2 yuav tsum tau sib cog lus nrog ib leeg. Yog hais tias txhua leej txhua tus tawm tsam nyias, lub taub hau liab yuav poob.

Txhawm rau kom tau txais kev pom zoo, cov thawj coj A1 thiab A2 tuaj yeem xa cov neeg xa xov mus rau ib leeg los ntawm thaj chaw ntawm lub nroog dawb. Tus neeg xa xov tuaj yeem ncav cuag tus neeg sib koom ua ke lossis tuaj yeem cuam tshuam los ntawm tus yeeb ncuab. Lo lus nug: Puas muaj qhov sib txuas ntawm kev sib txuas lus ntawm cov tub rog plaub hau liab (qhov sib lawv liag ntawm kev xa cov tub txib los ntawm A1 mus rau A2 thiab rov qab los ntawm A2 mus rau A1), uas lawv tau lees tias pom zoo rau kev tawm tsam ntawm teev X. Ntawm no, kev lees paub txhais tau tias ob tus thawj coj yuav muaj kev lees paub tsis meej tias ib tus phooj ywg (lwm tus thawj coj) yuav tawm tsam ntawm lub sijhawm teem X.

Piv txwv tias A1 xa ib tug xa mus rau A2 nrog cov lus: "Cia peb tawm tsam hnub no thaum ib tag hmo!" General A1 tsis tuaj yeem tawm tsam yam tsis muaj kev lees paub los ntawm General A2. Yog hais tias tus tub txib los ntawm A1 tau tuaj txog, ces General A2 xa lus pom zoo nrog cov lus: "Yog lawm, cia peb tua cov dawb hnub no." Tab sis tam sim no General A2 tsis paub tias nws tus tub txib tuaj txog los yog tsis tau, nws tsis muaj kev lees paub tias qhov kev tawm tsam yuav yog ib txhij. Tam sim no General A2 rov xav tau kev pom zoo.

Yog tias peb piav qhia ntxiv txog lawv cov kev sib txuas lus, nws yuav pom tseeb tias txawm tias muaj pes tsawg lub xov tooj sib pauv hloov pauv, tsis muaj txoj hauv kev los lav tias ob tus thawj coj tau txais lawv cov lus (xav tias tus neeg xa xov tuaj yeem cuam tshuam).

Qhov teeb meem Ob Generals yog ib qho piv txwv zoo ntawm qhov kev faib tawm yooj yim heev uas muaj ob lub nodes nrog kev sib txuas lus tsis txaus ntseeg. Qhov no txhais tau tias peb tsis muaj 100% lav tias lawv tau synchronized. Cov teeb meem zoo sib xws tsuas yog tham txog ntawm qhov loj dua tom qab hauv kab lus.

Peb qhia txog lub tswv yim ntawm kev faib tshuab

Ib qho kev faib tawm yog ib pawg ntawm cov khoos phis tawj (tom qab no peb yuav hu rau lawv cov nodes) uas tuaj yeem sib pauv lus. Txhua tus ntawm tus kheej yog qee hom kev tswj hwm tus kheej. Ib lub node tuaj yeem ua cov haujlwm ntawm nws tus kheej, tab sis txhawm rau sib txuas lus nrog lwm cov nodes, nws yuav tsum xa thiab txais cov lus.

Yuav ua li cas raws nraim cov lus raug siv, dab tsi raws tu qauv siv - qhov no tsis txaus siab rau peb hauv cov ntsiab lus no. Nws yog ib qho tseem ceeb uas cov nodes ntawm ib qho kev faib tawm tuaj yeem sib pauv cov ntaub ntawv nrog ib leeg los ntawm kev xa xov.

Lub ntsiab lus nws tus kheej tsis zoo li nyuaj heev, tab sis peb yuav tsum coj mus rau hauv tus account tias ib qho kev faib tawm muaj ntau tus cwj pwm uas yuav tseem ceeb rau peb.

Cov yam ntxwv ntawm kev faib tshuab

  1. Nyiaj Txiag – muaj peev xwm ntawm ib txhij los yog concurrent txheej xwm tshwm sim nyob rau hauv lub system. Tsis tas li ntawd, peb yuav xav txog cov xwm txheej uas tshwm sim ntawm ob qhov sib txawv kom muaj peev xwm ua ke ntev npaum li peb tsis muaj qhov tseeb ntawm qhov tshwm sim ntawm cov xwm txheej no. Tab sis, raws li txoj cai, peb tsis muaj nws.
  2. Tsis muaj lub moos ntiaj teb. Peb tsis muaj qhov kev txiav txim meej ntawm cov xwm txheej vim tsis muaj lub sijhawm thoob ntiaj teb. Nyob rau hauv lub ntiaj teb zoo tib yam ntawm tib neeg, peb tau accustomed mus rau lub fact tias peb muaj moos thiab sij hawm kiag li. Txhua yam hloov thaum nws los txog rau cov tshuab faib. Txawm tias ultra-precise atomic moos muaj drift, thiab tej zaum yuav muaj qhov xwm txheej uas peb tsis tuaj yeem qhia qhov twg ntawm ob qhov xwm txheej tshwm sim ua ntej. Yog li ntawd, peb tsis tuaj yeem cia siab rau lub sijhawm.
  3. Kev ywj pheej tsis ua haujlwm ntawm qhov system nodes. Muaj lwm qhov teeb meem: ib yam dab tsi tuaj yeem ua tsis ncaj ncees vim peb cov nodes tsis nyob mus ib txhis. Lub hard drive tuaj yeem ua tsis tiav, lub tshuab virtual hauv huab yuav rov pib dua, lub network yuav ntsais thiab cov lus yuav ploj. Ntxiv mus, tej zaum yuav muaj cov xwm txheej uas cov nodes ua haujlwm, tab sis tib lub sijhawm ua haujlwm tawm tsam lub system. Cov chav kawm kawg ntawm cov teeb meem txawm tau txais ib lub npe cais: teeb meem Byzantine generals. Cov piv txwv nrov tshaj plaws ntawm kev faib tawm nrog qhov teeb meem no yog Blockchain. Tab sis hnub no peb yuav tsis xav txog cov teeb meem tshwj xeeb no. Peb yuav txaus siab rau cov xwm txheej uas tsuas yog ib lossis ntau lub nodes yuav ua tsis tau.
  4. Cov qauv kev sib txuas lus (cov qauv xa xov) ntawm cov nodes. Peb twb tau tsim cov nodes sib txuas lus los ntawm kev sib pauv lus. Muaj ob hom kev xa xov zoo: synchronous thiab asynchronous.

Cov qauv ntawm kev sib txuas lus ntawm cov nodes nyob rau hauv faib systems

Synchronous qauv - peb paub tseeb tias muaj lub sijhawm paub txog qhov kawg ntawm lub sijhawm thaum cov lus tau lees paub kom ncav cuag los ntawm ib qho mus rau lwm qhov. Yog tias lub sijhawm no tau dhau mus thiab cov lus tsis tuaj txog, peb tuaj yeem hais tias qhov node ua tsis tiav. Hauv cov qauv no peb muaj lub sijhawm tos tos.

Asynchronous qauv - hauv cov qauv asynchronous peb xav tias lub sijhawm tos yog qhov kawg, tab sis tsis muaj lub sijhawm zoo li no tom qab ntawd peb tuaj yeem lav tias cov node ua tsis tiav. Cov. Lub sijhawm tos rau cov lus los ntawm cov node tuaj yeem ntev ntev. Qhov no yog ib qho tseem ceeb txhais, thiab peb yuav tham txog nws ntxiv.

Lub tswv yim ntawm kev pom zoo nyob rau hauv faib systems

Ua ntej kev txiav txim siab lub tswv yim ntawm kev pom zoo, cia peb xav txog ib qho piv txwv ntawm qhov xwm txheej uas peb xav tau, uas yog - Lub Xeev Machine Replication.

Peb muaj ib co faib log. Peb xav kom nws zoo ib yam thiab muaj cov ntaub ntawv zoo ib yam ntawm txhua qhov ntawm cov kab ke faib. Thaum ib qho ntawm cov nodes kawm txog tus nqi tshiab uas nws yuav sau rau hauv lub cav, nws txoj hauj lwm yuav muab tus nqi no rau tag nrho lwm cov nodes kom lub cav hloov tshiab ntawm tag nrho cov nodes thiab lub kaw lus txav mus rau lub xeev tshiab. Hauv qhov no, nws yog ib qho tseem ceeb uas cov nodes pom zoo ntawm lawv tus kheej: tag nrho cov nodes pom zoo tias qhov kev thov tshiab tus nqi yog lawm, tag nrho cov nodes txais tus nqi no, thiab tsuas yog nyob rau hauv cov ntaub ntawv no txhua leej txhua tus tuaj yeem sau tus nqi tshiab rau lub cav.

Hauv lwm lo lus: tsis muaj ib qho ntawm cov nodes tau tawm tsam tias nws muaj cov ntaub ntawv tseem ceeb dua, thiab tus nqi tawm tswv yim tsis raug. Kev pom zoo ntawm cov nodes thiab kev pom zoo ntawm ib tus nqi raug lees txais yog kev pom zoo hauv ib qho kev faib tawm. Tom ntej no, peb yuav tham txog algorithms uas tso cai rau ib qho kev faib tawm kom tau lees paub kom ncav cuag kev pom zoo.
Schrödinger's miv tsis muaj lub thawv: qhov teeb meem ntawm kev pom zoo hauv kev faib khoom
Ntxiv rau, peb tuaj yeem txhais qhov kev pom zoo algorithm (lossis ib qho kev pom zoo algorithm) raws li qee yam haujlwm uas hloov cov txheej txheem faib los ntawm xeev A mus rau xeev B. Tsis tas li ntawd, lub xeev no tau txais los ntawm tag nrho cov nodes, thiab tag nrho cov nodes tuaj yeem lees paub nws. Raws li nws hloov tawm, txoj haujlwm no tsis yog qhov tsis tseem ceeb raws li nws zoo li thaum xub thawj siab ib muag.

Properties of Consensus Algorithm

Qhov kev pom zoo algorithm yuav tsum muaj peb lub zog txhawm rau kom lub kaw lus txuas ntxiv mus thiab muaj qee qhov kev nce qib hauv kev txav ntawm lub xeev mus rau lub xeev:

  1. Daim ntawv cog lus - tag nrho cov kev khiav hauj lwm kom raug yuav tsum coj tus nqi tib yam (hauv cov khoom no kuj raug xa mus rau cov cuab yeej kev nyab xeeb). Tag nrho cov nodes uas tam sim no ua hauj lwm (tsis tau ua tsis tau tejyam los yog poob kev sib cuag nrog lwm tus) yuav tsum tuaj mus rau qhov kev pom zoo thiab lees txais ib co zaum kawg tus nqi.

    Nws yog ib qho tseem ceeb kom nkag siab ntawm no tias cov nodes hauv cov kab ke faib peb tab tom txiav txim siab xav pom zoo. Ntawd yog, tam sim no peb tab tom tham txog cov tshuab uas qee yam tuaj yeem ua tsis tau (piv txwv li, qee qhov ntawm tsis ua haujlwm), tab sis hauv qhov system no yeej tsis muaj cov nodes uas txhob txwm ua haujlwm tawm tsam lwm tus (cov haujlwm ntawm Byzantine generals). Vim yog cov cuab yeej no, qhov system tseem zoo ib yam.

  2. ntseeg - yog tias tag nrho cov nodes ua haujlwm raug muab tib yam nqi v, uas txhais tau hais tias txhua qhov kev ua haujlwm raug cai yuav tsum lees txais tus nqi no v.
  3. txiav - tag nrho cov kev khiav hauj lwm kom raug yuav nws thiaj li coj tau ib qho txiaj ntsig (cov cuab yeej muaj sia nyob), uas tso cai rau cov algorithm kom ua tiav hauv qhov system. Txhua tus neeg ua haujlwm raug cai yuav tsum sai lossis tom qab lees txais tus nqi kawg thiab lees paub nws: "Rau kuv, tus nqi no yog qhov tseeb, Kuv pom zoo nrog tag nrho cov kab ke."

Ib qho piv txwv ntawm qhov kev pom zoo algorithm ua haujlwm li cas

Txawm hais tias cov khoom ntawm cov algorithm yuav tsis meej meej. Yog li ntawd, peb yuav piav qhia nrog ib qho piv txwv dab tsi theem qhov yooj yim pom zoo algorithm mus rau hauv ib qho system nrog ib tug synchronous messaging qauv, nyob rau hauv uas tag nrho cov nodes ua hauj lwm raws li xav tau, cov lus tsis ploj thiab tsis muaj dab tsi tawg (qhov no puas tiag tiag?).

  1. Nws tag nrho pib nrog daim ntawv thov kev sib yuav (Propose). Cia peb xav tias tus neeg siv khoom txuas nrog lub npe hu ua "Node 1" thiab pib ua lag luam, dhau tus nqi tshiab rau ntawm node - O. Txij li tam sim no, peb yuav hu "Node 1" los tawm tswv yim. Raws li tus kws tshaj lij, "Node 1" tam sim no yuav tsum ceeb toom rau tag nrho cov kab ke tias nws muaj cov ntaub ntawv tshiab, thiab nws xa cov lus mus rau tag nrho lwm cov nodes: "Saib! Lub ntsiab lus "O" tuaj rau kuv thiab kuv xav sau cia! Thov paub meej tias koj tseem yuav sau "O" hauv koj lub cav."

    Schrödinger's miv tsis muaj lub thawv: qhov teeb meem ntawm kev pom zoo hauv kev faib khoom

  2. Cov theem tom ntej yog kev pov npav rau tus nqi uas tau hais tseg (Kev Pov Npav). Nws yog dab tsi? Tej zaum nws yuav tshwm sim tias lwm cov nodes tau txais cov ntaub ntawv tsis ntev los no, thiab lawv muaj cov ntaub ntawv ntawm tib qhov kev hloov pauv.

    Schrödinger's miv tsis muaj lub thawv: qhov teeb meem ntawm kev pom zoo hauv kev faib khoom

    Thaum node "Node 1" xa nws cov lus qhia, lwm cov nodes tshawb xyuas lawv cov cav rau cov ntaub ntawv ntawm qhov kev tshwm sim no. Yog tias tsis muaj qhov tsis sib xws, cov nodes tshaj tawm: "Yog lawm, kuv tsis muaj lwm cov ntaub ntawv rau qhov xwm txheej no. Tus nqi "O" yog cov ntaub ntawv tshiab tshaj plaws uas peb tsim nyog."

    Hauv lwm qhov xwm txheej, nodes tuaj yeem teb rau "Node 1": "Mloog! Kuv muaj cov ntaub ntawv tsis ntev los no ntawm qhov kev hloov pauv no. Tsis yog 'O', tab sis ib yam dab tsi zoo dua."

    Thaum lub sijhawm pov npav, cov nodes tuaj rau kev txiav txim siab: lawv txhua tus lees txais tus nqi qub, lossis ib qho ntawm lawv pov npav tawm tsam, qhia tias nws muaj cov ntaub ntawv tsis ntev los no.

  3. Yog tias qhov kev xaiv tsa tau ua tiav thiab txhua tus tau txais kev pom zoo, tom qab ntawd lub kaw lus txav mus rau theem tshiab - Txais tus nqi. "Node 1" sau tag nrho cov lus teb los ntawm lwm cov nodes thiab cov lus ceeb toom: "Txhua tus neeg pom zoo rau tus nqi "O"! Tam sim no kuv tshaj tawm tias "O" yog peb lub ntsiab lus tshiab, tib yam rau txhua tus! Sau nws hauv koj phau ntawv me me, tsis txhob hnov ​​​​qab. Sau rau hauv koj lub log!”

    Schrödinger's miv tsis muaj lub thawv: qhov teeb meem ntawm kev pom zoo hauv kev faib khoom

  4. Cov nodes uas tseem tshuav xa ntawv lees paub (Tau txais) tias lawv tau sau tus nqi "O"; tsis muaj dab tsi tshiab tuaj txog lub sijhawm no (ib hom kev cog lus ob theem). Tom qab qhov xwm txheej tseem ceeb no, peb txiav txim siab tias qhov kev faib tawm tau ua tiav.
    Schrödinger's miv tsis muaj lub thawv: qhov teeb meem ntawm kev pom zoo hauv kev faib khoom

Yog li, qhov kev pom zoo algorithm nyob rau hauv cov ntaub ntawv yooj yim muaj plaub kauj ruam: tawm tswv yim, pov ntawv tawm suab (tso pov npav), lees txais (accept), lees paub lees txais (tsim).

Yog hais tias ntawm qee cov kauj ruam peb tsis tuaj yeem ncav cuag qhov kev pom zoo, ces lub algorithm pib dua, coj mus rau hauv tus account cov ntaub ntawv muab los ntawm cov nodes uas tsis kam lees paub qhov kev thov tus nqi.

Kev pom zoo algorithm nyob rau hauv ib qho asynchronous system

Ua ntej no, txhua yam yog du, vim hais tias peb tab tom tham txog cov qauv kev xa xov synchronous. Tab sis peb paub tias nyob hauv lub ntiaj teb niaj hnub no peb tau siv los ua txhua yam asynchronously. Yuav ua li cas ib tug zoo xws li cov algorithm ua hauj lwm nyob rau hauv ib tug system nrog ib tug asynchronous messaging qauv, qhov twg peb ntseeg hais tias lub sij hawm tos rau cov lus teb los ntawm ib tug node yuav arbitrarily ntev (los ntawm txoj kev, qhov tsis ua hauj lwm ntawm ib tug node kuj yuav xam tau tias yog piv txwv li thaum. ib lub node tuaj yeem teb rau lub sijhawm ntev arbitrarily).

Tam sim no peb paub tias qhov kev pom zoo algorithm ua haujlwm li cas hauv cov ntsiab lus, ib lo lus nug rau cov neeg nyeem xav paub uas tau ua kom deb li deb: muaj pes tsawg leeg hauv ib qho system ntawm N nodes nrog cov qauv lus asynchronous tuaj yeem ua tsis tiav kom lub kaw lus tseem tuaj yeem ncav cuag kev pom zoo?

Cov lus teb raug thiab kev ncaj ncees yog tom qab tus spoiler.Cov lus teb raug: 0. Yog tias txawm tias ib qho ntawm lub asynchronous system ua tsis tiav, lub kaw lus yuav tsis muaj peev xwm ncav cuag kev pom zoo. Cov lus no tau raug pov thawj hauv FLP txoj kev xav, paub zoo hauv qee lub voj voog (1985, Fischer, Lynch, Paterson, txuas mus rau tus thawj ntawm qhov kawg ntawm tsab xov xwm): "Kev ua tsis tau zoo ntawm kev ua tiav kev pom zoo yog tias tsawg kawg ib qho tsis ua tiav ”
Schrödinger's miv tsis muaj lub thawv: qhov teeb meem ntawm kev pom zoo hauv kev faib khoom
Cov txiv neej, ces peb muaj teeb meem, peb tau siv rau txhua yam ua asynchronous. Thiab ntawm no nws yog. Yuav ua li cas mus ntxiv?

Peb tsuas yog tham txog kev xav, hais txog lej. Qhov "kev pom zoo tsis tuaj yeem ua tiav" txhais tau li cas, txhais los ntawm cov lus lej rau hauv peb li engineering? Qhov no txhais tau tias "tsis tuaj yeem ua tiav txhua lub sijhawm", i.e. Muaj ib rooj plaub uas qhov kev pom zoo tsis tuaj yeem ua tiav. Qhov no yog dab tsi?

Qhov no yog raws nraim qhov kev ua txhaum ntawm cov khoom muaj sia nyob tau piav qhia saum toj no. Peb tsis muaj ib qho kev pom zoo, thiab lub kaw lus tsis tuaj yeem muaj kev vam meej (tsis tuaj yeem ua tiav hauv lub sijhawm kawg) nyob rau hauv rooj plaub uas peb tsis muaj lus teb los ntawm tag nrho cov nodes. Vim hais tias nyob rau hauv ib qho asynchronous system peb tsis muaj lub sij hawm teb yuav kwv yees thiab peb tsis tuaj yeem paub seb lub node puas tau poob lossis tsuas yog siv sijhawm ntev los teb.

Tab sis hauv kev xyaum peb tuaj yeem nrhiav kev daws teeb meem. Cia peb cov algorithm tuaj yeem ua haujlwm ntev ntev thaum ua tsis tiav (tej zaum nws tuaj yeem ua haujlwm tsis tas li). Tab sis feem ntau cov xwm txheej, thaum feem ntau cov nodes ua haujlwm raug, peb yuav muaj kev vam meej hauv qhov system.

Hauv kev xyaum, peb suav nrog cov qauv kev sib txuas lus ib nrab. Ib nrab synchrony yog to taub raws li hauv qab no: nyob rau hauv cov ntaub ntawv, peb muaj ib tug asynchronous qauv, tab sis ib tug tej lub tswv yim ntawm "lub ntiaj teb no stabilization lub sij hawm" ntawm ib tug tej yam taw tes nyob rau hauv lub sij hawm yog raug qhia.

Lub sijhawm no hauv lub sijhawm yuav tsis tuaj rau lub sijhawm ntev, tab sis nws yuav tsum tuaj ib hnub. Lub moos tswb virtual yuav nrov, thiab txij li lub sijhawm ntawd peb tuaj yeem kwv yees lub sijhawm delta uas cov lus yuav tuaj txog. Txij ntawm no mus, lub kaw lus hloov ntawm asynchronous mus rau synchronous. Hauv kev xyaum, peb cuam tshuam nrog cov txheej txheem zoo li no.

Paxos algorithm daws teeb meem kev pom zoo

Paxos yog tsev neeg ntawm algorithms uas daws qhov teeb meem kev pom zoo rau ib feem ntawm lub tshuab synchronous, raug rau qhov ua tau tias qee qhov nodes yuav ua tsis tiav. Tus sau Paxos yog Leslie Lamport. Nws tau tshaj tawm cov ntaub ntawv pov thawj ntawm lub neej thiab qhov tseeb ntawm algorithm hauv xyoo 1989.

Tab sis cov ntaub ntawv pov thawj tau pom nyob deb ntawm qhov tsis tseem ceeb. Thawj qhov kev tshaj tawm tsuas yog tso tawm xyoo 1998 (33 nplooj ntawv) piav qhia txog cov txheej txheem. Raws li nws tau muab tawm, nws nyuaj heev rau kev nkag siab, thiab hauv 2001 kev piav qhia ntawm tsab xov xwm tau luam tawm, uas coj 14 nplooj ntawv. Qhov ntim ntawm cov ntawv tshaj tawm tau muab los qhia tias qhov tseeb qhov teeb meem ntawm kev pom zoo tsis yog txhua qhov yooj yim, thiab tom qab cov algorithms no muaj ntau qhov kev ua haujlwm los ntawm cov neeg ntse tshaj plaws.

Nws yog qhov nthuav tias Leslie Lamport nws tus kheej tau sau tseg hauv nws cov lus qhuab qhia tias nyob rau hauv tsab xov xwm piav qhia thib ob muaj ib nqe lus, ib kab (nws tsis tau qhia tias ib qho twg), uas tuaj yeem txhais tau ntau txoj hauv kev. Thiab vim li no, ntau qhov kev siv Paxos niaj hnub no tsis ua haujlwm kom raug.

Kev soj ntsuam ntxaws ntxaws ntawm Paxos txoj haujlwm yuav siv ntau tshaj ib tsab xov xwm, yog li kuv yuav sim luv luv qhia lub tswv yim tseem ceeb ntawm algorithm. Hauv cov ntawv txuas tom kawg ntawm kuv tsab xov xwm koj yuav pom cov ntaub ntawv rau kev dhia dej ntxiv rau hauv cov ncauj lus no.

Lub luag haujlwm ntawm Paxos

Paxos algorithm muaj lub tswv yim ntawm lub luag haujlwm. Cia peb xav txog peb lub ntsiab (muaj kev hloov kho nrog lub luag haujlwm ntxiv):

  1. Cov kws tshaj lij (cov ntsiab lus kuj tseem siv tau: cov thawj coj lossis cov neeg koom tes). Cov no yog cov txiv neej uas kawm txog qee qhov txiaj ntsig tshiab los ntawm tus neeg siv thiab ua lub luag haujlwm ntawm tus thawj coj. Lawv txoj haujlwm yog los tsim ib puag ncig cov lus pom zoo rau tus nqi tshiab thiab koom tes ua haujlwm ntxiv ntawm cov nodes. Ntxiv mus, Paxos tso cai rau muaj ntau tus thawj coj hauv qee qhov xwm txheej.
  2. Txais (Cov neeg pov npav). Cov no yog cov nodes uas pov npav lees txais lossis tsis lees txais ib qho nqi tshwj xeeb. Lawv lub luag haujlwm tseem ceeb heev, vim tias qhov kev txiav txim siab nyob ntawm lawv: lub xeev qhov system yuav (lossis yuav tsis) mus rau theem tom ntej ntawm kev pom zoo algorithm.
  3. Neeg Kawm. Nodes uas tsuas lees txais thiab sau tus nqi lees txais tshiab thaum lub xeev ntawm lub kaw lus tau hloov pauv. Lawv tsis txiav txim siab, lawv tsuas yog tau txais cov ntaub ntawv thiab tuaj yeem muab rau cov neeg siv kawg.

Ib lub node tuaj yeem ua ke ntau lub luag haujlwm hauv ntau qhov xwm txheej.

Lub tswvyim ntawm pawg pawg

Peb xav tias peb muaj ib qho system N nodes Thiab ntawm lawv qhov siab tshaj plaws F nodes tej zaum yuav poob. Yog tias F nodes poob, ces peb yuav tsum muaj tsawg kawg 2 F + 1 txais nodes.

Qhov no yog qhov tsim nyog kom peb ib txwm muaj feem ntau, txawm tias nyob rau hauv qhov xwm txheej tsis zoo, ntawm "zoo" nodes uas ua haujlwm raug. Qhov ntawd yog F+1 "zoo" nodes uas pom zoo, thiab tus nqi kawg yuav raug lees txais. Txwv tsis pub, tej zaum yuav muaj qhov xwm txheej uas peb cov pab pawg hauv zos sib txawv sib txawv thiab tsis tuaj yeem pom zoo ntawm lawv tus kheej. Yog li ntawd, peb xav tau ib tus neeg feem coob los yeej qhov kev pov npav.

Lub tswv yim dav dav ntawm yuav ua li cas Paxos pom zoo algorithm ua haujlwm

Paxos algorithm suav nrog ob theem loj, uas nyob rau hauv lem tau muab faib ua ob kauj ruam txhua:

  1. Theem 1a: Npaj. Thaum lub sijhawm npaj, tus thawj coj (tus neeg thov) qhia rau tag nrho cov nodes: “Peb tab tom pib lub sijhawm pov npav tshiab. Peb muaj ib puag ncig tshiab. Tus lej ntawm qhov kev sib tw no yog n. Tam sim no peb yuav pib pov npav. " Txog tam sim no, nws tsuas yog qhia txog qhov pib ntawm lub voj voog tshiab, tab sis tsis qhia txog tus nqi tshiab. Lub luag haujlwm ntawm theem no yog los pib qhov kev hloov tshiab thiab qhia txhua tus ntawm nws tus lej tshwj xeeb. Tus lej puag ncig yog qhov tseem ceeb, nws yuav tsum yog tus nqi ntau dua li cov lej pov npav dhau los ntawm txhua tus thawj coj dhau los. Vim nws yog ua tsaug rau tus lej puag ncig uas lwm cov nodes hauv lub kaw lus yuav nkag siab tias tus thawj coj cov ntaub ntawv tsis ntev los no. Nws zoo li lwm cov nodes twb muaj kev pov npav los ntawm ntau qhov kev sib tw tom qab thiab yuav tsuas qhia tus thawj coj tias nws nyob tom qab lub sijhawm.
  2. Theem 1b: Kev cog lus. Thaum tus neeg txais cov nodes tau txais cov naj npawb ntawm qhov kev pov npav tshiab, ob qhov txiaj ntsig tau ua tau:
    • Tus naj npawb n ntawm qhov kev pov npav tshiab yog ntau dua li tus lej ntawm kev pov npav yav dhau los uas tus neeg txais tau koom nrog. Tom qab ntawd tus txais yuav xa cov lus cog tseg rau tus thawj coj tias nws yuav tsis koom nrog kev pov npav ntxiv nrog tus lej qis dua n. Yog tias tus neeg lees paub twb tau pov npav rau ib yam dab tsi (uas yog, nws twb tau txais qee tus nqi nyob rau theem thib ob), ces nws muab tus nqi lees paub thiab tus naj npawb ntawm cov pov npav uas nws tau koom nrog nws cov lus cog tseg.
    • Tsis tas li ntawd, yog tias tus neeg lees paub twb paub txog qhov kev pov npav ntau dua, nws tuaj yeem tsis quav ntsej txog kev npaj cov kauj ruam thiab tsis teb rau tus thawj coj.
  3. Theem 2a: Txais. Tus thawj coj yuav tsum tau tos cov lus teb los ntawm pawg pawg (feem ntau ntawm cov nodes hauv lub cev) thiab, yog tias tau txais cov lus teb xav tau, ces nws muaj ob txoj hauv kev rau kev txhim kho cov xwm txheej:
    • Qee cov neeg lees txais tau xa cov txiaj ntsig uas lawv twb tau pov npav rau. Hauv qhov no, tus thawj coj xaiv tus nqi los ntawm kev pov npav nrog tus lej siab tshaj plaws. Cia peb hu tus nqi no x, thiab nws xa tawm cov lus rau tag nrho cov nodes xws li: "Accept (n, x)", qhov twg thawj tus nqi yog tus naj npawb pov npav los ntawm nws tus kheej Propose kauj ruam, thiab tus nqi thib ob yog qhov uas txhua tus tau sau rau, i.e. tus nqi uas peb yeej pov npav.
    • Yog tias tsis muaj leej twg lees txais qhov tseem ceeb, tab sis lawv tsuas yog cog lus tias yuav pov npav hauv qhov kev sib tw no, tus thawj coj tuaj yeem caw lawv los pov npav rau lawv tus nqi, tus nqi uas nws tau los ua thawj coj. Wb npe y. Nws xa lus mus rau tag nrho cov nodes xws li: “Accept (n, y)”, zoo ib yam li qhov tshwm sim dhau los.
  4. Theem 2b: Txais. Tsis tas li ntawd, tus txais nodes, thaum tau txais cov lus "Accept(...)" los ntawm tus thawj coj, pom zoo nrog nws (xa ntawv lees paub rau txhua lub pob uas lawv pom zoo nrog tus nqi tshiab) tsuas yog lawv tsis tau cog lus rau qee qhov (lwm yam) ) tus thawj coj los koom nrog kev pov npav nrog tus lej n' > n, txwv tsis pub lawv tsis quav ntsej qhov kev thov kev lees paub.

    Yog tias feem ntau ntawm cov nodes teb rau cov thawj coj, thiab tag nrho cov ntawm lawv tau lees tias tus nqi tshiab, ces tus nqi tshiab raug txiav txim siab txais. Hooray! Yog tias feem ntau tsis ncav cuag lossis muaj cov nodes uas tsis kam lees txais tus nqi tshiab, ces txhua yam pib dua.

Qhov no yog li cas Paxos algorithm ua haujlwm. Txhua theem no muaj ntau yam subtleties, peb xyaum tsis tau xav txog ntau yam kev ua tsis tiav, teeb meem ntawm ntau tus thawj coj thiab ntau ntxiv, tab sis lub hom phiaj ntawm tsab xov xwm no tsuas yog qhia cov neeg nyeem rau lub ntiaj teb ntawm kev faib xam ntawm qib siab.

Nws tseem tsim nyog sau cia tias Paxos tsis yog tib qho ntawm nws hom, muaj lwm cov algorithms, piv txwv li, Phuaj, tab sis qhov no yog lub ntsiab lus rau lwm tsab xov xwm.

Txuas rau cov ntaub ntawv rau kev kawm ntxiv

Qib pib:

Leslie Lamport qib:

Tau qhov twg los: www.hab.com

Ntxiv ib saib