DataEngr.com
Back to Knowledge Base

Microservices

A guide to Microservices, the architectural design pattern that breaks massive, monolithic applications down into small, independent, loosely-coupled services that communicate over standard network protocols.

Microservices Data Architecture Cloud Computing Software Engineering APIs

Breaking the Monolith

For decades, software applications were built as “Monoliths.” The user interface, the business logic, the database connections, and the background processing were all written in a single, massive codebase and deployed as a single massive executable file running on a single server.

Monoliths are simple to build initially, but they become a nightmare as the company grows. If the team wants to change the color of a button on the homepage, they have to recompile and redeploy the entire application, risking breaking the critical billing system hidden deep inside the same codebase. Furthermore, if the billing system experiences a spike in traffic and crashes the server, the entire application (including the homepage) goes offline.

Microservices architecture solves these scaling and operational bottlenecks by shattering the monolith into dozens of small, independent applications, each focused on doing exactly one thing perfectly.

The Principles of Microservices

Independent Deployment: The Billing Service, the User Profile Service, and the Inventory Service are entirely separate codebases, often maintained by entirely separate engineering teams. The Billing team can deploy updates to their service 10 times a day without ever talking to the Inventory team or risking taking the Inventory service offline.

Loose Coupling: Microservices communicate with each other over the network, usually using REST APIs or event streams (like Apache Kafka), rather than calling internal functions within the same code.

Polyglot Programming: Because the services only communicate via standard JSON APIs, they don’t have to be written in the same language. The high-performance Machine Learning Service might be written in Python, while the highly-concurrent Web Traffic Service is written in Go, and the legacy Billing Service remains in Java. Teams use the best tool for the specific job.

Microservices Architecture

The Trade-offs of Microservices

While microservices provide ultimate organizational scalability, they introduce massive operational complexity:

Network Latency: In a monolith, calling a function takes nanoseconds. In a microservices architecture, fetching a user’s profile and their billing history requires sending data across the physical cloud network, introducing milliseconds of latency and the potential for network failures.

Data Consistency: In a monolith, a single relational database uses ACID transactions to guarantee data consistency. In a microservices architecture, the golden rule is “Database per Service”-the Billing service has its own database, and the User service has its own. If a transaction spans both services and the network fails halfway through, engineers must implement complex distributed patterns (like the Saga Pattern) to rollback the changes and maintain consistency across the fractured databases.

Learn More

To dive deeper into these architectures and master the modern data ecosystem, check out the comprehensive books by Alex Merced available in our Books section.