1

I am using digitalocean $5 plan.

1 cpu , 512mb ram , mysql + apache , nginx + centos 6.5 + cpanel installed. 2 wordpress site on that.

But if I reload page of one of my sites, cpu usage increasing to 50% , 60% .If I check mysite from woorank (SEO analyzer), my server is crashing, cpu and ram usage increased to 100%. These sites not so big. I can say new. What can I do about it? In shared hosting, I am getting much more performance.

Htop away:

enter image description here

Htop when I refresh one of my wordpress sites anypage:

enter image description here

I am using wp-super cache , cloudflare.Not so many plugin installed just necessary ones.

Here is my.cnf

[mysqld]
     port            = 3306
     socket          = /var/lib/mysql/mysql.sock
     default-storage-engine=MYISAM 
     max_connections = 50
     key_buffer_size = 16M
     max_allowed_packet = 1M
     table_open_cache = 1000
     sort_buffer_size = 64K
     read_buffer_size = 256K
     read_rnd_buffer_size = 256K
     net_buffer_length = 2K
     thread_cache_size = 128
     query_cache_type = 1
     query_cache_size = 16M
     query_cache_limit = 1M
     log-slow-queries= /var/lib/mysql/slow.log
     log-error = /var/lib/mysql/error.log
     expire_logs_days   = 10
     max_binlog_size         = 100M

     # For low memory, InnoDB should not be used so keep skip-innodb uncommented unless required
     skip-innodb

     # Uncomment the following if you are using InnoDB tables
     #innodb_data_home_dir = /var/lib/mysql/
     #innodb_data_file_path = ibdata1:10M:autoextend
     #innodb_log_group_home_dir = /var/lib/mysql/
     #innodb_log_arch_dir = /var/lib/mysql/
     # You can set .._buffer_pool_size up to 50 - 80 %
     # of RAM but beware of setting memory usage too high
     #innodb_buffer_pool_size = 16M
     #innodb_additional_mem_pool_size = 2M
     # Set .._log_file_size to 25 % of buffer pool size
     #innodb_log_file_size = 5M
     #innodb_log_buffer_size = 8M
     #innodb_flush_log_at_trx_commit = 1
     #innodb_lock_wait_timeout = 50

     [mysqldump]
     quick
     max_allowed_packet = 16M

     [mysql]
     no-auto-rehash
     # Remove the next comment character if you are not familiar with SQL
     #safe-updates

     [isamchk]
     key_buffer = 8M
     sort_buffer_size = 8M

     [myisamchk]
     key_buffer = 8M
     sort_buffer_size = 8M

     [mysqlhotcopy]
     interactive-timeout

Here is my apache config :

Start Servers : 1
Min. Spare Servers: 5
Max. Spare Servers: 10
Server limit : 256
Max clients : 15
Max request per child :10000
Keep-alive : ON
Keep-alive timeout: 15
Max keep alive request: 100
Timeout: 300
mrblithe
  • 21
  • 2

2 Answers2

6

The $5 VM cannot hold a full cPanel installation.

A few suggestions:

  • Configure MySQL to use the minimum settings example .cnf
  • Disable all unnecessary modules in Apache and tune the number of Max/Min/Spare servers
  • Consider switching to nginx and php-fpm
  • Investigate Wordpress plugins that will convert the websites to static HTML
  • Use CloudFlare free account to shield your server from usage spikes

If you plan to use this for cPanel web hosting, I would consider using a bigger VM (or even multiple bigger VMs).

gtirloni
  • 5,746
  • 3
  • 25
  • 52
2

The sites themselves may not be so big, but just running apache (and php) and mysql and the OS can exceed your allotted ram (which you're doing, see your swap usage) if you don't take measures to optimize and keep things small. 512MB doesn't get you very far these days, especially with php and apache at their default settings.

Look into optimizing your programs for a small memory footprint and reduce their active process/listeners to a bare minimum. If you're going to run on an embedded-sized machine you have to run it like an embedded machine.. or go up to the $10 plan.

jerm
  • 637
  • 3
  • 5