Amazon Web Services – Infrastructure as Code
Page 18
Monitoring and Performance
Having reviewed the role of Infrastructure as Code in the provisioning of
infrastructure resources and configuration management, we now look at
infrastructure health. Consider how the following events could affect the
operation of a website during periods of peak demand:
• Users of a web application are experiencing timeouts because of latency
of the load balancer, making it difficult to browse the product catalogs.
• An application server experiences performance degradation due to
insufficient CPU capacity and can no longer process new orders.
• A database that tracks session state doesn’t have enough throughput.
This causes delays as users transition through the various stages of an
application.
These situations describe operational problems arising from infrastructure
resources that don’t meet their performance expectations. It’s important to
capture key metrics to assess the health of the environment and take corrective
action when problems arise. Metrics provide visibility. With metrics, your
organization can respond automatically to events. Without metrics, your
organization is blind to what is happening in its infrastructure, thereby
requiring human intervention to address all issues. With scalable and loosely
coupled systems written in multiple languages and frameworks, it can be
difficult to capture the relevant metrics and logs and respond accordingly. To
address this need, AWS offers the Amazon CloudWatch services.
55
Amazon CloudWatch
Amazon CloudWatch is a set of services that ingests, interprets, and responds to
runtime metrics, logs, and events. CloudWatch automatically collects metrics
from many AWS services, such as Amazon EC2, Elastic Load Balancing (ELB),
and Amazon DynamoDB.
56
,
57
,
58
Responses can include built-in actions such as
sending notifications or custom actions handled by AWS Lambda, a serverless
event-driven compute platform.
59
The code for Lambda functions becomes part
of the infrastructure code base, thereby extending Infrastructure as Code to the
operational level. CloudWatch consists of three services: the main CloudWatch
service, Amazon CloudWatch Logs, and Amazon CloudWatch Events. We now
consider each of these in more detail.