Evolution of Microservices
With the acceptance of XML and HTTP as standard protocols for cross-platform communication, service-oriented architecture (SOA) attempted to define a set of standards for interoperability.
Based on XML and Simple Object Access Protocol (SOAP), the initial standards for web services interoperability were handed over to a committee called Oasis.
Suppliers like IBM, Tibco, Microsoft and Oracle started to ship enterprise application integration products based on SOA principles.
While these were gaining traction among the enterprises, young Web 2.0 companies started to adopt representational state transfer (REST) as their preferred protocol for distributed computing.
Key Attributes of Microservices
Microservices are fine-grained units of execution. They are designed to do one thing very well. Each microservice has exactly one well-known entry point. While this may sound like an attribute of a component, the difference is in the way they are packaged.
Microservices are not just code modules or libraries – they contain everything from the operating system, platform, framework, runtime and dependencies, packaged as one unit of execution.
Each microservice is an independent, autonomous process with no dependency on other microservices. It doesn’t even know or acknowledge the existence of other microservices.
Microservices communicate with each other through language and platform-agnostic application programming interfaces (APIs). These APIs are typically exposed as REST endpoints, WebHooks, or can be invoked via lightweight messaging protocols such as RabbitMQ. They are loosely coupled with each other to avoid synchronous and blocking-calls whenever possible.
Why Should Developers Embrace Microservices?
With microservices, developers and operators can develop and deploy self-healing applications. Since each microservice is autonomous and independent, it is easy to monitor and replace a faulty service without impacting any other.
By moving to microservices, organisations can invest in reusable building blocks that are composable. Unlike monolithic applications, microservice-based applications can be selectively scaled out.
Instead of launching multiple instances of the application server, it is possible to scale-out a specific microservice on-demand. When the load shifts to other parts of the application, an earlier microservice will be scaled-in while scaling-out a different service. This delivers better value from the underlying infrastructure as the need to provision new virtual machines shifts to provisioning new microservice instances on existing virtual machines.
Developers and administrators will be able to opt for best-of-breed technologies that work best with a specific microservice. They will be able to mix and match a variety of operating systems, languages, frameworks, runtimes, databases and monitoring tools.
Finally, by moving to microservices, organisations can invest in reusable building blocks that are composable. Each microservice acts like a Lego block that can be plugged into an application stack. By investing in a set of core microservices, organisations can assemble them to build applications catering to a variety of use cases.
What’s in it for Businesses?
While microservices make developers focus on one component or a module of the software, it also benefits the businesses by delivering agility. Organizations embracing microservices will build highly reusable software that can be utilized across a variety of projects. The modularity of microservices enables them in engaging the best teams to build the components.
Faster “go to market” strategy, high reusability, and modularity are some of the advantages of adopting microservices.
Building Microservices with DreamFactory
DreamFactory is an open source REST API middleware platform that provides RESTful services for building mobile, web, and IoT applications.
It enables developers to connect to any data source and instantly get a full palette of secure, reliable, and customizable REST APIs for their projects. It is a runtime environment that can be easily integrated with web-scale applications. Developers can declare database endpoints that are invoked at runtime.
DreamFactory is based on a modular architecture with clean separation of stateful and stateless layers. The core building blocks of DreamFactory are based on popular open source languages, frameworks, and databases. Each of these layers can be packaged into independent deployment units based on virtual machines or containers. The core runtime built on PHP can be easily scaled out to handle additional load. Redis and MongoDB layers are stateful that can be configured for redundancy and higher availability.
Features such as server-side scripting and API-driven administration makes DreamFactory ideal for microservices. Developers can dynamically update the endpoints without changing the code. Server-side scripting makes it possible to define business logic specific to data sources. Basic validation and error handling can be embedded within DreamFactory without hardwiring it in the application logic.
The DreamFactory stack can be composed of a set of containers that can be deployed on container management platforms such as Swarm, Kubernetes, and Apache Mesos. These container definitions can be integrated with contemporary microservices based on Docker.
DreamFactory is available as a single Dockercontainer image that can be pulled from Docker Hub. Microservices developers can take advantage of the modular architecture of DreamFactory
by deploying and scaling individual containers. The blog post on scaling DreamFactory with Docker explains how to achieve scalability in production environments. The Docker Compose file available on Github can be used as a reference architecture to get started. It can be easily modified for creating the YAML artifacts supported by Kubernetes.
While system and application requirements continue to evolve, the methodology behind how we solve these problems is often based on older models and patterns. As mentioned before, microservices architecture has its roots in models like COM, CORBA, EJB and SOA, but there are still some rules to live by when creating microservices utilizing current technologies.
Developers can leverage microservices to achieve modularity and scale required by contemporary applications. API-first platforms such as DreamFactory enable developers to separate stateless and stateful service through a declarative mechanism.