Everyone is talking about microservices. This topic keeps coming up in meetings with our customers. What are microservices anyway? When should they be used? And when shouldn't they be used?
Wikipedia defines the term as follows:
Microservices is a variant of the service-oriented architecture (SOA) architectural style that structures an application as a collection of loosely coupled services. In microservices architecture, services should be fine-grained and the protocols should be lightweight.
Let's take a webshop as an example. Typical business processes consist of searching for items, managing a shopping cart, inventory or item management, checkout, and many others. Each of these processes would now be implemented as a separate piece of software. The webshop itself ultimately consists of a front end that connects the various services through an interface (generally a REST API via HTTP).
Fragmenting a large application into smaller elements has several benefits:
But this architecture has its own issues. If the individual services aren't separated from each other thoroughly enough, you end up building a fragmented monolith. This makes the system even more complex than it may have otherwise been.
The following questions should help you to decide whether or not you want to use microservices when designing a system.
Compared to conventional architectures, there are no additional technical requirements. There are, however, a few tools and technologies that can help when using microservices.
Automated tests are definitely mandatory. Unit tests ensure the internal operation of the service, while integration tests can automatically preserve the interaction between the various services.
In order to take full advantage of the simpler deployment and the independent scalability of smaller services, it makes sense to use a container technology such as Docker. Big platforms - such as RedHat OpenShift or Cloud Foundry - have built-in features for automatic deployments or auto scaling.
It is also worth investing in the area of infrastructure as code. More services also mean more infrastructure. Maintaining this manually leaves it vulnerable to errors and is also very expensive. Tools such as Puppet, Ansible, and Terraform can help automate many processes and provide infrastructure versioning.
Since a task may involve multiple different services in the application landscape, it is important to create a central and structured place for the logging data. A front end request should be identifiable through to the last service in its sequence, so that debugging and auditing can be carried out.
Microservices can help to break down large and complex systems into smaller and more easily manageable units. It is, however, of utmost importance to make sure that the fragments are logical, and that services are constructed independently from each other. The number of microservices produced should never be used to evaluate the effectiveness of a development team.
Get more exciting information about technical background and experience reports from our engineers. Sign up for the Engineering Logbook updates to make sure you don't miss anything.