0

I host am ExpressionEngine based website on a single Amazon EC2 instance in the US East (Virginia) region. I use Ubuntu.

The website allows members to post their content, and displays it for other members and for users who are not logged in.

Goal: I need to begin serving the same website across the globe, equally fast to Hong Kong, New York, and Los Angeles.

I considered two solutions:

1.Setting up three separate EC2 instances for three regions: Virginia, Oregon, and Singapore. Use Amazon Rot53 Geo Location to direct traffic to instances based on the browser's IP address.

Pro: the website will load fast for the region.

Contra: these will be essentially three separate websites. Unless I am mistaken?

  1. Setting up one instance in a region equally remote from all three locations: (Ireliand), and boost the server to the highest performance available.

Pro: It will be the same website for all regions.

Contra: it will cost a lot to make it fast enough.

My challenges:

a) I do not know a way to sync server settings, database, and content between multiple Ubuntu instances in real time. If a knowledgeable person could explain to me how to do that, I would be most grateful.

b) I am not thoroughly familiar with all Amazon AWS resources. Does AWS has a built-in method that would allow me to achieve my goal of serving a single PHP / MySQL based membership website across the globe equally fast in all three chosen locations?

  • This might be closed since it's off topic.. but I feel the best way is to have a master/master/master db replication where your id fields are UUIDs and not auto incrementing ids. This will allow for no id collisions and allow each server to write to its own "local" database. – Mike Sep 13 '14 at 03:50
  • I think you are mistaken about `it will cost a lot to make it fast enough` since no matter how much you pay, you will not get communication faster than the speed of light. The first question you need to ask yourself is what are your integrity guarantees? Can updates from different regions be processed in different order and yield the same result? Or do you need updates to processed in the same order globally? For financial transactions the later is often required, and it will be bound by the speed of light. – kasperd Sep 14 '14 at 08:29

1 Answers1

4

There are many ways to skin a cat, but basically you do need to replicate your site in multiple geographic locations one way or another.

Here's several options which might be suitable assuming your application is read heavy (which most websites are). I'm not familiar with Expression Engine so I'm not sure how difficult these architectures would be to implement in your case.

Option 1: Cross-region read replicas

  • Have an EC2 application server in each region
  • Have a read replica database in each region
  • Only write to your master region database
  • If you have to deal with file uploads it's best to store these in S3 and have CloudFront cache them in various regions

Option 2: Caching proxies

If your content is almost completely static you can have a caching proxy in each region. If you don't need advanced caching rules CloudFront is a very easy solution, otherwise you can have EC2 instances with say varnish.

Option 3: Database caching

Databases are the most difficult element to distribute in your scenario, so you could leave this in a single region (and have other regions connect to the database in your master region), then use data caching in your application to minimise the latency. If your application supports memcache then ElastiCache might be an option.

thexacre
  • 1,849
  • 13
  • 14
  • I have a question though, @thexacre – I understand how to handle the database. What about the files (such as images uploaded by the users, and so on)? Are there any Amazon AWS-specific methods to replicate all the files across instances in multiple region, or is there any effective general method? – Dimitri Vorontzov Sep 13 '14 at 23:57
  • 1
    @DimitriVorontzov the most "AWS" way is to modify your application to store user generated files in S3 and use CloudFront to distribute them globally. There's plugins to achieve this for many off the shelf web applications. With regard to application code, you should deploy this in each region via ElasticBeanstalk or OpsWorks. – thexacre Sep 14 '14 at 00:28