Saturday, September 21, 2013

Writing a Fault-tolerant Database Application using MySQL Fabric

In this post, we are going to show how to develop fault-tolerant applications using MySQL Fabric, or simply Fabric, which is an approach to building high availability sharding solutions for MySQL and that has recently become available for download as a labs release (http://labs.mysql.com/). We are going to focus on Fabric's high availability aspects but to find out more on sharding readers may check out the following blog post:
Servers managed by Fabric are registered in a MySQL Server instance, called backing store, and are organized into high availability groups which deploy some sort of redundancy to increase resilience to failures. Currently, only the traditional MySQL Asynchronous Replication is supported but we will consider other solutions in future such as MySQL Cluster, Windows Server Failover Clustering and Distributed Replicated Block Device. For a great analysis of alternatives for MySQL High Availability Solutions certified and supported by Oracle readers should check out the following white paper:
Different from a traditional MySQL Client Application, a Fabric-aware Client Application does not specify what server it wants to connect to but the Fabric instance from where it will fetch information on the available servers in a group. So a fabric-aware connector is required for this task. Currently, only the connectors PHP, Java and Python have extensions to access Fabric. In the future, we aim to add Fabric support to other connectors as we are fortunate to have a strong influence over many of the key connectors in the MySQL ecosystem.

class Application(object): 
    def __init__(self): 
        fabric_params = { 
            "fabric" : {"host" : "localhost", "port" : 8080}, 
            "user"   : "oracle", "passwd" : "oracle" 
        } 
        self.__cnx = MySQLFabricConnection(**fabric_params) 

    def start(self): 
        self.__cnx.set_property(group="YYZ") 
        cursor = self.__cnx.cursor() 
        cursor.execute("...")

In this sample code, written in Python, the connector sends a request to a Fabric instance located at address "localhost", port "8080" in order to retrieve information on all servers registered in the "YYZ" group and then creates a connection to the master in the group. The communication between the connector and Fabric is done through the XML-RPC protocol which has been chosen for being a "quick and easy way to make procedure calls over the Internet". However the XML-RPC protocol is not well-known for its performance, and to reduce the overhead of contacting Fabric every time a connector needs information on a group, data is stored in a local cache.

If the current master fails though, the "InterfaceError" exception is raised and the application is responsible for catching the exception and getting a new connection to a new elected master if it wants to carry on its regular operations. See a sample code in what follows: 
 
class Application(object): 
    def __init__(self): 
        fabric_params = { 
            "fabric" : {"host" : "localhost", "port" : 8080}, 
            "user"   : "oracle", "passwd" : "oracle" 
        } 
        self.__cnx = MySQLFabricConnection(**fabric_params) 
        self.__cnx.set_property(group="YYZ") 

    def start(self): 
        while self.__run: 
            try: 
                self.__cnx.start_transaction() 
                cur.execute("...") 
                self.__cnx.commit() 
            except InterfaceError as error: 
                cur = self._get_cursor() 
            time.sleep(1) 

    def _get_cursor(self): 
        return self.__cnx.cursor()

Readers will find a full-fledged application, which shows how all the concepts introduced in this post are used together here. The application creates a simple database, a high availability group, registers the MySQL Servers into Fabric and runs a thread that mimics a client and another one that periodically executes a switchover.

To run the application, we need:
  • Python 2.6 or 2.7
  • Three or more MySQL Servers:
    • One backing store (5.6 or later preferable)
    • Two managed servers (5.6 or later necessary)
  • Fabric running
  • Connector Python (Fabric-aware Version) installed 
After configuring the environment appropriately, we can run the application as follows: 

python switchover_application.py --user=root --passwd="" --group="YYZ" \ 
--fabric-addresses="localhost:8080" \ 
--servers-addresses="localhost:13002 localhost:13003"

Please, note that Fabric and the MySQL instances may be running in different addresses and ports in our environment. So change this information accordingly.

Note that Fabric is in it early development stages and there is a long way ahead of us. However we have decided to make it public available through a labs release so that you could contribute to the project with comments, feedback or patches. Any feedback or comment is highly appreciated. Leave messages at this blog or contact us through the following forum:

http://forums.mysql.com/list.php?144

55 comments:

viru sehwag said...

Thankful for sharing utilization Hadoop Training Chennai requesting locations exchange destinations are extraordinarily significant...

Roshini RS said...

This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
Regards,
Salesforce training in Chennai

Mathew Stephen said...

There are lots of information about hadoop have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get to the next level in big data. Thanks for sharing this.


Hadoop Course in Chennai
Hadoop training institutes in chennai

kovalan Jayamurugan said...

Hi admin thanks for sharing informative article on hadoop technology. In coming years, hadoop and big data handling is going to be future of computing world. This field offer huge career prospects for talented professionals. Thus, taking Hadoop Training in Chennai will help you to enter big data technology.

Amirtha rao said...

It’s too informative blog and I am getting conglomerations of info’s. Thanks for sharing; I would like to see your updates regularly so keep blogging. If anyone looking SAS just get here.
Regards,
sas training in Chennai|sas course in Chennai

Jhon anderson said...

I was just wondering how I missed this article so far, this is a great piece of content I have ever seen in the entire Internet. Thanks for sharing this worth able information in here and do keep blogging like this.

Hadoop Training Chennai | Big Data Hadoop Training in Chennai | Best Hadoop Training in Chennai

geethu said...

Great content. I really enjoyed while reading this content with useful information, keep sharing.
Hadoop Training in Chennai | Hadoop Training Chennai | FITA Velachery | FITA Academy Chennai.

varshini devi said...

Thanks for sharing the wonder article, SAS is the recent technology, you must learn this valuable course to get future in IT firm.
Regards,
SAS Training in Chennai|SAS Course in Chennai

1croreprojects said...

Thanks for sharing this valuable information.
ieee java projects in chennai
ieee dotnet projects in chennai
mba projects in chennai
be projects in chennai
ns2 projects in chennai
mca projects in chennai
bulk projects in chennai
bsc projects in chennai
msc projects in chennai

Kaviya R said...

This blog is very informative about the concepts involved in hadoop and its scope in future. Interesting concepts on its architectute and syllabus which are covered by big data hadoop training institute in Chennai that is functioning effectively.

yasar said...

very nice and informative blog
matlab projects in chennai
ieee android projects in chennai
robotics projects in chennai
iot projects in chennai

sunilkumarkuppam said...


This content is so informatics and it was motivating all the programmers and beginners to switch over the career into the Big Data Technology. This article is so impressed and keeps updating us regularly.
Hadoop Training in Chennai | Big Data Course in Chennai | Big Data Training in Chennai

Ramya Krishnan said...

Thanks for your info, very nice and useful message. once again thanks for your valuable time.
Software Training institute in Chennai

Luckperson said...

Hi, You have shared very informative news.Thanks for sharing your wonderful experience.Very nice post with step by step explanation.
digital marketing courses in Chennai | digital marketing training institutes in Chennai | digital marketing course fees in Chennai | digital marketing training in Chennai

unknown said...

Everybody is talking about microservices. Industry veterans may remember monolithic or SOA-based solutions being the way of doing things. Times have changed. New tools have allowed developers to focus on specific problems without adding excessive complexity to deployment or other administrative tasks that are usually associated with isolated services.
Microservices training in chennai

unknown said...

The Spring Framework is a lightweight framework for developing Java enterprise applications. It provides high performing, easily testable and reusable code. Spring handles the infrastructure as the underlying framework so that you can focus on your application.Spring is modular in design, thereby making creation, handling and linking of individual components so much easier. Spring implements Model View Container(MVC) design pattern.
spring mvc validation example

venkatesh krishna said...

Thanks for the insightful article from https://godigitally.in/

svr online Training said...

The presentation of your article is out of the box......Salesforce .....just loving your way of presentation......great blog......

rn reddy said...

Thank You

TechVelocity Partners said...

This is one of the trending technology, You explained it very well, Thanks for sharing this great article.
Risk management consulting services
ROI consultant minnesota
consulting company minnesota

venkatesh s said...

THE INFORMATION YOU PROVIDED IS MUCH APPRECIATED AND I AM VERY THANK FULL FOR YOU VALUABLE INFORMAION YOU PROVIDED
online training

tansitanu said...

Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.
google-cloud-platform-training-in-chennai



venkatesh ICN said...

THE INFORMATION YOU PROVIDED IS MUCH APPRECIATED
online training visit:

Anonymous said...

I am happy to this post..Interesting post! Thanks for writing it.What's wrong with this kind of post exactly? It follows your previous guideline for post length as well as clarity.
mulesoft training videos

yalini win said...

very usefull writeups about "Writing a Fault-tolerant Database Application using MySQL Fabric".
thanks for sharing.
selenium training in chennai

rajesh redddy said...

the scripts was well formatted and really useful.keep share your articles.Hadoop Training in Chennai

lenin christ said...


Hello. This post couldn’t be written any better! Reading this post reminds me of my previous roommate. He always kept chatting about this. I will forward this page to him. Fairly certain he will have a good read. Thank you for sharing.
bigdata training institute chennai

arjun reddy said...

very useful post.

Python Training in Bangalore

arjun reddy said...

excellent post..keep sharing
Python Training in Bangalore

SRI said...

Nice and usefull contents. thanks for sharing. expecting much in the future.

RPA Training in Chennai

rahim said...

This was an nice and amazing and the given contents were very useful and the precision has given here is good.


Bigdata AnalyticsTraining in Bangalore

Nila shri said...

Thank you for your pretty information. This content is very useful to me.
Data science training in chennai
Data Science Training in Chennai

Amar G said...

Nice blog Python Training in Bangalore

genga g said...
This comment has been removed by the author.
genga g said...

Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great

content of different kinds of the valuable information's.

angularjs Training in bangalore

angularjs Training in btm

angularjs Training in electronic-city

angularjs Training in online

angularjs Training in marathahalli

vimal kumar said...

I am really happy with your blog because your article is very unique and powerful for new reader.
Click here:
Selenium Training in Chennai | Selenium Training in Bangalore | Selenium Training in Pune | Selenium online Training

Madhu Bala said...

Thanks for the blog loaded with so many information.
german language course
best german classes in chennai
best french classes in chennai
french coaching classes in chennai
Selenium Course in Chennai
Hadoop Training in Chennai

Hemapriya said...

The blog you had post is verymuch useful for us to know about the Web designing. thanks for your information sharing ith us.
Web Designing Institute in Coimbatore
Web Designing Course
Web Design Classes
Website Design Course
Learning Web Design

Vicky Ram said...

Excellent post! keep sharing such a post.

reviewcouncil
Article submission sites

mercyroy said...

Innovative thinking of you in this blog makes me very useful to learn.i need more info to learn so kindly update it.
core Java Training in Bangalore
Java Training in Chennai Anna Nagar
Java Institute in T nagar
Java Training in Sholinganallur

Anbarasan14 said...

I liked your blog. Thanks for your interest in sharing the information. keep updating.

IELTS Coaching in Mulund | IELTS Training in Mulund West | IELTS Centres in Mulund East | Best IELTS Coaching Institute in Mulund | IELTS Courses in Mulund | IELTS Coaching Centres in Mulund | IELTS Training in Mulund

Prityyou said...

Outstanding blog thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.
Airport Management Courses in Chennai | Airport Management Training in Chennai | Airline Courses in Chennai | Airport Courses in Chennai | Airline and Airport Management Courses in Chennai

sharmi chithra said...

Thanks for your sharing such a useful information. this was really helpful to me.

Informatica course in Chennai
Informatica Training center in Chennai
Informatica Training institutes in Chennai
Best Informatica Training Institute In Chennai

Harish said...

This article you have shared is very useful. Keep up the good work

Corporate Training in Chennai | corporate training | corporate training companies | Corporate Training in Adyar | Corporate Training Institute in Velachery | Corporate Training Institute in Tambaram

Annie said...

Awwsome informative blog ,Very good information thanks for sharing such wonderful blog with us ,after long time came across such knowlegeble blog. keep sharing such informative blog with us.
Aviation Academy in Chennai | Aviation Courses in Chennai | Best Aviation Academy in Chennai | Aviation Institute in Chennai | Aviation Training in Chennai

Aruna Ram said...
This comment has been removed by the author.
john jersy said...

Awesome..You have clearly explained …Its very useful for me to know about new things..Keep on blogging..
python training Course in chennai | python training in Bangalore | Python training institute in kalyan nagar

Aruna Ram said...

Amazing Article, thank you!.I am very glad to read your informative blog. Kindly keep updating.
Ethical Hacking Course
Ethical Hackingp Training in Perambur
Ethical Hackingp Training in Nungambakkam

gowsalya said...

I have read a few of the articles on your website now, and I really like your style of blogging. I added it to my favourites blog site list and will be checking back soon.
advanced excel training in bangalore

jeeva said...


A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article. I am learning a lot from you.

rpa training in electronic-city | rpa training in btm | rpa training in marathahalli | rpa training in pune

w3 Webschool said...

Nice post By reading your blog, i get inspired and this provides some useful information. Thank you for posting this exclusive post for our vision.
Web Design Training

simbu said...

Great thoughts you got there, believe I may possibly try just some of it throughout my daily life.
Java training in Chennai | Java training in Bangalore

Java online training | Java training in Pune

shalinipriya said...

Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....
Data Science Training in Chennai | Data Science training in anna nagar

Data Science training in chennai | Data science training in Bangalore

Data Science training in marathahalli | Data Science training in btm layout


Anjali Siva said...

This is a great article, it gave lots of information. It is extremely helpful for all.
Spring framework Certification
Spring framework Training
Spring Training in Adyar
Hibernate course in Chennai
Struts Training Chennai
Best Struts Training in Chennai

sharmi chithra said...

Very interesting blog. It helps me to get the in depth knowledge. Thanks for sharing such a nice blog

Pega Training Institutes
Pega Training Courses
Pega Administrator Training
Pega Classes
Pega Testing Training
Pega Software Training
Pega Software Course