Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Wordpress website is currently hosted in the US, this is where 40% of our target audience is. The rest of visitors are coming form Middle east, Australia, Russia, China, Singapore, UK, Switzerland, Kazakstan... all over the map.

With all caching in place (not CDN) it still barely loads in Asia / Oceania and has speed issues in Europe.

Can I simply setup multiple servers and create multiple A records that point to different servers in different regions and assume that a visitor from Australia will be served form australian server?

Any tips?

share|improve this question
    
Have you measured how slow the website is, and what the cause is? Without details you're likely to just get random performance advice. My top tip is CDN. Caching & DB are good to look at after that. –  Drew Khoury Aug 28 '13 at 0:55

3 Answers 3

The problems with geographically distributing WordPress, as you'll see, all revolve around the MySQL database.

There are basically two ways to architect this:

Read replicas

In this architecture, you run your LAMP frontend with WordPress in several geographic locations, each of which has a read-only replica (slave) of the master MySQL database. You will need to use something like MySQL Proxy to direct write operations back to the master, as WordPress doesn't natively support using a different database connection for reads versus writes.

The big problem with this setup is that if your master goes down, you can't make changes (e.g. no new posts or comments). So the master should probably be clustered or otherwise protected (e.g. using Amazon RDS Multi-AZ). Database writes are also delayed slightly due to network latency between the LAMP frontend and the remote MySQL master.

Multi-master

In this architecture, you run your LAMP frontend with WordPress in several geographic locations, each of which has a multi-master replicated database, using something like MariaDB Galera or an equivalent MySQL solution (if you can find one). You need to have at least three masters if you go this route.

As there's no single point of failure, it really doesn't matter if one master goes down (so long as they don't ALL go down at the same time; that situation requires manual intervention to recover).

The problem with this is that writes take much longer, as they have to be replicated to all of the multiple masters. So people may notice a few seconds' delay when doing anything that writes to the DB, such as commenting or writing a new post. In practice, this delay isn't that significant, as users already expect delays when they submit information in these contexts.


If you have three or more geographic locations you're going to deploy to, I'd go ahead and spend the effort to go multi-master. If you only have two locations, you can get by with a read replica and proxy for now.

share|improve this answer
    
On that note, be prepared for slow shell access overseas. I had a server in Japan through AWS (because I could, mostly) and the delay was a good 1-2 seconds. –  Nathan C Aug 27 '13 at 23:29
    
Ok, so If we take one of these roads what do we do with the DNS? How do I get the Australian audience to the Australian server, and US audience to the US server? - that's the main question. Do we just point multiple A records to different servers? –  Alex Aug 28 '13 at 13:05

I'm assuming since this question has been tagged amazon-web-services that your Wordpress site is running on Amazon AWS EC2 instances. If so, you can use Amazon's Route53 product to serve geographic DNS records. You can find an in depth tutorial here. There are other DNS providers that support geographic DNS records such as Dyn but note that it will be a premium feature which you'll need to pay for.

share|improve this answer
    
This is helpful, we are contemplating staying on Amazon or getting a dedicated SSD server for the US, but putting Asia on Amazon. I'll definitely look into Route 53 –  Alex Aug 27 '13 at 22:36

Can I simply setup multiple servers and create multiple A records that point to different servers in different regions and assume that a visitor from Australia will be served form australian server?

no, it not possible. In such case it would be something like round robin. In your case CDN would be the best choice, imho.

share|improve this answer

Your Answer

 
discard

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.