Microservice Architecture - Modern Application Development on AWS

Microservice Architecture

As monolithic applications grow, it becomes difficult to modify or add functionality to them, and to track what parts of the codebase are involved in a specific change. As a result, small changes can require lengthy regression testing, and development of new features can slow. In an application built with a microservice architecture and loosely coupled components, many new features and bug fixes can be implemented at the level of a single service and released much more rapidly.

Organizations with monolithic legacy applications can become more agile and flexible by redesigning their applications into microservices. Each service is deployed separately, and all the services work together to offer the same functionality as the monolithic system. Microservices can be built, modified, and released quickly, which provides faster experimentation and innovation. Each team that builds microservices can also take clear ownership of their own design, development, deployment, and operations.

To achieve this loose coupling, the microservices in a system must communicate with each other. A datastore that is shared between services creates tight coupling, hidden dependencies, timing issues, and challenges with scaling and availability. It is better to use published APIs or asynchronous message queues to communicate between separate services. Separating processes into different pieces that are connected by messages in queues creates clear transaction boundaries and enables services to operate more independently.

Messaging systems can provide scalability, resilience, availability, consistency, and distributed transactions because of the following characteristics:

  • Trusted and resilient message delivery system

  • Non-blocking and one-way operation

  • Loosely coupled services

  • Bringing focus to different logical components in the system, and allowing each to work independently

Architectures that take advantage of these elements can easily expose robust APIs and asynchronous communication channels, which enables each service to be operated and automated independently, and which also improves reliability.

When many different microservices are connected to perform a process, you must have a method to monitor the state of a single end-to-end task. You must also make sure that all the necessary steps happen in the correct order and at the correct time. You can use state machines to both monitor the state of tasks and make sure they occur in the correct order.

You also need a method to manage the overall workflow between services, to configure various timeouts, cancellations, heartbeats for long-running tasks, and granular monitoring and auditing. Managing services with this type of tooling improves speed, productivity, and flexibility. To make sure that microservices execute in the correct sequence with appropriate timing, modern applications take advantage of orchestration and messaging tools. Using orchestration tools makes it easy to build robust services in a repeatable way. AWS Step Functions is a fully managed tool that can coordinate arbitrary workflows across services. When you use messaging tools, you remove direct dependencies between services, which improves reliability and scalability. You can use different tools—such as Amazon Simple Queue Service (Amazon SQS), Amazon CloudWatch Events, and Amazon Kinesis—depending on the specific workload. By using orchestration and messaging tools together, your developers do not have to spend time on workflow execution, state management, and inter-service communication, which gives them valuable time to focus on core business logic.