Devops For Database
Devops For Database
Devops For Database
the Database
DevOps for
the Database
IN THIS ISSUE
DevOps for
the Database 12 Treating Shared Databases
Like APIs in a DevOps World 28
Ben Linders
is an Independent Consultant in Agile, Lean,
Quality and Continuous Improvement,
based in The Netherlands. Author of
Matthew Skelton Getting Value out of Agile Retrospectives,
Waardevolle Agile Retrospectives, What
has been building, deploying, and operating Drives Quality, The Agile Self-assessment
commercial software systems since Game, and Continuous Improvement.
1998. Head of Consulting at Conflux, Creator of many Agile Coaching Tools,
he specialises in Continuous Delivery, for example, the Agile Self-assessment
operability and organisation design for Game. As an adviser, coach and trainer he
software in manufacturing, ecommerce, and helps organizations by deploying effective
online services, including cloud, IoT, and software development and management
embedded software. practices.
The InfoQ eMag / Issue #74 / June 2019
A LETTER FROM
THE EDITOR
Sooner or later, database chang- once you hear it from the experts
es become the bottleneck for who’ve been there and done that.
traditional organizations trying to
accelerate software delivery with Jonathan Allen gets us started
modern CI/CD deployment pipe- with the basics: version con-
lines. After building, testing and trolling all database changes and
deploying application changes making sure they are visible and
through the pipeline, environment deployed from a pipeline rath-
configuration, infrastructure er than via standalone manual
changes and even automated processes. Changes might refer
security tests are usually next to schema and index updates but
Manuel Pais in line. Databases tend to get also procedures, views, triggers,
is a DevOps and Delivery Consultant,
left behind (no one heard of configuration settings, reference
focused on teams and flow. DevDBOps yet), partly because data, and so on. The key is to en-
Manuel helps organizations adopt
test automation and continuous of concerns around testing data sure the ability to recreate a full
delivery, as well as understand migration and performance. But database from scratch if need be
DevOps from both technical and
human perspectives. Co-curator of there are often issues around - minus the data (which should
DevOpsTopologies.com. DevOps ownership as well, with gate- come from backups).
lead editor for InfoQ. Co-founder of
DevOps Lisbon meetup. Coauthor keeping DBAs incentivized to
of the book “Team Topologies:
ensure stability and security of Besides tooling (for CI/CD,
Organizing Business and Technology
Teams for Fast Flow”. central databases (customer deployment, monitoring and
Tweets @manupaisable
data has become, after all, the observability), we must also ad-
most important asset for many dress people (growing database
organizations) while application skills for application engineers),
teams are incentivized to move culture (make sure the new ways
fast and deliver features, thus of working are more resilient and
requiring frequent changes to the easy to apply, thus avoiding a
database. reversion to old habits), and pro-
cess concerns (plan ahead and
In this eMag we provide you con- stick to it, but do it in an iterative
crete directions on how to deal fashion), says Baron Schwartz.
with the above concerns, and The article is an adaptation from
some new patterns for database a talk where Schwartz highlights
development and operations in patterns and anti-patterns he’s
this fast paced DevOps world. seen in 20 years of experience
It’s not as scary as it may seem with databases and tools.
4
The InfoQ eMag / Issue #74 / June 2019
A short report on a talk by Simon Because CI/CD and DevOps are
Sabin at WinOps 2017 points also about people and culture,
out the benefit of treating shared we include an interview with the
databases as APIs. This includes always pragmatic Dan North
practices like respecting con- talking about the evolution of the
sumer (application) driven con- DBA role (and team) and how it
tracts and reducing batch size relates to dev and ops roles.
for database changes, adding
deployment information in the Matthew Skelton recommends a
database itself, or improving se- “DBA-as-a-Service” model sup-
curity with a “private” vs “public” porting independent application
approach to database design. teams with their own database
Plenty of food for thought! development skills, especially
when moving to a microservices
Eduardo Piairo’s article talks us approach. Skelton reminds us of
through a staged approach to CI/ the need to consider the impor-
CD for databases, highlighting tance of Conway’s law when de-
the practices required for each signing systems and the underly-
stage. Continuous Integration ing data stores. In particular, the
means that database changes effectiveness of microservices
are validated through automated can be hindered if the database
testing, while Continuous Deliv- design does not match the orga-
ery means that new database nization’s team structures and
versions can be deployed from responsibilities.
the pipeline. Piairo further iden-
tifies different pipeline design
strategies for databases, based
on the organization’s maturi-
ty - from fully independent DB
pipelines to joined pipelines (app
and DB code) at the deployment
stage to fully integrated app/DB
pipelines, sharing a single CI/CD
process.
5
The InfoQ eMag / Issue #74 / June 2019
Deliver
Deliver
Deliver
value
value
quicker
value
quicker
quicker
while
while
keeping
while
keeping
keeping
youryour
data
your
data
safe
data
safe
safe
Redgate
Redgate
Redgate
helps
helps
IT
helps
teams
IT teams
IT teams
balance
balance
balance
the need
thethe
need
toneed
to to
deliver
deliver
deliver
software
software
software
faster
faster
with
faster
with
the
with
need
thethe
need
toneed
protect
to protect
to protect
andand
preserve
and
preserve
preserve
business
business
business
critical
critical
critical
data.data.
data.
YouYou
and
You
and
your
andyour
business
your
business
business
benefit
benefit
benefit
fromfrom
a from
DevOps
a DevOps
a DevOps
approach
approach
approach
to database
to database
to database
development,
development,
development,
whilewhile
staying
while
staying
staying
compliant
compliant
compliant
andand
minimizing
and
minimizing
minimizing
risk.risk.
risk.
FindFind
out
Find
out
more
out
more
atmore
at at
www.red-gate.com/DevOps
www.red-gate.com/DevOps
www.red-gate.com/DevOps
6
The InfoQ eMag / Issue #74 / June 2019
How to Source-Control
Your Databases for DevOps
by Jonathan Allen, Software Engineer and Lead Editor
A robust DevOps environment requires having continuous integration for every component of the system
but too often the database is omitted from the equation, leading to problems from fragile production re-
leases and inefficient development practices to simply making it harder to onboard new programmers.
both relational and NoSQL databases have aspects to consider in making them a part of a successful
continuous integration.
• database configuration.
When planning your source control for the da-
tabase, make sure you capture everything. This
You may think that because you are using a sche-
includes, but is not limited to:
ma-less database, you don’t need source control.
7
But even then, you are going to When working with whole-sche- the database objects themselves,
The InfoQ eMag / Issue #74 / June 2019
need to account for indexes and ma source control, you usually you store the list of steps nec-
overall database configuration don’t write your migration scripts essary to create the database
settings. If your indexing scheme directly. The deployment tools objects. The one I’ve used suc-
in your QA database is differ- figure out what changes you cessfully in the past is Liquibase,
ent than that in your production need by comparing the current but they all work pretty much the
database, it will be difficult to state of the database with the same.
perform meaningful performance idealized version in source con-
tests. trol. This allows you to rapidly The main advantage of a change-
make changes to the database script tool is your full control over
There are two basic types of and see the results. When using the final migration script. This
source control for databases, this type of tool, I rarely alter the makes it easier to perform com-
which I’ll call “whole schema” database directly and instead plex changes such as splitting or
and “change script”. allow the tooling to do most of combining tables.
the work.
“Whole-schema” source control Unfortunately, there are several
is where your source control Occasionally, the tooling isn’t disadvantages to this style of
looks how you want your data- enough, even with pre- and source control. The first is the
base to look. When using this post-deployment scripts. In need to write the change scripts.
pattern, you can see all the tables those cases, a database develop- While it does give you more
and views laid out exactly as they er or DBA will have to manually control, it is also time consum-
are meant to be, which can make modify the generated migration ing. It is much easier to just add
it easier to understand the data- script, which can break your a property to a C# class than to
base without having to deploy it. continuous deployment scheme. write out the ALTER TABLE script
This usually happens when there in longhand.
An example of whole-schema are major changes to a table’s
source control for SQL Server structure, as the generated mi- This becomes even more prob-
is SQL Server Data Tools (SSDT). gration script can be inefficient in lematic when working with things
In SSDT, all of your database these cases. like SchemaBinding. SchemaB-
objects are expressed in terms of inding enables some advanced
CREATE scripts. This can be con- Another advantage of features in SQL Server by lock-
venient when you want to pro- whole-schema source control ing down the table schema. If
totype a new object using SQL, is that it supports code analy- you make changes to a table or
then paste the final draft directly sis. For example, if you alter the view’s design, you have to first
into the database project under name of a column but forget to remove the SchemaBinding from
source control. change it in a view, SSDT will any views that touch the table
return a compile error. Just like or view. And if those views are
Another example of whole-sche- static typing for application pro- schema-bound by other views,
ma source control is Entity gramming languages, this catch- you need to temporarily unbind
Framework migrations. Instead es a lot of errors and prevents those too. All of this boilerplate,
of SQL scripts, the database is you from attempting to deploy while easy for a whole-schema
primarily represented by C#/VB clearly broken scripts. source control tool to generate, is
classes. Again, you can get a hard to do correctly by hand.
good picture of the database by The other option is change-script
browsing the source code. source control. Instead of storing
8
Another disadvantage of change- bles that hold data that users are actions (e.g., shipping receipts or
9
a database that allows you to the migration scripts no longer As a rule of thumb, I allow the
The InfoQ eMag / Issue #74 / June 2019
manually set a value in an iden- work, requiring you to restore the shared developer database to
tity column. In SQL Server, this is database from backups. update whenever a check-in is
done via the SET IDENTITY_IN- made the relevant branch. This
SERT command. Another issue is schema drift. can be somewhat disruptive, but
This is when the development usually it is manageable. And
Another option for dealing with database no longer matches you do need a place to verify the
this scenario is to have a col- what’s in source control. Over deployment scripts before they
umn called “SystemControlled” time, developer databases tend hit integration.
or something to that effect. to accumulate non-production
When this entry is set to 1/true, tables, test scripts, temporary For my integration databases, I
it means the application will not views, and other cruft to be tend to schedule deployments to
allow direct modifications. If set cleared out. This is much easier happen once per day along with
to 0/false, then the deployment to do when each developer has any services. This provides a
scripts know to ignore it. their own database that they can stable platform that UI develop-
reset whenever they want. ers can work with. Few things are
Individual developer databases as frustrating to UI developers as
Once you have the schema and The final and most important not knowing if code that sudden-
data under source control, you issue is that service and UI de- ly starts failing was their mistake
can take the next step and start velopers need a stable platform or a problem in the services/
setting up individual developer to write their code. If the shared database.
databases. Just as each devel- database is constantly in flux,
oper should be able to run their they can’t work efficiently. At one Database security and source
own instance of a web server, company I worked at, it was not control
each developer who may be usual to see developers shout, An often-overlooked aspect of
modifying the database design “Services are down again!” and database management is secu-
needs to be able to run their own then spend an hour playing video rity — specifically, which users
copy of the database. games while the shared database and roles have access to which
was put back together. tables, views, and stored pro-
This rule is frequently violated, cedures. In the all-too-familiar
to the determent of the devel- Shared developer and integration worst-case scenario, the ap-
opment team. Invariably, de- databases plication gets full access to the
velopers making changes to a The number-one rule for a shared database. It can read and write to
shared environment are going to developer or integration database every column of every table, even
interfere with each other. They is that no one should directly ones it has no business touching.
may even get into deployment modify the database. The only Data breaches often result from
duels, when two developers each way a shared database should exploitations of flaws in a minor
try to deploy changes to the update is via the build server utility application with far more
database. When this happens and the continuous-integration/ access rights than it needs.
with a whole-schema tool, they deployment process. Not only
will alternately revert the other’s does this prevent schema drift, The main objection to locking
changes without even realizing it allows scheduled updates to down the database is that devel-
it. If using a change-script tool, reduce disruptions. opers don’t know what will break.
the database may be placed in Because they have never locked
an indeterminate state for which down the database before, they
10
literally have no idea what permissions the application actually
11
The InfoQ eMag / Issue #74 / June 2019
DevOps for
the Database
Presentation summary by Manuel Pais, DevOps and Delivery Consultant
12
databases. The strategy was to outages will still happen if devs all developers have to be able
13
erally speaking, if you can apply harder for developers to build ap- keeps the wheels on. That kind of
The InfoQ eMag / Issue #74 / June 2019
DevOps principles, practices, cul- plications that run well in produc- work should be automated.
tures, habits, and so forth to the tion. They become limited in the
database, you get similar benefits speed at which they can learn, fix, You also need tooling for data-
as you do from the other parts of and improve. Ultimately, develop- base monitoring and observabil-
your applications. er productivity declines and they ity, otherwise you can’t improve
become dependent on DBAs to their performance. Schwartz’s
One major gain is entering a literally debug their application. definition of observability is an
virtuous cycle of stability, which Schwartz has seen many cases attribute or property of a system
leads to more speed, which in where application bugs could that allows it to be observed,
turn leads to more stability. only be diagnosed by looking at besides all the required tooling
Instability slows things down, database behavior, which really to do so. For Schwartz, monitor-
which means that you can’t fix should be unacceptable. ing is the activity of continually
problems as quickly and appli- testing a system for conditions
cations get less stable. DevOps Bringing DevOps to the database that you have predetermined.
definitely helps increase stability There are four core elements to Observability is about taking the
and speed. successfully bring DevOps to the telemetry from the system and
database: people, culture, struc- guiding it into an analysis pipe-
Without DevOps, you have DBAs ture and process, and tooling. It line in order to be able to ask
responsible for code that they also requires a continuous learn- questions on the fly about how
can’t control — because a query ing process — you can’t do it with your systems are behaving. In
is code that runs in the database. a single DevOps adoption project. other words, monitoring tells you
When you deploy an application, if your systems are broken; ob-
you’re deploying queries into Tooling is the most concrete servability tells you why they’re
the database as well. That often and immediate of elements to broken and how to fix them.
leads to putting in gatekeeping grasp, so let’s start with it. You
controls and processes, which need tooling for deploying and All teams that Schwartz sees
creates a dependency for devel- releasing database changes in a working under high scale with
opers by offloading developer continuous fashion. You need to low downtime focus on knowl-
work onto the DBA team. The eliminate manual interactions to edge sharing. They use ancillary
latter lack the time to focus on be able to do frequent and auto- tooling like wiki pages, doc-
strategic activities like designing mated changes to the database. umentation (e.g., runbooks),
the next version of the platform Manual toil keeps you working dashboards, chatbots, and so on.
and helping developers design in the current system instead of There’s a lot of ancillary tooling
better applications and sche- focusing on improving it. that serves to tie people’s expe-
ma. This means you have highly rience, knowledge, and mental
knowledgeable, hard-to-find It’s easy to see how much man- models about the system to-
database administrators who are ual work there is because it’s gether in a shareable way that
doing unskilled routine work and, typically a painful process that allows other people to rapidly
even worse, becoming a bottle- people are explicitly conscious benefit from it. These teams put
neck to faster delivery. of. By participating in retrospec- in the time and effort to share
tives and conversations within knowledge.
With this approach, production the organization, you might be
feedback doesn’t come back surprised to realize how much
to development, making it even manual work is still required to
14
important, but what is lacking
15
Schwartz finds that statement to with them. Psychological safety stores, in production. Schwartz
The InfoQ eMag / Issue #74 / June 2019
be truthful. and trust mean three things to noted several successful cases
Schwartz: listening to people and where engineers use the data-
In order to change culture, you saying, “I hear you, you matter to base toolset extensively to mon-
need to change the perceived me, you exist;” empathizing with itor what is happening, even if
value of work. Operations work them and saying, “I care;” and they didn’t understand specifics
shouldn’t have low status. Car- supporting them and saying, “I’ve like buffer pools and latches and
rying a pager shouldn’t have low got your back.” When you put SQL transaction isolation levels.
status. Being on call for your own those three things together, you
code shouldn’t have low status. can create psychological trust in Failure
Reverse these perceptions by in- a team. And this kind of safety is Many database-automation
creasing the status of the person critical to enable risk taking and and operational tools are frag-
who is owning the production learning. ile because they were not built
behavior of your systems. by people with experience run-
When it comes to people, you ning databases at scale. This
Look at what creates friction and need experts. Increasing the will cause critical outages and
resistance to the change that you autonomy of development teams perhaps impact careers. Automa-
want to create and then create doesn’t mean you no longer tion that tries to work outside a
a path of least resistance. Make need database experts. You need well-defined scope is more likely
the right thing the easiest thing people who are going to be able to experience these problems.
to do and try to make the wrong to predict that a tool is going to On the other hand, giving up on
thing or the old ways a little bit cause an outage because it was automation and relying on man-
harder to do. Definitely get every- written for Microsoft Access on ual toil will not help either. That
body on the same page as far as a desktop and you are running will perpetuate the problems until
experiencing the benefits of the PostgreSQL on a thousand nodes they build to a crisis.
new ways of working and share in the cloud. When Schwartz was
the pain among everyone. Don’t doing performance consulting, Another problem Schwartz has
always call the same engineer often the performance problems seen is the use of distinct sets
every time there is a problem at that he saw were caused by au- of tooling for deploying code to
3:00 a.m. tomation, by monitoring systems production and for deploying
that were causing undue burden database changes to produc-
At the same time, you need on the systems. Many problems tion. That means you have two
leadership support. And leader- come from the tooling itself rath- distributed systems that must
ship comes from all levels, not er than the applications using coordinate with each other. Try to
just from the top of the org chart. them. use the code-deployment tooling,
You need real buy-in and sup- automation, and infrastructure
port from peers and SMEs, not DBAs are subject-matter experts as code for the database as well,
just with words but through their with deep domain knowledge; rather than building a shadow
actions. If you have somebody they should not be caretakers copy in parallel.
passive-aggressively working of the database. They should be
against changes, the changes helping everybody else to get Culture change is hard. Too often
will never stick. better, enabling engineers in ser- people expect that bringing in a
vice teams to learn the necessary new vendor with modern tools
Finally, you need to build trust database skills to build and run will create culture change. But
with other people and empathize their applications, including data you can’t really do that from the
16
outside, so relying on these tools maintenance becomes nearly
17
Why and How Database
The InfoQ eMag / Issue #74 / June 2019
Changes Should
Be Included in the
Deployment Pipeline
by Eduardo Piairo, DevOps Coach
18
Data makes databases special. Data must persist data and should consider both to justify the chang-
By not including the database in the pipeline, most Where you start automation depends on your cho-
of the work related to database changes ends up sen approach. However, it’s a good idea to move
being manual, with the associated costs and risks. from left to right in the deployment pipeline and
On top of that, this: take baby steps.
• results in a lack of traceability of database The first step is to describe the database change
changes (changes history), using a script. Normally, a person does this.
19
CREATE TABLE [dbo].[Member]( The following script represents how the database
The InfoQ eMag / Issue #74 / June 2019
[MemberId] [INT] IDENTITY(1,1) NOT should start from scratch, not the commands need-
NULL,
ed to migrate from the current database state. This
[MemberFirstName] [NVARCHAR](50)
NULL, is known as a declarative-state or desired-state
[MemberLastName] [NVARCHAR](50) NULL, approach.
CONSTRAINT [PK_Member] PRIMARY KEY
CLUSTERED CREATE TABLE [dbo].[Member](
( [MemberId] [INT] IDENTITY(1,1) NOT
[MemberId] ASC NULL,
)WITH (PAD_INDEX = OFF, STATISTICS_ [MemberFirstName] [NVARCHAR](50)
NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, NULL,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = [MemberLastName] [NVARCHAR](50) NULL,
ON) ON [PRIMARY] [MemberEmail] [NVARCHAR](50) NULL,
) ON [PRIMARY] CONSTRAINT [PK_Member] PRIMARY KEY
CLUSTERED
Source control is the first stage of the deployment (
pipeline and provides a number of benefits. [MemberId] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_
NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
Traceability through change history allows you ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS =
to discover what changed, when it changed, who ON) ON [PRIMARY]
changed it, and why. ) ON [PRIMARY]
20
The state approach is usually faster in terms of change script cre-
CI and CD
Achieving source control for database changes unlocks the second
and third stages of the deployment pipeline. You can now apply CI
and CD practices.
21
gration, etc.), and when to test (before, during, and after deployment).
The InfoQ eMag / Issue #74 / June 2019
Deployment scenarios
Scenario 1, a fully independent pipeline, is common in organizations
starting the process of database automation/integration with appli-
cation development. The first instinct is to build a separate pipeline
dedicated to the database in order to avoid affecting the existing
application pipeline.
It’s possible, however, that a database (or a part of it) lives inde-
pendently from the application. For example, the database may not
connect to any application and users can establish a direct connec-
tion to the database. Although this use case is not common, having
an independent pipeline for the database would then be appropriate.
22
A second scenario is delivering the application and database
23
Scenario 4 is a fully integrated pipeline. The database and applica-
The InfoQ eMag / Issue #74 / June 2019
TL;DR
tion code live in the same repository and share the same CI and CD
processes.
The deployment pipeline is a cultural and technical tool for managing • Migrations-based and
changes in the software development process and should include state-based are two differ-
databases, applications, and infrastructure. ent approaches to describ-
ing a database change.
Independent of the choice,
Following the same deployment process for databases as well as small batches are always a
applications aligns with Gene Kim’s “three ways”, the principles un- good option.
derpinning DevOps, because it increases flow visibility, leading to a
• The deployment pipeline
better understanding of how to safely and quickly change the system, is a technical and cultural
it increases feedback and creates more learning opportunities at all tool that should reflect
levels, and sharing knowledge through the pipeline allows the organi- DevOps values and practic-
es according to the needs
zation to build a learning system, to avoid extensive documentation of each organization.
(often a source of waste), and to reduce the truck factor (relying on a
system instead of relying on heroes).
The deployment pipeline is your software factory: the better your fac-
tory, the better your product, your software.
24
The InfoQ eMag / Issue #74 / June 2019
How Database
Administration
Fits into DevOps
by Ben Linders, Trainer / Coach / Author / Speaker
The Interviewee
The Agile Consortium Interna- database administration when
tional and Unicom organized organizations adopt DevOps.
the DevOps Summit Brussels
2016 on February 4 in Brussels, InfoQ: What activities do DBAs
where Dan North spoke about typically perform?
how database administration fits
into the world of DevOps. Dan North: The DBA role typically Dan North
spans multiple production envi- writes software and coaches
InfoQ interviewed him about the ronments, development teams, teams in Agile and Lean
methods. He believes in
activities that database admin- technologies, and stakeholders. putting people first and
istrators (DBAs) perform and They may be tuning a database writing simple, pragmatic
software. He believes
how they relate to the activities one minute, applying a security that most problems that
of developers and operations, patch the next, responding to a teams face are about
communication, and all the
how database administration is production issue, or answering others are too. This is why he
puts so much emphasis on
usually organized, how the data- developers’ questions. They need “getting the words right”, and
base fits into DevOps or contin- to ensure backups and replica- why he is so passionate about
BDD, communication and how
uous delivery (CD), and what he tion are configured correctly, to people learn.
expects the future to bring for ensure the appropriate systems
25
and users (and no one else!) have equivalent OO data structures, conservative, if not outright skep-
The InfoQ eMag / Issue #74 / June 2019
access to the right databases, but things quickly become com- tical, about database changes
and they need to be on hand to plex when your desired domain coming through from developers.
troubleshoot unusual system model diverges from the data-
behavior. base schema or when there are Sometimes, there is a mix of pro-
performance, availability, or scal- duction DBAs and development
Their real value lies in under- ing considerations. At this point, DBAs. The former tend to sit
standing the mechanics and having a helpful DBA as part of together, doing all the production
details of the database itself, its the development team can be maintenance work I described
run-time characteristics, and invaluable. above. The latter are helping
configuration, so they can bridge development teams interact with
the gap between developers On the operations side, the DBA the database correctly, both in
writing queries and operations is often responsible for imple- terms of schema design and
staff running jobs. A skilled DBA menting a business’s replication querying. This model can work
can identify ways to speed up or availability strategy. It is oper- really well, especially where the
slow-running queries, either by ations’ role to monitor the sys- production and development
changing the query logic, altering tems, diagnose issues, and keep DBAs have an existing relation-
the database schema, or editing the lights on, but the DBAs will ship of trust. The production
database run-time parameters. be closely involved in monitoring DBAs know the development
For instance, changing the order and diagnosing database-re- DBAs will ensure a level of quality
of joins, introducing an index (or lated issues. They also define and sanity in the schema design
sometimes removing an index!), the database management and and database queries, and the
adding hints to the database’s maintenance processes that the development DBAs trust the pro-
query execution planner, or up- operations team carry out. duction DBAs to configure and
dating database heuristics can maintain the various database
all have a dramatic impact on InfoQ: How is database adminis- instances appropriately.
performance. tration usually organized? What
are the benefits and pitfalls of InfoQ: How does the database
InfoQ: How do their activities re- organizing it that way? fit into DevOps or continuous
late to those done by developers delivery?
and by operations? North: Traditionally, the DBA
role is another technology silo, North: In a lot of organizations,
North: Sadly, too few developers turning requests or tickets into it simply doesn’t. Any database
really understand what goes on work. This means they can be changes go through a separate
in a relational database. Map- lacking context about the broader out-of-band process indepen-
ping layers like Hibernate or business or technology needs dent of application code chang-
Microsoft’s Entity Framework and constraints, and are doing es, and shepherding data-
hides the internals from regular the best they can in an informa- base-and-application changes
enterprise developers, whose tion vacuum. In my experience, through to production can be
bread and butter is C# or Java DBAs are often in an on-call fraught.
programming, and of course this support role so they are the ones
is a double-edged sword. On one being paged in the middle of the Some organisations talk about
hand, it makes it easier to de- night when a developer’s query “database as code”, and have
velop basic applications where exceeds some usage threshold. some kind of automated process
the database schema maps onto Because of this, they tend to be that runs changes into the data-
26
base as managed change scripts. The database tooling should
27
Treating Shared
The InfoQ eMag / Issue #74 / June 2019
28
The database respects an im- anisms are more complemen- “DataOps” or “database lifecycle
29
SPONSORED ARTICLE
The InfoQ eMag / Issue #74 / June 2019
30
Continuous Delivery for Databases:
31
for better deployability and will affecting other applications and chronous, and complex — are
The InfoQ eMag / Issue #74 / June 2019
investigate the emerging pattern features, but without waiting for a often not possible to understand
of microservices for building and large regression test of all con- fully prior to deployment, and
deploying software. nected systems. their behavior is understood only
by observation in production.
Along the way, we’ll consider why Several factors drive this in-
and how we can apply some of creased need for deployability. Finally, an ability to rapidly
the lessons from microservices First, startup businesses can deploy changes is essential to
to databases in order to improve now build a viable product, using defend against serious security
deployability. In particular, we’ll new cloud technologies, with vulnerabilities such as Heart-
see how the eventual consisten- staggering speed to rival those of bleed and Shellshock in core
cy found in many microservices large incumbent players. Since it libraries, or platform vulnera-
architectures could be applied began to offer films over the In- bilities such as SQL injection in
to modern systems, avoiding the ternet via Amazon Web Services’ Drupal 7. Waiting for a two-week
close coupling (and availability cloud services, Netflix has grown regression-test cycle is simply
challenges) of immediate consis- to become a major competitor to not acceptable in these cases,
tency. Finally, we’ll look at how both television companies and to nor is manual patching of hun-
Conway’s law limits the shape the film industry. With software dreds of servers: changes must
of systems that teams can build, designed and built to work with be deployed using automation,
alongside some new (or redis- the good and bad features of driven by pre-tested scripts.
covered) ownership patterns, hu- public cloud systems, companies
man factors, and team topologies like Netflix are able to innovate at In short, organizations must val-
that help to improve deployability speeds significantly higher than ue highly the need for change in
in a CD context. organizations relying on systems modern software systems, and
built for the pre-cloud age. design systems that are amena-
Factors driving deployability ble to rapid, regular, repeatable,
The ability to deploy new or A second reason why deployabili- and reliable change — an ap-
changed functionality safe- ty is now hugely important is that proach characterized as “con-
ly and rapidly to a production if software systems are easier to tinuous delivery” by Jez Humble
environment — deployabili- deploy, deployments will happen and Dave Farley in their 2010
ty — has become increasingly more frequently and so more book of the same name.
important since the emergence feedback will be available to de-
of commodity cloud computing velopment and operations teams. The use of the microservices
(virtualization combined with Faster feedback allows for more architectural pattern to compose
software-defined elastic infra- timely and rapid improvements, modern software systems is one
structure). There are plenty of responding to sudden changes in response to the need for software
common examples of where this the market or user base. that we can easily change. The
is important: we might want to microservices style separates
deploy a new application, a mod- Faster feedback in turn provides a software application into a
ified user journey, or a bug fix to a an improved understanding of number of discrete services, each
single feature. Regardless of the how the software really works providing an API and each with
specific case, the crucial thing is for teams involved, a third driver its own store or view of data that
that the change can be made in- for good deployability. Modern it needs. Centralized data stores
dependently and in an isolated software systems — which are of the traditional RDBMS form
way in order to avoid adversely increasingly distributed, asyn- are typically replaced with local
32
data stores and either a central the services is often left up to set, and the subsequently lower
33
need to adopt a different sense of common — it might take min- boundary as the line at which
The InfoQ eMag / Issue #74 / June 2019
scale. utes, hours, or days to process the default data update scheme
and the organization deals with switches to immediate consis-
Consider a successful organ- the small proportion of anom- tency — it was merely a conve-
isation with a typical web- alies in back-office processing, nient place for that in the 1990s
based OLTP system for orders, refunds, etc. They use proven and 2000s. The boundary for
built around 2001 and since techniques such as master immediate consistency has to lie
evolved. Such a system likely has data management (MDM) to tie fairly close to the operation being
a large core database running on together identifiers from different performed; otherwise, if we in-
Oracle, DB2, or SQL Server plus databases, allowing audits and sisted on immediate consistency
numerous secondary databases. queries for common data across across all supplier organizations
The databases may serve several the enterprise. and their suppliers ad infinitum
separate software applications. we’d have to “stop the world”
Database operations might be Between the databases of dif- briefly just to withdraw cash
coordinated across these data- ferent organizations, eventual from an ATM! There are times
bases using distributed transac- consistency, not immediate when immediate consistency is
tions or cross-database calls. consistency, is the norm. Con- needed, but eventual consistency
sider the Internet domain-name should be seen as the norm or
However, the organization need system (DNS) as a great example default.
to send data or read data from of eventual consistency that has
remote systems — such as those been proven to work robustly for When considering microservices
of a supplier — and it is likely decades. and eventual consistency in par-
to only sparingly use distribut- ticular, we need to take the kinds
ed transactions. Asynchronous There is nothing particular of rules that we’d naturally apply
data reconciliation is much more special about the organizational to larger systems (say book-
keeping for a single organiza-
tion or orders for a single online
store) and apply these at a level
or granularity an order of mag-
nitude smaller: at the boundary
of individual business services.
In the same way that we have
come to avoid distributed trans-
actions across organizational
boundaries, with a microservices
architecture, we avoid distrib-
uted transactions across sepa-
rate business services, allowing
event-driven asynchronous
messaging to trigger workflows
in related services.
Figure 2 / For the vast majority of activities, eventual
consistency is the norm. This approach is also perfect for most So, we can see that there are
services and systems within an organization. similar patterns of data updates
at work between organizations
34
and between business services years ago, particularly in terms has some reasonable dash-
35
to focus on the functionality they and operating the software is consistency, and queue-based
The InfoQ eMag / Issue #74 / June 2019
cared about. that the microservices are easier event-sourced operations for
to understand than the larger background updates. The sense
Rather than spending time monolithic systems. Systems of ownership tends to keep the
deploying database schema that are easier to comprehend quality of code high, and avoids a
changes manually to individual and deploy (avoiding ma- large and unwieldy mass of tests
core relational databases, the chine-level multitenancy) make accreting to the software.
next-generation DBA will likely be teams much less fearful of
monitoring the production estate change, and in turn allows them Conway’s law and the
for new database instances, to feel more in control of the sys- implications for CD
checking conformance to basic tems they deal with. For modern The way in which teams commu-
standards and performance, and software systems whose behav- nicate and interact is the major
triggering a workflow to auto- ior cannot easily be predicted, the determinant of the resulting soft-
matically backup new databases. removal of fear and increase in ware system architecture; this
Data audit will be another im- confidence are crucial psycho- force (termed the “homomorphic
portant part of that DBA’s role, logical factors in the long-term force” by software guru Allan
making sure that there is trace- success of such systems. Kelly) is captured by Conway’s
ability across the various data law, published in 1968: organiza-
sources and technologies and Microservices architectures aim tions that design systems… are
flagging any gaps. for human-sized complexity, constrained to produce designs
decoupling behavior from other that are copies of the commu-
One of the advantages of micro- systems by the use of asynchro- nication structures of these
services for the teams building nous, lazy data loading, tuneable organizations.
36
end up with an architecture that After we start looking at soft- own DBA, because many mi-
37
• auditing data from multiple A good way to think about a “DBA limitations, and keep the bound-
The InfoQ eMag / Issue #74 / June 2019
databases for business-level as a service” team is to imagine it aries clear; adhere to the social
consistency (such as postal as something you’d pay for from contracts and seek collaboration
formats). AWS. Amazon don’t care about at the right places.
what’s in your application but will
Of course, each autonomous coordinate your data/backups/ Supporting practices for
service team must also commit resilience/performance. It’s im- database CD
to not breaking functionality for portant to maintain only a mini- In addition to changes in tech-
other teams. In practice, this mal interaction surface between nologies and teams, there are
means that software written by each microservice and the “DBA some essential good practices
one team will work with multiple as a service” team (perhaps just for effective CD with databases
versions of calling systems, ei- an API) so that they’re not pulled using microservices. Foremost is
ther through implicit compatibili- into the design and maintenance the need for a focus on the flow
ty in the API (“being forgiving”) or of individual services. of business requirements with
through use of some kind of ex- clear cross-program prioritiza-
plicit versioning scheme (prefer- There is no definitively correct tion of multiple workstreams, so
ably semantic versioning). When team topology for database that teams are not swamped with
combined with a concertina management within a microser- conflicting requests from differ-
approach — expanding the num- vices approach, but a traditional ent budget holders.
ber of supported older clients, centralized DBA function is likely
then contracting again as clients to be too constraining if the DBA The second core practice is
upgrade — this decouples each team must approve all database to use version control for all
separate service from changes changes. Each team topology database changes: schema,
in related services, an essential has implications for how the users, triggers, stored proce-
aspect of enabling independent database can change and evolve. dures, reference data, and so on.
deployability. Choose a model based on an un- The only database changes that
derstanding of its strengths and should be made in production
are CRUD operations result-
ing from inbound or scheduled
data updates; all other changes,
including updates to indexes and
performance tuning, should flow
down from upstream environ-
ments, having been tested before
being deployed (using automa-
tion) into production.
38
tion to gradually move towards a the 1990s and 2000s, in fact the
39
InfoQ @ InfoQ InfoQ InfoQ
Curious about
previous issues?
ODR brings you insights In this eMag, we explore In this eMag, we present you
on how to build a great the real-world stories of expert security advice on
organisation, looking at the organizations that have how to effectively integrate
evidence and quality of the adopted some of these security practices and
advice we have available new ways of working: processes in the software
from academia and our sociocracy, Holacracy, teal delivery lifecycle, so that
thought leaders in our organizations, self-selection, everyone from development
industry. This is a collection self-management, and with to security and operations
of reviews and commentary no managers. understands and contributes
on the culture and methods to the overall security
being used and promoted of the applications and
across our industry. Topics infrastructure.
cover organisational
structuring to leadership and
team psychology.