title: Best practice apache and mysql configuration
body: <p>I home somebody can help me with tips of optimization, thank you :-)</p>
  <p>I have the following vps server:<br>
  6 CPU Cores<br>
  320 GB Storage SSD<br>
  16 GB RAM<br>
  Apache version 2.4.6<br>
  MariaDB version 5.5.60<br></p>
  <p>Most load is between time 17.00 to 19.00 and there the server is slow and sometimes goes down.
  The server has around 200 websites with mysql queries.</p>
  <p>my apache httpd.conf configuration:</p>
  <pre><code>KeepAlive Off
  KeepAliveTimeout 5
  MaxKeepAliveRequests 200
  HostnameLookups Off
  
  #KeepAlive Off
  &lt;IfModule prefork.c&gt;
      StartServers        50
      MinSpareServers     50
      MaxSpareServers     100
      ThreadsPerChild     200
      MaxClients          250
      MaxRequestsPerChild 2000
  &lt;/IfModule&gt;
  </code></pre>
  <p>and in 01-cgi.conf</p>
  <pre><code>&lt;IfModule mpm_worker_module&gt;
      LoadModule cgid_module modules/mod_cgid.so
  &lt;/IfModule&gt;
  &lt;IfModule mpm_event_module&gt;
      LoadModule cgid_module modules/mod_cgid.so
  &lt;/IfModule&gt;
  &lt;IfModule mpm_prefork_module&gt;
      LoadModule cgi_module modules/mod_cgi.so
      MaxRequestWorkers 4000
      ServerLimit 5000
  &lt;/IfModule&gt;
  </code></pre>
  <p>mariadb my.cnf</p>
  <pre><code>symbolic-links=0
  innodb_file_per_table = 1
  myisam_sort_buffer_size = 64M
  read_rnd_buffer_size = 512K
  net_buffer_length = 8K
  read_buffer_size = 256K
  sort_buffer_size = 512K
  table_open_cache = 64
  max_allowed_packet = 1M
  key_buffer_size = 16M
  max_connections = 500
  
  connect_timeout=30
  max_connect_errors=2000
  log-slow-queries=/var/log/mariadb/mysql-slow.log
  skip-name-resolve
  query_cache_limit = 1M
  query_cache_size = 256M
  </code></pre>
  <p>I tried load test with loader.io with following settings but it seems to reach about 180-185 clients and my server timeout</p>
  <pre><code>clients from 0-250 duration 1 min
  
  </code></pre>