Freediving
Freediving

Reputation: 3

AWS multi-zone distaster recovery and load balancing - best approach?

I’m using Amazon Web Services, and trying to set up a modest system for load balancing and disaster recovery. The application is PHP based, with Zend Framework 2 (ZF2) on the front end, a local memcached server and MySQL through RDS. All servers are running Amazon Linux.

I am trying to configure the elastic load balancer to use two servers in two different AWS “availability zones.” To seamlessly allow one server to shut down and another take over, we need shared PHP sessions. So I set up PHP database sessions with ZF2.

In general, I assume the likelihood of an outage of an AWS zone is considerably lower than chance of a fatal problem in the individual servers or the application itself. So I am considering a different approach:

  1. All the servers in the same availability zone
  2. Separate AWS ElastiCache server (essentially memcached, cannot be used across zones)
  3. PHP sessions stored in the cache (built-in support for memcached)
  4. One emergency server in a different zone – in the rare case of a zone outage, we would change the DNS record to use the different server

Is this a good standard approach to DR and load balancing? I don’t like the DR solution in the case of zone outage, but I haven’t seen a zone go down much, and we can probably handle that level of risk if it simplifies the design. If the load balancer could weight be servers, I would pull all the weight on one zone, with the backup server weighted much lower.

Upvotes: 0

Views: 256

Answers (1)

Ben Whaley
Ben Whaley

Reputation: 34426

What would be the benefit of keeping all the PHP servers in the same AZ vs distributing them among multiple AZs? I can't think of any, except a very small (3-5ms) latency improvement. Since there's very little downside, why not spread the servers among multiple AZs?

Your Elasticache memcached is still a single point of failure. If the AZ that the Elasticache instance is running in has a problem you will lose sessions. You could switch to use Elasticache w/ Redis (which supports master/slave) to achieve multi-AZ for your cache layer as well.

Upvotes: 1

Related Questions