Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

What is the best way to have a web server using apache 2 / rails / Phusion Passenger connect to a separate mysql db server. Right now im using MySQL TCP socket on port 3306 for them to communicate and I think it may be causing an increase in load time.

share|improve this question

If by "separate" you mean "on a separate machine", then TCP is your only option. Yes, talking over a network is slower than talking over a local socket, but unless you're doing something unwise like opening and closing the DB connection for every query on a page, then the increase in page load time will be unnoticable.

share|improve this answer

You'll see an increase in load time, but it's the only way to have them on different machines and talking to one another. Are the machines adjacent? Can you use a 2nd network connection on each machine? That should reduce the latency.

Also, make sure you're using persistent connections and making use of caching. Those are just smart changes to make no matter where your database server is located.

share|improve this answer

Your Answer


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