Page 32 - MSDN Magazine, September 2018
P. 32

MICROSERVICES
Architect Blockchain
Smart Contracts as
Microservices
Stefano Tempesta
Microservices and blockchain smart contracts have a lot in common. They’re both expected to run in isolation (on-chain) and communicate with the outside (off-chain) via a message-based channel. They should both be small in size, developed to run auto- nomously and independently, and perform better when they’re deployed on a decentralized network.
This article presents design principles, artifacts and code sam- ples for building blockchain applications using a microservice architecture style and deploying them on the Microsoft Azure Blockchain platform.
Microservices perfectly embody the spirit of the Unix philoso- phy: Do one thing and do it well (tcrn.ch/2vnq5Pb). A microservice is an independent, deployable component of bounded scope that supports interoperability through message-based communica- tion. Given this premise, microservice architecture is a style of
engineering that helps build highly automated, evolvable software systems made up of single-capability microservices.
What do blockchain applications have in common with microser- vices, and what design principles can be applied from microservice architectures to the decentralized world? The table in Figure 1 compares microservices and smart contracts against specific design attributes.
Designing blockchain applications as microservices can bring the following benefits to your solution:
• Allow many software engineering initiatives to run in parallel. • Lessen dependencies between software development and
test teams.
• Support multiple technologies, languages and frameworks. • Promote ease of innovation through disposable code.
Microservices typically speak to the outside world via an applica- tion programming interface (API) that shares a common language, say JSON or SOAP, with the client—providing a lingua franca of messaging-enabled systems across different technologies (.NET, Java, Node.js and so on) and platforms (Windows, Linux). This is true also for the blockchain API exposed by Azure Blockchain Workbench, as you’ll see later in this article.
From Microservices to Decentralized Applications
If you’re familiar with the DevOps sentiment of treating your servers like cattle and not pets (bit.ly/2vrdM4p), you might apply the same approach to your source code. Easily disposable code can reduce technical debt, promote modernization of engineering processes and decrease operational costs by optimizing infrastructure (for example, in containers or entirely serverless configurations).
This article discusses:
• Microservice architecture design
• Decentralized domain-driven design • Event sourcing and CQRS
• Distributed transaction
• Azure Blockchain Workbench API
• Asynchronous messaging Technologies discussed:
Microservices, Blockchain, Ethereum, Microsoft Azure Blockchain Workbench
24 msdn magazine


































































































   30   31   32   33   34