php - My API and website can't load with timeout but cPanel work normal
Get the solution ↓↓↓all. I'm a newbie in running dedicated server. In some times, , my server is down, API/Website will be kept loading until ERROR_TIMEOUT. But, at the same time, I login the server cPanel, it works normal. I must close all Api/website connection and wait(less then 5 mins) until the server response normal.
Every time when it is more than 400 threads(according to image1), the server will not respond and timeout.
I am trying to find out the problem.
Please help me to find out/how to find out the problem or give me direction=[.
I guess:
1. Mysql: some queries are running too long.
But, according to image2, it seems not the critical part.
2. Too many requests at the same time.
But why cPanel load normal?
3. Is it possible related the port 80 because cPanel and WHM are using port 2083 and 2087 ?
Checklist:
- DDoS
triednetstat -ntu|awk '{print $5}'|cut -d: -f1 -s |cut -f1,2 -d'.'|sed 's/$/.0.0/'|sort|uniq -c|sort -nk1 -r
to check whether my server is under DDoS. The result is no.
Sorry for my poor English.
Some backgrounds:
- php 7.2
- Centos 7
- WHM v86.0.21
- yii2 framework (production mode i think..)
(comment out "defined('YII_DEBUG') or define('YII_DEBUG', true);defined('YII_ENV') or define('YII_ENV', 'dev');)" - php.ini
display_errors = Off
max_execution_time = 20
max_input_time = 30
max_input_vars = 1000
memory_limit = 128M
post_max_size = 10M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php72"
upload_max_filesize = 2M
zlib.output_compression = Off
I installed Munin in WHM to check the stat.
There are related images:
image1
Answer
Solution:
I solved it. This message is for some ppl who are facing similar problems. The problem is from yii2 active record using too many queries and server limited MaxClients.
Please follow the following step to check and solve your problem:
Please check your yii2 code.
Active record is convenient but it may use too many queries. You can use "Yii2 debugger" to check you Restful API. Related topic: How to use Yii2 debugger when developing RESTful application?Check you server Apache Configuration
You apache may limit your MaxClients. Please update you setting to meet your situation.
Hope this help!
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: property [id] does not exist on this collection instance.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.