Starting today, I found that the nginx of the server generated a lot of logs, and prompted PHP Warning: Memcache::connect(): Can't connect to 127.0.0.1:11211, Connection timed out (110) in. Later, after many twists and turns, I found Something went wrong.
During a routine log check, I found a large number of PHP connection Memcached timeout error messages in the Nginx log, as follows:
PHP Warning: Memcache::connect(): Can't connect to 127.0.0.1:11211, Connection timed out (110) in ...
Connect to the server to check that the Memcached process is running normally. Then I use a test code to check whether Memcached can connect normally, and the result is also normal.
So I analyzed the log carefully and found that the error message appeared at intervals, indicating that there was a certain probability. At this time, I recalled that I had just pointed PHP's Session storage path to Memcached last week due to architectural issues. It may be because this configuration increased the load on Memcached, which caused Memcached to experience connection timeout when the amount of concurrency was high.
It’s easy to solve once you find the cause. Re-adjust the startup parameters of Memcached and add the -c parameter to increase the number of connections. The default is 1024, which can be increased gradually to find the optimal value. I set it to 2048.
The startup command is:
The code is as follows
|
Copy code
|
||||
memcached -d -m 256 -c 2048 -l 127.0.0.1 -p 11211 -u root |
http: //www.bkjia.com/PHPjc/633195.html