Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Microservice Patterns and Best Practices

You're reading from   Microservice Patterns and Best Practices Explore patterns like CQRS and event sourcing to create scalable, maintainable, and testable microservices

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher Packt
ISBN-13 9781788474030
Length 366 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Vinicius Feitosa Pacheco Vinicius Feitosa Pacheco
Author Profile Icon Vinicius Feitosa Pacheco
Vinicius Feitosa Pacheco
Arrow right icon
View More author details
Toc

Table of Contents (20) Chapters Close

Title Page
Dedication
Packt Upsell
Contributors
Preface
1. Understanding the Microservices Concepts FREE CHAPTER 2. The Microservice Tools 3. Internal Patterns 4. Microservice Ecosystem 5. Shared Data Microservice Design Pattern 6. Aggregator Microservice Design Pattern 7. Proxy Microservice Design Pattern 8. Chained Microservice Design Pattern 9. Branch Microservice Design Pattern 10. Asynchronous Messaging Microservice 11. Microservices Working Together 12. Testing Microservices 13. Monitoring Security and Deployment 1. Other Books You May Enjoy Index

The databases


The programming with languages and development frameworks, this type of database is not good enough to cover all the uses of application scenarios.

To choose to use a database is necessary to assess the functioning and microservice operation mode in question. There are situations where the relational database makes sense, at other times one NoSQL can be better, and there are, of course, situations where none of these databases are sufficient and we need to use the database using graphs. This is exactly the situation in our news portal.

It would be very simple to say that SQL is sufficient for all, but it definitely is not. Think of our microservices to see what kind of database is best for each. The following application has these areas:

  • SportNewsService
  • PoliticsNewsService
  • FamousNewsService
  • RecommendationService
  • UsersService

For microservices that directly show news, if you think about it, there is a direct relationship system. The purpose of these microservices is to simply and quickly bring out the news theme by batch. This behavior is very close to NoSQL, where the relational structure is weak and the speed of basic operations such as searches are faster.

For services and the features previously mentioned, use one database NoSQL, which in this case will be the MongoDB. This choice includes good documentation, and performance benchmarks of implementation simplicity and cost.

UsersService is totally different. A user's credentials for an application is only a login and a password, but there is other data that is related to this login and password. This will be the case for any possible registration data or default preference. So, we have information-relevant relationships in this area, but the best option is to use a conventional SQL.

The UsersService can use a database such as MariaDB, MySQL, Oracle, SQL Server, or PostgreSQL, for example. In the case of our application, use PostgreSQL due to compatibility features, maturity, and compatibility with the rest of the stack already selected.

There is another microservice with an entirely different function from the previous microservices. The RecommendationService should establish the relationship between preferences and users, but not only that. You should also be able to provide what or how many users are interested in the same topic. You can create this type of relationship with a conventional SQL database. However, over time, increasingly complex queries will emerge, and possibly a microservices understanding of speed, as well as maintenance, can be compromised by a bad choice in the stack of conception.

For RecommendationService, a good option is to adopt the database Neo4J. The quality of work with graphs and simplicity of the tool is exactly what we are looking for in this microservice.

The big target when it comes to the database, is again, understanding how the fields behave and not putting in any comfort zones at the time of choice. The most important thing is always to choose the best tool for each case.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images