The document discusses various techniques for optimizing costs when using AWS cloud services. It recommends using spot instances, reserved instances, and managed services to reduce costs compared to on-demand instances. It also suggests right-sizing instances to match workload needs, using containers to improve density, and adopting serverless architectures to optimize for pay-per-use and continuous scaling. Additional tips include using tools like Trusted Advisor, tagging resources, and automating schedules to optimize development environments.
5. Cost Benefits of the Cloud
Let’s establish why financially cloud is the right way to go
1. Move from a forecast-procurement model to a consumption model
2. Flexibility - Continuously reevaluate design choices
3. Benefit from the AWS economies of scale – price reductions over time
4. Use managed services for bigger reduction of total cost of ownership
5. Transparently attribute expenditure
6. Pareto Principle
Know where to target when cost optimizing
The Pareto principle (also known as the
80/20 rule, the law of the vital few, or the
principle of factor sparsity) states that, for
many events, roughly 80% of the effects
come from 20% of the causes.
80%
Spend
10. EC2 Tips
Four easy ways to help reduce EC2 spend
Spot Instances
Bid on Spot instances to significantly reduce the cost of running your applications and
lower your operating costs by up to 90% compared to On-Demand.
EC2 Scheduler
AWS offers the EC2 Scheduler, a simple solution that allows you to create custom start
and stop schedules for your Amazon EC2
EC2 Auto-scaling
Easily and automatically scale up and down clusters to meet demand based on metrics or
schedule.
Reserved Instances
With Reserved Instances, you commit to a certain term of usage to receive a significant
discount.
11. EC2 Tips
Four easy ways to help reduce EC2 spend
Spot Instances
Bid on Spot instances to significantly reduce the cost of running your applications and
lower your operating costs by up to 90% compared to On-Demand.
EC2 Scheduler
AWS offers the EC2 Scheduler, a simple solution that allows you to create custom start
and stop schedules for your Amazon EC2
EC2 Auto-scaling
Easily and automatically scale up and down clusters to meet demand based on metrics or
schedule.
Reserved Instances
With Reserved Instances, you commit to a certain term of usage to receive a significant
discount.
For advanced users:
Lambda + CloudWatch = Automated
Scheduling*
(Don’t forget to tag! – Check )
* https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-cloudwatch/
12. Cost Awareness & Education
Increase visibility of spend to your teams
Treat your cost as a counterweight to performance and find the right balance.
Leverage tagging, budgets, and alerts you can notify teams of how much their
service is costing.
A simple measure of resource waste is idle resources. Identify unused CPU,
Memory, Storage. Empower your teams to pay attention to these metrics.
CostBot: Hey @rotem yesterday your services cost $28.33 which is 8%
more than the week prior.
14. Advanced Users - Build Your Own Dashboard
Track performance and savings over time
Metric Tracking
Savings
Spend & Metrics
by Account
EC2 Usage by
Purchase Option
16. Right-sizing
Different applications require different resources
Memory
CPU
NetworkInstances come pre-optimized for
these types of workloads:
M = Balanced
C = Compute
R/X = Memory
I/D = Storage
T = Bursting (Balanced)
P/G = GPU
Simply adding more instances without
understanding your workload can be costly.
17. Right-sizing
Different applications require different resources
Horizontally scaling an entire application
because you only need more CPU means
you’re potentially wasting unused resources
with memory, storage, and networking.
Understanding your workloads enables you to
optimize instance type and scale horizontally
only after you leveraged all of the currently
used resources.
Identify resource intensive components of your
application and isolate them to optimize your
utilization.
Memory
CPU
Network
18. EC2 Rightsizing
Am I using the most cost-effective instances?
AWS offers the Cost Optimization: EC2
Right Sizing solution, which uses
managed services to perform a right-
sizing analysis and offer detailed
recommendations for more cost-effective
instances.
21. Open Source Load Testing Tools
Over 50+ available
Siege, nGrinder, k-hawk, D-ITG, postal, mstone, iperf, loadUI, GrinderStone,
Ostinato, ContiPerf, Multi-Mechanize, Allmon, Raw Load Tester, MessAdmin,
benerator, Pylot, Hammerora, Lobo, p-unit, Faban, WebLOAD, Valgrind, httperf,
Seagull, Jchav, Tsung, Sipp, JCrawler, NTime, http_load, Web Polygraph,
Apache JMeter, and more..
http://www.opensourcetesting.org/category/performance/
You can automate this into your CI/CD pipeline to trend performance
23. Reserved Instances for Always-On Instances
Commitment level
1 year
3 year
AWS services offering RIs
Amazon EC2
Amazon RDS
Amazon DynamoDB
Amazon Redshift
Amazon ElastiCache
* Dependent on specific AWS service, size/type, and region
24. Convertible RIs
Consider where flexibility is required
With a Convertible Reserved Instance, you can modify
your existing reservation across:
Instance families
Instance sizes
Operating Systems
Tenancy
25. Standard and Convertible Reserved Instances
Payment Attributes
Characteristic Standard Convertible
Terms (avg. discount off On-Demand) 1yr (40%),
3yr (60%)
3yr (45%)
Change Availability Zone, instance size (for Linux OS),
networking type
Yes Yes
Change instance families, operating system, tenancy, and
payment option
No Yes
27. Object Storage Classes on Amazon S3
Selecting the right storage class can increase savings
Active data Archive dataInfrequently accessed data
Standard
Hot
Standard - Infrequent Access
Warm
Amazon Glacier
Cold
28. Standard-Infrequent Access (SIA)
Comparing S3-IA to S3 Standard
What’s the Same?
Access:
Almost identical to S3 standard with
same buckets and URLs
Durability:
11 “9’s” of durability
Performance:
Same characteristics as S3
Standard, low latency, high
throughput.
What’s Different?
Availability:
Designed for 99.9% availability, vs.
99.99% availability of S3.
Cost:
Lower Capacity fees, plus retrieval
fees. Minimum object size and
retention.
29. Running the Numbers: S3 or S3-IA
Comparing 1 PB of object storage*
S3 S3-IA Savings %
Rule of thumb: Breakeven ≈ 100% Retrieved per Month
Content Accessed
per Month
1PB Monthly $24,117 $14,116 41%10%
$24,117 $18,350 24%50%1PB Monthly
$24,117 $23,593 2%100%1PB Monthly
* Based on US-East Prices
36. Density
Understanding how Containers help
Ec2 Container Service
Container
Container
Container
Container
Container
Bins,
Libs
App
Bins,
Libs
App
Bins,
Libs
App
Bins,
Libs
App
Bins,
Libs
App
EC2EC2EC2
Reduced five instances
To three instances (-40%)
83% 78% 91%
37. EC2 Container Service
Highly scalable, high performance container management service
Easily Manage Clusters for Any Scale
Secure
Flexible Container Placement
Designed for Use with Other AWS Services
Extensible
Performance at Scale
43. EC2 Scheduler
Easily Stop & Start your instances in AWS
Plan for exceptions and account for different schedules and usage scenarios.
A one-size-fits-all approach is seldom realistic, even within the same team.
Choose flexible and customizable tools that can accommodate your needs.
Implement a resource-identification system, such as tags for Amazon EC2
instances.
This helps to ensure that automated actions are targeted to the correct
resource, and also allows for easier filtering, modification, and troubleshooting
according to categories that you define. You can then implement policies like
“Stop all @7 pm unless tagged otherwise”
Grant least-privilege access to individuals or systems that perform automated
actions on resources.
44. Autoscaling
Types of Scaling
Scaling by Schedule
- Date, time, min and max of Auto Scaling Group Size
- You can create up to 125 actions, scheduled up to 31 days into the future, for
each of your auto scaling groups. This gives you the ability to scale up to four
times a day for a month.
Scaling by Policy
- Scaling up policy – Double the group size
- Scaling down policy – Decrement by 1
- When coupled with ELB connection draining is handled for you
aws autoscaling put-scheduled-update-group-action --scheduled-action-name
scaleup-schedule-year --auto-scaling-group-name my-asg --recurrence "30 0 1
1,6,12 0" --desired-capacity 3
45. Dev Workloads
Use ChatOps To Power On Instances
[Rotem 2:18PM] @mrbot instances status
[MrBot 2:18 PM] rotem-dev-outerspace-b1 powered off for 2h18m
[MrBot 2:18 PM] rotem-dev-brickred-d1 powered off for 1h32m
[Rotem 2:18PM] @mrbot start dev
[MrBot 2:18 PM] Powering on rotem-dev-outerspace-b1
[MrBot 2:19 PM] Powering on rotem-dev-brickred-d1
1. Trivial to enable developers to see status of their dev instances and control start/stopping
2. Use a CloudWatch alarm to stop idle instances and send alert to tagged owner
3. Great if the developer goes on vacation or an extended holiday
46. Dev Workloads
T2s can handle most of your dev work
T2 Instances are incredibly cost efficient for standard development environments including RDS
47. Deploy Pipelines
Set thresholds to drive improvements into your processes
Source Code CI Server
Test &
Scan
Artifacts Deploy Monitoring
“Our deploys should not take longer than 2 minutes.”
Cost optimization is more than just resource optimization. It’s optimizing
your processes so your team can produce faster. Faster development = less
cost.
8s 1m 18s 21s 6s 24s 0s
48. Build Servers
The always on beasts of the CI/CD pipeline
Source Code CI Server
Test &
Scan
Artifacts Deploy Monitoring
12 Features Deployed
8 Core Machine
Maxed Out
- Your build server can be a blocker when a large number of simultaneous jobs are kicked off
- As a result, many people over-provision their build server to handle these situations
- Powering this off at night is helpful, but we can solve this in a more efficient way.
49. Source Code CI Server
Test &
Scan
Artifacts Deploy Monitoring
Build Servers
Jenkins Spot Instances Plugin
12 Features Deployed
Jenkins SpotFleet plugin
This plugin uses Spot Fleet to launch instances instead of directly
launching them by itself. Amazon EC2 attempts to maintain your Spot
fleet's target capacity as Spot prices change to maintain the fleet within the
specified price range.
Spot Spot Spot Spot
Spot Spot Spot Spot
Spot Spot Spot Spot
50. Using Spot
A marketplace for AWS’s excess compute capacity
• Be Fault Tolerant
• Workloads should be Stateless
• Loosely Coupled workloads preferred
• If possible, deploy to Multiple AZs
• Instance Flexibility is king
• Take advantage of the 2 minutes warning
• There is always Spot capacity available
¢
Save up to 90% compared to On-Demand¢
51. Build Servers
AWS CodeBuild
Fully Managed Build Service
Eliminates need to set up, patch, update,
and manage your own build servers.
Extensible
Use your own build tools and programming
Runtimes by creative custom build environments.
Continuous Scaling
Automatically scales to meet your volume. Can
Run separate builds concurrently.
Pay as You Go
Charged by the minute. No longer
billed for idle compute.
Enables CI/CD
Part of the Code* family. Integrates
Into existing CI/CD workflows including
Jenkins.
Secure
Artifacts are encrypted with keys
managed by KMS. Integrates with
IAM for granular permissions.
54. Serverless
Benefits of Serverless Architecture
Continuous ScalingNo Servers to Manage
AWS Lambda automatically
scales your application by
running code in response to each
trigger. Your code runs in parallel
and processes each trigger
individually, scaling precisely with
the size of the workload.
Subsecond Metering
With AWS Lambda, you are
charged for every 100ms your
code executes and the number of
times your code is triggered. You
don't pay anything when your
code isn't running.
AWS Lambda automatically runs
your code without requiring you to
provision or manage servers. Just
write the code and upload it to
Lambda.
55. Serverless
Simple serverless architecture example
Amazon
API
Gateway
AWS
Lambda
Amazon
DynamoDB
API call from
client app
Request/Response CRUD Operations
No servers to manage, update, or scale.
56. Summary
Reviewing Key Takeaways
The cloud helps you focus on your product and not having to manage day
to day infrastructure.
Pay for what you need - Understand your workloads and tune your
resources to match
Leverage containers and serverless architecture to reduce spend, and
simplify day to day operations.
57. Additional Resources
Optimize your costs when using AWS
https://aws.amazon.com/pricing/cost-optimization
AWS TCO Calculator
https://aws.amazon.com/tco-calculator
EC2 Rightsizing
https://aws.amazon.com/answers/account-management/cost-optimization-ec2-right-sizing
AWS Serverless
https://aws.amazon.com/serverless
AWS EC2 Container Service
https://aws.amazon.com/ecs