NGINX+PHP-FPM access for when fast and slow

Source: Internet
Author: User

Reason:

A test environment, NGINX+PHP-FPM to provide services to the outside, testing personnel access when the time when the situation is slow, slower than the normal Web page waiting to open the time range. Restart Nginx php-fpm, after several visits will be slow

Find ideas:

1, System load, disk IO

Top, view load, load less than 1 exclude.

Vmstat View disk IO test environment IO small, exclude.

2, do you have a PHP slow query program

Open php Slow query log in PHP-FPM

Request_slowlog_timeout = 5

Slowlog = Var/log/slow.log

Reload no slow query log after access to determine the non-execution time of the PHP program is relatively slow

Check the configuration file

PM = static

Pm.max_children = 300

Pm.start_servers = 15

Pm.min_spare_servers = 8

Pm.max_spare_servers = 48

Request_terminate_timeout = 200

Exclusion is a problem caused by pm.max_children setting too small.

3, suspected MySQL has slow query

Web site when the slow restart after the faster to open the unified page, the elimination of MySQL has slow query. At this time into confusion and embarrassment.

View Nginx configuration file

Worker_rlimit_nofile 65535 stumbled upon how familiar the number, defined here to limit the number of open files, is associated with the Ulimit parameter

Ulimit-n did not optimize, showing the default of 1024

echo ‘*  -  nofile  65535‘ >> /etc/security/limits.conf

then execute the next ulimit-hsn  65535

也可以把ulimit -SHn 65535命令加入到/etc/rc.local,然后每次重启生效

File descriptor

The file descriptor is formally a non-negative integer. In fact, it is an index value that points to the record table in which the kernel opens a file for each process maintained by the process. When a program opens an existing file or creates a new file, the kernel returns a file descriptor to the process. In programming, some of the underlying programming often revolves around file descriptors. However, the concept of file descriptors is often applied only to operating systems such as UNIX and Linux.

Traditionally, standard input has a file descriptor of 0, standard output is 1, and standard error is 2. Although this habit is not characteristic of the Unix kernel, it is used by some shell and many applications, so if the kernel does not follow this habit, many applications will not be able to use it.

调整完之后访问时快时慢的问题解决。

This article is from the "chapter Small Fish _linux" blog, please be sure to keep this source http://zhangxylinux.blog.51cto.com/5041623/1543613

NGINX+PHP-FPM access for when fast and slow

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.