httpd service interview questions

1, please talk about your understanding of the httpd service?

A: Apache is a modular service, more support module, using servlet processing model, synchronous blocking model, changing the operating mode, high concurrency processing speed for the scene will be slow, stable operation. Support asynchronous read and write, you can do expressions separated by a positive movement.

2, three operating modes httpd service that you know about?

A: httpd has three operating modes.

prefork: pre-spawn child process

prefork mode can be regarded as very old but very stable mode. httpd service just started, some will fork a child process (the default is 5), a child process corresponds to a thread, and then wait for the request to come in, and always tried to keep some spare child processes, the reason for doing so is in order to reduce the frequency of process creation and destruction overhead. In the same point in time, a thread can only handle a process.

worker operating mode

worker and prefork mode mode than it is to use a multi-threaded multi-process model, it is also a pre-fork several sub-processes, each child process can generate some service thread and a listening thread, the thread monitor and an access request and delivery threading to the service and response. Less worker working mode memory used in highly concurrent performance was excellent. But we must consider thread safety issue, because multiple sub-processes are shared memory address of the parent process. If long connection keep-alive, maybe the middle of almost no request, it will be a blockage occurs, the thread is suspended, we need to wait until the timeout will not be released. If too many threads, and it was occupied, no services will lead to the thread at high concurrency scenarios available. (This problem also occurs in prefork mode).

event mode of operation

This is the latest mode of Apache, like it and worker mode, the biggest difference is that it solves the next keep-alive scenario, the waste of resources issues the thread is the long occupied.

event mode of operation, there will be a dedicated thread to manage the keep-alive type of thread, when there is a real request came even, passes the request to the server thread, after the implementation, but also allow it to be released. Thus, a thread can handle multiple requests, and asynchronous non-blocking.

event work mode when it encounters certain incompatible module, it will fail, and return to the model worker, a worker thread handling a request. Official module comes with all modes of operation are supported event.

3. Where can optimize several aspects httpd?

  • The rational allocation of its processes and threads;
  • Httpd open the deflate compression;
  • Open expires cache function;
  • Httpd prohibited conduct directory traversal;
  • Httpd version of the hidden information;
  • Enable the log cutting function;
  • Configuring security chain;

Guess you like

Origin blog.51cto.com/14154700/2451041
Recommended