Solutions Engineer
Oct 26, 2022 | 5 mins read
Cloud computing, particularly cloud-native computing, is a rapidly growing paradigm that has evolved from a monolithic to a microservices architecture. Cloud computing and the shift from monolithic to microservices have transformed how applications are developed, deployed, and operated. Consequently, cloud data centers have expanded dramatically, with cloud-native applications now regarded as the backbone of the modern economy.
This trend is primarily due to the relentless pace of digital innovation. The 2022 API & Microservices Report describes the origins of Moore’s Law and how it continues to predict the pace of digital innovation.
Succinctly stated, Moore’s Law is a famous observation and prediction made by Gordon Moore, the co-founder of Intel, in 1965. It refers to the trend in the semiconductor industry that describes the exponential increase in the number of transistors that can be placed on a microchip over time.
Gordon Moore’s original statement predicted that the number of transistors on a microchip would double approximately every two years. He noted that this trend was driven by advancements in semiconductor manufacturing technology and improvements in design practices.
The principle and practice of Moore’s Law can also be used to predict the pace of digital innovation. However, as this report notes:
“Innovation involves much more than chipset density and cost. Business leaders see innovation all around them, from Agile business models to novel ways of organizing supply chains to virtualized software architectures.”
Therefore, based on Moore’s Law, it is reasonable to assume that the continually evolving digital innovation trends will significantly impact the global economy now and to come. Ergo, there should be significant shifts in global digital trends every two years.
According to this report, in 2020, 57% of senior technology leaders across multiple industries were concerned that their organizations were at risk of competitive displacement if they failed to innovate in line with Moore’s Law. This figure rose to 62% in 2021, and as many as 75% of technology leaders surveyed in 2022 were concerned that failure to keep track of the current pace of digital innovation is staring significant financial losses in the face.
As stated at the top of this article, leveraging the microservices architecture, specifically containerized microservices, to build cloud-native applications is a top trend in 2023.
The microservices architecture packages each microservice with all dependencies, libraries, and runtime modules in containers like Docker containers. These containers are then deployed to the cloud and are expected to execute each microservice when called upon. However, it is all good and well to containerize the components of a cloud-native application, but what do you do with these containers?
The book titled: Cloud-Native Computing: How to Design, Develop, and Secure Microservices and Event-Driven Applications notes that these containers must be managed using a container orchestration platform like Kubernetes (K8s). The book’s authors have the following to say about Kubernetes:
“The aspect of cluster computing, operations, management, networking, governance, resource efficiency, workload consolidation, and deployment is greatly simplified through Kubernetes.”
Note: As stated in the book Kubernetes Patterns, authored by Bilgin Ibryam and Roland Huss, Kubernetes is now the de facto container orchestration tool used to manage containers in production environments worldwide.
Let’s look at the following scenario for a practical use case using Kubernetes to orchestrate containerized microservices.
Imagine you are part of a team developing a Large Learning Model (LLM) psychiatrist chatbot designed to diagnose mental health issues and disorders for a MedTech mental health start-up. This chatbot integrates natural language processing (NLP) and machine learning, interacting with the patient based on a provided evaluation framework.
The research paper, LLM-Empowered Chatbots for Psychiatrist and Patient Simulation: Application and Evaluation, notes the following:
“Since the diagnosis standards of different mental disorders vary greatly, psychiatrists recommend concentrating on depressive disorders for this study” or use case.
Therefore, based on this statement, the scope of this use case is to describe the development of a psychiatrist chatbot that is trained to diagnose depressive disorders only.
This chatbot app is divided up into the following microservices:
Each microservice is packaged in a Docker container with APIs exposing its core functionality to the other microservices and allowing the different components of the chatbot app to communicate with each other. This ensures consistent deployment across diverse environments.
As described above, these Docker containers cannot be left to their own devices. They must be orchestrated (or coordinated) by Kubernetes, a container orchestration platform. One of the best ways to use K8s to coordinate any number of containers is to adopt an existing design pattern developed by a K8s expert and made available to other software developers.
What is a design pattern?
Let’s return to the book cited above by Bilgin Ibryam and Roland Huss for the answer to this question:
“In short, a pattern describes a repeatable solution to a problem.”
However, a pattern is more than a repeatable solution. It also forms a language where each pattern has a unique name, evoking “similar mental representations” when discussing these patterns. For instance, when we talk about a computer keyboard, everyone who speaks English assumes we are talking about a peripheral input device used to input text, numbers, and other commands into a computer.
As you can imagine, many different Kubernetes design patterns exist, including the Single-Container Pattern, Sidecar Pattern, Ambassador Pattern, Adapter Pattern, and Microservices Pattern.
Let’s adopt the Microservices Pattern to orchestrate our chatbot’s containerized microservices by implementing the following 12-step guide:
Note:Steps 1 and 2, identifying and containerizing these microservices, have already been described earlier in this text. Therefore, here are next steps.
Create K8s deployment objects for each containerized microservice. Deployments manage the desired state of these containers and allow for easy scaling.
Expose each microservice using Kubernetes Services. This enables communication and load balancing between microservices. For instance, a user authentication microservice can be exposed as a service so that other microservices can authenticate users.
Enable communication between microservices. Microservices often need to interact with each other. You can use environment variables or Kubernetes ConfigMaps to pass configuration values and API endpoints between microservices.
For microservices with variable loads, set up Horizontal Pod Autoscaling. Kubernetes will automatically adjust the number of pods based on resource utilization, ensuring optimal performance.
Integrate monitoring and logging solutions compatible with K8s. This helps you keep track of the health, performance, and behavior of each microservice.
Set up an ingress controller to manage external access to your microservices. This handles routing and SSL termination, making it easier for users to interact with the chatbot.
Choose a deployment strategy, like rolling updates, to ensure seamless updates of microservices without downtime. Kubernetes provides mechanisms for updating containers gradually, minimizing user impact.
Use Kubernetes ConfigMaps and Secrets to manage configuration settings and sensitive information separately from your application code.
Leverage Kubernetes’ built-in scaling and load balancing capabilities to ensure each microservice can handle varying user loads.
Integrate your K8s deployment into your CI/CD (continuous integration/continuous deployment) pipeline for automated testing, continuous integration, and continuous deployment of microservices.
By adopting the Microservices Pattern and using Kubernetes to orchestrate your chatbot’s containerized microservices, you’ll create a modular, scalable, and maintainable architecture. This approach enables you to independently develop, test, deploy, maintain, and manage different parts of the chatbot, allowing for rapid development, easier updates, and improved reliability.