

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: DoS
incomplete
2: Rate Limiting
incomplete
3: Protecting Auth from Abuse
incomplete
4: Throttling Requests
incomplete
5: Queuing Work
incomplete
6: Resource Limits
incomplete
7: Timeouts
incomplete
8: Usage Quotas
incomplete
9: DDoS
incomplete
10: Mitigating DDoS
incomplete
11: Bot Detection
incomplete
12: CAPTCHA
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Rate limiting controls how often a client can call your API. Resource limits control how much work a single request can demand. For example:
I used to do a lot of work with the Facebook and Instagram APIs, and their limits were based on request processing time. One complex query can be 100x more expensive than ten simple ones!
HTTP servers should enforce a maximum request body size. Go's http.MaxBytesReader stops a handler from reading beyond an explicit limit:
request.Body = http.MaxBytesReader(responseWriter, request.Body, 32*1024)
File uploads need their own limits. A multipart request includes file bytes and encoding overhead, so limit both the request body and the bytes read from each uploaded file. Also reject extra files instead of quietly processing the first one.
Go's io.LimitReader is useful for enforcing the per-file boundary after parsing the multipart form.
Keep in mind that a tiny compressed file can still expand into gigabytes, and a small input to an evil regex can burn through your server's CPU. Limit the resource that can actually be exhausted.
Bearly Secure has the limit settings and max-aware APIs, but several request paths don't enforce them yet.
Complete the app's per-request resource limits.
With Bearly Secure still running, run and submit the CLI tests from the project root.