)→c Ohttpdapacheorg/does/2a/newfeatures2 □ HACTOM福堂花回MsDN园csDN⑥回翻虾米胃颗亮曾言站回c开源中围□献掌示□用网址 移动版书签 APACHE a■ HttpSerVeR ProJecT Apache Http Server Version 2.4 Overview of new features in Apache Http Server 2.4 Ths documen cestnbes some of the major changes between the 22 and 2 4 versons of ne apAche Http Server For new features snce verson 20. see tne 22new leatures document O nts Module Enhancements Run-time Loadable MPMs MPMs can now be bu at comple time The MPM of choKe can be configured at run time wa waedModule directive Event PM Event MeM is no longer expenmental but b now tuly supported Module eloper Chinois See also Bener support for asynchronous read/write for supporting MPMs and patrons be configured per module and per rectory New levels tracel to tracel added above the debug log level <If>, cElaeIE> and cLaes sections can be used to set me configuraton based on pef-request antena A new expression parser alows to specify complex conditons using a common syntax in directives ke setEnvIEXxTr, Revrttecend: Mender. <IE> and( ND longer needed and is now deprecated -aat drecire alows more nne grained control whch ir lower,hac能aes ane varables in the configuraton, allowing a claer representation if the same valuc s used at many places n the contour ate many new features, 2. 4 x lenas to use ess memory than 2.2x Bod proxy fogi ocol backend for rod proxy mod proxy express 河南中医药大学/阮晓龙/13938213680/htt/ inuxxg. hactcm. edu.cn/htp//w.51 xuewen. cn
河南中医药大学 / 阮晓龙 / 13938213680 / http://linux.xg.hactcm.edu.cn / http://www.51xueweb.cn 2.Apache服务器 11 2.1Apache简介
12 2 Apache服务器 22 Apache工作原理 Apache支持多种处理模式: perfor的工作原理 个单独的控制进程(父进程)负责产生子进程,子进程用于监听请求并 作出应答。 Apache总是试图保持些备用的( spare)或是空闲子进程用 于迎接即将到来的请求,客户端不需要在得到服务前等候子进程的产生。 perfor下有 StartServers、 Min Spare Servers、 MaxSpareServers、 MaxRequestWorkers四个指令用于调节父进程如何产生子进程。通常情况 下 Apache具有很强的自我调节能力,当需要处理的并发请求较高时,服务 器可能就需要增加 MaxRequestWorkers的值。 StartServers:初始的工作进程数。 a Min Spare Servers:空闲子进程的最小数量 口 MaxSpareServers:空闲子进程的最大数量。 MaxRequestWorkers:最大空闲线程数 河南中医药大学/阮晓龙/13938213680/http://linux.xg.hactcm.edu.cn/http:/www.51xueweb.cn
河南中医药大学 / 阮晓龙 / 13938213680 / http://linux.xg.hactcm.edu.cn / http://www.51xueweb.cn 2.Apache服务器 Apache支持多种处理模式:perfork的工作原理 一个单独的控制进程(父进程)负责产生子进程,子进程用于监听请求并 作出应答。Apache总是试图保持一些备用的(spare)或是空闲子进程用 于迎接即将到来的请求,客户端不需要在得到服务前等候子进程的产生。 perfork下有StartServers、MinSpareServers、MaxSpareServers、 MaxRequestWorkers四个指令用于调节父进程如何产生子进程。通常情况 下Apache具有很强的自我调节能力,当需要处理的并发请求较高时,服务 器可能就需要增加MaxRequestWorkers的值。 StartServers:初始的工作进程数。 MinSpareServers:空闲子进程的最小数量。 MaxSpareServers:空闲子进程的最大数量。 MaxRequestWorkers:最大空闲线程数。 12 2.2Apache工作原理
3 2 Apache服务器 22 Apache工作原理 ¤ Apache支持多种处理模式: worker的工作原理 worker模式相对于 perfor来说,使用了多进程和多线程混合的模式 Worker模式预先分了几个子进程(数量比较少),然后每个子进程创建一 些线程,同时包括一个监听线程。每个请求过来,会被分配到一个线程来 服务。因为线程通常会共享父进程的内存空间,所以内存的占用会减少 些,线程处理比起进程会更轻量 worker模式在高并发的情况下,比 prefork有更多的可用进程,表现会更优 秀一些。 worke不完全使用多线程,引入多进程的原因是需要考虑稳定性,如果一 个线程出错,会导致父进程连同其它正常的子线程都出错,使用多个进程 再加多个线程,如果某个线程出现异常,受影响的只是 Apache的一部分服 务,而不是整个服务。 河南中医药大学/阮晓龙/13938213680/http://linux.xg.hactcm.edu.cn/http:/www.51xueweb.cn
河南中医药大学 / 阮晓龙 / 13938213680 / http://linux.xg.hactcm.edu.cn / http://www.51xueweb.cn 2.Apache服务器 Apache支持多种处理模式:worker的工作原理 worker模式相对于perfork来说,使用了多进程和多线程混合的模式。 Worker模式预先分了几个子进程(数量比较少),然后每个子进程创建一 些线程,同时包括一个监听线程。每个请求过来,会被分配到一个线程来 服务。因为线程通常会共享父进程的内存空间,所以内存的占用会减少一 些,线程处理比起进程会更轻量。 worker模式在高并发的情况下,比prefork有更多的可用进程,表现会更优 秀一些。 worker不完全使用多线程,引入多进程的原因是需要考虑稳定性,如果一 个线程出错,会导致父进程连同其它正常的子线程都出错,使用多个进程 再加多个线程,如果某个线程出现异常,受影响的只是Apache的一部分服 务,而不是整个服务。 13 2.2Apache工作原理
2 Apache服务器 22 Apache工作原理 ¤ Apache支持多种处理模式: event的工作原理 event和 worker模式很像,最大的区别在于它解决了keep-aive场景下,线 程长期被占用而造成的资源浪费问题,如某个线程因为被keep-aive空挂 着等待,长时间没有请求,甚至等到超期 event模式中,会有一个专门的线程来管理这些keep-aive类型的线程,当 有真实请求时,将请求传递给服务线程,执行完毕后,又允许它释放,这 样增强了高并发场景下的请求处理能力 河南中医药大学/阮晓龙/13938213680/http://linux.xg.hactcm.edu.cn/http:/www.51xueweb.cn
河南中医药大学 / 阮晓龙 / 13938213680 / http://linux.xg.hactcm.edu.cn / http://www.51xueweb.cn 2.Apache服务器 Apache支持多种处理模式:event的工作原理 event和worker模式很像,最大的区别在于它解决了keep-alive场景下,线 程长期被占用而造成的资源浪费问题,如某个线程因为被keep-alive空挂 着等待,长时间没有请求,甚至等到超期。 event模式中,会有一个专门的线程来管理这些keep-alive类型的线程,当 有真实请求时,将请求传递给服务线程,执行完毕后,又允许它释放,这 样增强了高并发场景下的请求处理能力。 14 2.2Apache工作原理
15 2 Apache服务器 2.2Apache Module ¤模块是在内核空间运行的程序,实际上是一种目标对象文件,没有链 接,不能独立运行,但是其代码可以在运行时链接到系统中作为内核 的一部分运行或从内核中取下,可以动态的扩展内核的功能。 Apache安装时会默认安装—些模块,如果需要实现某种特定的功能就 需要增加 Apache模块。 口以 mod easiⅳve为例来讲 Apache模块的安装。 mod easiⅳe是 Apache 服务器的防DDOS模块。 河南中医药大学/阮晓龙/13938213680/http://linux.xg.hactcm.edu.cn/http:/www.51xueweb.cn
河南中医药大学 / 阮晓龙 / 13938213680 / http://linux.xg.hactcm.edu.cn / http://www.51xueweb.cn 2.Apache服务器 模块是在内核空间运行的程序,实际上是一种目标对象文件,没有链 接,不能独立运行,但是其代码可以在运行时链接到系统中作为内核 的一部分运行或从内核中取下,可以动态的扩展内核的功能。 Apache安装时会默认安装一些模块,如果需要实现某种特定的功能就 需要增加Apache模块。 以mod_evasive为例来讲Apache模块的安装。mod_evasive是Apache 服务器的防DDOS模块。 15 2.2Apache Module