Skip to content

Instantly share code, notes, and snippets.

@niquola
Created December 2, 2021 17:52
Show Gist options
  • Save niquola/96d4bd548a43c80ac61f5e15af39caaa to your computer and use it in GitHub Desktop.
Save niquola/96d4bd548a43c80ac61f5e15af39caaa to your computer and use it in GitHub Desktop.

SRE & DevOps

Books:

What we want to achieve with SRE?

SRE

automatic recovery

  • Alerting - something wrong - paging or tickets

  • Monitoring - what's wrong?

  • Logging - what's wrong?

  • Postmortem Culture: Learning from Failure

https://sre.google/sre-book/postmortem-culture/

Error budget

100% is bad objective

SLO - metric - цели - все меншье 1сек SLA - metric + range SLI -

  • 99.9 SLA - 1000h - 8h
  • 99.95
  • 0.1

The Four Golden Signals

  • Latency - duration
  • Traffic - RPS
  • Errors - 500
  • Saturation - потребление ресурсов

SLO -> Resource Planing (Capacity planing)

RED & USE

  • Requests

  • Errors

  • Durations

  • Usage

  • Saturation

  • Errors

Latency

The time it takes to service a request. It’s important to distinguish between the latency of successful requests and the latency of failed requests. For example, an HTTP 500 error triggered due to loss of connection to a database or other critical backend might be served very quickly; however, as an HTTP 500 error indicates a failed request, factoring 500s into your overall latency might result in misleading calculations. On the other hand, a slow error is even worse than a fast error! Therefore, it’s important to track error latency, as opposed to just filtering out errors.

Traffic

A measure of how much demand is being placed on your system, measured in a high-level system-specific metric. For a web service, this measurement is usually HTTP requests per second, perhaps broken out by the nature of the requests (e.g., static versus dynamic content). For an audio streaming system, this measurement might focus on network I/O rate or concurrent sessions. For a key-value storage system, this measurement might be transactions and retrievals per second.

Errors

The rate of requests that fail, either explicitly (e.g., HTTP 500s), implicitly (for example, an HTTP 200 success response, but coupled with the wrong content), or by policy (for example, "If you committed to one-second response times, any request over one second is an error"). Where protocol response codes are insufficient to express all failure conditions, secondary (internal) protocols may be necessary to track partial failure modes. Monitoring these cases can be drastically different: catching HTTP 500s at your load balancer can do a decent job of catching all completely failed requests, while only end-to-end system tests can detect that you’re serving the wrong content.

Saturation

How "full" your service is. A measure of your system fraction, emphasizing the resources that are most constrained (e.g., in a memory-constrained system, show memory; in an I/O-constrained system, show I/O). Note that many systems degrade in performance before they achieve 100% utilization, so having a utilization target is essential. In complex systems, saturation can be supplemented with higher-level load measurement: can your service properly handle double the traffic, handle only 10% more traffic, or handle even less traffic than it currently receives? For very simple services that have no parameters that alter the complexity of the request (e.g., "Give me a nonce" or "I need a globally unique monotonic integer") that rarely change configuration, a static value from a load test might be adequate. As discussed in the previous paragraph, however, most services need to use indirect signals like CPU utilization or network bandwidth that have a known upper bound. Latency increases are often a leading indicator of saturation. Measuring your 99th percentile response time over some small window (e.g., one minute) can give a very early signal of saturation. Finally, saturation is also concerned with predictions of impending saturation, such as "It looks like your database will fill its hard drive in 4 hours."

Prometheus

What is metric?

  • timestamp
  • name
  • value
  • attributes

How it works

Types of metrics

Counter

A counter is a cumulative metric that represents a single monotonically increasing counter whose value can only increase or be reset to zero on restart. For example, you can use a counter to represent the number of requests served, tasks completed, or errors.

Gauge

A gauge is a metric that represents a single numerical value that can arbitrarily go up and down.

Histogram

A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets. It also provides a sum of all observed values.

Average vs Percentile

https://www.dynatrace.com/news/blog/why-averages-suck-and-percentiles-are-great/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment