Microservices for the Enterprise: Designing, Developing and Deploying

Santosh Karla | < 1 min read

Globally, the percentage of enterprises utilizing microservices amounts to 63%. Most of these are in the process of building a few or every application using microservices. Microservices has emerged as a popular architectural pattern owing to its efficient solutions. These include domain-driven design, offering continuous delivery, scalable platform, infrastructure automation, and usage of different programming languages. The reason behind this emergence is that microservices reflect the way business leaders want to structure teams and development processes for application development.

Getting started with microservices architecture

When it comes to designing microservices architecture, there are no definitive set of standard principles. However, there are some design themes and techniques used by various organizations to get started with the initial stages of building an efficient microservices architecture.

1. Decomposing

Firstly, identifying the business capabilities of applications will help teams to build services accordingly. Once the capabilities are identified, the teams can decide which service they want to work on and start building according to their business requirements. Each team can become an expert in the domain they are working on and figure out techniques and strategies that best suit the application.

2. Building

After identifying the business capabilities, the teams can narrow down on the required tools, techniques, platforms, and approaches for building the services. Approaches like Java with MySQL and Scala/Spark can be used as per the team’s expertise and the application’s requirements.

3. Designing

While designing the microservices architecture, it is imperative to analyze the parts of the services that need to be exposed and the protocols that should be used to communicate with the given services. Unnecessary and heavy detailing will lead to confusion and loss of flexibility in the services.

4. Decentralizing

The architecture can be decentralized by teams working on specific services. An internal source model will allow developers to make the necessary changes in the code and move ahead without having to worry about the service owner to rectify the error. Having a detailed service model will simplify the process for the developers, resulting in better performance and development.

5. Deploying

A detailed consumer-driven contract will assist each consumer API to capture the requirements of the application. These contracts are shared with the service providers to help them fulfill the requirements for each client. It is important to pass consumer-driven contracts before deploying the services to help providers understand the interdependency of the services.

Some tools and frameworks for implementing microservices

1. REST

REST (Representational State Transfer) is one efficient tool that allows microservices to communicate directly via HTTP and is used for building RESTful APIs. The requests and responses are handled using standard formats such as XML, HTML, and JSON.

2. Consul

A service discovery technology, Consul offers support for HTTP REST APIs and DNS. This framework allows developers to auto-generate configuration in files using a Consul template. It also performs health checks and excludes certain microservices from service discovery when health checks fail.

3. Oracle Helidon

Helidon is a microservices framework developed and launched by Oracle. It is a repository of Java libraries that can be used by developers for building microservices architecture. Helidon comes in two variants, Helidon MP and Helidon SE. The former is a good choice for Java developers as it is an implementation of MicroProfile specifications. The latter acts as a toolkit that supports Java SE features and fluent APIs.

4. Spring Boot

Another Java framework, Spring Boot offers collaborating components and enables large-scale systems to be built using simple architectures. Spring Boot is easy to integrate with other frameworks due to the inversion of control.

New call-to-action

Let’s take a look at some deployment options:

For the deployment of microservices, developers can choose from four commonly used patterns, such as :

1. Multiservice Instances per Host

While using the multiple Service Instances per Host pattern, the developers can position one or more physical or virtual hosts to run multiple service instances on each. Here, each service functions on a well-known port on one or multiple ports.

There are two variants of this pattern. One variant involves each service instance to be a process or a process group. Developers can choose to deploy a Java service instance as a web application on an Apache Tomcat server. The other variant involves running multiple service instances in the same process or process group, like deploying multiple Java web applications on the same Apache Tomcat server or running multiple OSGi bundles in the same container.

The pattern offers significant advantages like the resource usage is comparatively efficient. The efficiency stems from the process or process group running multiple service instances like multiple web applications sharing the same Apache Tomcat server and JVM.

2. Service Instance per Host Pattern

This pattern allows developers to run each service in isolation on its personal host. There are two specializations in this approach:

– Service Instance per Virtual Machine
– Service Instance per Container

a) Service Instance per Virtual Machine Pattern

This approach involves packaging each service as a virtual machine (VM) image such as an Amazon EC2 AMI. A good example is Netflix as they have used this approach to deploy their video streaming service by packaging each service as an EC2 AMI using Aminator, deploying each service as an EC2 instance.

A wide range of tools is available to build VMs such as Aminator, Jenkins, and Packer.io. Aminator packages the services as an EC2 AMI, whereas Packer.io automates the VM image creation and supports virtualization technologies like DigitalOcean, VirtualBox, VMware, and EC2.

While using the Service Instance per Virtual Machine pattern, teams can enjoy the benefits of mature cloud infrastructure and don’t have to worry about exhausting resources and CPU memory as the services run in isolation, making the deployment simpler and more reliable.

b) Server Instance per Container Pattern

As the name suggests, this pattern involves deploying service instances that run on their own containers. The containers have a dedicated root filesystem and port namespace, which enables teams to limit a container’s memory and CPU resources. Some examples of container technologies are Solaris Zones and Docker. Teams might also use Kubernetes and Marathon to manage the container placement aligned with the resources required and resources available on each host.

The benefits of containers are slightly similar to VMs as both approaches involve the isolation of services and allow monitoring of resources consumed by each container. Containers are lightweight and are pretty easier to build as there are no heavy OS boot mechanisms.

3. Serverless Deployment

AWS Lambda is a good example of a serverless deployment pattern. The technology supports Node.js, Java, and Python services. Teams have to simply package the microservices in a ZIP file and upload it on AWS Lambda and it automatically runs instances and handles requests.

There are four ways to implement the AWS Lambda function:

– Invoking the function directly by using a web service request.
– Implementing automatically in response to events generated by AWS services including DynamoDB, Kinesis, S3, or Simple Email Service.
– Using AWS API Gateway to manage HTTP requests from clients of the application.
– Periodically, following a cron-like schedule.

AWS Lambda is one of the most convenient ways to deploy microservices. It gives out the benefit of request-based pricing that allows organizations to pay for the world that the services actually perform, enabling teams to focus more on developing the application than worrying about the IT infrastructure.

Conclusion

Success is a moving target, and when it comes to scaling technology, there’s no silver bullet. Microservices are a relatively new approach, but when executed in the right manner, they show incomparable results. Microservices help breaks bigger applications into smaller pieces that are easier to manage. Additionally, the approach also allows an organization’s culture to be more open and adaptable to changes and improvements.

Global players including Coca-Cola, Netflix, Amazon, and Etsy have resolved their most complicated problems related to scaling and expansion using the microservices architecture. This shift has allowed these organizations and others to gain flexibility, durability, and enhanced engagement within teams.

With microservices, younger organizations can harness the power of legacy software and modern technologies and simplify the learning curve for teams and the next generation of developers, guiding them towards a road to digital transformation.