0

i'am not professional server administrator.have an ubuntu server that host a Wordpress website use for shoping with almost 200 user's per day.

Server config is : 512 MB Memory with 25 GB SSD I need advice and guides to decrease subprocess of apache and mysqld and also increase server sped

some things that i does to make server stable is : * Make swap file for when memory is completely taken * Restart apache and MySQL server every 1 hour(using a cronjob) * Instead of using Dedicate DNS Server ( like BIND) I just use Cloudflare.

Now I have some questions:

  1. What other options and methods i have that can use to decrease the running process or increase server speed?
  2. some times of the week, server use 100% of CPU.. but i dont know what process causes this.how can I log process's that use 100% percent of CPU( is this posible? )
  3. and a common question is this usual that mysqld and apache use this lot of subprocess?

Here is result of command free -m:

          total        used        free      shared  buff/cache   available

          Mem:   488   353    12    42   121    57

          Swap:  1023  182    841

Here is the screen shot of command htop

enter image description here enter image description here enter image description here

Mostafa
  • 111

1 Answers1

1

To answer Q1 & 3 - The way the Apache web server works is that it creates a new process for each connection to the server. You can change the maximum number of processes that Apache creates or see what it's current maximum is in the Apache configuration file (see the Apache documentation for more), that's really the only way to change the number of these processes that are created. This is just the way that Apache was built. There's a well known type of DOS (Denial of Service) attack that exploits this fact called Slowloris. Some other web servers (e.g. Nginx) don't create a separate process for each connection to the server (but that doesn't neccessarily mean you'd see lower CPU usage with a different web server).

To answer Q2 - something like this should do what you're after (sourced here):

while true; do (echo "%CPU %MEM ARGS $(date)" && ps -e -o pcpu,pmem,args --sort=pcpu | cut -d" " -f1-5 | tail) >> ps.log; sleep 5; done
ycnz
  • 146