Portal Home > Knowledgebase > Articles Database > mysql master-slave replication


mysql master-slave replication




Posted by anonymous718, 07-22-2008, 10:04 PM
Hi folks, I'm not too experienced with this, so I'm hoping someone more enlightened here can help. Scenario: I'm trying to build a social network site geared towards old people. I'm using LAMP environment. I want to have 1 mysql master (writes) and 2 mysql slaves (reads). Two web servers will read from the 2 mysql slaves and write to the one mysql master. Questions: My concern is this: when a user posts a comment via the webserver, the comment is written to the mysql master. I would like for him/her to see the comment he posted right away so they don't think something failed or went wrong. I'm afraid that replication to the mysql slaves will take some time to sync all of the mysql databases together. How can I work around this? Or am I mistaken and this doesn't actually happen? How fast is replication? How can I mitigate this delay in replication to show the user instant results of their submission. The same thing can apply to uploading photos to a user's profile. Thanks! Sean

Posted by zuborg, 07-23-2008, 07:19 AM
Replication is quite fast, few milliseconds.

Posted by RBBOT, 07-23-2008, 03:57 PM
If you want to be bullet-proof, have the submit comment page pass the ID number of the new comment that was just inserted to the next page that displays the comment. Code this page such that if the comment ID does not appear in the list retrieved from the slave, sleep half a second and rerun the query. Best to limit the number of retries though in case something goes wrong and it goes into an infinite loop.

Posted by anonymous718, 07-23-2008, 05:43 PM
I've been thinking of using MySQL Cluster to forgo the problems associated with replication: - the delay in syncing current data to the slaves. - replication is ideal for read-intensive applications. - MOST IMPORTANTLY: the single point of failure and bottleneck point with 1 master server. Even if I partition my data across different master databases, if one of them fails then part of the site (and potentially the entire site) might go offline. From what I read and understand, MySQL cluster is ideal for both read and write intensive applications and is built for high availability and scalability. Yes some of its functions have not been optimized thus far (like JOINS), but they expect to have that done within the year. Do you or anyone else have any ideas on these concerns or if MySQL Cluster is up to the task for a social network with 1 million unique visitors per day after 30 days? Kon



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
aventure-media.co.uk (Views: 509)
Site5 is Great (Views: 486)