Microservices and the Blockchain

Building unique blockchain infrastructure

In the world of application development, microservices and containers are all the rage. Developers everywhere are working to break monolithic applications into smaller, more modular pieces by using microservice architectures coupled with technology like Docker containers.

At Po.et, we believe in the power of microservices. However, as we are building a decentralized application powered by the blockchain, we've learned that implementing microservice architecture into a decentralized application needs a special approach.

In many ways, what we're doing is quite unique, and this speaks to the special challenges and opportunities that arise when you combine microservices with the blockchain.

Traditional Microservices

Microservices have become so popular in recent years for two main reasons:

The Original Plan For Po.et's Microservice Architecture

When we began developing Po.et, our plan was to adopt a traditional microservice model.

Each Po.et node needs to run multiple services — ranging from a torrent service and Bitcoin scanner to a system for processing "claims," which refer to information regarding ownership of digital content that is managed on the Po.et network.

Initially, we intended to implement the Po.et node application so that each of these services would run as a distinct microservice inside its own container. The containers would be managed using Docker Swarm.

The major goals of this approach were to make it easy for the services to scale independently and to simplify management using Swarm.

The Decentralization Dilemma

As the project developed, we realized that the Po.et node is different from most traditional applications in one key way: it is a decentralized app.

That is a big deal. Traditional microservice architectures are designed to support applications that are deployed and managed centrally. In most cases, a company or group of administrators hosts the app in a datacenter somewhere. The app might be "distributed" in the sense that it is hosted on a cluster of servers rather than a single one, but, even in that case, the server cluster is still centralized. One authority controls the application and is responsible for managing it. In this case, being able to deploy the app using containers and manage it with an orchestrator like Swarm is useful.

Po.et is fundamentally different. Po.et is a decentralized network of nodes, with each node more or less running like a desktop application rather than a cloud-based one. No single entity is responsible for managing the nodes or making sure the network can scale. Instead, the network manages itself and scales automatically as nodes are added or subtracted.

Centralized management through an orchestrator like Swarm is, therefore, unnecessary in Po.et's case. In addition, breaking each node into traditional microservices isn't advantageous from a management standpoint because the nodes are self-managed and self-contained. It's important to ensure that each node instance is able to stand on its own, but having to deploy multiple microservices to start a single node would make it harder, not easier, for people to use Po.et.

The New Po.et Architecture

The new Po.et architecture.

Because of these considerations, we have migrated to a new application architecture. You might say it is microservice-inspired, even though it does not use microservices or containers in the conventional sense.

Instead, what we are doing is building Po.et as a set of distinct code modules but not separate services. Each module behaves in a fashion similar to a microservice. The modules have no knowledge of each other and communicate only via a message queue.

From a programming standpoint, modules are easier to manage. They also help to make Po.et nodes more efficient and secure.

However, this module-based architecture doesn't require each node to run multiple microservices, so setup and management is simpler on a decentralized network.

Conclusion

Microservices are great, but decentralized apps have special challenges that traditional microservices cannot easily solve.

At Po.et, we're applying the microservices concept to the development of our decentralized platform, but we're doing something different from run-of-the-mill microservices.

We hope that our example will help lead the way for the development of other decentralized apps as the blockchain space matures and developers adapt to the new realities of programming for a decentralized world.


Originally published on Medium.

A newsletter for programmers

Yo! This is Taro. I've been doing JavaScript for years and TypeScript for years. I have experience with many programming languages, libraries, frameworks; both backend and frontend, and in a few company roles/positions.

I learned a few things over the years. Some took more effort than I wish they had. My goal with this blog and newsletter is to help frontend and backend developers by sharing what I learned in a friendlier, more accessible and thorough manner.

I write about cool and new JavaScript, TypeScript and CSS features, architecture, the human side of working in IT, my experience and software-related things I enjoy in general.

Subscribe to my newsletter to receive notifications when I publish new articles, as well as some newsletter-exclusive content.

No spam. Unsubscribe at any time. I'll never share your details with anyone. 1 email a week at most.

Success!
You have subscribed to Taro's newsletter
Shoot!
The server blew up. I'll go get my fire extinguisher — please check back in 5.