Archive for the ‘Career’ Category
MySQL Replication
Thursday, May 7th, 2009Replication has now become an essential feature for most MySQL users. The good news I can share at the same time is that the working and implementation of this concept is also less complicated. It involves a minimum of 2 servers: a master and a slave (in most cases). The slave makes use of the binary logs created by the master to update its database thereby keeping both of them in exact synchronization.
Issues Leading to the Need of Replication
Heavy Load:
Lets consider a website with an exponentially increasing number of users regularly. There will arrive a state in which the single database server could no longer handle the load anymore. If the server receives more number of read queries rather than write queries (which will be the normal case for most of the websites) then, the best choice will be to adopt replication into the current architecture. Here, the read queries refer to SELECT statements and the write queries refer to INSERT, UPDATE and DELETE statements.
Now I am going to explain how replication solves the issue of heavy load. When the concept of replication is implemented we will be having more than one server. Among these servers, the one named as master will receive queries related to write and make changes to its database immediately. Consequently, when the binary log is updated, the slaves update their database reading from the log files. The slaves on the other hand receive all read queries. Depending on the number of queries received, the number of slaves can be increased or decreased. Now by using any scheduling algorithm (Round Robin is an example), we can effectively load balance the incoming read queries to different slave servers so that all of them get equal workloads.
Backup: Anytime and Without Client Disturbance
During backup requirements, we normally stop MySQL or lock the read queries to get an exact backup. This may sometimes result in the annoyance of the clients who access the website during the process. Although there are a few clever techniques with which you may do this without the notice of the clients, things become very simple with replication.
The slaves always remain in exact synchronization with the master. In other words, the slaves will have another copy of the entire repository that the master processes. And hence backing up of a slave is similar and as good as backing up of the master. Also the presence of slaves as exact replicas will in most cases help avoid the need for backup of the master. This is because we always have the slaves as a spare in case of any misfortunes to the master.
Distribution of Data Without Respect to Distance:
Next issue I am to focus on deals with distributing copies of data in various locations that are geographically very apart which is not a trivial task. But the replication factor gives the flexibility that we require to make it trivial.
The master provides no errors even if the slave remains disconnected for some time. So in spite of the poor connection and other factors that may influence the link between the different destinations, a synchronized copy of the master can be made to exist in a geographically distant region.
Architectures of Replication
There are a few rules that I recommend to be kept in mind to better understand the different architectures.
- There needs to be a unique server ID for every slave
- There can be many slaves for a master
- There can be only one master for a slave
- Slaves can also function as masters
Master: Slave
This architecture best suits an environment, which has low number of write queries and high number of read queries. Effective load balance can be achieved by spreading the workload among the different servers. Here is an illustration.
Dual Master:
This kind of architecture is particularly useful when servers are geographically far apart. Although during interruptions, neither will have access to their data both will catch up from each other when the connection is reestablished. An extension of this architecture will be to have a slave on either side that is also diagrammatically shown below.
.
Pyramid:
In a large organization where there is diverse distribution in a hierarchical manner, a possible architecture like this will be the best suit. There is no necessity to configure every slave with the master as the slave above in the hierarchy can act as their master.
Although replication solves problems, it demands so much precision, which if not taken care of, can even result in the crash of the master database. Slaves are not always in synchronized state with their master. But with proper monitoring systems this can be detected. The concept of replication is provided by MySQL and can definitely improve overall performance if dealt with proper caution.
Software Testing Tips
Wednesday, April 29th, 2009Do you know that software testing can be an art? Being able to evaluate the capability of a system or application and ensuring it meets with client requirement involves a certain amount of craftsmanship.
This could be a dull chore where you simply perform ad hoc testing or a challenging experience that involves a good deal of planning and designing before testing.
Here are 10 tips that can help to develop good quality software that works according to specifications.
1. Understand the application: How can you test if you do not know if the application is functioning as designed or if a functionality is missing? You first need to understand and have a good knowledge of the software before you start testing. Understand what the software can do, what external resources it uses to do it, its major behaviors and how it interacts with its environment. This knowledge would help you write effective test cases.
2. Start with a plan: Strong testing begins with a good test plan. You need to come up with a good strategy that defines your requirements in terms of tests. This means knowing what you need to test, what constitutes a bug and how to prioritize your work according to associated risks.
3. Write effective test cases: A combination of domain knowledge, prior experience and good writing skills help you to write good test cases. Your test cases should be understandable and repeatable that explains the intention of the tests and the expected results.
4. Ensure maximum coverage: You can never guarantee 100% coverage but you can ensure that every requirement is covered by at least one test case. You can also break your application under test into smaller modules and write individual test cases for each module. This would ensure maximum test coverage.
5. Start early: Writing your test cases in the requirement analysis and design phase ensures that all requirements are testable. Bugs detected early in the development process are also considered cheaper to fix.
6. Give access to developers: It’s a good idea to give developers access to your test cases before they begin coding. This helps them to understand and analyze your test cases completely and develop good quality software. It also helps them save time on re-working.
7. Test with the right attitude: No software is bug-free. So, test with the intention of finding bugs and you will definitely succeed in finding some. Testing should ensure that the application does what it should and doesn’t do what it should not.
8. Record test results: Besides writing test cases, you should record your test results and provide solutions. This data helps when you do regression testing as probable bugs in the application can now be easily predicted.
9. Test for performance: Many testers tend to ignore performance testing when the volume of data is large. However, testing for performance is very important and you need to find ways to test your application for performance even if it means writing just basic scripts to create test data performance test.
10. Remove changes in code base after testing: For testing, changes are made to the code base. Don’t forget to note down these changes and remove them from the code base before final release.
To summarize, no matter how much testing you perform, you can never guarantee a bug free application. What you can ensure is that the basic and crucial functions of the application work well and your customer is happy with the software you deliver.
Google Launches API for Google Analytics
Wednesday, April 22nd, 2009When it comes to web then it’s all the way Google. Right from search engine to browser to email, they are now providing with API for their Analytics feature. Google Analytics is their free service for tracking and analyzing website traffic and usage.
It was a much-awaited release from Google. “Large organizations and agencies now have a standardized platform for integrating Analytics data with their own business data,” says Google’s Nick Mihailovski.
Google was blamed of storing the browsing history of a user. Now they are willing to share this data. So it is really an interesting move from Google.
One can access Aoogle Analytics from phone using Android application and from desktop using Desktop-Reporting. For more details about how the API works, you can read this blog post from Google about it.