Coder Social home page Coder Social logo

Comments (3)

albertcht avatar albertcht commented on September 1, 2024

Hi @chinawilon ,

First, workers cannot share one app container because they are in different processes.

To create(load) a new app is to ensure the original container will not be affected in the request. If anyone did something strange in the request process, for example, unsetting some essential singleton properties, that might cause the whole application crashed.

from laravel-swoole.

chinawilon avatar chinawilon commented on September 1, 2024

hi @albertcht

感谢你的回答,但是我依然有个疑问。

image

从Swoole Structure 的这张图可以看出,如果一开始application就在master进程里面,那么它将会复制一份到manager进程,然后manager在fork新的worker进程的时候,同样也会复制一份最原始的那个application,我们知道父子进程之间的内存遵守COW(写时复制), 那也就是说,不管request请求里面如何改变application,都不会影响到manager进程里面的application。也就是说新的worker同样会得到最原始的那个application。不知道是不是我理解错了,还请求指教下。

from laravel-swoole.

albertcht avatar albertcht commented on September 1, 2024

Hi @chinawilon ,

目前一個 worker 中會含有:一個主架構用的 container,一個 laravel application,每次處理請求時會由 laravel application 經由 sandbox clone 出一份新的 application 去給 http kernel 處理,這個時候 request 過程中會有可能對 laravel application 中預先綁定的 singleton 進行污染,但是 container 無論如何是被隔離開來,在 request 中碰不到的,因此可以確保程式的穩定性

雖說新的 worker 可以獲得一份新的 application,但關鍵點就在於 worker 不會在處理一次請求後就被幹掉重新由 manager 再 fork 一份出來,一個 worker 會被預期處理至少上千個以上的請求,所以以上的情況就會存在

from laravel-swoole.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.