Puas yog Ruby ntawm Rails multithreaded?
Puas yog Ruby ntawm Rails multithreaded?

Video: Puas yog Ruby ntawm Rails multithreaded?

Video: Puas yog Ruby ntawm Rails multithreaded?
Video: Keith Richards plays Before They Make Me Run backstage before the show in Minneapolis 2024, Tej zaum
Anonim

Phusion Neeg nrog caij siv cov txheej txheem raws li concurrency los lis ob peb qhov kev thov concurrently, yog li, nruj me ntsis hais lus, tsis yog " multithreaded , "tab sis tseem concurrent. Qhov no tham los ntawm Ruby MidWest 2011 muaj qee qhov kev xav zoo rau kev tau txais Multithreaded Ruby on Rails mus.

Hauv qhov no, Ruby puas txhawb nqa multithreading?

A multithreaded program muaj ntau tshaj ib txoj xov ntawm kev ua tiav. Ruby ua kom yooj yim los sau cov kev pab cuam ntau txoj xov nrog Thread class. Ruby threads yog lub teeb yuag thiab muaj txiaj ntsig txoj hauv kev kom ua tiav qhov sib txuam hauv koj cov cai.

Qhov thib ob, yog Ruby concurrent? Tshwj xeeb, Ruby concurrency yog thaum ob txoj haujlwm tuaj yeem pib, khiav, thiab ua tiav hauv lub sijhawm sib tshooj. Nws tsis tas txhais tau tias, txawm li cas los xij, tias lawv yuav puas tau ob leeg khiav ntawm tib lub sijhawm (piv txwv li, ntau cov xov ntawm lub tshuab ib leeg).

Ib yam li ntawd, puas yog Ruby ib leeg threaded?

Cov lus teb luv luv yog yog, lawv yog ib threaded . Cov lus teb ntev yog nws nyob ntawm. JRuby yog multithreaded thiab tuaj yeem khiav hauv tomcat zoo li lwm yam java code. MRI (npe ruby ) thiab Python ob leeg muaj GIL (Global Interpreter Lock) thiab yog li ntawd ib threaded.

Puas yog Ruby muaj Gil?

MRI muaj ib yam dab tsi hu ua tus neeg txhais lus thoob ntiaj teb xauv ( GIL ). Nws yog ib lub xauv nyob ib ncig ntawm kev tua ntawm Ruby code. Qhov no txhais tau hais tias nyob rau hauv ib tug multi-threaded ntsiab lus, tsuas yog ib tug xov yuav ua tau Ruby code thaum twg los tau. Cov GIL muaj los tiv thaiv Ruby internals los ntawm haiv neeg tej yam kev mob uas yuav corrupt cov ntaub ntawv.

Pom zoo: