为网页的每个请求创建新流程吗? [英] Creation of new process for each request of web page?

查看:91
本文介绍了为网页的每个请求创建新流程吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是一个基本问题,但是每次用户从服务器调用php文件时,都会从该服务器创建新进程吗?

It might be a basic question but everytime a user call a php file from a server, does it create a new process from that server ?

例如,我有一个基本形式(假设在index.php上),它将文本提交到另一个php文件. 在该php文件中,我打印 posix_getpid().

For example, I have a basic form (let's say on index.php) that submits a text to another php file. In that php file, I print the posix_getpid().

我在index.php的两个选项卡中打开并填写了文本,最后我得到了 每个标签上有两个不同的pid.

I opened in two tabs my index.php an filled in and submitted a text and I ended up with two different pid on each tab.

这使我得出一个结论,即服务器可能为每个脚本创建一个新进程. 我说的对吗?

Which lead me to the conclusion that a server probably create a new process for each script. Am I right ?

干杯!

推荐答案

我假设您正在将apache作为Web服务器运行.

I assume that you're running apache as your web server.

当请求进入时,apache启动一个新线程.然后在这个新线程上调用PHP,因此为什么每次都会获得一个新的进程ID.

When a request comes in, apache starts a new thread. PHP is then invoked on this new thread, hence why you get a new process id every time.

这当然被大大简化了.

我建议阅读

I recommend reading this article for a deeper understanding.

平台之间的过程似乎有所不同.它按照我在Windows上所描述的方式工作,但是在Unix上执行了多个Apache进程.

It seems that the process differs between platforms. It works the way I described above on Windows, but multiple apache processes are executed on Unix.

这篇关于为网页的每个请求创建新流程吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆