

# Software and architecture patterns
<a name="a-sus-software-architecture-patterns"></a>

**Topics**
+ [SUS 3 How do you take advantage of software and architecture patterns to support your sustainability goals?](sus-03.md)

# SUS 3 How do you take advantage of software and architecture patterns to support your sustainability goals?
<a name="sus-03"></a>

Implement patterns for performing load smoothing and maintaining consistent high utilization of deployed resources to minimize the resources consumed. Components might become idle from lack of use because of changes in user behavior over time. Revise patterns and architecture to consolidate under-utilized components to increase overall utilization. Retire components that are no longer required. Understand the performance of your workload components, and optimize the components that consume the most resources. Be aware of the devices your customers use to access your services, and implement patterns to minimize the need for device upgrades. 

**Topics**
+ [SUS03-BP01 Optimize software and architecture for asynchronous and scheduled jobs](sus_sus_software_a2.md)
+ [SUS03-BP02 Remove or refactor workload components with low or no use](sus_sus_software_a3.md)
+ [SUS03-BP03 Optimize areas of code that consume the most time or resources](sus_sus_software_a4.md)
+ [SUS03-BP04 Optimize impact on customer devices and equipment](sus_sus_software_a5.md)
+ [SUS03-BP05 Use software patterns and architectures that best support data access and storage patterns](sus_sus_software_a6.md)

# SUS03-BP01 Optimize software and architecture for asynchronous and scheduled jobs
<a name="sus_sus_software_a2"></a>

 Use efficient software designs and architectures to minimize the average resources required per unit of work. Implement mechanisms that result in even utilization of components to reduce resources that are idle between tasks and minimize the impact of load spikes. 

 **Level of risk exposed if this best practice is not established:** Low 

## Implementation guidance
<a name="implementation-guidance"></a>
+  Queue requests that don’t require immediate processing. 
+  Increase serialization to flatten utilization across your pipeline. 
+  Modify the capacity of individual components to prevent idling resources waiting for input. 
+  Create buffers and establish rate limiting to smooth the consumption of external services. 
+  Use the most efficient available hardware for your software optimizations. 
+  Use queue-driven architectures, pipeline management, and On-Demand Instance workers to maximize utilization for batch processing. 
+  Schedule tasks to avoid load spikes and resource contention from simultaneous execution. 
+  Schedule jobs during times of day where carbon intensity for power is lowest. 

## Resources
<a name="resources"></a>

 **Related documents:** 
+  [What is Amazon Simple Queue Service?](https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/welcome.html) 
+  [What is Amazon MQ?](https://docs.aws.amazon.com/amazon-mq/latest/developer-guide/welcome.html) 
+  [Scaling based on Amazon SQS](https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-using-sqs-queue.html) 
+  [What is AWS Step Functions?](https://docs.aws.amazon.com/step-functions/latest/dg/welcome.html) 
+  [What is AWS Lambda?](https://docs.aws.amazon.com/lambda/latest/dg/welcome.html) 
+  [Using AWS Lambda with Amazon SQS](https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html) 
+  [What is Amazon EventBridge?](https://docs.aws.amazon.com/eventbridge/latest/userguide/what-is-amazon-eventbridge.html) 

 **Related videos:** 
+  [Building Sustainably on AWS](https://www.youtube.com/watch?v=ARAitMSIxc8) 
+  [Moving to event-driven architectures](https://www.youtube.com/watch?v=h46IquqjF3E) 

# SUS03-BP02 Remove or refactor workload components with low or no use
<a name="sus_sus_software_a3"></a>

 Monitor workload activity to identify changes in utilization of individual components over time. Remove components that are unused and no longer required, and refactor components with little utilization to limit wasted resources. 

 **Level of risk exposed if this best practice is not established:** Low 

## Implementation guidance
<a name="implementation-guidance"></a>
+  Analyze load (using indicators such as transaction flow and API calls) on functional components to identify unused and underutilized components. 
+  Retire components that are no longer needed. 
+  Refactor underutilized components. 
+  Consolidate underutilized components with other resources to improve utilization efficiency. 

## Resources
<a name="resources"></a>

 **Related documents:** 
+  [What is AWS X-Ray?](https://docs.aws.amazon.com/xray/latest/devguide/aws-xray.html) 
+  [What is Amazon CloudWatch?](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html) 
+  [Using ServiceLens to monitor the health of your applications](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/ServiceLens.html) 
+  [Automated Cleanup of Unused Images in Amazon ECR](https://aws.amazon.com/blogs/compute/automated-cleanup-of-unused-images-in-amazon-ecr/) 

 **Related videos:** 
+  [Building Sustainably on AWS](https://www.youtube.com/watch?v=ARAitMSIxc8) 

# SUS03-BP03 Optimize areas of code that consume the most time or resources
<a name="sus_sus_software_a4"></a>

 Monitor workload activity to identify application components that consume the most resources. Optimize the code that runs within these components to minimize resource usage while maximizing performance. 

 **Level of risk exposed if this best practice is not established:** Low 

## Implementation guidance
<a name="implementation-guidance"></a>
+  Monitor performance as a function of resource usage to identify components with high resource requirements per unit of work as targets for optimization. 
+  Use a code profiler to identify the areas of code that use the most time or resources as targets for optimization. 
+  Replace algorithms with more efficient versions that produce the same result. 
+  Use hardware acceleration to improve the efficiency of blocks of code with long execution times. 
+  Use the most efficient operating system and programming language for the workload. 
+  Remove unnecessary sorting and formatting. 
+  Use data transfer patterns that minimize the resources used based on how frequently the data changes and how it is consumed. For example, push state change information to a client instead of having it consume resources to poll and receive valueless ‘no change’ messages. 

## Resources
<a name="resources"></a>

 **Related documents:** 
+  [What is Amazon CloudWatch?](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/WhatIsCloudWatch.html) 
+  [What is Amazon CodeGuru Profiler?](https://docs.aws.amazon.com/codeguru/latest/profiler-ug/what-is-codeguru-profiler.html) 
+  [FPGA instances](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/fpga-getting-started.html) 
+  [The AWS SDKs on Tools to Build on AWS](https://aws.amazon.com/tools/) 

 **Related videos:** 
+  [Building Sustainably on AWS](https://www.youtube.com/watch?v=ARAitMSIxc8) 

# SUS03-BP04 Optimize impact on customer devices and equipment
<a name="sus_sus_software_a5"></a>

 Understand the devices and equipment your customers use to consume your services, their expected lifecycle, and the financial and sustainability impact of replacing those components. Implement software patterns and architectures to minimize the need for customers to replace devices and upgrade equipment. For example, implement new features using code that is backward compatible with older hardware and operating system versions, or manage the size of payloads so they don’t exceed the storage capacity of the target device. 

 **Level of risk exposed if this best practice is not established:** Low 

## Implementation guidance
<a name="implementation-guidance"></a>
+  Inventory the devices your customers use. 
+  Test using managed device farms with representative sets of hardware to understand the impact of your changes, and iterate development to maximize the devices supported. 
+  Account for network bandwidth and latency when building payloads, and implement capabilities that help your applications work well on low-bandwidth, high-latency links. 
+  Pre-process data payloads to reduce local processing requirements and limit data transfer requirements. 
+  Perform computationally intense activities server-side (such as image rendering), or use application streaming to improve the user experience on older devices. 
+  Segment and paginate output, especially for interactive sessions, to manage payloads and limit local storage requirements. 

## Resources
<a name="resources"></a>

 **Related documents:** 
+  [What is AWS Device Farm?](https://docs.aws.amazon.com/devicefarm/latest/developerguide/welcome.html) 
+  [Amazon AppStream 2.0 Documentation](https://docs.aws.amazon.com/appstream2/) 
+  [NICE DCV](https://docs.aws.amazon.com/dcv/) 
+  [Amazon Elastic Transcoder Documentation](https://docs.aws.amazon.com/elastic-transcoder/) 

 **Related videos:** 
+  [Building Sustainably on AWS](https://www.youtube.com/watch?v=ARAitMSIxc8) 

# SUS03-BP05 Use software patterns and architectures that best support data access and storage patterns
<a name="sus_sus_software_a6"></a>

 Understand how data is used within your workload, consumed by your users, transferred, and stored. Select technologies to minimize data processing and storage requirements. 

 **Level of risk exposed if this best practice is not established:** Low 

## Implementation guidance
<a name="implementation-guidance"></a>
+  Analyze your data access and storage patterns. 
+  Store data files in efficient file formats such as Parquet to prevent unnecessary processing (for example, when running analytics) and to reduce the total storage provisioned. 
+  Use technologies that work natively with compressed data. 
+  Use the database engine that best supports your dominant query pattern. 
+  Manage your database indexes to ensure index designs support efficient query execution. 
+  Select network protocols that reduce the amount of network capacity consumed. 

## Resources
<a name="resources"></a>

 **Related documents:** 
+  [Athena Compression Support file formats](https://docs.aws.amazon.com/athena/latest/ug/compression-formats.html) 
+  [COPY from columnar data formats with Amazon Redshift](https://docs.aws.amazon.com/redshift/latest/dg/copy-usage_notes-copy-from-columnar.html) 
+  [Converting Your Input Record Format in Firehose](https://docs.aws.amazon.com/firehose/latest/dev/record-format-conversion.html) 
+  [Format Options for ETL Inputs and Outputs in AWS Glue](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-format.html) 
+  [Improve query performance on Amazon Athena by Converting to Columnar Formats](https://docs.aws.amazon.com/athena/latest/ug/convert-to-columnar.html) 
+  [Loading compressed data files from Amazon S3 with Amazon Redshift](https://docs.aws.amazon.com/redshift/latest/dg/t_loading-gzip-compressed-data-files-from-S3.html) 
+  [Monitoring DB load with Performance Insights on Amazon Aurora](https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_PerfInsights.html) 
+  [Monitoring DB load with Performance Insights on Amazon RDS](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PerfInsights.html) 
+  [AWS IoT FleetWise](https://aws.amazon.com/about-aws/whats-new/2021/11/aws-iot-fleetwise-transferring-vehicle-data-cloud/) 

 **Related videos:** 
+  [Building Sustainably on AWS](https://www.youtube.com/watch?v=ARAitMSIxc8) 