Refactoring Part I
I’m currently in the process of refactoring parts of a web based application I wrote. The main purpose is to allow it to run across several servers and support automatic fail-over and load balancing. This is an application that has been developed and used internally in our department, with one physical server. In the near future, a second department will be installing the application on their own server, and it’s plausible that there will be a third in the medium distance. I’d like there to be a lot more in the future.
The application is currently fairly monolithic, consisting of one (heavily threaded) large chunk of code, and a RDBMS behind it. Right now, we can just install it on each server and it will run fine standalone, with each department administering their own one.
However, one of the biggest things we could gain from this situation is the ability to have fail-over - should one department have network or hardware trouble, or even just become heavily loaded at a peak time, it’d be really nice if another departmentcould help out. I envision agreements between departments to do this, it’s a win-win
situation.
Using the current version we can just install backup copies on each others servers and have some form of database synchronization. If things fall over, users can be told to use the backup system. Fairly straightforward, but not ideal - data will be lost back to the last synchronization, and re-merging the backup system with the production one after it comes back will be hard. Probably a heavily manual process. Certainly better than nothing, but not as nice as it could be. Also there’s not real ability to share load during peak times.
I envison the next release of the software having the ability for the administrator to specify friendly neighbours with a simple set of parameters. The application would then automatically deal with fail-over and load balancing. Re-merging should be clean and transparent.
That is a long way from where we are now, of course, so I’m planning to tackle it in a series of steps.
The old version is written as a monolithic application. Single process, lots of threads, with a RDBMS behind it. It’s grown that way for various plausible and typical reasons, however it is now getting quite large. I have decided to modularise it slowly, adding the required failover features to each module as I address it. The idea is that as each
module (there should be 5-10 of these) is completed, the application will be quite useable and will have gained the required abilities for the aspects covered by the module.
That means I can focus on a relatively small piece of the problem at a time, take the time required to get it right, and still be able to handle regular functional releases.
More to come.
- Colin