一个Web服务器(Apache)如何处理多个HTTP请求,在code级 [英] how a web server(apache) handles multiple HTTP requests, on the code level

查看:466
本文介绍了一个Web服务器(Apache)如何处理多个HTTP请求,在code级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望这不是很明显,只是想澄清一些事情,我不能完全肯定。一边看如何实现高速缓存的教程中,我得到了这个问题。还有就是似乎只是增加在服务器上的一些全局缓存变量,将实现缓存为所有客户端。我使用PHP和Apache网络服务器。

Hope this is not something obvious, just want to clarify some things I am not totally sure about. I got this question while watching a tutorial on how to implement caching. There is seems that just adding some global caching variables on the server, will implement caching for all clients. I use PHP with Apache webserver.

我知道,一个Web服务器可以接受多个客户端的HTTP请求。我的问题是在Web服务器上code会发生什么。

I know that a web-server can accept multiple client HTTP requests. My question is what happens on the web server code.

时相同的服务器code每次执行?这意味着有些全局变量preserved?或用于每一个新的HTTP请求,在创建code的新实例。如果是,则是连接这些多个实例,或者可以以任何方式进行相互感知

Is the same server code executed each time? Meaning that some global variables are preserved? Or for each new HTTP request, a new instance of the code is created. If yes, are those multiple instances connected or can be made aware of each other in any way?

推荐答案

坏消息是Apache服务器不那种工作的原生支持。你必须使用一些中间的东西,如数据库来处理这个问题。
不过,好消息是node.js中轻松做到这一点的东西,在一个优雅的方式:D

Bad news is the apache server does not native support for that kind of work. You have to use some intermediate stuff like database to handle this. However, good news is node.js do that stuff easily in an elegance way :D

这篇关于一个Web服务器(Apache)如何处理多个HTTP请求,在code级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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