LEMP stack running out of memory

Posted September 4, 2017 1.6k views
Nginx Ubuntu Configuration Management LEMP

i have a lemp stack for wordpress, currently getting an average of 70- 100 visitors per day.
1gb server and mysql keeps crashing. i have netdata on as well, and i keep having to go into the ssh console to restart it as a result.

this is what i see in the error log
Out of memory: Kill process 29383 (mysqld) score 244 or sacrifice child
Killed process 29383 (mysqld) total-vm:1169884kB, anon-rss:288068kB, file-rss:0kB, shmem-rss:0kB

do i need more memory?

here are my configs for NGINX

user www-data;
worker_processes 1;
pid /run/;
include /etc/nginx/modules-enabled/*.conf;

events {
workerconnections 1024;
use epoll;
accept on;

http {

# Basic Settings

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 100000;
types_hash_max_size 2048;
server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

#from ngninx optimize linode page
client_body_buffer_size      128k;
client_max_body_size         10m;
client_header_buffer_size    1k;
large_client_header_buffers  4 4k;
output_buffers               1 32k;
postpone_output              1460;
client_header_timeout  3m;
client_body_timeout    3m;
send_timeout           3m;
open_file_cache max=1000 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 5;
open_file_cache_errors off;

include /etc/nginx/mime.types;
default_type application/octet-stream;

# SSL Settings
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

# Logging Settings

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

# Gzip Settings

gzip on;
gzip_min_length 1000;
gzip_types text/html application/x-javascript text/css application/javascript text/javascript text/plain text/xml application/json application/ application/x-font-opentype application/x-font-truetype application/x-font-ttf application/xml font/eot font/opentype font/otf image/svg+xml image/;
#gzip_disable "msie6";
gzip_disable "MSIE [1-6]\.";

# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

# Virtual Host Configs

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;


——– and MYSQL config

maxallowedpacket = 1M
threadstack = 128K
connections = 50
tableopencache = 32M
keybuffersize = 64M

thank you in advance!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

1 answer

Use mysql tuner, you obviously haven’t allocated enough memory to mysql.

Submit an Answer