Deploying Microservices on AWS

Deploying Microservices on AWS

The term Microservices has become a buzzword over the last couple of years. This google trend link clearly shows how people from around the world are interested in understanding what Microservices are: https://trends.google.com/trends/explore?q=microservices. So let me try and take a stab at what it means and what its characteristics are. Microservices is an architectural approach for software development which helps to speed up development cycles, foster innovation, and ownership and improve maintainability and scalability of software applications. To boil it down, the microservices approach helps to build a software that is composed of small independent services that communicate over well-defined APIs. The individual services are often run in containers, and when a service becomes too complex, it is broken down into multiple services in order to comply with the architectural pattern. Building a microservices architecture has the following characteristics:

  1. Decentralized: Microservices architectures are distributed systems, thus they can be developed, deployed, managed and operated separately.
  2. Independent: Different services in the architecture can be upgraded or replaced individually without affecting other components. This also helps reduce the span of the failure domain, as one service failing doesn’t impact everything else.
  3. Polyglot: Services can be built using heterogeneous components eg. Operating Systems, programming languages, and tools. No need to use the “one size fits all” approach.
  4. Black Box: The internal working of each service is irrelevant, different services should talk to each other through APIs only.
  5. Do one thing well: Each service is responsible for doing just one thing, hence can be optimized to make sure that it does that in the best way possible.

Now let’s talk about how we can build and run a microservices-based application on Amazon Web Services. AWS breaks down microservices architecture into the following four layers:

  1. Content Delivery: The purpose of this layer is to accelerate the delivery of content and potentially off-load the backend servers of the API layer. Amazon CloudFront can be a great asset for this layer, as it is a global content delivery network (CDN) service that users can use to cache data across the many Edge locations that AWS has around the world.
  2. API Layer: This is an important layer in the microservices architecture because different services need APIs to talk to each other. This layer acts as the central entry point for all client requests as it accepts and processes all the requests. All the AWS services have a set of rich APIs associated with them. An important service that AWS offers to use for this layer is the Amazon API Gateway. It helps address some of the challenges like Access Authorization, throttling requests, caching API responses, request and response transformation etc. API Gateway makes it easy for the developers to create, publish, maintain, monitor, and secure APIs at any scale.
  3. Application Layer: This layer is responsible for implementing the actual logic for your application. You can use services like AWS Elastic BeanStalk, Amazon ECS or AWS Lambda for this layer. Elastic BeanStalk enables you to upload your code, and then AWS will take care of deploying, maintaining and scaling the backend infrastructure. You can use Amazon ECS to spin up containers that run your code. And similarly, you can also use AWS Lambda for running your application code. “The best servers to manage are no servers at all”, this is the philosophy on which AWS Lambda was built. You can define the individual services as individual functions in AWS Lambda and have those functions talk to each other using the API Layer.
  4. Persistence Layer: One of the characteristics of the microservices architecture is to “do one thing well”. Each individual service needs to be able to store and retrieve data from a persistent storage layer. If there is data corruption, then it would create a huge impact on your application as all the services treat this layer as the single source of truth. For this layer, you can use services ranging from Amazon S3 for static content, to Amazon ElastiCache which alleviates the load between your application servers and your database, to database services like Amazon RDS and Amazon DynamoDB. Amazon RDS is a relational database service which is easy to setup and maintain. A NoSQL Database can also be used as it doesn’t have a fixed schema. Amazon DynamoDB is a NoSQL DB that provides consistent, single-digit millisecond latency at any scale and single click upgrades to your read and write throughput capacity.

As you can see AWS offers a wide variety of services that you can use to build out your microservices architecture based applications. The picture below shows us an example of how you can build your own microservices application using AWS services.

We have CloudFront at the Content Delivery Layer, API Gateway at the API Layer, Amazon ECS at the application layer and using Amazon DynamoDB for the persistent layer. Building out applications using AWS services is always an awesome experience, and if you are interested in learning more you can refer to the following links:

  1. https://d0.awsstatic.com/whitepapers/microservices-on-aws.pdf
  2. https://www.slideshare.net/AmazonWebServices/microservices-architectures-on-amazon-web-services
  3. aws.amazon.com/this-is-my-architecture
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s