Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using ubuntu 12.04LTS server alongwith LAMP module. I configured my server with 2GB memory but after some time either I have to restart my apache2 web server and mysql process or think about upgrade memory as there is lot of database write operations on my server near about 70k per hour. Just for benchmarking I stopped mysql and test application without database server still heavy and doesn't working properly. On using top and free -m, memory resources still shows occuppied like out of 2gb only 100mb free. In this case what to do, should I go for upgrade or minimize incoming traffic requests?

Update: on top, resources stats are shown below:

top - 04:37:19 up 1 day,  5:13,  1 user,  load average: 0.01, 0.03, 0.05
Tasks: 233 total,   1 running, 232 sleeping,   0 stopped,   0 zombie
Cpu0  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu1  :  2.7%us,  0.7%sy,  0.0%ni, 96.3%id,  0.0%wa,  0.0%hi,  0.3%si,  0.0%st
Cpu2  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Cpu3  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   2066856k total,  1239164k used,   827692k free,    30028k buffers
Swap:   262140k total,        0k used,   262140k free,   827112k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                  
 2188 mysql     20   0  989m 105m 6420 S    0  5.2   0:38.97 mysqld                                                                                   
 2470 root      20   0 37976 7736 4092 S    0  0.4   0:16.68 apache2                                                                                  
18880 www-data  20   0 38872 7164 2820 S    0  0.3   0:02.42 apache2                                                                                  
18976 www-data  20   0 38872 7164 2820 S    0  0.3   0:02.09 apache2                                                                                  
19104 www-data  20   0 38872 7164 2820 S    0  0.3   0:01.95 apache2                                                                                  
19249 www-data  20   0 38872 7164 2820 S    0  0.3   0:01.61 apache2                                                                                  
18890 www-data  20   0 38744 7160 2824 S    0  0.3   0:02.37 apache2                                                                                  
18605 www-data  20   0 38744 7152 2820 S    0  0.3   0:03.10 apache2                                                                                  
19361 www-data  20   0 38744 7152 2820 S    0  0.3   0:01.36 apache2                                                                                  
18203 www-data  20   0 38872 7136 2792 S    0  0.3   0:04.20 apache2                                                                                  
18207 www-data  20   0 38872 7136 2792 S    0  0.3   0:04.14 apache2                                                                                  
18359 www-data  20   0 38872 7136 2792 S    0  0.3   0:03.74 apache2                                                                                  
18893 www-data  20   0 38872 7136 2792 S    0  0.3   0:02.25 apache2                                                                                  
19253 www-data  20   0 38872 7136 2792 S    0  0.3   0:01.58 apache2                                                                                  
19410 www-data  20   0 38872 7136 2792 S    0  0.3   0:01.12 apache2                                                                                  
18054 www-data  20   0 38872 7132 2788 S    0  0.3   0:04.63 apache2                                                                                  
18335 www-data  20   0 38872 7132 2788 S    0  0.3   0:03.72 apache2                                                                                  
18738 www-data  20   0 38872 7132 2788 S    0  0.3   0:02.86 apache2                                                                                  
18761 www-data  20   0 38872 7132 2788 S    0  0.3   0:02.93 apache2                                                                                  
18795 www-data  20   0 38872 7132 2788 S    0  0.3   0:02.78 apache2                                                                                  
18857 www-data  20   0 38872 7132 2788 S    0  0.3   0:02.44 apache2                                                                                  
18870 www-data  20   0 38872 7132 2788 S    0  0.3   0:02.31 apache2                                                                                  
18876 www-data  20   0 38872 7132 2792 S    0  0.3   0:02.45 apache2                                                                                  
18878 www-data  20   0 38872 7132 2788 S    0  0.3   0:02.35 apache2                                                                                  
18882 www-data  20   0 38872 7132 2788 S    0  0.3   0:02.37 apache2                                                                                  
19034 www-data  20   0 38872 7132 2788 S    0  0.3   0:02.03 apache2                                                                                  
19039 www-data  20   0 38872 7132 2788 S    0  0.3   0:01.95 apache2                                                                                  
19082 www-data  20   0 38872 7132 2788 S    0  0.3   0:01.96 apache2                                                                                  
19110 www-data  20   0 38872 7132 2788 S    0  0.3   0:01.89 apache2  

It shows normal data, but on doing free -m

             total       used       free     shared    buffers     cached
Mem:          2018       1210        808          0         29        808
-/+ buffers/cache:        372       1645
Swap:          255          0        255

It shows used memory is 1210, and sometime it goes to 1900 usage of memory when i am doing a bit of database read operation alongwith write operation. So whenever http traffic more, memory goes to peak usage and my server is like jammed.

Update:

vmstat:

procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0      0 669368  30732 1122448    0    0     0     6   25   42  1  0 99  0

iostat:

  01/01/2013      _i686_  (4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0.76    0.01    0.27    0.01    0.02   98.92

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
xvda              1.57         1.52        22.89     258473    3893460
xvdb              0.00         0.00         0.00        468          0

I just restart my server and is working fine. But after few hours it behaves like hung up all things and now at this stage, i can see there is some free memory but still server connection time out during SSH. I don't know whats going on on server? If there is need of more diagnostics then please tell me, but help me to resolve this problem?

Update:

I did some optimization in apache main configuration file, like raise maximum client requests and requests limit per process. Now server performance is chill and ssh is accessible normally. But i am doing all these things randomly not specific to RESIDENT memory and SHR memory specific. If there is any specific link for apache optimization then please forward it to me.

share|improve this question
    
please post the output of top, ps and free –  Eric DANNIELOU Dec 31 '12 at 8:48
    
provide some output as asked by Eric. Most of the time if you install apache then many modules gets enabled to load on the start time. I would recommend to check the apache conf and disable un-used modules as well as take a look on my.cnf file too and optimize the setting and php settings as well. –  PratapSingh Dec 31 '12 at 11:03
    
I feel like you're just misreading top output (guessing since you didn't include). See linuxatemyram.com –  Grumpy Dec 31 '12 at 19:00
    
@PratapSingh: i already tried to configure mysql through my.cnf, like tuned database engine parameters, about apache and php setting i dont know more info about how to tune parameters, juts tried to configure child process parameter in apache prefork mpm module which is used with php, but not very effective in performance of server. –  shihon Jan 1 '13 at 13:03
    
as you have updated free -m out put total used free shared buffers cached Mem: 2018 1210 808 0 29 808 which shows that 808 is in cached so there is nothing to worry about it. cached memory are in use to increase the performance and if all the memory is assigned to cache memory then it clears up the cache memory as per the new requirement and follows the algo least recently used cached memory data to clear up the memory. –  PratapSingh Jan 1 '13 at 13:06
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.