Microservices Architecture, as practiced by Amazon and Netflix, is not ideal for every organization, but that doesn't mean they can't reap the benefits by implementing some Microservices Architecture methods and ideas in a different way. As a starting step, these companies can select between Modular Monoliths and Miniservices.
Recommended Techniques and Concepts
The following are the recommended techniques and concepts for designing systems based on Microservices Architecture for smaller firms who wish to reap the greatest benefits while spending the least amount of money and being just one step away from Microservices.
Segregation of Concerns (Modularization) — Divide application into loosely linked modules so that each module is only concerned with one item. Each module's code should be stored in a distinct source control repository, and separate teams should work on each module independently. Authentication, User Management, Order Management, Payments, Product Catalog Management, Cart Management, Shipping, Notifications, and Inventory Management are a few examples.
Deployment Independence — Each Module should be deployed as a separate application/executable/deployable. This enables for more frequent and faster deployments, which improves agility and reduces time to market. Containers and Container Orchestration should be used to automate infrastructure. Infrastructure as Code (IaC) practices can also be deployed as an option.
Resilient Discrete Services – Define discrete services within each Module, each executing a specific operation with well-defined APIs. These services must be capable of handling faults and recovering rapidly. Techniques such as circuit breaking, retries, and graceful degradation can help achieve this.
Database per Module – Each Module should have its own database that is not shared with any other Module. Data is only transferred across modules by using the public APIs given by the modules' services. The tables and schema are shared by the services within the module.
Stateless Services — Create stateless services by persisting all data at the data source or via an external caching service (NoSQL, key-value store, or clustered sessions).
Inter-Service Communication — To communicate with one another, the services employ an externally configured service locator/service discovery and support numerous messaging protocols, both synchronous and asynchronous.
Continuous Integration, Automated Testing, and Deployment — Establishing a continuous integration infrastructure is a must. Each Module is developed and deployed as a separate application with its own pipeline, automated testing, and deployment targets.
Monitoring - Create a simple monitoring system based on logs gathered centrally and the use of analytical and visual tools.
Specialized Patterns and Practices: Not One-Size-Fits-All
Certain patterns and practices are not universally applicable and should be avoided, as they cater to very specific use-cases. These patterns are:
Independent Service Deployment: This refers to deploying each microservice independently, which may not be necessary for all organizations and could add complexity and overhead.
Choreography, events, and asynchronous communication: These involve complex interactions between services, which may not be required in all scenarios, and could introduce unnecessary challenges.
Event Sourcing Using CQRS (Command Query Responsibility Segregation): CQRS is a pattern that separates the read and write operations of a system, while event sourcing is a way of storing changes to the application state as a sequence of events. These advanced patterns may not be essential for every organization.
Compensating Transactions and Sagas: These are techniques used to manage distributed transactions across multiple services. However, they can be complex to implement and might not be necessary for all enterprises.
Infrastructure as Code for Dedicated DevOps Teams: While Infrastructure as Code (IaC) can be beneficial, it may not be needed for every organization, especially if they don't have a dedicated DevOps team to manage and maintain it.
By avoiding these patterns, organizations can focus on implementing Microservices Architecture in a simpler, more cost-effective manner that is better suited to their specific needs.
Organizations can achieve the majority of the benefits of microservices architecture without incurring the large overheads and costs associated with standard Microservices Architecture by following the recommended techniques and concepts.
Smaller firms can design or move to systems based on microservices architecture that are scalable, resilient, and readily maintainable while lowering costs and time-to-market by adhering to these principles. This also positions the organization to readily evolve in the future to enable highly scalable, performant, dependable, and independently deployable Microservices to suit changing business needs. Consider dividing, for example, a monolithic application to alleviate stress on the entire app by transferring logic to an independent, specialized service.