Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: Apache or MySQL crash
PostPosted: Mon Jun 22, 2015 11:12 pm 
Offline
Senior Newbie

Joined: Mon Sep 29, 2014 1:21 am
Posts: 17
About 2 or 3 times a week my database crashes. All my websites get the "error establishing a database connection" error - only way to solve this is to restart my linode since I'm unable to login ssh when this happens.

my Linode has: 1gb ram, ubuntu 14.04 with 256mb swap size. My apache/php/mysql configuration is according the Linode tutorials for 1gb ram.

This is the syslog of when it occured. It seems like it tries to kill processes in order to free up memory and because (after some research) it has 0 swap file size.
Syslog
Code:
Jun 23 04:09:02 www CRON[26655]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Jun 23 04:09:18 www kernel: apache2 invoked oom-killer: gfp_mask=0x200da, order=0, oom_score_adj=0
Jun 23 04:09:18 www kernel: apache2 cpuset=/ mems_allowed=0
Jun 23 04:09:18 www kernel: CPU: 0 PID: 26613 Comm: apache2 Not tainted 4.0.5-x86_64-linode58 #1
Jun 23 04:09:18 www kernel: 0000000000000000 ffff8800029d67c0 ffffffff8193b626 ffff8800029d6180
Jun 23 04:09:18 www kernel: ffffffff819360a4 0000000000000400 ffff88003fe16000 0000000000000020
Jun 23 04:09:18 www kernel: ffff88003fe16000 0000000000000000 0000000000000000 0000000000000000
Jun 23 04:09:18 www kernel: Call Trace:
Jun 23 04:09:18 www kernel: [<ffffffff8193b626>] ? dump_stack+0x40/0x50
Jun 23 04:09:18 www kernel: [<ffffffff819360a4>] ? dump_header.isra.10+0x78/0x1e3
Jun 23 04:09:18 www kernel: [<ffffffff81941bb6>] ? _raw_spin_unlock_irqrestore+0x2e/0x3f
Jun 23 04:09:18 www kernel: [<ffffffff81172f4a>] ? oom_kill_process+0xbe/0x380
Jun 23 04:09:18 www kernel: [<ffffffff8117369a>] ? __out_of_memory+0x43d/0x47d
Jun 23 04:09:18 www kernel: [<ffffffff8117381b>] ? out_of_memory+0x52/0x67
Jun 23 04:09:18 www kernel: [<ffffffff811777e5>] ? __alloc_pages_nodemask+0x708/0x846
Jun 23 04:09:18 www kernel: [<ffffffff81004a2d>] ? __raw_callee_save_xen_pte_val+0x11/0x1e
Jun 23 04:09:18 www kernel: [<ffffffff811a57d6>] ? alloc_pages_vma+0x111/0x15a
Jun 23 04:09:18 www kernel: [<ffffffff8119fc14>] ? read_swap_cache_async+0x76/0x121
Jun 23 04:09:18 www kernel: [<ffffffff8119fe04>] ? swapin_readahead+0x145/0x155
Jun 23 04:09:18 www kernel: [<ffffffff811700bb>] ? find_get_entry+0x1a/0x68
Jun 23 04:09:18 www kernel: [<ffffffff81170b9f>] ? pagecache_get_page+0x26/0x160
Jun 23 04:09:18 www kernel: [<ffffffff8119365a>] ? handle_mm_fault+0x9c1/0xd80
Jun 23 04:09:18 www kernel: [<ffffffff8104219d>] ? __do_page_fault+0x321/0x37b
Jun 23 04:09:18 www kernel: [<ffffffff8193ec28>] ? __schedule+0x5de/0x7cd
Jun 23 04:09:18 www kernel: [<ffffffff81943f08>] ? page_fault+0x28/0x30
Jun 23 04:09:18 www kernel: Mem-Info:
Jun 23 04:09:18 www kernel: Node 0 DMA per-cpu:
Jun 23 04:09:18 www kernel: CPU    0: hi:    0, btch:   1 usd:   0
Jun 23 04:09:18 www kernel: Node 0 DMA32 per-cpu:
Jun 23 04:09:18 www kernel: CPU    0: hi:  186, btch:  31 usd:   5
Jun 23 04:09:18 www kernel: active_anon:104835 inactive_anon:104945 isolated_anon:0
Jun 23 04:09:18 www kernel: active_file:38 inactive_file:348 isolated_file:0
Jun 23 04:09:18 www kernel: unevictable:0 dirty:0 writeback:0 unstable:0
Jun 23 04:09:18 www kernel: free:2444 slab_reclaimable:17327 slab_unreclaimable:5466
Jun 23 04:09:18 www kernel: mapped:4636 shmem:5034 pagetables:2252 bounce:0
Jun 23 04:09:18 www kernel: free_cma:0
Jun 23 04:09:18 www kernel: Node 0 DMA free:3948kB min:60kB low:72kB high:88kB active_anon:4084kB inactive_anon:4224kB active_file:16kB inactive_file:24kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15996kB managed:15912kB mlocked:0kB dirty:0kB writeback:0kB mapped:836kB shmem:1152kB slab_reclaimable:864kB slab_unreclaimable:200kB kernel_stack:96kB pagetables:60kB unstable:0kB bounce:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:252 all_unreclaimable? yes
Jun 23 04:09:18 www kernel: lowmem_reserve[]: 0 968 968 968
Jun 23 04:09:18 www kernel: Node 0 DMA32 free:5828kB min:3948kB low:4932kB high:5920kB active_anon:415256kB inactive_anon:415556kB active_file:136kB inactive_file:1368kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:1032192kB managed:995724kB mlocked:0kB dirty:0kB writeback:0kB mapped:17708kB shmem:18984kB slab_reclaimable:68444kB slab_unreclaimable:21664kB kernel_stack:2848kB pagetables:8948kB unstable:0kB bounce:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:9264 all_unreclaimable? yes
Jun 23 04:09:18 www kernel: lowmem_reserve[]: 0 0 0 0
Jun 23 04:09:18 www kernel: Node 0 DMA: 13*4kB (UM) 10*8kB (UR) 11*16kB (R) 8*32kB (R) 5*64kB (R) 4*128kB (R) 2*256kB (R) 0*512kB 0*1024kB 1*2048kB (R) 0*4096kB = 3956kB
Jun 23 04:09:18 www kernel: Node 0 DMA32: 461*4kB (UEM) 122*8kB (UEMR) 30*16kB (MR) 17*32kB (R) 7*64kB (R) 2*128kB (R) 1*256kB (R) 0*512kB 1*1024kB (R) 0*2048kB 0*4096kB = 5828kB
Jun 23 04:09:18 www kernel: 7000 total pagecache pages
Jun 23 04:09:18 www kernel: 1563 pages in swap cache
Jun 23 04:09:18 www kernel: Swap cache stats: add 164053, delete 162490, find 242212/264237
[b]Jun 23 04:09:18 www kernel: Free swap  = 0kB[/b]
Jun 23 04:09:18 www kernel: Total swap = 262140kB
Jun 23 04:09:18 www kernel: 262047 pages RAM
Jun 23 04:09:18 www kernel: 0 pages HighMem/MovableOnly
Jun 23 04:09:18 www kernel: 9138 pages reserved
Jun 23 04:09:18 www kernel: [ pid ]   uid  tgid total_vm      rss nr_ptes nr_pmds swapents oom_score_adj name
Jun 23 04:09:18 www kernel: [ 1554]     0  1554      919        0       4       1      230             0 upstart-udev-br
Jun 23 04:09:18 www kernel: [ 1561]     0  1561     2505        1       7       2      124         -1000 systemd-udevd
Jun 23 04:09:18 www kernel: [ 2477]     0  2477     1379       42       5       1      395             0 dhclient
Jun 23 04:09:18 www kernel: [ 2696]   105  2696     1060        0       6       2       77             0 dbus-daemon
Jun 23 04:09:18 www kernel: [ 2736]   101  2736     7752       72       9       2      213             0 rsyslogd
Jun 23 04:09:18 www kernel: [ 2745]     0  2745     1055        2       6       2       74             0 systemd-logind
Jun 23 04:09:18 www kernel: [ 2774]     0  2774      765       15       5       2       34             0 cron
Jun 23 04:09:18 www kernel: [ 2776]     0  2776     1951        1       7       1      121         -1000 sshd
Jun 23 04:09:18 www kernel: [ 2814]     0  2814      789        0       4       1      126             0 upstart-file-br
Jun 23 04:09:18 www kernel: [ 2815]     0  2815      851        0       5       1      199             0 upstart-socket-
Jun 23 04:09:18 www kernel: [ 2831]   104  2831    85771     6457      72       1    11904             0 mysqld
Jun 23 04:09:18 www kernel: [ 2853]     0  2853     8720     1524      17       2     2162             0 linode-longview
Jun 23 04:09:18 www kernel: [ 2914]     0  2914    31136      841      34       1      961             0 apache2
Jun 23 04:09:18 www kernel: [ 2986]     0  2986     9731      576      14       2      566             0 fail2ban-server
Jun 23 04:09:18 www kernel: [ 3026]     0  3026      606        1       5       2       27             0 getty
Jun 23 04:09:18 www kernel: [ 4462]     0  4462     1077        4       5       1       63             0 ntpd
Jun 23 04:09:18 www kernel: [ 4463]   103  4463     1046       21       5       1       43             0 ntpd
Jun 23 04:09:18 www kernel: [ 4802]     0  4802     3321        1      10       1      242             0 sshd
Jun 23 04:09:18 www kernel: [ 4840]  1001  4840     3321        0       9       1      242             0 sshd
Jun 23 04:09:18 www kernel: [ 4841]  1001  4841     1414        2       6       2       84             0 bash
Jun 23 04:09:18 www kernel: [ 4850]     0  4850     3294        0       9       1      218             0 sshd
Jun 23 04:09:18 www kernel: [ 4887]     0  4887     3294        1       8       1      226             0 sshd
Jun 23 04:09:18 www kernel: [ 4907]     0  4907     3335        1       9       1      247             0 sshd
Jun 23 04:09:18 www kernel: [ 4908]     0  4908     3424        1       9       1      294             0 sshd
Jun 23 04:09:18 www kernel: [ 4910]     0  4910     3423        1      10       1      291             0 sshd
Jun 23 04:09:18 www kernel: [ 4912]     0  4912     3336        1       9       1      248             0 sshd
Jun 23 04:09:18 www kernel: [ 4916]     0  4916     3335        1       9       1      277             0 sshd
Jun 23 04:09:18 www kernel: [ 4917]     0  4917     3424        1      10       1      297             0 sshd
Jun 23 04:09:18 www kernel: [ 4918]     0  4918     3336        1       9       1      248             0 sshd
Jun 23 04:09:18 www kernel: [ 4920]     0  4920     3336        1      10       1      270             0 sshd
Jun 23 04:09:18 www kernel: [ 5242]     0  5242     3294        1       9       1      232             0 sshd
Jun 23 04:09:18 www kernel: [ 5243]     0  5243     3294        1       8       1      233             0 sshd
Jun 23 04:09:18 www kernel: [ 5244]     0  5244     3294        1       9       1      233             0 sshd
Jun 23 04:09:18 www kernel: [ 5245]     0  5245     3293        1       9       1      232             0 sshd
Jun 23 04:09:18 www kernel: [ 5247]     0  5247     3293        0       9       1      230             0 sshd
Jun 23 04:09:18 www kernel: [ 5248]     0  5248     3294        1       8       1      233             0 sshd
Jun 23 04:09:18 www kernel: [ 5249]     0  5249     3294        1       8       1      233             0 sshd
Jun 23 04:09:18 www kernel: [ 5250]     0  5250     3293        1       8       1      232             0 sshd
Jun 23 04:09:18 www kernel: [ 6504]     0  6504     3319        1       9       1      239             0 sshd
Jun 23 04:09:18 www kernel: [ 6564]  1001  6564     3319        0       8       1      239             0 sshd
Jun 23 04:09:18 www kernel: [ 6565]  1001  6565     1411        1       7       2       82             0 bash
Jun 23 04:09:18 www kernel: [25014]    33 25014    41642    12866      82       1     3171             0 apache2
Jun 23 04:09:18 www kernel: [25659]    33 25659    39383    13394      78       1      632             0 apache2
Jun 23 04:09:18 www kernel: [25957]    33 25957    39999    13490      79       1     1002             0 apache2
Jun 23 04:09:18 www kernel: [26400]    33 26400    39188     9968      77       1     3742             0 apache2
Jun 23 04:09:18 www kernel: [26458]    33 26458    39328     9139      77       1     4478             0 apache2
Jun 23 04:09:18 www kernel: [26471]    33 26471    39158     9203      67       1     3690             0 apache2
Jun 23 04:09:18 www kernel: [26477]    33 26477    39237     8606      58       1     4674             0 apache2
Jun 23 04:09:18 www kernel: [26487]    33 26487    38906     9313      66       1     3349             0 apache2
Jun 23 04:09:18 www kernel: [26548]    33 26548    38992     8646      58       1     3761             0 apache2
Jun 23 04:09:18 www kernel: [26556]    33 26556    39402     7976      59       1     5365             0 apache2
Jun 23 04:09:18 www kernel: [26603]    33 26603    38660     6534      46       1     2150             0 apache2
Jun 23 04:09:18 www kernel: [26606]    33 26606    38546     7032      46       1     1567             0 apache2
Jun 23 04:09:18 www kernel: [26607]    33 26607    38542     7204      46       1     1470             0 apache2
Jun 23 04:09:18 www kernel: [26610]    33 26610    38332     7546      45       1      902             0 apache2
Jun 23 04:09:18 www kernel: [26611]    33 26611    38330     7587      45       1      925             0 apache2
Jun 23 04:09:18 www kernel: [26612]    33 26612    38402     7610      45       1      844             0 apache2
Jun 23 04:09:18 www kernel: [26613]    33 26613    38272     7648      45       1      776             0 apache2
Jun 23 04:09:18 www kernel: [26618]    33 26618    38394     7857      45       1      589             0 apache2
Jun 23 04:09:18 www kernel: [26619]    33 26619    38460     7895      46       1      601             0 apache2
Jun 23 04:09:18 www kernel: [26620]    33 26620    38265     7766      45       1      609             0 apache2
Jun 23 04:09:18 www kernel: [26621]    33 26621    38336     7803      46       1      611             0 apache2
Jun 23 04:09:18 www kernel: [26622]    33 26622    38208     7745      45       1      602             0 apache2
Jun 23 04:09:18 www kernel: [26623]    33 26623    38272     7762      45       1      593             0 apache2
Jun 23 04:09:18 www kernel: [26624]    33 26624    38079     7614      45       1      586             0 apache2
Jun 23 04:09:18 www kernel: [26625]    33 26625    38009     7585      45       1      586             0 apache2
Jun 23 04:09:18 www kernel: [26631]    33 26631    37494     7152      44       1      598             0 apache2
Jun 23 04:09:18 www kernel: [26632]    33 26632    37815     7340      45       1      594             0 apache2
Jun 23 04:09:18 www kernel: [26633]    33 26633    37753     7305      44       1      594             0 apache2
Jun 23 04:09:18 www kernel: [26635]    33 26635    37433     6984      44       1      594             0 apache2
Jun 23 04:09:18 www kernel: [26640]    33 26640    31154      419      29       1      942             0 apache2
Jun 23 04:09:18 www kernel: [26641]    33 26641    31144      399      27       1      951             0 apache2
Jun 23 04:09:18 www kernel: [26642]    33 26642    31144      399      27       1      951             0 apache2
Jun 23 04:09:18 www kernel: [26643]    33 26643    31144      399      27       1      951             0 apache2
Jun 23 04:09:18 www kernel: [26644]    33 26644    31144      399      27       1      951             0 apache2
Jun 23 04:09:18 www kernel: [26645]    33 26645    31144      399      27       1      951             0 apache2
Jun 23 04:09:18 www kernel: [26646]    33 26646    31144      399      27       1      951             0 apache2
Jun 23 04:09:18 www kernel: [26647]    33 26647    31144      399      27       1      951             0 apache2
Jun 23 04:09:18 www kernel: [26648]    33 26648    31144      399      27       1      951             0 apache2
Jun 23 04:09:18 www kernel: [26650]    33 26650    31144      399      27       1      951             0 apache2
[b]Jun 23 04:09:18 www kernel: Out of memory: Kill process 2831 (mysqld) score 57 or sacrifice child[/b]
Jun 23 04:09:18 www kernel: Killed process 2831 (mysqld) total-vm:343084kB, anon-rss:25828kB, file-rss:0kB
Jun 23 04:09:18 www kernel: init: mysql main process (2831) killed by KILL signal
Jun 23 04:09:18 www kernel: init: mysql main process ended, respawning
Jun 23 04:09:19 www kernel: init: mysql main process (26693) terminated with status 1
Jun 23 04:09:19 www kernel: init: mysql main process ended, respawning
Jun 23 04:09:19 www kernel: init: mysql post-start process (26694) terminated with status 1
Jun 23 04:09:20 www kernel: init: mysql main process (26728) terminated with status 1
Jun 23 04:09:20 www kernel: init: mysql respawning too fast, stopped


the error log from /var/log/mysql shows:
Code:
150623  4:09:18 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
150623  4:09:18 [Note] Plugin 'FEDERATED' is disabled.
150623  4:09:18 InnoDB: The InnoDB memory heap is disabled
150623  4:09:18 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150623  4:09:18 InnoDB: Compressed tables use zlib 1.2.8
150623  4:09:18 InnoDB: Using Linux native AIO
150623  4:09:18 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(135987200 bytes) failed; errno 12
150623  4:09:18 InnoDB: Completed initialization of buffer pool
150623  4:09:18 InnoDB: Fatal error: cannot allocate memory for the buffer pool
150623  4:09:18 [ERROR] Plugin 'InnoDB' init function returned error.
150623  4:09:18 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150623  4:09:18 [ERROR] Unknown/unsupported storage engine: InnoDB
150623  4:09:18 [ERROR] Aborting

150623  4:09:18 [Note] /usr/sbin/mysqld: Shutdown complete

150623  4:09:19 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
150623  4:09:19 [Note] Plugin 'FEDERATED' is disabled.
150623  4:09:19 InnoDB: The InnoDB memory heap is disabled
150623  4:09:19 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150623  4:09:19 InnoDB: Compressed tables use zlib 1.2.8
150623  4:09:19 InnoDB: Using Linux native AIO
150623  4:09:20 InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(135987200 bytes) failed; errno 12
150623  4:09:20 InnoDB: Completed initialization of buffer pool
150623  4:09:20 InnoDB: Fatal error: cannot allocate memory for the buffer pool
150623  4:09:20 [ERROR] Plugin 'InnoDB' init function returned error.
150623  4:09:20 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
150623  4:09:20 [ERROR] Unknown/unsupported storage engine: InnoDB
150623  4:09:20 [ERROR] Aborting

150623  4:09:20 [Note] /usr/sbin/mysqld: Shutdown complete



Code:
$ free -m
                                  total       used       free     shared    buffers     cached
Mem:                           987        969         18         64         29        388
-/+ buffers/cache:        551        436
Swap:                          255         21        234



How can I prevent (I think) MySQL from crashing?

Many thanks


Top
   
PostPosted: Mon Jun 22, 2015 11:20 pm 
Offline
Senior Member

Joined: Mon Jul 05, 2010 5:13 pm
Posts: 392
It's trying to free up RAM because you're exhausting your RAM. Figure out what is using the RAM, then tune it to use less RAM or upgrade your system to have more RAM.

Longview/munin/htop all have varying degrees of usefulness there.

- Les


Top
   
PostPosted: Mon Jun 22, 2015 11:56 pm 
Offline
Senior Newbie

Joined: Mon Sep 29, 2014 1:21 am
Posts: 17
Seems like RAM usage was normal when it happen. (timestamps of logs and longview are different)

Image


Top
   
PostPosted: Mon Jun 22, 2015 11:58 pm 
Offline
Junior Member
User avatar

Joined: Mon Jun 22, 2015 12:55 am
Posts: 30
Website: http://iserversupport.com/
See the line

Jun 23 04:09:18 www kernel: Out of memory: Kill process 2831 (mysqld) score 57 or sacrifice child


MySQL got killed because there is no enough spam, either upgrade ram or optimize these service

_________________
Server Management with 24x7 monitoring
http://iserversupport.com/on-demand/


Top
   
PostPosted: Tue Jun 23, 2015 12:14 am 
Offline
Senior Newbie

Joined: Mon Sep 29, 2014 1:21 am
Posts: 17
According to this thread http://www.webtrafficexchange.com/solve ... uffer-pool
which is very similar to my setup. I have set:
Code:
## Edit /etc/my.cnf, and add the following line under the [mysqld] heading.
[mysqld]
innodb_buffer_pool_size=64M


Think that will help in my situation?


Top
   
PostPosted: Tue Jun 23, 2015 7:15 am 
Offline
Senior Member

Joined: Fri Feb 13, 2015 8:12 pm
Posts: 101
Quote:
there is no enough spam

No, he does not need more spam, he just needs more swap.


Top
   
PostPosted: Tue Jun 23, 2015 1:07 pm 
Offline
Linode Staff

Joined: Sat Oct 05, 2013 7:50 pm
Posts: 8
Website: http://www.thetechstewart.com
Twitter: thetechstewart
sanvila wrote:
No, he does not need more spam, he just needs more swap.


More swap is never the best answer. It's far slower to access than physical memory. Issues with running out of memory should be addressed, as many folks have said here, by increasing the memory allocated to the system to provide more headroom, or by optimizing the processes on the system consuming unnecessary resources.

_________________
James Stewart
Linode Docs Team


Top
   
PostPosted: Tue Jun 23, 2015 2:26 pm 
Offline
Senior Member

Joined: Fri Feb 13, 2015 8:12 pm
Posts: 101
By looking at the graphs, I think he was not really running out of memory.

Instead, the Out Of Memory killer (OOM killer) decided somehow that some process had to die.

Let me quote Andries Brouwer:

Quote:
An aircraft company discovered that it was cheaper to fly its planes with less fuel on board. The planes would be lighter and use less fuel and money was saved. On rare occasions however the amount of fuel was insufficient, and the plane would crash. This problem was solved by the engineers of the company by the development of a special OOF (out-of-fuel) mechanism. In emergency cases a passenger was selected and thrown out of the plane. (When necessary, the procedure was repeated.) A large body of theory was developed and many publications were devoted to the problem of properly selecting the victim to be ejected. Should the victim be chosen at random? Or should one choose the heaviest person? Or the oldest? Should passengers pay in order not to be ejected, so that the victim would be the poorest on board? And if for example the heaviest person was chosen, should there be a special exception in case that was the pilot? Should first class passengers be exempted? Now that the OOF mechanism existed, it would be activated every now and then, and eject passengers even when there was no fuel shortage. The engineers are still studying precisely how this malfunction is caused.


Source: https://lwn.net/Articles/104185/

My suggestion to have more swap is not for it to be actually used (which we all know it's a lot slower than real RAM),
it's just something that may help to keep the OOM killer away.

Try building a kernel without swap on a Linode 1024 and see what happens. With enough swap, it works.
Does somebody know how to "optimize" gcc? I for sure would not even know where to start.
Do I need a Linode 2048 to build the kernel? Surely not if I can use a Linode 1024 with 2G of swap.

You can reduce overcommiting in MySQL or Apache by "optimizing" them, but there is not a general recipe for optimizing everything.

BTW: What I do to avoid OOM killer myself (in addition to have plenty of swap, 1G or 2G), is to have a file called /etc/sysctl.d/10-no-overcommit.conf containing this:

Code:
vm.overcommit_ratio = 100
vm.overcommit_memory = 2

(enable with "sysctl --system").

Then I will worry whenever I see that the system runs slow, not whenever OOM killer randomly decides to kill a random process following some strange algorithm, as if they were passengers in a plane in the story by Brouwer.


Top
   
PostPosted: Tue Jun 23, 2015 8:56 pm 
Offline
Senior Newbie

Joined: Mon Sep 29, 2014 1:21 am
Posts: 17
Quote:
My suggestion to have more swap is not for it to be actually used (which we all know it's a lot slower than real RAM),
it's just something that may help to keep the OOM killer away.


Quote:
No, he does not need more spam, he just needs more swap.


Linode's documentation on swap: https://www.linode.com/docs/troubleshooting/troubleshooting-memory-and-networking-issues They recommend no more than 256mb swap
In this post they say 256swap for 1gb ram is good. More will slow down the server. viewtopic.php?p=40217

So setting vm.overcommit_ratio = 100 and vm.overcommit_memory = 2 can stop the OOM and doesn't slow down my server?

Thanks


Top
   
PostPosted: Wed Jun 24, 2015 5:34 am 
Offline
Senior Member

Joined: Fri Feb 13, 2015 8:12 pm
Posts: 101
robertstam wrote:
So setting vm.overcommit_ratio = 100 and vm.overcommit_memory = 2 can stop the OOM and doesn't slow down my server?

Not exactly. Do not ever think of settting vm.overcommit_memory = 2 (which is what really disables OOM killer) without understanding the consequences. In particular, do not ever think of disabling OOM killer without increasing swap first.

Moreover, don't do this or that because you read it in a forum like this one, and don't do something just because I tell you that it works for me. Investigate for yourself and draw your own conclusions.

The problem of overcommiting is complex and it should be understood without over-simplifications.

Recommended readings:

http://www.etalabs.net/overcommit.html
http://serverfault.com/questions/362589 ... mit-memory
http://www.hskupin.info/2010/06/17/how- ... der-linux/

BTW: More available swap by itself will not make your system to go slower.
In either case, it's actual usage of it what could make your system to go slower, but not its mere availability.


Top
   
PostPosted: Wed Jun 24, 2015 6:03 am 
Offline
Senior Member

Joined: Fri Feb 13, 2015 8:12 pm
Posts: 101
robertstam wrote:
my Linode has: 1gb ram, ubuntu 14.04 with 256mb swap size. My apache/php/mysql configuration is according the Linode tutorials for 1gb ram.

Hmm. If you refer to this page:

https://www.linode.com/docs/websites/ap ... e-pangolin

where it's suggested to install libapache2-mod-php5, you should really consider php5-fpm instead. Memory usage with php5-fpm is predictable and almost flat.


Top
   
PostPosted: Fri Jun 26, 2015 5:27 am 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
Well, the OP clearly did not follow the instructions in Linode's Ubuntu 14.04 LAMP guide, since it suggests a MaxClients of 30.
Code:
<IfModule mpm_prefork_module>                                 
StartServers 2                                               
MinSpareServers 6                                             
MaxSpareServers 12                                           
MaxClients 30                                                 
MaxRequestsPerChild 3000                                     
</IfModule>


The posted syslog shows 36 Apache processes running - reduce MaxClients and tune your MySQL settings and your memory problems will lessen.


Top
   
PostPosted: Sat Jun 27, 2015 12:46 am 
Offline
Senior Newbie

Joined: Mon Sep 29, 2014 1:21 am
Posts: 17
Vance wrote:
Well, the OP clearly did not follow the instructions in Linode's Ubuntu 14.04 LAMP guide, since it suggests a MaxClients of 30.


I count 39. Although my settings already were:
Code:
<IfModule mpm_prefork_module>
    StartServers          2
    MinSpareServers       6
    MaxSpareServers      12
    MaxClients          30
    MaxRequestsPerChild   3000
</IfModule>


Top
   
PostPosted: Sat Jun 27, 2015 8:42 pm 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
That is really odd. For mpm_prefork, the maximum number of Apache processes should be the MaxClients value plus one (for the master process which controls all the others). If you run the following command as root, do you see mpm_prefork_module listed?
Code:
apache2ctl -M


Top
   
PostPosted: Sun Jun 28, 2015 1:58 am 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
Vance wrote:
That is really odd. For mpm_prefork, the maximum number of Apache processes should be the MaxClients value plus one


Perhaps OP has some scripts that use the pcntl_fork() function in PHP.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group