Common Web program servers (static Web server)
Application Server (can read Web site dynamic elements directly) IIS Tomcat,jetty,jboss,resin
Webshpere
SEBLOGIC,OC4//orcale
A complete HTTP request process//network communication is the communication between processes
1 establishing or processing links; Accepting requests or rejecting requests
2 Accepting requests
Accept a request for a resource from the Wang Dan request message process
Concurrent access to the appropriate model
One: single-threaded I/O structure//A request disconnects to accept the next request, multiple requests are serially responded to one at a time; serial corresponding system
Two: multi-threaded IO structure//Start multiple processes in parallel, each process corresponding to a request;
Three: Multiplexing I/O: one process responds to n Requests//event-driven
Multithreaded model: One process generates multiple threads, and each thread responds to a user's request
Event-driven
: multiplexed multi-process I/O structure: Initiates multiple (m) processes, each of which responds to n requests;
3 Processing Request: Multi-Request message parsing, and obtaining the requested resources and request methods and other related information
Meta Data: Request headers
Host: Requesting hosts
<methoud> <URL> <VERSION>
Host:www.baidu.com Request Host Name
Connection:
4 Access resource: Gets the requested resource in the request message:
A Web server, a server that hosts Web resources, that is responsible for returning the requested resource to the requestor
, or dynamically run-generated resources that are placed under a path on the local file system, usually called Docroot
/var/www/html
The home directory of the Web server
Web Server resource Path mapping method
A:docroot
B:alias
C: Virtual Host Docroot
D: User home directory Docroot
5 Building Response Messages
The premise of building the corresponding message is to find the resource and allow the user to access
MIME type of resource:
Show categories
Magic Category
Negotiation classification
URL redirection//URL rewriting for requests, access to changed URLs
Permanent redirection
Temporary redirection
6 Sending response messages
7 Logging
A patchy server = Apache
Asf:apache Software doundation Apache Foundation
Features of the httpd:
Highly modular: Core + modules
Dos:dynamic Shared Object Module
Mpm:multipath processing Modules multi-path processing module. The module has three modes of Operation Prefork Mpm,work mpm,event MPM block
Prefork: Multi-process model, each process corresponding to a request;
A master process (not responsible for processing user requests), is responsible for generating n sub-processes, the child process is also a worker process, each child process processing a user's request: Even if there is a user request, will be pre-generated a number of idle processes (improve efficiency), waiting for customer requests , maximum no more than 1024 (this limit can not achieve high concurrency);
This multi-path processing module (MPM) implements a non-threaded, pre-derived Web server that works in a similar way to Apache 1.3. It is suitable for systems that do not have a thread-safe library and need to avoid threading compatibility issues. It is the best mpm to require each request to be independent of each other, so that if a request has a problem it will not affect the other request.
Worker MPM: This multi-processing module (MPM) enables a network server to support mixed multithreaded multi-process. Because a thread is used to process requests, a large amount of requests can be processed, while the overhead of system resources is less than the process-based MPM. However, it also uses a multi-process, with each process having multiple threads to obtain the stability of the process-based MPM.
The number of threads that each process can have is fixed. The server increases or decreases the number of processes depending on the load. A separate control process (parent process) is responsible for the creation of child processes. Each child process can establish a threadsperchild number of service threads and a listener thread that listens to the access request and passes it to the service thread for processing and answering.
Whether it's worker mode or prefork mode, Apache always tries to keep some spare (spare) or idle child processes (the free service thread pool) to meet the incoming requests. This way, the client does not need to wait for the child process to be generated before the service is received.
Event MPM: Both of these stable MPM methods are somewhat inadequate under very busy server applications. Although the keepalive way of HTTP can reduce the number of TCP connections and network load, keepalive needs to be bound to the service process or thread, which causes a busy server to consume all the threads. The Event MPM is a new model for solving this problem, which separates the service process from the connection. The event MPM approach is most effective when the server is processing fast and has a very high click-through rate, the number of threads available is the critical resource limit. A busy server that works as a worker mpm can withstand a good tens of thousands of visits per second (for example, at the peak of a large news Service site), and event MPM is used to handle higher loads. It is important to note that the Event MPM does not work under secure HTTP (HTTPS) access
Apache working processes and patterns