Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have this dedicated server :

AMD Opteron 1218 HE Dual-Core (2 x 2,6GHz)

4 Go RAM

2 x 400 Go Software RAID

i have one web site with a low traffic in this server, 150< daily.

and another Facebook application with a high traffic 50,000+ daily UV.

my Facebook application have : 1 SWF file, some php files with few array functions, and MySQL queries, i start receiving : Too many connections from MySQL, i fixed it, and i want to know what is the best : Apache , PHP, MySQL configuration for this kind of traffic ?

the new problem is that the Fb app page not load sometimes.

btw, I'm using Centos 5, Plesk 9.0.1, PHP+MySQL 5.

Thanks in advance.

share|improve this question

migrated from Sep 1 '10 at 22:05

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

What about your database schema not being optimal ? Even 60k UV is not a lot for a machine like this...

What I would do is :

  • Make sure i'm not using mysql_pconnect()
  • Explicitely close mysql connections when I don't need them anymore
  • Make sure that my queries are running efficiently (using indexes etc...)
  • Set a low idle timeout in the my.cnf with the connect_timeout directive

Also, you mention RAID, is it RAID 1 ? Last and probably worst, you could increase the max_connections directive in my.cnf

share|improve this answer
Hi, Thanks for the advice ^^ yes I have RAID 1 HD, please what is the best value for me for connect_timeout directive. Best Regards, and Thanks again. – Hamza Sep 3 '10 at 0:30
Well, if you want to tune this parameter, first check that you have many idle connections by running a "show processlist" and see if you have many process in the "sleep" state for a long time (eg more than 30 seconds). Unless you run some background jobs on your database, there's no need to have long running idle threads, since php's max_execution_time will end the script, so a good value might be "30" seconds :) Hope it helps :) – MunsterNet Sep 3 '10 at 6:21

It is not exactly the response to your question, but for high scalability, I would use nginx instead of Apache as http server.

I had (very) bad response times with an Apache server: migrating to nginx solved this.

share|improve this answer
yes, I'm with you nginx is the best, but i'm newbie with servers installation and configuration, I have to continue using apache for few months, then migrate to nginx – McShark Sep 1 '10 at 21:53

You can do a specific server to offer static files, which must be configured with a long period of time to cache.

share|improve this answer
I don't have many static files. – Hamza Sep 1 '10 at 22:13

Make sure you have sysstat installed so you can track hardware metrics. I always start first by looking for hardware limitations, especially disk IO and RAM exhaustion.

After this, assure you have mysql slow query logging and apache errors logs configured properly.

When the page fails to load what do you have to do to get it going again?

Another technique I use is to create a set of pages:

  1. Just text 'hello world'

  2. PHP info page

  3. PHP page with a connect to the database, including timing functions.

  4. PHP page with a connect to the database and simply query.

By polling these pages during the time of the incident, I've found you can quickly hone in on where the issue may be happening. Being able to eliminate PHP, MySQL and focus just on apache an be very useful. If the PHP info page is fast, but your pages are down it could be a database or web programming issue.

I do a lot of performance tuning and I find that by taking small steps you can begin to fix the issue.

Also, you may want to install some server monitoring tools. I recently posted a blog on server monitoring but cannot remember if I can link it here?

share|improve this answer
I could not find anything specific preventing a link: Serverdensity is a nice turn-key install but limited in specs. However, I've found it good for quick diagnostics. Setup RAM, Apache and MySQL monitors and you can cross-correlate. These types of monitoring tools can really speed up diagnostics of problems like this, so if you are not already monitoring I suggest you do so. Of course, on the FOSS side there is Cacti which rocks. – jeffatrackaid Sep 3 '10 at 14:06

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.