Taking Too Much CPU Utilization

Sumit6 years ago

Hello Anton,
I am using AWS instances and I have records 2M above rows. Now I am getting my MySQL server taking too much CPU utilization (say max: 60%, average: 30% to 40% and min: 15% to 20%) and before that it was taking only less than 5% usage of CPU. And now all of sudden, it is taking too much CPU usage and I also have incremented the configuration of the MySQL instance VM but it is still not working well in respect of CPU utilization.

How to overcome CPU utilization for more rows to hit more queries at a time? Suppose it is working on localhost it is taking 60% of CPU utilization.
I am really getting tired of this thing.

Anton Tananaev6 years ago

You need to check queries and try to optimise them. That's something DBA usually does.

Sumit6 years ago

Okay.

Sumit6 years ago

I deleted all queries those are taking much time and CPU% but it still it is taking CPU% more or I revert back the code where it takes the up to 5% of CPU usage.

Sumit6 years ago

Actually, positions table records are increasing rapidly and now they are above 2 million. So I think this can be a reason? Due to this, insertion gets slow.

Anton Tananaev6 years ago

It shouldn't if your database is configured properly and you have enough resources.

Sumit6 years ago

Current Resources config is:

  • 1 CPU
  • 2GiB Memory

Is this sufficient?

And I deployed database as it was.

And when I don't hit any query on the server and just reporting to the server, it still takes more 15% of CPU.

Anton Tananaev6 years ago

Depends on how many devices you have. Database as it was? Do you mean H2 database? That's definitely a problem. Read this:

https://www.traccar.org/optimization/

Sumit6 years ago

I am having 35 devices. And after sometimes, it will go up to 200 devices more.
And I add one column in devices table, one column in users table and one column in user_device table.
And for the database configuration file, it is just as it is defined in the Traccar Documentation.

Anton Tananaev6 years ago

2GB should be enough for 35 devices, but for 200 you will probably need more. At least 4GB.

Sumit6 years ago

And 1 CPU is enough to handle the performance of 35 devices?

Anton Tananaev6 years ago

Yes, it should be fine.

Sumit6 years ago

So there is no issue from hardware side?
But when I do the top command, it shows me only mysqld is taking most of the CPU utilization.

Anton Tananaev6 years ago

You need to investigate it yourself. What queries take long and why.

Sumit6 years ago

So if I have millions or billions of record, insertion time or retrieval time would not be affected or it would be same as it was when the records in hundreds to thousands?