Table of Contents
回复内容:
Home Backend Development PHP Tutorial linux 服务器负载很高,缘由貌似是 php进程过多,而且一直保持 400多

linux 服务器负载很高,缘由貌似是 php进程过多,而且一直保持 400多

Jun 06, 2016 pm 08:51 PM
linux php

linux 服务器负载很高,缘由貌似是 php进程过多,而且一直保持 400多linux 服务器负载很高,缘由貌似是 php进程过多,而且一直保持 400多 ,有图所示,php-cgi 进程数一直是不降的,没有用户访问网站也是这么多,每个进程大概占用内存150-200M左右,16G内存有时候会阻塞。求大牛帮忙。,负载有时候会达到顶峰,前无古人后无来者,120 负载,cpu 跑满。求教

回复内容:

linux 服务器负载很高,缘由貌似是 php进程过多,而且一直保持 400多linux 服务器负载很高,缘由貌似是 php进程过多,而且一直保持 400多 ,有图所示,php-cgi 进程数一直是不降的,没有用户访问网站也是这么多,每个进程大概占用内存150-200M左右,16G内存有时候会阻塞。求大牛帮忙。,负载有时候会达到顶峰,前无古人后无来者,120 负载,cpu 跑满。求教

可以考虑用fastcgi.
http://php.net/manual/en/install.fpm....

这么多的进程数load值很高也是可以预见的,建议还是查下PHP执行过程中的性能瓶颈究竟在哪。

mod_php是和apache同步执行的, 如果fastcgi的话, 服务器(一般nginx)和php之间是异步关系, 在某些情况下可以无需那么多php进程

打个比方, 如果一个用户用龟速上传一个文件, 那么apache和apache里面的那个php就在等待这个用户上传完成, 所以系统里面就需要更多的apache进程来应对并发

如果异步执行, 那么nginx在处理用户的上传, 一旦用户上传文件完成, 传给php处理只是一瞬间的事情.

当然有时候fastcgi也不一定能解决问题, 比如php在等待一个sql查询, 这个查询花了5秒, 那么5秒之内有新用户来访, 这个php就不能出门欢迎, 所以必须新开一个php进程

所以查一查你的php执行要花多久, 再看一看自己的访问量, 综合的去找原因并想办法解决吧

每个php进程都是很费内存的,建议根据服务器配置做适当调整,修改fastcgi配置文件或php-fpm配置文件,一般100个内对于大部分场景就够用了,再多就要考虑做任务调度或者消息队列处理了

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP and Python: Different Paradigms Explained PHP and Python: Different Paradigms Explained Apr 18, 2025 am 12:26 AM

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

Choosing Between PHP and Python: A Guide Choosing Between PHP and Python: A Guide Apr 18, 2025 am 12:24 AM

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

PHP and Python: A Deep Dive into Their History PHP and Python: A Deep Dive into Their History Apr 18, 2025 am 12:25 AM

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP vs. Python: Use Cases and Applications PHP vs. Python: Use Cases and Applications Apr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

The Continued Use of PHP: Reasons for Its Endurance The Continued Use of PHP: Reasons for Its Endurance Apr 19, 2025 am 12:23 AM

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

See all articles