Month: September 2020
Monolith and Microservices: a comparative review
As stated before, just because microservices is the latest trend, doesn’t mean that you have to change your system architecture accordingly. Other than the organisational and technical challenges ahead, it may not necessarily even result in a better system performance for your application.
Although there are not that many researches around this area, a comparison done by Al-Debagy & Martinek (2018) shows interesting trends. The research that focuses on the performance of microservices and monolithic applications and uses JHipster to generate web applications consisting of Angular framework and Spring Boot and had three services: A register of all the components called JHipster registry, a backend service that provides API to the frontend and a microservices API gateway. The JMeter software was then used to test the performance and measure response time and throughput. Also, load testing and concurrency was done to see how the application behaved under heavy load.
The conclusion was that both architectural style can behave similarly under normal load. The only scenario when microservices shine is under heavy-load and concurrency. What needs to be highlighted more is that the monolithic application can respond faster (due to lower over-head as there’s no remote call) so it provides higher throughput on average.
Rererences
Al-Debagy, O., & Martinek, P. (2018, 21-22 Nov. 2018). A Comparative Review of Microservices and Monolithic Architectures. 2018 IEEE 18th International Symposium on Computational Intelligence and Informatics (CINTI)
Monolith migration: rewrite or refactor?
When talking about big changes in a software, there are two approaches: gradual refactoring or big bang rewrites. Which one is suitable when migrating to microservices? As with any sensible answer: it depends.
If your application already has a poor performance or design issues (such as being very tightly coupled to a database), or if the application is written on a very old platform and language, it may not even be possible to do gradual rewrites. Imaging a system that is written with Fortran language and you’d have to find developer that are fluent in Fortran to be able to understand and refactor the code-base.
On the other hand, if you are on a somewhat modern technology stack and have a decent architecture, it’d be quite possible to gradually migrate to a microservices design.
Kazanavičius & Mažeika (2019) state that the main challenge when gradually migrating to microservices is “the extraction of microservices from existing legacy monolithic code bases”.
References
Kazanavičius, J., & Mažeika, D. (2019, 25-25 April 2019). Migrating Legacy Software to Microservices Architecture. 2019 Open Conference of Electrical, Electronic and Information Sciences (eStream)
Week 10 – Progress Report
Monolith migartion to microservices: tools
You have finally decided that it is time to move to a microservices design and reap all the benefits. Let’s go through the the code and start refactoring…but wait. Before you do that, let’s see what are the tools that you need in place beforehand.
The requirements can be summarized as, infrastructural, environments, monitoring and logging. Let’s review each quickly.
Infrastructural needs
As stated before, running a microservices-base application is not exactly like running a monolith. So you will be working quite differently when developing a microservices application. First thing that can probably be put in place, is a Continuous Integration/Delivery pipeline if your organization does not have one. As this pipeline will be critical to your organization when releasing updates, make sure you have a group responsible for maintaining it.
Environments
Even when running monoliths, a lot of organizations choose to run their applications on virtual machines. That is a good start, if you are running on bare-metal. To take a further step, you can use docker as a virtualization technology and with these pave the way to running your application in the cloud. Once you decompose your monolith, you can decide which parts should be running on the virtual machines, which services should run in a docker container and which services can be run directly in the cloud.
Monitoring and Logging
With microservices you’d have to monitor tens to hundreds of services, machines, virtual machines, docker containers, database, etc and this is not an easy task. The monitoring tool that you choose should not only monitor services being up and running, but that they are actually doing work. Logging is also different as each piece of the system will be running on various services (not to mentioned scaling where you have more than one service running for the same task). A better approach to logging is to use structured logging backed by a structure log server that allows searching. Your logs should also use correlation and context so that you can trace a workflow end-to-end, regardless of where it is run.
Week 9 – Progress Report
Migration of Monolith to Microservices
As a result of microservices becoming so popular, the monolithic architecture got a bad rap, but there are lots of software systems that are perfectly fine to run as a monolith.Think about it: you only have one application to release, deploy, maintain and monitor. Due to the components of the system being tightly coupled, you can test things a lot easier and problems are easier to find. The question is, which architectural style is suitable for what purpose?
According to Kazanavičius & Mažeika (2019) monolithic architecture is fine when you have an application that is simple and lightweight (so it doesn’t require scaling), and microservices are suitable when the application is complex and evolving. (p. 2)
After some years of developing the said monolith, things would become too hard to manage, partly due to the tight-coupling and side-effects of it (e.g. when you fix a bug, ten more appear). But when would you migrate such monoliths to a more microservices based design?
Kazanavičius & Mažeika also summarize that you should migrate to microservices when:
- The monolith is too complex to maintain
- You benefit from decentralization and modularization of the monolith
- You see importance in the long run (as there’ll be a lot of growing-pain for the short time)
References
Kazanavičius, J., & Mažeika, D. (2019, 25-25 April 2019). Migrating Legacy Software to Microservices Architecture. 2019 Open Conference of Electrical, Electronic and Information Sciences (eStream)
Week 8 – Progress Report
Backwards compatibility in Microservices
As stated in the previous posts, a side effect of designing a system using microservices is that you end up having tens and hundreds of services that you need to keep operational. When you deploy a new version of a service that contains a bug fix in particular service, or when you want to improve another by adding a feature to it, the ‘system’ as a whole would still require to be functional. But how do you ensure that?
The problem is that if there is a fault at one of the services, other services communicating with it may fail and this would end up having a domino-effect bringing down the whole system. Furthermore, what if due to that bug-fix or enhancement, you need to update the service interfaces of that microservice. This would be a breaking change so any other service relying on it won’t be able to communicate with it anymore and would have to update.
Is it possible to spend time and resources to run the new release (of the whole system) in pre-production environment? To simulate things running in production, now you’d have to have two sets of production environment, which would have running and maintenance costs.
Kargar & Hanifizade (2018) advise that “the microservices must have backward compatibility, so that each version of microservices must also support the previous version inputs” and this can be enforced with the use of regression and integration testing.
References
Kargar, M. J., & Hanifizade, A. (2018, 25-26 April 2018). Automation of regression test in microservice architecture. 2018 4th International Conference on Web Research (ICWR)