Development
8 min readMicroservice architectures promise benefits such as faster delivery, independent scalability, and resilience but also present several challenges. Determining the granularity of microservices is often a hot topic among enterprise architecture teams.
While microservice purists might argue for truly “micro” contexts with 100s or even 1000s of services, most companies benefit from more coarse-grained service organizations. Key to this decision is determining the proper boundaries for your organization. What’s even more challenging is that there is not just one type of boundary to consider; there are 3:
At Broadleaf, these challenges and boundary concerns are magnified as our goal is to provide an extensible microservices framework for enterprise commerce that can support the needs and opinions of many organizations. Our architecture team faced a vital issue: the proper boundaries for one company might need to be more relevant or ideal for another. For example, in one solution, a few more minor services may make sense in the same deployment, while in another, they need to be separated. The wrong choice on any of the boundaries can significantly impact the overall costs and benefits of using microservices.
One of Broadleaf's core products includes a set of headless enterprise commerce microservices built using Java and the Spring Framework. Thinking about how to deal with these three boundaries was at the top of my mind.
Logical Service Boundary—The Broadleaf Platform was developed with years of experience in a reasonably well-traveled domain (e.g. eCommerce Architecture), resulting in logical service boundaries like Cart, Customer, Catalog, Pricing, Inventory, Order, etc.… making this delineation reasonably straightforward.
Code and Deployment Boundaries—We wanted to provide the most flexibility with these boundaries. Given the needs and opinions of many large organizations on best handling microservices, one of our primary objectives was to provide a solution that supports differentiated options and use cases.
These challenges led to a critical component of Broadleaf’s Microservices Accelerator Framework that we refer to as Flex Packages.
Broadleaf's Flex Package technology is a unique deployment configuration and packaging concept that allows multiple microservices to exist in a single JVM runtime under a Spring application context (effectively functioning as an individual Spring Boot application). This technology is designed to maximize the flexibility of deployment options for those microservices. For example, Broadleaf provides three compositions to help illustrate and understand the various possibilities. Note that Broadleaf Flex Packages are not the only options you can achieve, as they can be constructed in any combination (you can even add your services to the mix) to support your own eCommerce platform needs.
This option represents a highly coupled service deployment footprint consisting of the full Broadleaf microservices stack. This composition has the advantage of having a simple and lower hardware footprint. If you think this sounds like a “monolith,” it is! This option does not get all of the benefits of microservices, such as independent scalability or having each service operate in its maintenance cycle. However, this option is an excellent option for local development, allowing you to experience the whole ecosystem without having to incur the overhead of running a ton of containers (all running their own JVMs)
The Low Coupled Service Deployment. This option allows each service to be deployed independently in its container. This is the “typical picture” most people have when they think about microservices. This option allows for maximum scalability and flexibility of each service and its lifecycle. However, this option also requires more infrastructure, CI/CD boundary considerations, management overhead, and complexity.
The Balanced Service Deployment. This is our initial recommended deployment footprint for most enterprise use cases. The services are broken down into four primary flex packages that make the most sense from a commerce perspective and represent a good balance of service composition based on typical use cases: browse, cart, supporting, and processing. Broadleaf commerce microservices are broken down into different composable “flex packages” that facilitate a consumer storefront experience, a transactional heavy deployment, a deployment focused on longer-running background tasks, and a supporting service deployment that underpins the others in the ecosystem. This option leverages read and process replicas and allows for each flex package's independent scaling and lifecycle management. This option also uses a message interlink to ensure data consistency and avoid data staleness across flex packages.
Broadleaf's Flex Package technology is best for the advanced needs of enterprise composable commerce applications. With the following benefits:
One of the key benefits of using Microservices is the ability to scale and deploy services independently, allowing for greater flexibility and agility in development. This means that teams can work on different services simultaneously without being held back by dependencies on other components. With Flex Package technology, you have the ability to keep these isolated project teams so that developers can focus on delivering valuable business capabilities and move packaging and actual deployment concerns to solution architects and the operations teams.
With that said, it is still important to consider the increased complexity of managing a larger number of services. Monitoring, debugging, and testing can become more challenging as the number of services grows. It is crucial to have a solid DevOps strategy in place to effectively manage and maintain the overall eCommerce solution running on a Microservices architecture. Broadleaf’s Microservices Accelerator framework provides several levels of tooling, patterns, and recommendations to help tame this complexity, with Flex Packaging being one of the core components.
While there are challenges associated with adopting Microservices, the benefits of increased flexibility, scalability, and fault isolation make it a valuable architectural pattern for organizations looking to modernize their software development practices. By carefully considering the design of your Microservices, keeping the three boundaries in mind, and implementing best practices, you can harness the power of this architecture to drive innovation and efficiency within your organization.