High memory usage on digital ocean droplet

Viewed 1594

I have a laravel application which I've installed on a 1GB standard droplet running ubuntu 20.4, nginx, MySQL 8 and php 7.4

The application isn't even live yet and I notice it's already using over 50% memory. Yesterday it was using 80% and after a system reboot its returned to using around 60% memory usage.

Below is a snap shot of the current high memory running processes. Is this level of memory usage normal for a laravel application which is not even live i.e. limited load?

top - 19:41:00 up  3:46,  1 user,  load average: 0.08, 0.04, 0.01
Tasks: 101 total,   1 running, 100 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.7 sy,  0.0 ni, 98.7 id,  0.3 wa,  0.0 hi,  0.0 si,  0.0 st
MiB Mem :    981.3 total,     90.6 free,    601.4 used,    289.3 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    212.2 avail Mem


PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
815 mysql     20   0 1305900 417008  13352 S   0.7  41.5   1:32.39 mysqld
2257 www-data  20   0  245988  44992  30180 S   0.0   4.5   0:04.67 php-fpm7.4
2265 www-data  20   0  243700  42204  29572 S   0.0   4.2   0:04.41 php-fpm7.4
2259 www-data  20   0  243960  42104  30380 S   0.0   4.2   0:04.44 php-fpm7.4
988 root      20   0  125160  36188  10604 S   0.3   3.6   0:09.89 php
388 root      19  -1   84404  35116  33932 S   0.0   3.5   0:01.14 systemd-journ+
741 root      20   0  627300  20936   6656 S   0.0   2.1   0:02.11 snapd
738 root      20   0  238392  18588  12624 S   0.0   1.8   0:00.83 php-fpm7.4
743 root      20   0   31348  18344   3844 S   0.0   1.8   0:02.75 supervisord
544 root      rt   0  280180  17976   8184 S   0.0   1.8   0:00.90 multipathd
825 root      20   0  108036  15376   7732 S   0.0   1.5   0:00.10 unattended-up+
736 root      20   0   29220  13200   5544 S   0.0   1.3   0:00.11 networkd-disp+
726 do-agent  20   0  559436  12120   6588 S   0.0   1.2   0:01.78 do-agent
  1 root      20   0  101964  11124   8024 S   0.0   1.1   0:02.52 systemd
623 systemd+  20   0   23912  10488   6484 S   0.0   1.0   0:00.42 systemd-resol+
778 www-data  20   0   71004   9964   5240 S   0.0   1.0   0:02.43 nginx

My concern is once the application goes live and the load increases, more database connection it going to run out of memory. I know I can resize the droplet and increase the memory or set up some swap space but is this amount of memory usage normal for an unused application?

How can I optimize the high memory usage processes such as mysql, niginx, php. Mysql8 appear to be the main culprit hogging all the memory. Below are my mysql setting:

#
# The MySQL database server configuration file.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

[mysqld]
#
# * Basic Settings
#
user            = mysql
# pid-file      = /var/run/mysqld/mysqld.pid
# socket        = /var/run/mysqld/mysqld.sock
# port          = 3306
# datadir       = /var/lib/mysql


# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system- variables.html#sysvar_tmpdir
# tmpdir                = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1
#
# * Fine Tuning
#
key_buffer_size         = 16M
# max_allowed_packet    = 64M
# thread_stack          = 256K

# thread_cache_size       = -1

# This replaces the startup script and checks MyISAM tables if needed
# the first time they are touched
myisam-recover-options  = BACKUP

# max_connections        = 151

# table_open_cache       = 4000

#
# * Logging and Replication
#
# Both location gets rotated by the cronjob.
#
# Log all queries
# Be aware that this log type is a performance killer.
# general_log_file        = /var/log/mysql/query.log
# general_log             = 1
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log
#
# Here you can see queries with especially long duration
# slow_query_log                = 1
# slow_query_log_file   = /var/log/mysql/mysql-slow.log
# long_query_time = 2
# log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
# server-id             = 1
# log_bin                       = /var/log/mysql/mysql-bin.log
# binlog_expire_logs_seconds    = 2592000
max_binlog_size   = 100M
# binlog_do_db          = include_database_name
# binlog_ignore_db      = include_database_name   

Any tips and advice much appreciate as this is the first time I'm using a vps.

0 Answers
Related