I have a Yii2 based web project. Recently I've write some REST API to it. I've realized, that every REST API call has a very long response time. 1134ms, 1250ms, 1034ms etc., so basically the avarage response time is above 1 second.
The Client model has no relation (Client table is a 'standalone' table).
My test table (client) is contains 173 record (1 row has 10 columns). I debugged the problem and marked the related line:
...
$client_id = Yii::$app->request->post('client_id');
// client_id ellenőrzése (pl. blokkolt-e a mobil kliens)
if (!empty($client_id)) {
$client = Client::findOne($client_id); <-----
...
So far I've not configured any cache components, because I don't think, that a table with 173 record is required that.
Without the mentioned findOne() line the response time is avarage 30ms. The environment:
- php 7,
- Mysql 5.5,
- Yii 2
What should be the problem ? Something in configuration? I developed another project with Yii 1.1 a few years ago, I didn't remember this kind of problem there.
Thank you.
UPDATE #1:
UPDATE #2: I've noticed, that every activerecord realated operation takes about 1 second to finish (not just Client related operations). Getting 10 items to a gridview, update 1 record etc.
UPDATE #3: Ok, something strange is happening. I've created a very simple action, which also requires ~1 second to render:
public function actionTest() {
echo "OK";
}
The login page requires avarage 32ms to load.