1. Multiple instances
A) Installing Mysql Cluster
A) Installing Mysql Cluster
- Instead of using regular mysql we could install mysql cluster that would provide us with on the go scaling as well as no downtime. Mysql cluster is a software just like mysql but requires at least 3 systems to work (minimal configuration). Further more we wont need to change any code, as each instance would host DB data node and apache server under a load balancer which would route the traffic based on the load on instances.
- The risks involved are,cumbersome management of cluster, Minimal configuration is prone to db outage if one of the nodes, out of two, crash which could take a bit of time to restore. The normal configuration is memory based and hence would require considerable expertise in making it disk based so that a failure of instance doesn't destroy the data (this in turn demands long times to startup the cluster after failure).
- But this is better than single instance for db and application by mitigating a single point of failure and since with the help of amazon cloud watch and auto scaling we can increase the nodes on the fly if required. Also Scale a single data node to a larger instance on the fly as its down time will be taken over by other nodes under a load balancer (demands more than two data nodes).
B) Scaling the read requests
- As our major work load on db is select queries (96% read queries and rest are DML queries), what we can do is increase the read resources. Auto scaling will work as well and we can dramatically increase the application performance under high work loads.
- The strategy demands on one instance for writes i.e. SQL inserts, updates, deletes. This instance will behave as a master server in replication model and two other instances will be our application host cum db instances (as in current model but two instances) under a load balancers. both these instances will read from their respective DBs and will update the master DB (which will be separate). The data will be replicated on these read instances by the master asynchronously (as implemented currently in live to test replication)
- Application changes will be required under models where all DML queries will be grouped to update master db only. This will enhance the performance of DML under high work loads as well due to relative low usage of master server (total 4% are DML queries, rest are all read/select queries.)
- This is not that complex as compared to MySql Cluster as it will be based on the our current setup. only addition would be the use of load balancer above the two read instances which will distribute traffic and allow us to increase instances on the fly without down time and also provide fail over protection i.e. site will be viewable in worst case scenario i.e. if we lose the master instance. The recovery time will be fast as we can convert one of the remaining instances as master and make other instance a slave, quickly.
- Site will be viewable until only one read instance is alive and full function will be restored with minimal two instances i.e one read instance and one master DB.
- the instance sizes can also be kept low initially and read instances can be auto scaled on the fly if required. (amazon's auto scaling can be used here). Master server will not be increased on the fly and since it doesnt have to do any heavy conputations its size can be kept m1.small with no on the fly scaling up.
- All the single instance scaling types would require downtime or few minutes.
- to mitigate the complete black out we can separate the db and application instances and meanwhile DB instance is scaled up application instance can show a temporary message.