有几台服务器都是windows2008系统
我配置了一下每台服务器的apache的最大并发量即ThreadsPerChild 1000
这几天为了优化原来的程序,需要写一个多线程(php借助apache的多线程实现)的长时间运行的程序,线程数是50个。
发现这些长时间运行的程序最多执行1个小时就会统一停止,找了半天原因发现当程序停止时apache的错误日志里会有“child process exited with status 255 -- Restarting.”的信息,然后apache就自动重启了。
于是我就检查每台服务器上的apache的错误日志,发现越高并发量的服务器,apache的重启频率就越频繁,有台并发在200左右的服务器竟然每隔几分钟就重启一次。
后来我试着用一个线程执行那个长时间运行的程序,发现1天下来都没有问题,再换50个线程的1小时不到又停了。
哎,我已经凌乱了,对apache实在不够了解,apache配置就设置了个多端口和并发数,其他都是原配,是不是还有些重要的配置我忽略了?
网上找了一段时间,没有合适的解决办法,各位一起分析讨论下吧
“child process exited with status 255 -- Restarting.”apache重启的问题如何解决?
php长时间执行程序遇到apache自动重启时怎么自动恢复?
回复讨论(解决方案)
你这样改改看看,httpd.conf文件, 我觉得一般瓶颈都在mysql上。 如果还不行, 果断换nginx,我前一段时间也是这样, 现在用nginx, 目前很愉快了。
<IfModule prefork.c> StartServers 5 MinSpareServers 5 MaxSpareServers 10 ServerLimit 2000 MaxClients 1500 MaxRequestsPerChild 1000</IfModule>
child process exited with status 255 -- Restarting
子进程的退出状态255??重启
windows 中的 php 是不支持线程的
如果你是通过 fsockopen 模拟,那就是主动发起的 http 进程。对于 apache 而言,这与浏览器发起的并无区别
当并发的 http 请求超过了 Apache 预设的并发数时,只会产生排队现象,而不会造成崩溃
当然,并发数是要有内存做保证的。内存不足,崩溃就是自然的
另外,如果 http 响应程序长时间没有输出的话,Apache 就会将其挂起。这不是 Apache 的问题,而是相应程序的问题
你这样改改看看,httpd.conf文件, 我觉得一般瓶颈都在mysql上。 如果还不行, 果断换nginx,我前一段时间也是这样, 现在用nginx, 目前很愉快了。
谢谢,我还没用过nginx,现在决定去试试
没注意你是windows系统, 可能版主说的对吧。
child process exited with status 255 -- Restarting
子进程的退出状态255??重启
windows 中的 php 是不支持线程的
如果你是通过 fsockopen 模拟,那就是主动发起的 http 进程。对于 apache 而言,这与浏览器发起的并无区别
当并发的 http 请求超过了 Apache 预设的并发数时,只会产生排队现象,而不会造成崩溃
当然,并发数是要有内存做保证的。内存不足,崩溃就是自然的
另外,如果 http 响应程序长时间没有输出的话,Apache 就会将其挂起。这不是 Apache 的问题,而是相应程序的问题
我就是通过 fsockopen模拟实现的。
我监控过一段时间当apache发生错误时任务管理器中的内存不高,应该不是内存不足引起的吧。
我也看网上说要输出,于是我也输出了如下
echo ' ';//一个空格ob_flush();flush();
输出写的对吗?输出缓冲区内容flush这两句不知是否要加,我理论功底不好,只是觉得输出内容一直放在缓冲区会有问题,请版主指正。
没注意你是windows系统, 可能版主说的对吧。
貌似有windows版的,总之我先看看去。
实在不行只有整体换Linux了,就是相应需要修改的项目就多了点。
php在linux下面跑。 基本上不需要改多少。 对应的文件注意大小写就好。
如果是windows下,建议使用fsockopen来模拟运行。
不要想了 更成Linux 这个时候可以继续使用apache 或者 nginx 即使你现在临时解决了win下的问题 下一个坑继续在等你.
一个坑接着一个坑的,太残酷了吧...
不过也确实随着系统越做越大,麻烦也越来越多,只得为以前没经验留下的隐患买单。
昨天想了个临时解决办法,写了一个监控程序监控多线程的运行,一旦发生长时间不操作就再次启动多线程(程序长时间运行现在观察好像不太会发生自己停止,基本上就是apache重启引起的,所以跟着他重启也就是了)。
今天观察了一下发现还算稳定,总算轻松了一把。
接下来我会尝试用最简单的程序,测试下apache并发时是否会发生不断重启的现象,把问题先定性一下,然后再决定是解决程序问题还是更换环境。
确认下来应该就是apache的问题了。
windows的nginx有问题,当一个访问未结束前,其他访问也不能执行,而我却偏偏要写一个长时间执行的程序。
环境问题就没办法了,看来目前最大的希望还是投向linux,哪怕又是一个坑。
谢谢各位,先结贴了。

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.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

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.

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 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.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

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

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6
Visual web development tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment