Defining the architecture of a microservices-based solution

In a microservices architecture, a single application is composed of many autonomous services.

The microservices architecture works with containerization technology, which is a form of virtualization that enables you to run applications in isolated spaces called containers. Containers are executable software units that contain application code along with associated libraries and dependencies.

Microservices offer lots of valuable benefits including:

  • Independently deployed modules
  • Easy management
  • Improved fault tolerance
  • Agility

With microservices, you can update and change each service separately without rebuilding and redeploying the entire application.

However, some specialists including Martin Fowler prefer to start software development with a monolithic architecture. And indeed, building a microservices-based solution can be tricky due to challenges such as data integrity, complexity, and lack of governance.

Thanks to our experience developing various projects based on a microservices approach, we know where to start and what pitfalls to expect. Let’s create a demo project with a simplified order workflow.

The architecture we offer can be used as a starting point for building an e-commerce solution, a ticket booking system, or any other software that provides paid goods or services. We’ll write a simple program in .NET and then deploy the .NET web app to Azure Service Fabric.

Here’s a scheme of the architecture we’re aiming for:

The solution we’ll build has four microservices, and two of them have public APIs. Here’s a brief description of our application’s flow:

  1. The API sends a command to OrderService to create an order.
  2. InitOrderHandler checks the data validity of the request and assigns unique identifiers to the request and the order.
  3. StockService checks whether there are enough products left to complete the order. If yes, it books the required number of products. If not, the service cancels the order.
  4. ProcessOrderSaga receives control over the next actions and waits five minutes to receive an OrderPaid message.
  5. If payment is received, ProcessOrderSaga completes the order. Otherwise, it cancels the booking.

To learn more, read the full article, where we show a practical example of how to build a microservices architecture and deploy a .NET application to Azure Service Fabric step by step.

We created this article to give developers who are considering migrating their products to microservices a helicopter view of this architecture.

--

--

Apriorit
Apriorit — Specialized Software Development Company

21+ yrs of expert software engineering services to tech companies worldwide, covering the entire software R&D cycle. Details: www.apriorit.com/about-us/company