Muaj pes tsawg qhov kev thov tuaj yeem node js?
Muaj pes tsawg qhov kev thov tuaj yeem node js?

Video: Muaj pes tsawg qhov kev thov tuaj yeem node js?

Video: Muaj pes tsawg qhov kev thov tuaj yeem node js?
Video: Tshuaj theem vim li cas thiaj tau nqi ?/ Siv kho mob dab tsi?/paris polyphylla use for? 2024, Kaum ib hlis
Anonim

Los ntawm kev zam txhua yam ntawd, Node . js ua tiav qib scalability ntau dua 1M sib txuas sib txuas, thiab tshaj 600k concurrent websockets sib txuas. Muaj, tau kawg, cov lus nug ntawm kev sib koom ib txoj xov ntawm txhua tus neeg siv khoom thov , thiab nws yog ib lub pitfall ntawm kev sau ntawv Node . js daim ntawv thov.

Ib yam li ntawd, muaj pes tsawg qhov kev thov tuaj yeem ua tus neeg rau zaub mov?

Zoo, tom qab ib tug thib ob, lub server tuaj yeem tsuas yog txheej txheem 100 thov , yog li ntawd yuav ua tiav 2 thov tib lub sijhawm. Lub operating system yuav sim qhia CPU, yog li tam sim no txhua tus thov siv 20ms. Cov server tseem teb 100 thov ib ob, tab sis lub latency tau nce.

Qhov thib ob, muaj pes tsawg Websockets tuaj yeem tuav tau? Xav txog cov lus teb luv luv: Raws li ntau raws li koj nyiam, mus txog thaum koj muaj li ntawd ntau cov neeg siv uas scaling yuav tsum tsis muaj teeb meem. Cov lus teb ntev dua: Node ua haujlwm ntawm qhov kev tshwm sim raws li qhov system, txhais tau tias koj ua tau qhib 10,000 qhov (socket), tsis xa cov lus los ntawm lawv, thiab tau ze rau 0 lub sijhawm ua haujlwm.

Kuj paub yog, node js ua li cas rau ntau qhov kev thov?

Ntau cov neeg ua ntau qhov kev thov mus rau NodeJS server. NodeJS tau txais cov no thov thiab muab lawv tso rau hauv EventQueue. NodeJS server muaj ib qho kev tivthaiv sab hauv hu ua EventLoop uas yog lub voj tsis kawg uas tau txais thov thiab ua lawv. Qhov EventLoop no yog ib qho threaded.

Cov kev thov sib koom ua ke yog dab tsi?

Concurrent Requests , Cov Kev Pabcuam, thiab Cov Txheej Txheem Thaum tus neeg siv sau ntawv qhia, a thov khiav daim ntawv qhia yog generated. Cov lus txib kom khiav daim ntawv qhia yog a ib leeg thov . Qhov kev pab cuam uas tsim cov ntawv tshaj tawm yog a ua ke qhov kev pab cuam. Concurrent cov kev pab cuam yog pib los ntawm a ua ke tus thawj coj.

Pom zoo: