Web server and MySQL server on different machines, causing latency on websites - mysql

I am currently running a virtualized environment for my web and db server. When I access the web server or the MySQL server individually, they are both fast. I also have websites running on the web server that do not require the db server and those all load quickly. However, when I access my hosted website that requires the web server to call from the db server, there is about a 5-7 second latency for every page load. This has been confirmed with both a very simple site and with a Word Press setup as well. Here is the config:
Web server - CentOS 6.5, Apache 2.2.15
DB server - CentOS 6.5, MySQL 5.1.73
My question is, are the servers continuously authenticating with one another (and thus causing latency) on every single db call? If that is the case, does anyone know how to permanently authenticate between the two?
I might be way off on this assumption and authentication could have nothing to do with it. I am completely open to any and all ideas at this point. Thank you very much.
V/R,
Tony

To me it seems to be a network issue.
and obviously the db-server will need authentication every time there is a hit.

Related

Load balancing on wordpress - 2 LAP web servers 1 Mysql DB - How?

Here is the problem: my client wants to setup a load-balancing wordpress server to handle the increasing number of visitors.
2 Web servers will have setting below:
Load balancer x 1
Server #1: Linux, Apache, PHP 5, Wordpress 3.8.1
Server #2: Linux, Apache, PHP 5, Wordpress 3.8.1
Server #3: Linux, MySQL
Load balancer will direct traffic to web server #1, and #2, and #1 and #2 will connect to #3 MySQL to get information.
Notes:
It is a must, so no need to consider another "Wordpress performance enhancement" solution.
I understand that it will also has single point of failure, but it is fine. My client just wants that.
My questions:
I will change the wp-config.php file to point to #3 database. Is it ok? Are there any potential problem?
I will also mount the /upload directory to share by two web servers, both writable. Is it fine?
Session problem: how to share session between wordpress? Somewhere on the web I read that the /tmp folder should be shared also, is it true? If I want to save session to database, will it also work?
Apart from the questions above, did I miss other steps that are critical to success? What should I pay attention to also?
Thanks in advance for your help. All other result on the web are just using rackspace, AWS and other service, which is not what I need.
Here is my notes on how to setup my own Load Balancing servers without other cloud services.
Wordpress Load balancing: 2 web servers 1 MySQL without any Cloud services

Pooling connection to mysql database server from django application server

I am designing the backend of my ios application. The backend has separate database and application server running mysql and django separately in different machines. Till now, I have connected my application server with my database server in simple way: I changed the database host in application server settings to point to remore database server and created a new remote host in database server configuration files allowing remote application server to access the database. All works fine and I have decided to go with this setup for production. Then when I was reading Instagram engineering blog, I saw them mentioning 'Pgbouncer' to pool connection to their postgresql database server. What is the need for something like this? Has this got something to do with only performance, or is this a production friendly approach to use something like this for communication between database and application server. Is my general approach mentioned too amateur?
Your approach is not amateur at all. The purpose of bouncer in your case would be to eliminate connection time that happens on each request django handles. For example, on Heroku, which is hosted on AWS servers, this could eat up 40-50ms of each request.
Now, if you had a master/slave setup or something like that, a connection pool would also provide you a failover functionality (just an example)

Windows XP localhost as MySQL server alias

I'm on the road at the moment and just had a thought
I have a Windows XP Virtual Machine installed with Delphi and a local MySQL server set up with copies of the "live" databases back in the office.
I'd like to be able to use the local db in place of the "live" one if I'm offline.
At the moment in Delphi I have "local" connections set up, but these are only any use within Delphi. And often lead to issues if I forget to switch back to the live connection when I get back to the office.
Is there any way I can fool Windows into thinking that the local MySQL server is in fact the office server if it can't reach the office server? Can it spoof two server names?
You can edit the hosts file in c:\windows\system32\drivers\etc\hosts which will allow you to make any requests to server.fqdn go to 127.0.0.1
http://kb.simplywebhosting.com/idx/0/045/article/
e.g. a request to servername.domain.tld using MySQL connection strings will redirect to your local DB.
You will still need to remember to change this back when you get to the office...
(If you have delphi on the laptop though, why not create a simple service which edits the hosts file based upon whether the server is reachable or not.)

Connecting to MySQL from local server slow

I just started using git to manage my website's distribution. My site is running a lighttpd server and a Symfony 2 PHP framework. It connects to a remote MySQL server. When I cloned my project to my mac (running Apache), the site still works but it's extremely slow. The problem seems to be with the mysql connection. Performing just a few extra queries (10 or so) results in significantly longer page load time. The remote server that hosts my site runs just fine, it's way faster than my local copy.
What are some common causes of a slowdown like this?
Firstly I'd take a look at the "just a few extra queries" to see if those are taking an unreasonable amount of time.
I'm assuming that you are still connecting to the remote MySQL server on your local copy? If this is the case the problem could be bandwidth. Rented servers are usually on 100Mbit+ connections, so the data transfer will be relatively quite compared to your broadband at home.
When your web app is running on your local copy try running a SHOW PROCESSLIST; on the MySQL Server.
Finally how powerful is your mac compared to the server? If you mac is underpowered and your trying to also run photoshop + illustrator + itunes etc etc this will make a difference.

Secure Remote mySQL Connection

Since our shared hosting server doesn't allow us to setup Tomcat I decided to install it on our local machine. The local Tomcat server allows us to listen to a certain port for Bancnet transactions which will then be processed and written to the remote site.
Question:
Is it safe for me to set the local PHP application to connect directly to the remote mySQL server? Any suggestions on how to make the connection secure. BTW, I have a self-signed certificate installed in the localhost but not sure how this applies to remote mySQL connection.
You could create a ssh tunnel between MySQL server and client. For more resiliency, use autossh.
If you don't connect over SSL or some other encrypted tunnel, I would absolutely assume that anything you send or receive from MySQL is done so in clear text that can be intercepted and used for malicious purposes from any link along the way. This might be fine for testing purposes with dummy data, but before you put this in production use or pull down live user data for testing, you really should either make arrangements for the data to be stored local to the web app or for there to be an encrypted connection.
Giving you a full overview of how to set up SSL connections to MySQL is beyond the scope of Stack Overflow and it's a bit complicated, but if you want to proceed, check out the documentation and do some research, there are some good informational resources out there.
I'm a bit confused as to the architecture you are trying to describe. What's running where?
If you can't install Tomcat then you probably won't be able to install anything like VPN software on the box.
MySQL can encrypt using SSL provided it has been enabled at compile time and at run time.
Alternatively, it should be fairly trivial to build a webservices tier on top of the remote database.
I would recommend switching to a VPS or managed host though.