0

I have some serious problems with my production server running Ubuntu 11.10 with 48GB RAM. The setup of my webserver (Apache 2.1) is configured to use approximately 18 GB of RAM. I tried to calculate this value by setting

  • max_clients 800

with each child process taking nearly 23MB ram

  • max_spare_servers 200
  • keepAlive on
  • keepalivetimeout 3

Apache MPM is set to prefork module

Additionally we are using

  • php 5.3.2
  • PDO to connect to database

I made similar changes to my MySQL server (v5.1) by changing max_used_connections to 800 with

  • key_buffer to 4Gb (Myisam as default engine with 3 tables of innodb)
  • key_buffer_size + (read_buffer_size + sort_buffer_size ) * max_connections = 5.4Gb

Now max_used_connection is increasing rapidly and after a couple of hours it stopped at 595 and again it climbed to its max value of 800. I even tried changing to default mysql configuration but still no change.

For some reason changing to Apache's default configuration solves the problem now max_used_connections is steady at around 57.

Does anyone have an idea about this behavior? Can Apaches configuration impact Mysql performance?

Chris
  • 1,185
  • 2
  • 9
  • 18
Newbie
  • 11
  • 3
  • What do you want to achieve? You talk about serious problems which are...? Does your server crash, quit services? Please be more precise. – Chris Mar 20 '12 at 09:31

1 Answers1

1

This is a horrible way to run apache on a large server.

Please consider running the worker MPM (lightweight threading model), and proxy dynamic requests (PHP) to a fastCGI backend via the official apache mod_fcgid module.

Also make SURE you set a static number of PHP -> mysqli connections, and re-use this pool.

You could trivially support 5000 concurrent clients with the above setup.

adaptr
  • 16,576
  • 23
  • 34
  • To switch to the worker MPM like suggest by adaptr, ensure all your PHP modules are thread safe, or you run into other problems. – Chris Mar 20 '12 at 09:33
  • 1
    I specifically advised him to run PHP on fastCGI. That does not have threading issues, since every connection is single-threaded. – adaptr Mar 20 '12 at 09:43
  • You are right, i skipped reading. My bad – Chris Mar 20 '12 at 10:00