0

I am not a server guru, could somebody help me understand what part of my server is under load and what can I do to fix this?

My best guess is too many connection to node server + mysql, becuse most the time I am getting mysql connection refeused errors in my node js app's logs

directadmin load report


[root@dominoserver ~]# vi /var/log/mysql/mysql_error.log
InnoDB: Progress in percent: 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

UPDATE : I checked the server's cpu usage chart and it had lots of 100% spikes so for now I added another cpu core to my sever ... have to wait and see what happens!

Exlord
  • 101
  • 6
  • 1
    High MySQL load is often caused by suboptimal database definitions / usage. Check that you have proper indexes in your table for your use and that your code properly utilises SQL to query data from database. – Tero Kilkanen Jun 28 '20 at 07:58

1 Answers1

1

You have some performance logs, and adding more resources to the server is never a bad idea.

Things I may suggest from experience.

Check all your logs, dmesg, service logs etc, for related messages. It's quite possible in some cases for the server to have enough resources but is coming up against kernel or mysql limits... such as number of open files for example, or concurrent connections (threads) to the mysql server.

You have some monitoring running on your server, which is great, but sometimes a picture paints a thousand words, and you can identify trends more quickly by actually seeing the data in a pictorial format.

There are overwhelming amount of monitoring tools. There might even be a option in your monitoring tool output graphs of some kind.

if it transpires that mysql is overloaded, then there are number of things you can do to optimise that part of your server.

  • tuning the mysql parameters.

  • optimising your database structure with faster indexes

  • organising data in a different way, or re-engineering you application to make better queries.

  • Focusing on how you application talks to your database (via a internal Unix domain sockets, or via a loopback TCP socket, does it reused connections pools)

'The best query to database , is one that you never have to make'. You think the 'youtube video number of views counter' is calculated with a database query? think again!

there are many tools to do, this some pay for tools/services , some you can just install for free.

https://github.com/major/MySQLTuner-perl

https://stackify.com/mysql-tutorial-improve-performance/

If it turns out that it's just the 'way' you accessing the data within the database, then think about you data? are you doing complex queries, or is mysql essential doing key/value pair looks ups... Experiment with different database servers , and take a look at nosql databases , your might have a database model that just fits these much faster ways of access data :-).

If you cannot rearchitect your database layer, then there are number of cache layers that can really speed up you application if it's making the same read queries over and over.

https://dev.mysql.com/doc/refman/5.7/en/innodb-memcached-intro.html

The last thing to think about is , who is accessing mysql? is the backend exposed to the internet? are all the request coming from where you think they should be? Do you have a backup job running remotely, that causes an already loaded server to become overloaded during the backup cycle?

Optimisation is a good think to learn, its ironic that many applications out there could support their current external loads with much less server hardware, and without scaling out. Scaling up is much easier (more NET/RAM/CPU/SSD/DISK).

Good luck.

https://www.tecmint.com/command-line-tools-to-monitor-linux-performance/ https://www.binarytides.com/linux-commands-monitor-network/

The Unix Janitor
  • 2,458
  • 15
  • 13