· 4 min read

Optimizing System Reliability and Cost Efficiency - Our SRE Journey

Optimizing System Reliability and Cost Efficiency: Our SRE Journey

Introduction

Managing system reliability is crucial for any large-scale enterprise, but it often comes with significant costs. Previously, our company outsourced a team for manual system monitoring and issue handling, costing us $30,000 per month. However, this approach proved to be both expensive and inefficient. To address this, we implemented our own Site Reliability Engineering (SRE) solution, integrating automated monitoring and recovery mechanisms to enhance system resilience while dramatically reducing costs.

Implementation Steps

1. Automated Sentry Project Generation

To ensure each deployment target (application) has its own Sentry DSN, we wrote a script that automatically generates Sentry projects based on deployment targets. This allows for seamless integration of error tracking across all our applications.

2. Integration of Sentry in Applications

We introduced a new shared library to integrate the Sentry monitoring library across our ecosystem, which includes:

  • 75 microservices
  • 50 legacy batch jobs
  • 2 websites

Each application’s Sentry DSN is linked to the CI/CD pipeline, ensuring that every deployment automatically binds Sentry to the respective application.

3. Configuring Alert Rules and Incident Handling

In Sentry, we set up alert rules to notify teams based on specific exceptions:

  • PagerDuty integration: Used for off-hours notifications to ensure round-the-clock coverage.
  • Microsoft Teams integration: Used during office hours for immediate responses by the designated team members.
  • Escalation policies in PagerDuty: Ensures that unresolved alerts are escalated to higher levels if the assigned person fails to acknowledge them.

4. Automated Recovery with Rundeck

For proactive issue resolution, we implemented Rundeck to automate recovery processes:

  • Hourly database and application status checks: Identifies failures due to application crashes or concurrency issues.
  • Triggering recovery processes: Either via stored procedures or dedicated recovery applications to correct data anomalies.
  • Logging issues into an operations log: Enables engineers to review and improve the system during retrospectives.

5. Metrics-Based Failure Detection

Apart from handling exceptions, we set up metrics-based alerting to detect application failures:

  • Alerts are sent to the person in charge for further investigation and recovery.
  • Allows for manual intervention when necessary.

6. Visualization with Prometheus and Grafana

To enhance visibility into system performance, we deployed Prometheus and Grafana:

  • Monitors application status and performance metrics.
  • Detects service failures and triggers alerts for immediate action.

Previous Challenges with the Outsourced Team

Prior to implementing our SRE framework, the outsourced team relied on manual alert handling via email notifications, powered by AlertManager and the ELK stack (Elasticsearch, Logstash, and Kibana). However, this approach had significant drawbacks:

  • Dependency on ELK: If ELK went down, alerts were not received.
  • Delayed responses: The outsourced team sometimes failed to notice alerts in time.
  • Manual reporting: The alert reports were created manually, leading to potential missing data.

Achievements and Benefits

By implementing this SRE framework, we successfully:

  1. Reduced costs: Eliminated the $30,000/month outsourcing cost. The new setup, including PagerDuty fees and on-premise Sentry infrastructure, is significantly cheaper.
  2. Accelerated data recovery: Automated processes handle incorrect data faster, reducing operational risks.
  3. Eliminated 90% of unnecessary manual alert operations, streamlining workflows.
  4. Ensured complete logging of incidents, improving retrospective analysis.
  5. Gained full control over our monitoring infrastructure, allowing further customizations, such as integrating business intelligence tools.
  6. Integrated additional tools, like GitHub Enterprise and Jira, to automate bug reporting and ticket creation, improving efficiency.

Areas for Further Improvement

While our current SRE system is highly effective, there are still opportunities for optimization:

  1. Replacing PagerDuty with an open-source alternative: While this could reduce costs, it might increase maintenance overhead, requiring a careful cost-benefit analysis.
  2. Automating Sentry alert rule creation: Currently, alert rules are manually configured. A bulk scripting solution could further reduce time spent on setup.
  3. Improving Prometheus integration: Shifting from direct API calls to a shared library would simplify implementation and standardize monitoring across applications.

Conclusion

By transitioning from manual outsourced monitoring to an automated SRE-driven approach, we have significantly enhanced system reliability, reduced operational costs, and streamlined alert management. Our journey is far from over, and we continue to refine our processes to further improve efficiency, scalability, and resilience.

This initiative has not only demonstrated the power of automation in SRE but also highlighted the importance of continuously iterating on monitoring and recovery strategies to maintain a highly reliable system at a lower cost.

Back to Blog