Courses / Site Reliability Engineering
1. Service Level Objectives (SLOs)
SLOs define the target level of reliability for a service.
How It Works
Think of SLOs like a performance target for a sports team; just as a team aims to win a certain percentage of games, an SLO sets a goal for how often a service should perform successfully.
Define the key metrics that indicate service reliability.
Set a target percentage for those metrics.
Monitor the service performance against the defined SLO.
Adjust resources and processes to meet or exceed the SLO.
See It
The code defines an SLO of 99.9% uptime and then calculates the current uptime in hours from the system's uptime. A small change could involve logging this uptime to a file for historical tracking.
echo "SLO: 99.9% uptime"
echo "Monitoring uptime..."
uptime=$(echo "scale=2; $(awk '{print $1}' /proc/uptime)/3600" | bc)
echo "Current uptime: $uptime hours"Use It
SLOs are used in web services to ensure users experience minimal downtime.
echo "Setting SLO for web service"
echo "SLO: 99.9% uptime"
echo "Monitoring service status..."
service_status="up" # Simulate service status
if [ "$service_status" = "up" ]; then
echo "Service is operating within SLO."
else
echo "Service is down, action required!"
fiSLOs matter because they provide a clear standard for service reliability that teams can strive to achieve.
Break It
What will this print?
echo "SLO: 99.9% uptime"
service_status="down" # Simulate service status
if [ "$service_status" = "up" ]; then
echo "Service is operating within SLO."
else
echo "Service is operating within SLO."
fiThe code incorrectly states that the service is operating within SLO even when the service status is "down" because both branches of the if statement print the same message.
Change the else statement to print "Service is down, action required!" for clarity.
echo "SLO: 99.9% uptime"
service_status="down" # Simulate service status
if [ "$service_status" = "up" ]; then
echo "Service is operating within SLO."
else
echo "Service is down, action required!"
fiLevel Up
Error Budgets: Error budgets are a way to balance reliability with feature development by allowing a certain amount of downtime within SLOs.
SLO-based Alerts: Setting alerts based on SLO breaches helps teams respond quickly to reliability issues.
Prove It
Create an SLO for a service that requires 99% uptime and implement a simple check to verify if the service is within that SLO.
General SRE practices
Service Level Objectives (SLOs)
SLOs are measurable targets that define how reliable a service should be.
"I want to ensure my service is reliable enough for users to trust it."
SLOs specify the desired level of service reliability, often expressed as a percentage of successful requests over a defined period.
"I want to ensure my service is reliable enough for users to trust it."
SLOs specify the desired level of service reliability, often expressed as a percentage of successful requests over a defined period.