Nginx server details

Source: Internet
Author: User
Tags nginx server

Lightweight Web Server

1. Functions of the nginx Server

Nginx servers can act as Web servers, application servers, proxy servers, reverse proxy servers, backend servers, and CDN cache servers.

Nginx Basic module:

  • Kernel module coremodule: used to control the basic functions of the nginx server. The commands of this module are placed at the root of the configuration file (the starting part). The kernel module also provides a large number of built-in variables: $ URL, $ host ....
  • Eventsmodule: used to control how nginx processes connections. The command parameters of this module have an important impact on the performance of the application and are placed in events.
  • HTTP kernel module httpcoremodule: provides HTTP-related functions. This module cannot be disabled and the commands are placed in HTTP.

2. nginx module and process management

Nginx adopts a modular design, but unlike Apache,Once the module is compiled, it cannot be uninstalled.To re-compile nginx.

Understand the default and uninstalled modules of nginx:./Configure -- Help

Third-party module: When configuring nginx-- Add-ModuleUsed to add third-party modules.

Nginx is divided into two process models: single and master. Due to the poor single error identification capability, the master Process Model (master process and worker process) is used in the actual production environment)

Signals that can be processed by the master process:

Signals that can be processed by the worker process:

 

3. Linux Server Optimization for nginx

1) disable unnecessary services in the system

Chkconfig -- list all services in Linux

Service Bluetooth stop

Chkconfig -- level 235 Bluetooth off -- disable the Bluetooth service

2) optimized disk write operations: After nginx accesses a file, the Linux system modifies its access time, that is, the access time.

Configuration File:/etc/fstab

/Dev/sdb1/dataext3 defaults, noatime, nodiratime 0 0

3) optimize resource restrictions

Ulimit-n-limits the use of file descriptors by a single user, that is, the number of files that can be opened

Ulimit-u -- maximum number of processes owned by a single user

Modify the configuration file/etc/security/limits. conf

4) Optimize kernel TCP options

Modify the configuration file/etc/sysctl. conf

 

4. Optimizing the nginx Server

1) Disable access logs

2) use epoll

3) Configuration Optimization

Worker_connections 65535

Keepalive_timeout 60

Client_header_buffer_size 8 K

Worker_rlimit_nofile 65535.

 

5. nginx andCache

Three methods for nginx to implement the cache function:

1) nginx's proxy_store, proxy_cache, and memcached modules

2) third-party module ncache

3) varnish Server

 

Cache Technology --- memcached

 

 

 

 

 

 

What is the difference between nginx and Apache from the perspective of accepting client requests?

Nginx adopts the event-driven structure and uses asynchronous sockets to receive requests. It is a non-blocking structure and does not use individual threads for processing. The purpose is to reduce memory and CPU overhead, apache uses synchronous sockets, threads, and processes. Each request is a separate process or thread.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.