Microservices is used a lot when talking about building applications, especially when most new applications are developed and hosted using cloud technologies. But why is this style of application architecture gaining such popularity, what does it mean for your applications and how can you start designing applications to take advantage of this architecture? In this post, we will take a high-level view of microservices, what makes them different from traditional monolithic applications and why leveraging this architecture can show big benefits for your next application.
Before we dive into why and how to use microservices, let’s talk about what microservices are. There are a number of different versions, but essentially microservice applications are built using small, componentized services that are composed together to form complete functions and processes. Each service is generally its own self-contained function, run in its own context with its own resources. Microservices are also loosely coupled and communicate with each other using mechanisms such as RESTful APIs. This allows developers to implement each service as its own, self-contained component independent of other aspects of the application.
Because of the different approach to application development, microservice-based applications have a number of key characteristics that set them apart from traditional, monolithic applications. These main characteristics include:
It is a significant change to your development practices when adopting a service-orientated approach but the resulting microservices application offers a lot of practical benefits. These include:
Due to the fundamental shift in the way applications are designed and delivered, adopting a microservices approach can be quite daunting. There are also no black and white rules on how to compose and deploy your functions but there is some general advice you can follow when creating a microservices application.
As mentioned early, creating services should be organized into singular business functions. In reality, this can be a lot harder than it seems. A good rule of thumb is if it is a step in a business process it should probably be a single service. For instance, if you take the example of adding a product to your cart in a web store application then adding a product, changing products and retrieving products from your cart would all be individual services.
When developing individual services, a lot of thought needs to be given to the design and intent of the service being delivered.
1. Am I increasing the scope of the service or doing multiple functions?
If you start building your microservice to do more than one task, consider splitting the service into two or more.
2. Is my service generic enough to be used outside of the current request?
Rather than building microservices for the current task, think about potential different uses for the service to increase its potential reuse.
3. Is my interface complete enough to warrant no changes?
When you change a service’s interface you potentially break other services that rely on it so try to build your interface to handle as many use cases as possible.
These questions can be hard to answer but they will get you thinking about the scope and design of individual services.
Microservice applications rely heavily on connectivity between APIs rather than within the bounds of their system. This can mean the pipelines between services can become a bottleneck if not maintained. From the perspective of your whole application, care should be given to ensure that your messaging pipelines are performant and scalable to ensure traffic flows between services. From an individual services perspective, care should be given to how much data is both sent and received by the service to perform its function. Additionally, try and ensure all messages are asynchronous and non-blocking where appropriate so that services aren’t waiting or halted. This can be even more important once you start integrating 3rd party services and APIs.
How services are deployed and tested once written can also factor into how you design your microservices application. If you are building services to run on more traditional virtual machines, does your deployment pipeline build the infrastructure as well using templates? If your application runs in containers or leverages serverless functions will your deployment pipeline configure and scale those elements as required? It is also important to define who manages the pipeline, how changes are tested and approved so deployments can be enacted quickly.
Microservice architectures have a number of benefits over traditional, monolithic applications. It requires a very different approach and while microservices don’t necessarily fit for every application or component, this pattern can make large, complex applications more flexible and maintainable. Microservices also inherently allows you to leverage the capabilities of cloud providers and 3rd party APIs seamlessly, such as the payment services API Rapyd provides, which just doesn’t make sense to write yourself. Your application can benefit from this approach and add real value. For more information about Rapyd Collect’s global API, built on microservices architecture, check out the overview.
This website uses cookies.
Read More