SQL Clone: Ending Provisioning Headaches
With SQL Clone, there is now an easy path away from the shared dev database model to allow for easier testing, provisioning, and dealing with sensitive data.
Join the DZone community and get the full member experience.Join For Free
when developing a database as a team, most team members would generally prefer to work with their own, isolated copy of the database, rather than work on a shared development database.
up to now, however, there have been a number of additional management and security problems with the dedicated database approach and these burdens only increase as the size of the database grows, and as regulations around data security and sharing grow. as a result, many organizations still tend to favor the shared model, despite its drawbacks.
sql clone can help reduce the pain associated with many of the provisioning tasks that go with database development, regardless of what development model you use. for teams who use a shared development database out of necessity rather than choice, i believe sql clone can remove enough of the additional problems to make the dedicated model viable for the first time.
why is the shared development database model still prevalent?
whichever model you use when developing a database, you are always going to have to overcome database provisioning problems. even in the shared model, you’ll still need to manage a few ‘sandboxes’, where developers can try out new ideas. both development models require test databases. both models require provisioning and management of databases in uat/qa/staging environments.
over the years, i’ve heard and read some impassioned arguments in favor of dedicated development databases. troy hunt’s article is a great example. central to his theme is the idea that on a dedicated database, each developer can do whatever is needed to accomplish an assigned task, without fear of conflicting with the work of others. they have the freedom to experiment without having to worry about causing unpredictable data states, disrupting integration tests, and so on.
a dedicated development database simplifies the task of diagnosing a sudden change in behavior or performance by removing the possibility that someone else’s modification caused the issue. in short, dedicated database development makes developers more productive.
these arguments are still valid, and yet in my experience, for databases of any size or significance, i’ve found the shared database development model to be more prevalent. why?
for many companies, the question is not why? , but rather why not? the shared model uses less disk space and requires less dba time to manage (at least, in theory). security concerns compel companies to keep data in locations where it is under it control. and if the workload and databases schemas and permissions are managed properly, the changes of different developers don’t often conflict with each other.
the risk of changing a development practice that isn’t broken, in favor of one that will likely have a higher administrative overhead, is not outweighed by the intangible reward of increased productivity.
of course, the benefits of the shared development database come at a cost. since multiple developer schedules are involved, opportunities for refreshing that shared development database are dramatically reduced. often, this means planning an outage on that database to allow time for the refresh.
when the time does finally come to provision the new copy of the database, work must be stopped while the provisioning is occurring – for large databases, the time required can be hours or even days. far too often, this means that the refresh is avoided in favor of keeping the normal flow of work moving. developers must adapt to using stale data for their testing, while companies settle for results that are ‘good enough’. the cost to change that state has traditionally been high enough to put it out of reach for many companies that may otherwise desire to improve.
sql clone is a tool that aims solely to reduce the pain of database provisioning. i believe it can remove enough of the burden that teams can simply choose whichever development model suits them best, rather than being constrained for logistical reasons.
so how does sql clone help?
sql clone allows you to get the best of both worlds by providing as many updateable copies of a database image as you wish, either on one server or on several servers within the same network. each clone shares the data from the original image, and merely stores locally any subsequent differences to that image that are caused by changes to the data or metadata.
sql clone does this by using windows own vm technology. sql server is entirely unaware of any difference in the cloned image and any other database. it is used entirely unchanged, because sql clone works at the operating system level. the effect is that the database is stored only once, and the clones store only the subsequent changes.
if additional data security is required, data masking or loading of development data can be completed before the image is created. development work can then proceed without any concern that user data or confidential data can be compromised.
even with sql clone, you’ll still require a slick management process to be able to keep things under control when provisioning, and regularly refreshing multiple development, test, and other environments. fortunately, in addition to a streamlined web interface that is accessible to both administrators and developers, sql clone comes with a library of powershell cmdlets, allowing full control of the process within a script.
provisioning copies of large databases
as the size of databases has increased, the difficulty of transferring those databases between servers has also increased. large production databases can take hours, or longer, to restore. finding space for multiple copies of these large databases is also a challenge in the face of ever-increasing demands for storage space from all sides.
sql clone solves this problem by significantly reducing the amount of space required to store multiple copies of these large databases. instead of requiring the full amount of space on the database server each time a copy is provisioned, the image is only stored once, in a central location. each clone is then created with a small differencing disk on the database server, starting with less than 50mb of space. even though the clone will grow as changes are made to the schema or data, the space required is generally a fraction of the amount that would have been required for a full copy of the database.
provisioning multiple development environments
sometimes, database provisioning simply means restoring the latest backup of the production database to the target server, though it’s rarely as simple as that sounds. for many databases, there are usually a number of additional steps to perform any time a fresh database copy is deployed, such as basic data cleansing, or removing production logins, and then recreating logins for that target environment and mapping them to existing users and roles.
for large databases containing sensitive data, the problems are challenging. it can be hard to keep up with the regular demand for fresh data, as well as the various ad-hoc requests from developers who need to return to a stable state after a failed experiment, or need to replicate a production issue from last night that didn’t exist the night before.
with sql clone, you can create an initial ‘clean’ data image (see later), and from that image create as many clones as required, in seconds. all local changes made to a particular developer’s clone are isolated, stored in a local differencing file, and simply committed to source control in the usual manner. the space required on each machine is just the space required to store any local changes.
it means, in effect, that each developer can work with their own copy of the production database. if they need to create a branch, they can quickly create a new clone to support development on that branch. likewise, if they need to reset their environment, or refresh it with a clone of the latest data image, it becomes a matter of seconds rather than hours or days.
clones can be created and destroyed at will to meet the specific situation, and because the changes made by the developer are not transferred back to the image, there is no chance that an experimental change will affect either production or other developers.
provisioning for database testing
for companies adopting a fully automated devops workflow, provisioning provides a unique challenge. ideally, a fresh copy of the database would be created for each run of the build process so that unit tests and integration tests could judge accurately whether the changes made in that build had the intended effect, and whether the changes introduced any unwanted regressions.
this ideal has not been feasible in many cases, simply because large databases take too long to restore. this has left teams with the choice of finding ways to revert the changes in the previous test or living with an unclean copy of the database.
with sql clone, a clean copy of the database can be provisioned as part of the build process without creating unwanted delays, and because a clone only requires a small amount of disk space, clones can be created as often as necessary to run the desired tests.
it even becomes feasible to do parallel testing with real databases. let’s say you have a series of five tests, one for each for end-to-end testing of a specific business function, which if run serially, take 16 hours. what if you could spin up five separate clones and test each business process in parallel? it would dramatically reduce the time required for end-to-end testing.
the end result is faster test times, much more accurate testing, and higher quality code.
dealing with sensitive data
most companies now have to comply with some sort of regulation regarding the privacy of the data they store, and in those cases, providing developers with realistic volumes of ‘production-like’ data for testing is a bigger problem.
sql clone can help make this process easier. in cases where there are no real data sensitivity issues, we can perform very basic data cleansing, such as replacing real email addresses that we don’t want the application to use, by altering the data in the clone. this can easily be incorporated in an automated powershell script that produces the clones. because a clone can also be imaged, we can still create a new data image to use for distribution.
for more stringent requirements, though, it’s probably best to produce clean data before creating the data image. this means restoring the backup, sanitizing or obfuscating the production data to an extent that it complies with any relevant regulations regarding data sharing, then creating the data image from that database.
alternatively, we can avoid production data altogether, by performing a new database build, from the latest version in source control, and then importing standard data sets for testing, and then creating the image.
creating a backup, restoring it to a different server, performing data cleansing, and adjusting the security for the development environment all take a significant amount of time when done manually. automation is possible with existing tools, but it often requires complex scripts, which also take time to create and maintain. if a company is affected by strict regulations that prevent a dba from seeing customer data, all of this must be performed under the watchful eyes of an auditor.
with sql clone, an image can be created using sql clone’s built-in powershell cmdlets, which simplifies the scripting required. that script can be scheduled during off-hours using the company’s standard scheduling tools. to satisfy regulators, the variant using non-production data can be created without intervention by a dba by using additional scripts.
clones can then be created from the resulting image, either automatically with powershell or on-demand from the sql clone web interface, by anyone with permissions, including developers. automation that was previously difficult becomes feasible for anyone.
sql clone might be a game-changer. developers benefit from being able to work with realistic data and ‘self-service’ provisioning. database administrators benefit from the reduced management overhead, leaving more time for tasks that add real value.
companies benefit from improved developer productivity and the higher quality code that results from improved testing. and the best part is, all of these benefits are possible without giving up the benefits of the development model you’re already using.
get rid of your database provisioning headache with a 14-day fully functional free trial of sql clone.
Published at DZone with permission of Ed Leighton-Dick, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.