Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dedicated postgresql server

Status
Not open for further replies.

etones

Programmer
Mar 7, 2002
9
0
0
GB
I have 2 servers on the same network and I've set one up as an apache and php server and the other up as a dedicated postgres server. I did this to try and reduce the load from one server and hopefully speed things up a little. The problem is that i think php accesses the postgres server through the internet because it is extremely slow. How can i get the php to use the internal network to access the postgres server.

Any help will be appreciated.
 
Well, it's impossible to help you without more specifics on your server setup. When you say "internal network", do you mean you have some sort of firewall/NAT system, where each machine has an internal address such as 10.1.1.45, or 192.168.1.45, and the firewall performs address translation to the external internet?

What exactly does your pg_connect() statement look like? Are you calling the external network address, or the internal one? What is the speed of your internal network? (hopefully, at least 100 MB/s). What is your network design?

PHP will never access a DB over the network as fast as a DB on the local disk, unless perhaps you have a gigabit network (which are getting cheaper these days). But speed of access is not the same as speed of data processing, so don't forget that. A database might not respond as quickly over the network, but it will still process searches, etc... every bit as fast.

Point is, you need to think about your architecture a little bit, and about what is really important. Splitting up database and webserver is a solution to scaleability problems, not speed problems. Usually, it involves giving multiple webservers access to one centralized DB server. This kind of thing works best if the webservers have at least two ethernet cards, where one card is dedicated to the internal network and DB connection, and the other one is serves HTTP requests to the outside world. Otherwise, you will have a lot of network data collision.

The network itself could be your problem. Have you done any testing, to see if it is running at full speed? Have you checked out the network with tools such as tcpdump, to see if any bad ethernet card is broadcasting junk data, etc...?

Also, there are choices to be made with both PHP and PostgreSQL. For example, using pg_pconnect (persistent connections) instead of pg_connect can really reduce the connection time penalty over the network. Also PostgreSQL itself has many tuneable settings in the "postgresql.conf" file. -------------------------------------------

"Calculus is just the meaningless manipulation of higher symbols"
                          -unknown F student
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top