# Step 4 - Wrap up

We discussed different algorithms of rate limiting and their pros/cons. Algorithms discussed include:&#x20;

* Token bucket&#x20;
* Leaking bucket&#x20;
* Fixed window&#x20;
* Sliding window log&#x20;
* Sliding window counter&#x20;

Then, we discussed the system architecture, rate limiter in a distributed environment, performance optimization and monitoring. Similar to any system design interview questions, there are additional talking points you can mention if time allows:&#x20;

* Hard vs soft rate limiting.&#x20;
  * Hard: The number of requests cannot exceed the threshold.&#x20;
  * Soft: Requests can exceed the threshold for a short period.
* Rate limiting at different levels. In this chapter, we only talked about rate limiting at the application level (HTTP: layer 7). It is possible to apply rate limiting at other layers. For example, you can apply rate limiting by IP addresses using iptables \[15] (IP: layer 3). Note: The Open Systems Interconnection model (OSI model) has 7 layers \[16]: Layer 1: Physical layer, Layer 2: Data link layer, Layer 3: Network layer, Layer 4: Transport layer, Layer 5: Session layer, Layer 6: Presentation layer, Layer 7: Application layer.&#x20;
* Avoid being rate-limited. Design your client with best practices:&#x20;
  * Use client cache to avoid making frequent API calls.&#x20;
  * Understand the limit and do not send too many requests in a short time frame.&#x20;
  * Include code to catch exceptions or errors so your client can gracefully recover from exceptions.&#x20;
  * Add sufficient back-off time to retry logic.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://huy312100.gitbook.io/software-development/system-design/fundamental/design-a-rate-limiter/step-4-wrap-up.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
