Microservices provide a way of breaking large applications into smaller, independent modules responsible for different tasks and using their own components like database or storage. Each module is a lightweight service performing a single function.
As all services within a single application are independent, they need some means of communication. They do it using APIs.
We can compare a microservice to a black box that takes some data as input via API and either returns a value as output or performs an action; for instance, it can modify data.
Another feature of microservices is that they’re stateless, which means that they don’t store any session values. If you need to store anything, external resources have to be used. The stateless approach allows applications using microservices to easily scale horizontally.
Application development with microservices
Microservices can be independently developed, tested, built and deployed. Their autonomous architecture helps improve fault isolation; a single microservice failure doesn’t usually impact the entire application. It also enables you to easily upgrade, update or replace an individual service. What’s more, with microservices, new technology stacks can be quickly implemented as each service can use a different stack.
Service independence makes it easy for your team to work in Scrum, an iterative and incremental software development framework, and to implement continuous integration, delivery, and deployment.
It would be a tortuous task to manage dozens of microservices without a mature DevOps model in place. Automation tools are absolutely imperative, and this is where cloud services can come in handy.
There are lots of services and resources available in the cloud, which makes the whole continuous delivery cycle much more manageable, starting from development, through testing and building up applications to their deployment. Cloud services facilitate creation and management of containers for microservices. They can even allow you to deploy microservices entirely serverless.
Microservices in the cloud
It may seem that cloud services have been created especially for microservices. Deploying microservices applications in the cloud is easy with a variety of available tools to support the process. And numerous services are native in the cloud, just to mention load balancing, auto-scaling, queue and notification management, code deployment tools or event-driven computing.
Looks like microservices have a lot to offer, right? Cloud providers will surely mention all the above advantages when trying to encourage you to build your application in the cloud and use their services. They will picture microservices in the cloud as something so intuitive and natural that you shouldn’t even think a second before redesigning your legacy, monolithic application to benefit from the possibilities offered by the cloud.
They might be right. Sure, using microservices applications in the cloud has a lot of pros, but… Sometimes cloud providers are not telling you everything.
10 Cons and challenges of microservices
Besides all advantages of microservices in the cloud, there are also some disadvantages you should be aware of. Those are not the reasons for you to resign from the cloud. Nevertheless, keep them in mind when deploying microservices-based applications.
It may be difficult to build applications based on microservices.
Although it’s usually easier to manage and scale microservices-based applications, they may be more challenging to build. Plan carefully how to join the services together. All services are independent but the whole application relies on them together, so remember about deployment.
Deploying microservices can get complicated.
You need to coordinate multiple services and handle requests between modules. Remember that your microservices may require a specific order of deployment. You can implement it by leveraging detailed startup scripts that provision, load, connect and start necessary components.
Some integration effort may be involved.
Deploying multiple services is more challenging than deploying a single one, which necessitates more integration work. Integrating services with one another and with other cloud resources takes time, especially when you’re starting your adventure with the cloud.
More independent systems may require more validation work.
As each microservice may use its own database and transaction management systems, you need to ensure that these resources are working before you start any dependent services.
Running microservices in the cloud can increase the user response time.
Services have to communicate with one another. Very often for communication you’ll use the Internet or a distant direct connect link. It may introduce some latency, which is highly unwelcome in real-time applications.
Using the cloud makes you dependent on network reliability and performance.
If you lose network connectivity to the cloud or between services, this may affect your application. When more components want to exchange information, you can face network congestion. Plan your deployment in such a way to provide redundancy where necessary, and calculate the required bandwidth to make sure it is enough for inter- and intra-service communication.
API Communication is great, but…
it requires some extra work from you. Make sure that entities at both ends accept the message formats for input and output. Double check your services APIs to ensure that they are able to exchange information with each other.
For complex applications, it may be difficult to trace logging and data traveling across services.
You have to use all the possibilities like CloudWatch and CloudTrail with S3 logging to observe the communication between your microservices.
Careful with third-party cloud-native services.
One of the aforementioned benefits of using the cloud for microservices is the possibility to use cloud-native supplemental services. It’s convenient, but you need to remember that you are dependent on a service you have no influence on. It can lead to reliability or version issues.
Last, but not least, beware of the vendor lock-in.
This may be the most critical disadvantage of deploying microservices in the cloud. When you build large applications based on function-as-a-service and other vendor-specific resources, it may be virtually impossible to take your application out of a given vendor and move to another one. Basically, such migration can possibly enforce building your application from scratch.
Are you for or against microservices?
Microservices in the cloud allow you to develop complex applications quickly and easily. They are ideal for cloud-based deployments. Moreover, cloud providers supply different tools and resources to ease the process and encourage you to choose their services.
The microservices architecture is a fundamental technology evolution, so you shouldn’t be afraid of using them. However, keep in mind that cloud providers may not always be telling you everything unless you ask.
You need to carefully consider the pros and cons of using microservices in the cloud and advantages and disadvantages of any given cloud provider before you decide to use their services. It may be a long-term relationship you’re getting into. Weigh your options.