AWS Services for Microservice Architectures: A Beginner's Overview (Part 1 - Computing)
Tags: aws, microservices, beginners, cloudcomputing
Published: 2024-06-07 22:29:05

<p>
  In today's rapidly evolving tech landscape, microservices have become a
  cornerstone for building scalable and maintainable software solutions.
  Leveraging the right tools and services is crucial for effectively
  implementing a microservice architecture, and AWS offers a comprehensive suite
  of services tailored to meet these needs. In this part, we will be delving
  into the AWS services you can use for actually running your application with a
  microservice architecture.
</p><br />

<h2>What are Microservices?</h2>
<p>
  Microservices are a fundamental component of many modern software solutions.
  They facilitate an approach in which software is composed of small,
  independent services that communicate over lightweight APIs. Unlike monolithic
  architectures, where all processes are tightly coupled and run together, each
  microservice performs a single function and is ideally owned by a small,
  self-contained team.
</p>
<p>Adopting a microservice architecture offers several benefits, such as:</p>
<ul>
  <li>
    Easier scaling of applications: Individual services can be scaled
    independently based on demand.
  </li>
  <li>
    Improved technology choice, code quality, and readability due to separation
    of concerns: Teams can choose the best technologies for each service.
  </li>
  <li>
    Isolated deployments and rollbacks: Changes to one service do not affect the
    entire application, reducing risk and improving deployment flexibility.
  </li>
</ul><br />

<h2>Running microservices with AWS</h2>
AWS provides four major managed services that can be used to supply the
computing power needed to run microservices:

<h4>Amazon Elastic Container Service (ECS)</h4>
<img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgb22fmgchjp1cajbgi2k.png" alt="Image description" loading="lazy"/>
<p>
  ECS is a container management service that runs code within Docker containers.
  You can run your applications on a managed cluster of Amazon Elastic Compute
  Cloud (EC2) instances or opt for AWS Fargate if you prefer a serverless
  approach.
</p>
<blockquote>
  <p>
    <b>Amazon EC2</b> provides computing capacity in the form of virtual servers
    that can run one or more containers. EC2 requires you to configure server
    instances according to your application's needs. There are various instance
    types to choose from, each with its own technical specifications and price
    points. For instance, a t3.nano instance with 0.5 GiB of memory currently
    costs $0.0052 per hour, while a t3.large instance with 8 GiB of memory is
    currently priced at $0.0835 per hour.
  </p>
  <p>
    <b>AWS Fargate</b> is a serverless option, meaning you don't need to manage
    any virtual servers to run your containers. Many scaling and configuration
    related processes are handled automatically, but you still need to configure
    certain aspects of your application deployment. For example, you may need to
    set up auto-scaling policies based on specific metrics to ensure your
    application can handle varying levels of traffic. Similarly, you might need
    to configure load balancing to distribute incoming traffic across multiple
    container instances for high availability and performance.
  </p>
  <p>
    Generally speaking, Fargate is less complicated to set up and maintain
    compared to EC2, but it is also slightly more expensive per hour for the
    same computing power. EC2 instances are ideal for scenarios where the team
    requires granular control over container instances, networking, and storage.
    Given a stable workload, it is possible to optimize costs using EC2
    instances. Conversely, EC2 instances are often only partly utilized,
    rendering some of the resources you pay for superfluous. Fargate, on the
    other hand, only uses the application's actual computing needs, ensuring you
    only pay for what you use.
  </p>
</blockquote>

<p>
  ECS is an excellent choice for a managed container service and is used in many
  projects worldwide. It is suitable for long-running processes (such as web
  pages that need to be available around the clock) and is ideal for teams with
  Docker expertise.
</p>

<h4>Amazon Elastic Kubernetes Service (EKS)</h4>
<img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftv08sml2vy0k33pbe8qv.png" alt="Image description" loading="lazy"/>
<p>
  EKS is a Kubernetes service for building, securing, operating, and maintaining
  Kubernetes clusters. It integrates seamlessly with core AWS services,
  providing monitoring, scaling, and load balancing capabilities for
  containerized applications. Like ECS, the computing power for EKS can be
  provided through EC2 instances or AWS Fargate.
</p>
<p>
  EKS is best for teams already invested in Kubernetes and wanting to leverage
  Kubernetes tooling and community support. It is also ideal for applications
  that need advanced orchestration features.
</p>

<h4>AWS Lambda</h4>
<img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxi52cqu5r71sb3spkaj4.png" alt="Image description" loading="lazy"/>
<p>
  Lambda is a fully managed, serverless solution similar to AWS Fargate. You
  just upload your code, and Lambda manages everything required to run and scale
  it.
</p>
<p>
  An important aspect of Lambda is its event-driven nature. This means your code
  is executed in response to specific events, such as API calls, file uploads,
  or scheduled time intervals.
</p>
<p>
  Lambda is a great choice if you want to go for an event-driven architecture
  and microservices that require minimal infrastructure management. It is also
  well-suited for applications that need to scale quickly due to large spikes of
  traffic at unexpected times. Lambda provides 1 million free requests and
  400,000 GB-seconds of free compute time per month, making it a cost-effective
  option for smaller projects or lightweight jobs like resizing images for
  thumbnails.
</p>

<h4>AWS App Runner</h4>
<img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8fo559jp1lmrl86g6fva.png" alt="Image description" loading="lazy"/>
<p>
  App Runner is a fully managed service that simplifies the deployment of
  containerized web applications and APIs, requiring no prior experience. Its
  primary aim is to eliminate the complexities of infrastructure management,
  enabling developers to focus solely on building and deploying their
  applications. Powered by AWS Fargate, App Runner requires even less
  configuration compared to direct usage of Fargate. It offers hands-off
  scaling, includes a built-in load balancer and provides HTTPS Support, amongst
  other features.
</p>
<p>
  Due to the additional features, using App Runner tends to be more expensive than the
  previously mentioned services. Its ability to automate scaling entirely,
  however, makes it a perfect fit for applications that do not receive traffic
  at all times. An example of this is a development environment that is only
  used during business hours. This way, one benefits from the streamlined
  deployment process while benefiting from automatic savings during the times
  the application is inactive.
</p><br />

<h2>Conclusion</h2>
<p>
  As we've explored the AWS services tailored for running applications with a
  microservice architecture, it's evident that each service brings its unique
  advantages to the table. Whether it's the granular control of EC2 instances,
  the simplicity of Fargate, the orchestration capabilities of EKS, the
  event-driven nature of Lambda, or the streamlined deployment process of App
  Runner, AWS caters to diverse needs and preferences. I hope this post has
  proven useful in helping you get an overview of these technologies. If you are
  interested in learning more, I have included some links below.
</p>
<p>
  Stay tuned for part 2 where I'll be addressing the topics of database and
  storage in AWS!
</p><br />

<h2>Further Reading</h2>
<ul>
  <li>
    <a
      href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html"
      >Amazon ECS Documentation</a
    >
  </li>
  <li>
    <a href="https://docs.aws.amazon.com/eks/latest/userguide/what-is-eks.html"
      >Amazon EKS Documentation</a
    >
  </li>
  <li>
    <a href="https://docs.aws.amazon.com/lambda/latest/dg/welcome.html"
      >AWS Lambda Documentation</a
    >
  </li>
  <li>
    <a
      href="https://docs.aws.amazon.com/apprunner/latest/dg/what-is-apprunner.html"
      >AWS App Runner Documentation</a
    >
  </li>
</ul>