Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

FOCUS: MICROSERVICES

Using reduce coordination effort and im­


prove team productivity.
It is therefore not surprising that

Microservices
companies are considering micro­
service adoption as a viable option
for modernizing their existing soft­
ware assets. Although some compa­

for Legacy nies have succeeded in a complete


rewrite of their applications, 2 incre­
mental approaches are commonly

Software preferred that gradually decompose


the existing application into micro­
services.3 Other approaches to

Modernization
modernization—e.g., restructuring
and refactoring of existing legacy
applications—are also valid options.4
However, decomposing a large, com­
plex application is far from trivial.
Holger Knoche and Wilhelm Hasselbring, Kiel University
Even seemingly easy questions like
“Where should I start?” or “What
services do I need?” can actually be
// Microservices promise high maintainability,
very hard to answer.
making them an interesting option for In this article, we present a pro­
software modernization. This article presents cess to modernize a large existing
software application using micro­
a migration process to decompose an service principles, and report on ex­
application into microservices, and presents periences from implementing it in an
ongoing industrial modernization
experiences from applying this process project. We particularly focus on the
in a legacy modernization project. // process of actually decomposing the
existing application, and point out
best practices as well as challenges
and pitfalls that practitioners should
watch out for.

The Legacy System


The legacy system to be modern­
ized is the customer management ap­
plication of an insurance company,
MICROSERVICES1 HAVE GAINED service for many years, maintain­ which provides customer data such
attention as an architectural style ability is of particular importance. as names and postal addresses to
for highly scalable applications run­ With respect to maintainability, the specific insurance applications. It
ning in the cloud. However, our dis­ microservices promise an improve­ was initially developed in the 1970s
cussions with practitioners show ment over traditional monoliths due and 1980s as a terminal­based ap­
that microservices are also seen as to their smaller code bases, strong plication on a mainframe using the
a promising architectural style for component isolation, and organiza­ Cobol programming language. In the
applications for which scalability is tion around business capabilities. early 2000s, user interfaces based on
not (yet) a priority. For business ap­ Furthermore, the team autonomy Java Swing were added, with the
plications, which are typically in fostered by microservices is likely to underlying logic being implemented

44 I E E E S O F T WA R E | PUBLI S HED BY THE IEEE COMPUTER SO CIE T Y 0 74 0 -74 5 9 / 1 8 / $ 3 3 . 0 0 © 2 0 1 8 I E E E


in Cobol on Unix servers. In recent The modernization goals are only two client applications, A and
years, new applications have been therefore as follows: B, both of which invoke the cus­
developed solely in Java, and a ser­ tomer application’s functionality by
vice infrastructure has been intro­ • establishing well­defined, directly calling modules. In addition,
duced to access the functionality on platform­independent interfaces module B1 from B directly accesses
the mainframe directly from Java. based on the bounded contexts one of the customer database tables
The customer application is cur­ of the underlying domain; as part of a query—for instance, a
rently used by a total of 35 client ap­ • improving the evolvability of join. This initial situation is depicted
plications, ranging across the entire the application—in particular, in Figure 1a. The remaining steps
technology stack. These applications reducing the number of entry are described next, together with ex­
access the customer application in points and preventing access to periences from implementing them
different ways, some by using defined internals, moving noncustomer in the aforementioned moderniza­
interfaces, but many by invoking in­ functionality into separate tion project.
ternal modules or even accessing the components, and eliminating
underlying database tables directly. redundant and obsolete parts of Step 1: Defining an External Service
In addition to the technological the application; and Facade
complexity, the scope of the applica­ • an incremental platform migra­ The first step of the modernization
tion has widened over the years. New tion from Cobol to Java. process is concerned with defin­
functionality not native to the cus­ ing an external service facade that
tomer domain has been added, lead­ Microservices are a suitable ar­ captures the functionality required
ing to further growth and complexity. chitecture for achieving these goals by the client systems in the form of
As of today, the customer application due to their organization around well­defined service operations (see
consists of about one million lines of business capabilities, high evolv­ Figure 1b). The implementation of
code in 1,200 Cobol modules. ability, strong component separa­ these operations is performed in
tion, and focus on cross­platform later steps.
Modernization Drivers interaction. The major challenge of this step
and Goals In order to choose a viable modern­ is to define domain­oriented ser­
The primary driver for modernizing ization process, several options were vices that provide the functionality
the customer application is the fact assessed with respect to their financial, needed by the clients, but without
that it has become increasingly diffi­ technical, and staff­related feasibility. conserving questionable design de­
cult to deliver new features on time. One of the fundamental questions of cisions from the legacy application.
Since a large, high­priority project this assessment was whether to imme­ We approached this challenge from
requires fundamental changes to diately implement the new services on two sides. First, we created a target
large parts of the application, this the Java­based technology stack or to domain model and used it to define
lack of evolvability is considered a first build Cobol implementations and service operations from scratch that
strategic risk. According to the de­ gradually replace them after migrating we expected to be provided by the
velopers, there are two main reasons the client applications. As the platform application. Afterward, we employed
for this low evolvability—namely, a migration from Cobol to Java was static analysis to identify the “entry
deterioration of the application’s in­ considered a high technical risk, the points” of the application—i.e., pro­
ternal structure and the high number latter option was chosen to separate grams, methods, or database tables
of entry points for client applica­ the client migration from the platform that were accessed from other appli­
tions. This has made the impact of migration. cations. This was indispensable, as
changes difficult to assess, leading to nobody was aware of all the accesses.
a high amount of testing and rework. The Modernization Once we knew the entry points, we
Secondary modernization drivers are Process proceeded to analyze the invoked
the vendor and technology lock­in as The proposed modernization pro­ functionality and to formulate it as
well as the fact that many developers cess consists of five steps and is provisional service operations.
are close to retirement and Cobol de­ shown schematically in Figure 1. Then, similar or redundant op­
velopers are difficult to obtain. For the sake of conciseness, we show erations were merged, and the

M AY/J U N E 2 0 1 8 | I E E E S O F T WA R E 45
FOCUS: MICROSERVICES

A1 A1
Client A Client A

Customer Client B Customer Client B


application C1 application C1

C2 B1 C2 B1

Table TC 1 Table TB 1 Table TC 1 Table TB 1

Shared database Shared database


(a) (b)

A1 A1
Client A Client A

Customer Ad Client B Customer Ad Client B


application C1 application C1
Ad Ad
C2 B1 C2 B1

Table TC 1 Table TB 1 Table TC 1 Table TB 1

Shared database Shared database


(c) (d)

A1 A1 Platform migration
Client A Client A

Ad Client B Ad Client B
C1 C1
Ad Ad
Ad C2 B1 Ad C2 B1

Platform migration

Table TC 1 Table TB 1 Table TC 1 Table TB 1

Shared database Shared database


Database migration
(e) (f)

FIGURE 1. Overview of the modernization process. (a) The initial situation. (b) Defining an external service facade. (c) Adapting
the service facade. (d) Migrating clients to the service facade. (e) Establishing internal service facades. (f) Replacing the service
implementations by microservices. Changes in the respective process steps are highlighted in blue.

46 I E E E S O F T WA R E | W W W. C O M P U T E R . O R G / S O F T W A R E | @ I E E E S O F T WA R E
provisional operations were seman­ mocking for the legacy database was, however, discarded, as this
tically matched against the expected proved to be a particular challenge. would have preserved the highly
operations. Ultimately, 29 service in­ All tests were therefore designed so complex interface structure the mod­
terfaces with about 150 service oper­ that modifications to the test data ernization was aiming to improve.
ations were derived from more than were either rolled back or explicitly During the migration, a few ser­
500 entry points. compensated. vice methods proved to be too finely
An important advantage of this grained, leading to performance deg­
approach is that in addition to the Step 3: Migrating Clients to the radation due to invocation overhead.
actual facade, it also produces in­ Service Facade Therefore, these methods had to be
formation on how to replace the Once the service operations are im­ refined during the migration.
existing entry points with service op­ plemented, client applications can In our project, the client migra­
erations, and provides candidates for start migrating to the new facade by tion took almost two years. To keep
adaptation. This information is used replacing their existing accesses with track of the overall migration prog­
extensively in subsequent steps. service invocations (see Figure 1d). ress, we employed the static­analysis
This step poses organizational as toolset used in step 1, regularly creat­
Step 2: Adapting the Service Facade well as technical challenges and ing a report of modules still using the
After defining the service operations, usually consumes a large part of old entry points. This report was then
implementations must be supplied. the overall project time and budget, compared to the migration plans of
While it is possible to immediately since large parts of the client appli­ the client applications to ensure that
provide microservice implemen­ cations must be changed and tested. the migration proceeded as planned.
tations, we chose to first build an In order to support the develop­
implementation by adapting the ex­ ment teams during the migration, we Step 4: Establishing Internal Service
isting system, as shown in Figure 1c. created a transition documentation. Facades
Thus, the client migration to the This documentation contained a tex­ The techniques described in steps 1
service facade and the platform tual description of how to replace to 3 can also be used to restructure
migration, which both posed con­ each of the entry points identified in applications internally (see Figure 1e).
siderable risk, were split into sepa­ step 1 with one or more service op­ Although this restructuring can be
rate steps, at the cost of creating a erations. For each of the new opera­ done in parallel with establishing the
throwaway implementation. tions, detailed descriptions and code external service facade, we decided to
A key challenge of this step is to snippets were provided to facilitate perform this step separately, as per­
find appropriate candidates for adap­ the transition as much as possible. forming both restructurings at the
tation. For this task, the results from This documentation was considered same time was considered both too
the entry point analysis from step 1 very helpful by the developers. risky and resource­demanding. Since
proved to be particularly helpful. For the actual migration, many no naming conventions could be ex­
However, due the refinement of the client applications successfully em­ ploited, all programs were inspected
service operations, several operations ployed client­side adapters that manually and assigned to the appro­
had to be implemented from scratch. emulated specific parts of the old priate components. Programs con­
For a successful adaptation, it is interfaces using the new service taining functionality from different
imperative to ensure sufficient test­ facade. Thus, the changes to the components were assigned to all the
ing. This can be difficult in legacy existing modules could be reduced respective components and marked
environments, as such environments significantly. Following the idea of for separation. Potentially obso­
may provide little to no facilities the Tolerant Reader pattern, 5 these lete programs were flagged for later
for common testing techniques like adapters relied on only those fields deletion.
mocking. The new microservices and operations actually required
are usually much easier to test, as for the respective application, thus Step 5: Replacing the Service
technologies like Docker Com­ preventing interface changes from Implementations with Microservices
pose can be used to set up environ­ trickling into the client applications. Once all desired service facades are
ments in an ad hoc fashion. In our The idea of creating a shared adapta­ established, the process of actually
modernization project, the lack of tion facility for all client applications introducing microservices can begin,

M AY/J U N E 2 0 1 8 | I E E E S O F T WA R E 47
FOCUS: MICROSERVICES

In total, new implementations


FURTHER READING were created for 23 service opera­
tions, several of which, though, still
have to access the Cobol code to re­
Additional information on migrating to microservices can be found in numerous main compatible with operations
sources. Patterns and transition strategies are discussed in Building Microservices8 that have not yet been migrated.
and Migrating to Cloud-Native Application Architectures.3 Detailed information on These implementations are not yet
common pitfalls and antipatterns can be found in Microservices AntiPatterns and true microservices, as several tech­
Pitfalls.9 Further industrial case studies are presented in “On Monoliths and nological and organizational bar­
Microservices”10 and “Microservices Architecture Enables DevOps: Migration to riers still have to be overcome. In
a Cloud-Native Architecture.”11 Information for implementing microservices on particular, the issue of transactional
specific platforms can be found, for instance, in Microservices, IoT, and Azure: guarantees is still subject to discus­
Leveraging DevOps and Microservice Architecture to Deliver SaaS Solutions12 sion, which is why mostly read­only
and Spring Microservices in Action.13 operations have been migrated so
far. We observe, however, that the
first careful steps toward infrastruc­
ture automation and DevOps prac­
as the adapted service implementa­ However, when microservice imple­ tices7 are being taken in the wake of
tions can now be transparently re­ mentations are introduced that do the migration, as the new implemen­
placed (see Figure 1f). It is, however, not provide the same transactional tations create opportunities for ex­
important to note that several mod­ guarantees as the former implemen­ perimenting with these approaches.
ernization goals have already been tation, the potential inconsistencies As for the time spent on the indi­
reached. Although the implementa­ must be investigated, and compensa­ vidual process steps, the definition
tion is still based on the old Cobol tion needs to be added to the client and adaptation of the service facade
code, it is now only accessed using application if necessary. took 10 and 15 months, respectively.
well­defined, platform­independent Distributed architectures are fur­ The client migration took about 20
interfaces, and the application has thermore susceptible to partial fail­ months, and the creation of the new
been internally restructured into the ure, a problem that does not arise in service implementations has taken
desired components. In particular, monolithic applications. Therefore, about nine months.
the database has been disentangled many applications rely on the avail­ It should, however, also be noted
so that, for instance, schema changes ability of their dependencies. In such that certain parts of the application
can now be performed without af­ situations, the ability to cope with cannot be modernized using the pre­
fecting client applications. unavailable dependencies needs to be sented approach. In particular, some
Although the platform migration established before the replacement— user interfaces, which are built on
is transparent in theory, there are for instance, by inserting circuit highly proprietary technologies, lack
numerous practical challenges. Two breakers.6 the necessary means for service ab­
exemplary challenges are described straction. As these user interfaces
next—namely, transactions and Current Situation, Further Steps, and are embedded by other client appli­
resilience. Limitations cations, they must be preserved for
Transactions are ubiquitous in As of now, our modernization proj­ the time being.
business software, and many ap­ ect has been running for almost
plications rely on the fact that all four years. The client migration is
changes are automatically rolled
back in case of failure. For distrib­
uted architectures such as micro­
services, transactions are notoriously
difficult to implement, and trans­
almost completed and is running
successfully in production. Further­
more, the first new service opera­
tions have been implemented, and
the first batch of requirements for
I n this article, we have presented
a process for decomposing an
existing software asset into
microservices based on our experi­
ence from an industrial case study.
actionless approaches such as ex­ the strategic project was delivered Obviously, this article can only
plicit compensation are preferred. on time. scratch the surface of this complex

48 I E E E S O F T WA R E | W W W. C O M P U T E R . O R G / S O F T W A R E | @ I E E E S O F T WA R E
ABOUT THE AUTHORS
matter. Therefore, additional mate­
rial on the topic has been compiled
in the “Further Reading” sidebar. HOLGER KNOCHE is a senior software architect at b1m
Even though our modernization Informatik and a PhD student in Kiel University’s Software
is not yet complete, we have already Engineering Group. His research interests include software
reached essential goals, as we were architecture and software modernization, especially runtime
able to eliminate uncontrolled access performance and data consistency during the move toward
to the internals of the application decentralized architectures such as microservices. Knoche
and we met the first batch of new received a master’s in computer science from FHDW Han-
requirements on time. Furthermore, nover. He’s a member of the German Association for Computer
practices like automated testing and Science. Contact him at hkn@informatik.uni-kiel.de.
code reviews have been established
as a by­product of the moderniza­
tion, which is considered a notable WILHELM HASSELBRING is a professor of software engi-
success. neering at Kiel University. In the Software Systems Engineer-
In retrospect, we conclude that ing competence cluster, he coordinates technology-transfer
despite the additional cost of creat­ projects with industry. His research interests include software
ing throwaway implementations, engineering and distributed systems, particularly software
separating the client migration from architecture design and evaluation. Hasselbring received a
the platform migration was the right PhD in computer science from the University of Dortmund.
thing to do in this particular project, He’s a member of ACM, the IEEE Computer Society, and the
as several technical challenges are German Association for Computer Science. Contact him at
still not solved. For projects with a hasselbring@email.uni-kiel.de.
less risky platform migration, how­
ever, this effort is not justified, and
new service implementations should
be immediately provided as micro­
services. Furthermore, due to the
effort involved, this process is viable
only for migrating large, complex Systems,” Proc. 26th Int’l Conf. 11. A. Balalaie, A. Heydarnoori, and P.
software systems with a high busi­ Software Eng. (ICSE 04), 2004, pp. Jamshidi, “Microservices Architec­
ness value. 117–126. ture Enables DevOps: Migration to
5. M. Fowler, “Tolerant Reader,” 9 May a Cloud­Native Architecture,” IEEE
References 2011; martinfowler.com/bliki Software, vol. 33, no. 3, 2016, pp.
1. J. Lewis and M. Fowler, “Micro­ /TolerantReader.html. 42–52.
services,” 2014; martinfowler.com 6. M. Nygard, Release It! Design and 12. B. Familiar, Microservices, IoT, and
/articles/microservices.html. Deploy Production-Ready Software, Azure: Leveraging DevOps and
2. W. Hasselbring and G. Steinacker, Pragmatic Bookshelf, 2007. Microservice Architecture to Deliver
“Microservice Architectures for Scal­ 7. L. Bass, I. Weber, and L. Zhu, SaaS Solutions, Apress, 2015.
ability, Agility and Reliability in DevOps: A Software Architect’s 13. J. Carnell, Spring Microservices in
E­Commerce,” Proc. IEEE Int’l Conf. Perspective, Addison­Wesley, 2015. Action, Manning, 2017.
Software Architecture Workshops 8. S Newman, Building Microservices,
(ICSAW 17), 2017, pp. 243–246. O’Reilly, 2015.
3. M. Stine, Migrating to Cloud-Native 9. M. Richards, Microservices AntiPat-
Application Architectures, O’Reilly, terns and Pitfalls, O’Reilly, 2015.
2015. 10. G. Steinacker, “On Monoliths and Read your subscriptions
4. W. Hasselbring et al., “The Dublo Microservices,” 2015; dev.otto.de through the myCS
publications portal at
Architecture Pattern for Smooth /2015/09/30/on­monoliths­and
Migration of Business Information ­microservices.
http://mycs.computer.org

M AY/J U N E 2 0 1 8 | I E E E S O F T WA R E 49

You might also like