Scaling Databases in Microservices Architecture with Horizontal, Vertical, and Functional Data Partitioning

In this article, we are going to discuss How to scale databases in Microservices Architectures with applying Horizontal, Vertical and Functional Data Partitioning. And we will use these pattern and practices when designing e-commerce microservice architecture.

By the end of the article, you will learn How to scale databases in Microservices Architectures with applying Horizontal, Vertical and Functional Data Partitioning in Microservices Data Design patterns and principles.

Step by Step Design Architectures w/ Course

I have just published a new course — Design Microservices Architecture with Patterns & Principles.

In this course, we’re going to learn how to Design Microservices Architecture with using Design Patterns, Principles and the Best Practices. We will start with designing Monolithic to Event-Driven Microservices step by step and together using the right architecture design patterns and techniques.

Scale Database in Microservices

We are going to talk about Data Partitioning types which’s are Horizontal, vertical, and functional data partitioning. When we are discussing about scaling databases in our microservices architecture, we said that we should split databases in order scale properly for databases.

So now we will see how data is divided into partitions with different ways.

Horizontal, Vertical, and Functional Data Partitioning

There are three typical strategies for partitioning data: Horizontal partitioning (often called sharding) and we mostly use this partitioning, Vertical partitioning, Functional partitioning.

Let me try to explain one by one.

Horizontal Partitioning — Sharding

Its Horizontal partitioning (often called sharding). horizontal partitioning or sharding. In this partitioning, each partition is a separate data store, but all partitions have the same schema. Each partition is known as a shard and holds a specific subset of the data.

https://hazelcast.com/glossary/sharding/

If we check the image here, product data is divided into shards based on the product keys. Each shard holds the data according to sharding keys which’s organized alphabetically. Sharding separate the load different servers and by this way system improves performance.

So this is Horizontally partitioning (sharding) data based on a partition key and its widely using in distributed databases when scaling the database servers.

Vertical Partitioning

We can call Vertical partitioning as a “Row Splitting”. Each partition holds a subset of the columns for table in the database. The columns are divided according to their pattern of use.

For example, frequently accessed columns can be use in one vertical partition and less frequently accessed fields in another.

Functional Partitioning

Functionally partitioning data by following the bounded context or subdomains. So Data is segregated according to usage of bounded contexts in the system. Its like decomposing microservices as per responsibilities with considering bounded contexts.

As you can see that we have understood our partitioning options for database in distributed systems. For our microservices architecture its best practice to use sharding — horizontal partitioning in our architecture.

Scale Database in Microservices

If we apply these partitioning pattern into our e-commerce microservices architecture, you can find the below design of that.

So this will illustrates scaling databases different servers with using database sharding pattern.

Main features are;

  • Peer-to-Peer Distributed Wide Column Database
  • Master-Master (Master-less) architecture
  • It is highly scalable and designed to manage very large amounts of structured data.
  • It provides high availability with no single point of failure.

So we should evolve our architecture with applying other Microservices Data Patterns in order to accommodate business adaptations faster time-to-market and handle larger requests.

Step by Step Design Architectures w/ Course

I have just published a new course — Design Microservices Architecture with Patterns & Principles.

In this course, we’re going to learn how to Design Microservices Architecture with using Design Patterns, Principles and the Best Practices. We will start with designing Monolithic to Event-Driven Microservices step by step and together using the right architecture design patterns and techniques.

--

--

Design microservice systems using the right architecture design patterns and techniques. Handle millions of request with designing system for high availability, high scalability, low latency, and resilience to network failures on microservices distributed architectures.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mehmet Ozkaya

Software/Solutions Architect, Udemy Instructor, Working on Cloud-Native and Serverless Event-driven Microservices Architectures https://github.com/mehmetozkaya