Skip to main content

Database choice for your assigned microservice

A database is an essential component of most modern software applications, providing a centralized location for storing and managing data. To ensure the integrity, availability, and security of this valuable resource, it is essential to establish clear guidelines for its use. This document aims to provide a set of best practices for database management and usage, covering everything from database design principles to security considerations. By following these guidelines, you can ensure that your database operates efficiently and effectively, and that your data is both accessible and protected.

Choice

Choosing the right database for a microservice is a critical decision that can have a significant impact on the overall performance and scalability of your application. Each microservice has unique requirements that must be carefully considered when selecting a database. One of the most important factors to consider is the type of data that the microservice will be managing. For example, if the microservice is responsible for handling large volumes of unstructured data, a NoSQL database may be a better choice than a traditional relational database. On the other hand, if the data is highly structured and needs to be queried in a variety of ways, a relational database may be a better fit. Another important consideration is the scalability requirements of the microservice. Will the database need to scale horizontally to handle large amounts of traffic, or will vertical scaling be sufficient? This will help determine whether a distributed database or a traditional monolithic database is the better choice.

Guidelines

Here are some guidelines to follow when designing your microservice database:

  • Conduct thorough research and choose a database based on evidence.
  • Take ownership of the design of your assigned database and ensure that it aligns with the requirements of your microservice.
  • Seek input from a colleague to review your design decisions and provide valuable feedback.

By adhering to these guidelines, we can ensure consistency across all our databases and achieve a superior outcome for our application.

Default database

For our schemaless database needs, we have chosen to use MongoDB. MongoDB is a NoSQL database that is designed to store unstructured data in a flexible, scalable and high-performance manner. It is an open-source database that is widely used in web applications, mobile apps, and other types of software. Its flexible document model allows for easy scaling and quick iterations, making it an excellent choice for microservices architecture.

On the other hand, for our schema-based database needs, we have decided to use PostgreSQL. PostgreSQL is an open-source, object-relational database that has been around for over 30 years. It is known for its robustness, stability, and ability to handle complex queries and large amounts of data. It has excellent support for transactions and can handle multiple users and concurrent access to the database. Its extensive feature set, including built-in support for indexing, replication, and clustering, make it an ideal choice for complex microservice applications.