Description of the scenario that appears:
1. There are users reported that registration can not be successful, through the front-end of the inventory to find that the upload file must be called when the interface a throws 500 errors, but not every time thrown but a great chance to throw 500.
The 2.A interface accepts 5 parameters and a file multi type, to pass the first 5 parameters can request to the code, but after the incoming file is not 500 error is a long time out.
3. Restart Nginx Invalid, the problem is still. Restarting FPM is invalid and the problem remains.
4. The machine has not been activated for a long time. Top shows a high memory consumption and then restarts the machine. Restarting the machine problem disappears, the A interface works correctly, and the problem recurs after 15 minutes and the symptoms remain.
5.nginx Log did not write anything in, see the specific error log (don't spray landlord not worthy of log directory, is equipped with ....) It just didn't write. Permission is also given, this is the most troublesome place, not afraid of the problem is not a clue.
The 6.ali cloud console shows low CPU load, low network footprint, and low disk footprint (you can still trust the command line in the future, Aliyun is not very reliable, later on)
The first step, then began to find the problem, first of all doubt whether it is the size of the upload file buffer, so draw on the http://www.aslibra.com/blog/read.php?1620 method to change the configuration of nginx buffer. So that the program does not report 500 errors, the purpose of running the program smoothly.
In the second step, the program is ready to run, but the interface call always returns a file upload error with an error code of 7 (the Nginx log still has no more records and the last record is written after the restart). Error=7 represents the constant of upload_err_cant_write, which means that the file's temporary directory write failed. So the landlord will be Nginx Client_body_temp_path re-designated position, the authority changed to 755, the problem is still, changed to 777, the problem is still.
In the third part, it seems that the problem appears to be deadlocked, with no logs, no temporary files, open permissions, increased buffer size, or not. But, as time will give us the answer, for a technical person, the extranet will give us the answer (intranet things are Shi, finally found is a huge simple problem.) )。 Even Google search error=7 upload_err_cant_write immediately get the answer that is ————df-h look? I am, the disk occupies 100%,aliyun incredibly did not have the alarm, instead shows the occupation is very low. fxxk!
The fourth step, since the problem is found to be resolved, because the TMP file is not long-term preservation, so the TMP directory is not hundreds of m, so use a more commonly used to view the folder command du
-hsx * |
sort
-rh |
head
-10,从/目录找起,最后竟然发现再源文件目录高达9个G,天哪我有那么伟大么,,写了9G的代码?那为毛工资还没有很高。。。。。别慌继续往下找,就发现问题处在thinkphp的runtime目录下的logs中,哈哈问题找到了,原来tp在默认情况下是要写日志的,而且增量还非常快,基本上每秒几kb。遂删除tp日志,再配置文件中关闭日志写入即可。
Report:
Landlord at the outset also thought of increasing the number of FPM sub-process, here by the way
1. Depending on how many FPM workers are loaded by PHP, the memory footprint of the worker is probably between 20m~50m, how it is allocated, and how much of the sub-process to allocate is a learning. If this machine does not run other things that big can set the child process to use half of the memory, the number of its own, and then after the use of the process based on the CPU load and so on some details adjustment.
2. If the machine needs to deploy some other services, such as the landlord of this 2-core 8G 20G 5M Aliyun CentOS on the deployment of more services, listing Gearman, MySQL, Redis, Nginx, FPM, as well as the landlord himself wrote APNs push, Tomcat, OpenFire, and a Java applet that gives OpenFire a front-end load balancer, and some don't list the poor as such. and file upload to go this machine, it can be said that the normal load or some, but not too large, access to the interface of the person is not much so can be used 200M to 500M to service FPM is acceptable, peak conditions 1G can also be received, so Pm.max_chindren = 20; Pm.start_servers = 10;pm.min_spare_servers = 1;//This is the dynamic minimum setting to be less than start_server pm.max_spare_servers=15;//This is the dynamic minimum setting, To be greater than start_servers
The number of processes in the 3.nginx I also modified a bit, the number of changes to the CPU 1~1.5 times more appropriate, after all, there are other services on the machine.
Well, it was a simple question that tortured me for a few hours, and it was a a fall into.
Sunyuw
Links: http://www.cnblogs.com/sunyuw/p/4207740.html
Welcome to reprint, but please specify and bring the original blog and the text of the link and my name, thank you.
The server uploaded a file with a 500 error, but the other interfaces that do not involve the file are normal