start	end	text
0	920	So let's get started.
920	1880	I'm Spencer Koch.
1880	3740	I'm a principal security engineer at Reddit.
3740	5220	And I'm joined by Prateek.
5360	8120	He's a senior security engineer at Reddit as well.
8120	9600	And we're on the security team.
10080	13720	And so thank you to the DDoS village for having us be up here.
13720	14620	And we sponsored them too.
14620	16140	So we're great to see that advance.
16280	18860	And I know we've got some moral support in the back as well.
18860	20060	So thanks for coming out.
20060	22360	And we're going to be talking about DDoS stuff.
23660	29940	So in terms of context, and I'll try to read the top of the slide as you attempt to follow me through my slides that are online.
30000	31700	So what are you going to get from this talk?
31700	35360	So hopefully we should be able to go through an architecture.
35360	36880	How do we think about rate limiting?
36880	42380	And so the way that we kind of construct that mental model at Reddit so that we can do defense against it.
42380	45320	We'll talk about signals and why they are so darn important.
45320	47180	We're going to talk about where do we do rate limiting?
47180	48500	When should we do that rate limiting?
48500	50340	And why do we want to do that rate limiting?
50540	57880	We'll talk about other resiliency strategies that don't necessarily fit in well to that particular do it at an edge or do it in an application.
57880	65600	And then we'll talk about some lessons learned as we've kind of fought DDoS literally forever, but at least the last six years, which is my tenure.
65600	70060	And there were only two of us when we started doing DDoS preventions a long time ago.
70060	76980	So a lot of interesting things as you start in a scrappy startup mode and don't pay a vendor to just make the problem go away.
78220	85980	So in terms of if you haven't heard of Reddit, and there's a banana for scale on the slide, which is the joke that would have been better delivered up here.
85980	88240	We do a lot of traffic.
88240	91320	So 1.3 trillion requests every week.
91320	94620	We do 175 petabytes every week.
94640	96280	That's a lot of stuff.
96280	99660	And so we do this in conjunction with some of our CDNs.
99680	102560	We are fastly and looking at Cloudflare right now.
102560	107680	We are also AWS based for the most part for our serving side of the platform.
107960	111100	And so that's a lot of stuff to flow through cloud providers.
111880	119200	In terms of services, just to give you another sense of scale, like our GraphQL endpoints, that's mostly all of our new APIs.
119640	122720	275,000 requests a second.
123380	126420	And you can see some of the other metrics that are there.
126420	128360	We do a lot of traffic.
128580	131700	And so doing things at scale becomes really important.
133380	144020	In terms of where we came from, from a DDoS perspective, in 2019, that's roughly when I joined myself and a gentleman named Jason Harvey.
144100	159220	We essentially were in charge of DDoS prevention, which was a lot of whack-a-mole, a lot of like, well, we think we could get away with this in the cheapest, easiest time frame and then wait until the next stupid DDoS attack came through and figure out how do we want to respond.
159400	161600	In 2021, we started getting more serious.
161600	164640	So this is right around the time of our API riots.
164640	168360	And we changed the way that we wanted to do how people interact with the platform.
168420	169900	Don't yell at me about that.
169900	171320	I just work here.
171540	177840	But that means we needed to figure out how do we monitor and manage the traffic that's coming to us and take actions against it.
177840	180820	So that's when we first started staffing our transport team.
180980	191400	And then finally, where we are now in 2025, we have a traffic and a transport team, both looking at the defense of the traffic coming into Reddit, as well as how do we distribute that from a global load balancing perspective.
191600	193820	And they're focused on DDoS mitigations.
194640	203680	So in terms of signals, the first major component of how do you think about DDoS prevention, you have a whole bunch of signals, or hopefully you do, if you're fighting against DDoS.
203860	206480	The first one that we'll talk about is the foundational ones.
206480	209480	These are the things that you basically get out of the box with any CDN.
209840	212460	Literally, you could be running an NGINX proxy somewhere.
212840	215500	It's the stuff you get basically for free.
215620	217140	GUIP is super easy.
217140	218480	It's not super useful.
218500	229120	We'll start talking about, as we go down this list, they get more and more interesting, more and more important into your mental model of how do you want to build a defense for DDoS, as we go through this.
229120	233440	I have GUIP+, because there's often an enrichment.
233700	235220	We're in Fastly right now.
235220	239340	We have a company called Digital Elements, who supplements data into Fastly.
239340	252220	They give us additional information around hosting provider, is it a Tor exit node, all these distinctions around what could the traffic be, or what the user base could be behind that IP that's hitting us.
252220	253100	That's why I say GUIP+.
254480	256320	User agent is a fantastic one.
256320	261100	Again, we're talking about 300,000 requests a second.
261100	264940	We can model a lot of things, interestingly, with user agent.
264940	271980	We can see, okay, for the patterns of the URLs that are being hit, for the paths that are being hit, do we see that that's actually coming from our iOS apps?
271980	275600	Or do we have a random iOS app that's now hitting something that it definitely shouldn't?
275600	276920	That's our web platform.
277240	278800	Okay, there's something fishy there.
278800	280400	Again, that signal helps us out.
280800	282720	And path and query, those things come for free.
282720	289900	So sure, these are all like the fundamental, bare minimum, things that you can do from a very raw, coarse-grained type modeling perspective.
290280	292040	Now we're going to start moving up the stack.
292400	294040	The first one is TLS fingerprints.
294040	300760	We're still very much focused on where that traffic originated, or how that traffic initially got out the door.
300900	305820	So at TLS fingerprint, if you aren't aware, I left a couple of links around Jaw 3 and Jaw 4.
305820	310920	I did not come up with them, but they are super great tools for how you think about fingerprinting.
310980	312320	What is the actual OS?
312340	313280	What is the client?
313280	315580	What are the libraries that are loaded behind the scenes?
315720	321860	That is how you can focus on the type of machine or the platform that is making that request.
322060	324540	And again, as we're going through here, we're stacking up a whole bunch of things.
324540	327580	We're actually starting low-level and starting to move up the OSI stack.
327980	331900	This is a great mechanism to figure out what is going on behind the scenes.
332460	336200	Definitely based on, again, if you're not familiar with it, go check it out.
336200	340180	It should be, by default, available for all of your CDN providers.
340180	344380	And there's Nginx plugins that you can add to add that in.
344380	346500	So pretty well solved.
346520	352060	There's some fun things like Grease, which was meant to help with determining the interoperability of cipher suites.
352080	356500	It's bad for us because that means there's a whole bunch of random garbage that shows up in those fingerprints.
356720	361280	And so that means we need something like a Jaw 3 or Jaw 4 to exclude that noise.
361560	363280	Same thing with protocol sprawl, right?
363280	370120	So if you have HTTP 3, you have QUIC coming along, you're seeing a modification of how those handshakes are happening.
370120	372920	That's just adding more complexity from a fingerprinting perspective.
373040	373860	But that's okay.
373860	375900	You just have to remember that it exists.
376420	379260	And the next slide, I included an overview of Jaw 4.
379580	381100	Again, you should totally go look it up.
381100	390420	If you don't know what it is, it should be readily available for you from a CDN perspective to add into your mix of here's a list of things that I can start doing rate limiting with.
391820	392400	Okay.
392400	393400	So now we're into the interming.
393400	394820	So we were fingerprints before.
394820	397140	We're now kind of sort of retina scanning.
397500	400380	The first thing we'll talk about is the request header fingerprints.
400380	402560	Now, this one's not super well publicized.
402560	403520	There are a couple.
403520	407540	I dropped a link that talks about what it is in theory.
407640	413360	I have not found a whole lot of documentation or examples out in the wild of this is exactly how it's done.
413680	418840	I'm hoping that we should be able to open source our implementation from a Reddit standpoint relatively soon.
418840	422860	It's actually, I mentioned Fastly on here, this Fastly info OH fingerprints.
423340	425720	Fastly built that using our algorithm.
426040	432700	And so now we have a header, this request header fingerprint that's available because we made Fastly do it.
432700	434940	We pay them enough, it's the least they could do.
435040	436560	Same thing with Cloudflare, right?
436560	440360	We got the exposure of what are the raw request header names.
440360	443220	And now we can start doing maths against that.
443220	445760	So what actually is the request header fingerprint?
446300	448620	So we talked about like the TLS fingerprint, right?
448620	452380	Like the way that the client is configured, the Cypher suites that it's going to have, et cetera.
452500	454780	Okay, well now bump it up into HTTP land.
455060	459360	The way that an HTTP request is constructed is very dependent upon what client you're using.
459360	460840	Is it a Golang request client?
460840	462620	Is it a Python request client?
462700	464440	Is it some, is it curl?
464440	473660	Like all of those have very distinct ways that they craft an HTTP packet, which provides you additional data about what type of thing is making that request behind the scenes.
473700	476260	So we're moving up the stack from OS to libraries perspective.
476260	480480	We're now in the land of what is the actual client that is making those calls.
480860	487140	On the subsequent slide in the code, I have a whole bunch of, like that is an example, literally taken from our source code internally.
487520	494080	Nothing juicy there, but it is essentially an example of, here's a request that might have come through from our proxy perspective.
494560	496200	We do some maths.
496440	498080	And I'm not a maths, I'm an engineer.
498120	503100	So you get maths and you get down at the bottom, which is essentially a glorified fingerprint, right?
503360	512580	Again, I'm going to hope to be able to publish the algorithm in open source relatively soon, but just know that Fastly will return you exactly that.
512720	520960	Which is great, because now you can take that as, this is a unique string that I can use in my ML learnings or to understand what do I want to block against.
521340	523800	It's a great another example of a fingerprint.
524760	527600	And so finally, we have advanced signals.
528580	532180	So the first thing to think about is the network request timings.
532180	541940	So we're starting to get into things where it makes a lot of sense to throw into a model and do things async, rather than I need to do something as the request is coming to me in a synchronous fashion.
542080	544560	Network request timings are great examples of that.
545180	553360	You should roughly know, if you know anything about your app, you should roughly know the order of operations and the timing that your app behaves.
553620	555580	And you can glean information from that.
555580	560900	So for example, if you go to Reddit, if you go to new Reddit, I'm not going to talk about old Reddit, also don't come after me.
561000	563900	New Reddit, we have, it's a single page app.
563900	569820	You load that, it loads a whole bunch of JavaScript bullshit, and then you're basically done until you scroll down.
569980	583060	So I should have a burst of network traffic at the very beginning that's loading in assets and resources, making a couple of GraphQL calls to populate the initial page, like populate the DOM out, and then I'm going to be quiet and maybe emit some events.
583260	584320	Is the user still there?
584320	585840	What experiments did we expose?
585840	586380	Et cetera.
586380	588980	There's a rough pattern that exists there.
589380	593160	And that's assuming that you're using a browser or Chrome or whatever.
593160	602280	Now, if you're just curling something, I can tell real quick that you didn't do anything, because curl's not going to do it, I mean, unless you add flags and you try to emulate that on purpose.
602280	608420	If you just try to hit a post, I can easily tell that, yep, you're behaving in a particular way that is non-human.
608420	610060	I can get that distinction then.
611080	612440	Same thing with analytic events.
612440	618960	If those fire or don't fire, curl doesn't care that there's JavaScript that needs to exist that should fire out that event.
619020	622360	I can get some information about the absence of that data there.
622360	624260	Same thing with cookies and JOTs.
624740	630860	We'll talk about a resiliency technique that happens when we don't have a JOT or a cookie on the request.
631140	639180	But if I see something and I can tell, like, oh, yeah, there's no actual, you know, you're hitting, you're going to a post directly, well, there probably should be trappings about that request.
639180	647260	So, like, if you're coming from an embed for maybe you're on some other competing platform, how dare you, there would be an origin that would come across that.
647260	655000	So I should be able to match up, okay, I understand there are additional headers that should flow as a natural evolution of web traffic.
655000	659300	If that doesn't exist, then I can pretty much tell that, yeah, you just sent out a curl request.
659300	662060	You're not an actual human that's surfing Reddit.
662760	672920	And then finally, the extension of that is to take your most prized or your most sensitive or most well-known flows and understand what that order of operation is.
672920	675320	We know exactly how our login flow works.
675320	678360	It is literally essentially three API calls.
678420	680580	If those happen out of order, well, okay, great.
680580	684860	Now I can tell that you're trying to brute force passwords or I can tell that you're doing something nefarious.
684860	685820	You're not a real human.
685820	690140	Again, this is additional signal, but it's much higher level of complexity.
690160	694720	I have to do some asynchronous processing to understand is it good or is it bad?
697480	697940	All right.
697940	700100	So now I'm going to talk about where do we rate limit.
700100	704500	So I have all this signals and these exist between an edge and an application.
704900	707180	And I'm completely discarding layer three and four.
707180	711500	There are, you know, I'm paying a CDN or I'm paying a cloud provider to make that problem go away.
711500	716660	So like the HTTP 1.1 desyncs that we had in the news the other week, I don't care.
716660	718940	Fastly can send me a postmortem and it's fine.
719200	722080	I do care from a HTTP perspective.
722360	724840	So now I get to make a decision of do I do that at the edge?
724840	728280	So if I'm in my CDN or do I do that at my application?
728720	731480	And so the way that I'm thinking about this are twofold.
731540	732840	I can think about cost.
732840	737980	So doing at the edge always makes it cheaper from my perspective because that means it doesn't have to hit my app.
737980	739100	I don't have to load data.
739100	746020	I don't have to go through this very complicated flow, which you'll see here is a network diagram of what does the Reddit ingress stack look like.
746400	750860	I can make that decision early on and save me a bunch of money.
751260	753400	Or I can do it at the application layer.
753560	755440	Maybe I need it to be more expensive.
755440	757740	Maybe I need to have that additional app context.
757740	759240	And that's where it makes sense.
759520	761340	Essentially, you always have to use both.
761340	766120	But thinking, being able to have that architectural pattern of, okay, here's how I'm doing this at the edge.
766120	767300	Here's how I'm doing at the app.
767300	770720	Extremely important so that you understand how good your defenses are.
770720	771620	Again, like defense in depth.
771620	773000	This is just defense in depth.
774980	777700	Okay, so we said we're going to do both.
777920	781800	We need to store essentially that data in some sort of KV.
782000	786080	Now, an edge and an app both have pros and cons around that KV structure.
786320	790020	So, you know, you might make a decision that, okay, I want to store that data.
790020	792000	But Fastly only gives you...
792000	793780	So Fastly has a product called Edge Rate Limiter.
793780	795060	We'll talk about it in a second.
795060	797820	It gives you very, very coarse-grained access to...
797820	799580	It actually doesn't even give you access to the KV.
799580	802940	If you wanted to go and look to see, like, what's in there, you can't.
803380	806580	Which is okay if you don't need that information.
806580	810140	Reddit is really weird and we want to be able to control and have observability for everything.
810140	811660	So we really want that.
812720	818180	So if I need to get something that I actually can inspect or I actually can invert, I'll probably do it at the app level.
818740	821620	Otherwise, sure, I'll stick it up in Fastly and call it a day.
822400	825520	This also extends to, like, the ability to flush or reset that.
825580	831260	You know, if you accidentally ban all of a particular TLS fingerprint, and we've never done this.
831260	831960	Oh, no, we have.
831960	835160	We do this much too often because it's hard.
835160	837580	But you want to be able to revert that very quickly, right?
837580	845020	So whether that is you're able to set a config variable or you're able to do an exclusion in that Edge logic, you got to figure out how you do that.
845020	849400	Because inevitably, you will block somebody that you did not mean to.
849900	852480	And then lastly is programmatic interactions, right?
852480	856680	Again, along the same lines, how often do you need to interact with your KV store?
857100	858720	Last one is a very interesting one.
858720	862000	We're going through a process right now of what we're calling worldwide Reddit.
862120	869100	So essentially, all of Reddit traffic, you know, if you asked us maybe a quarter ago, all of that was served out of AWS US East One.
869240	872680	Not super great if you are literally anywhere else but on the East Coast.
872680	876340	So if you're in India, it's going to take a long ass time for your site to load.
876340	878720	Obviously, not a good user experience.
878720	879840	So we want to fix that.
879840	886380	That means we now are going to be deploying essentially serving stacks across the globe in different points of presence.
886940	888840	But what happens about rate limiting?
888840	902180	I now have a problem of if somebody is hitting me in Germany through a Tor exit node, and they're able to... if I'm silly about my routing, and I don't have a great consistent way that I'm saying, okay, this German traffic always needs to go to this particular pop.
902220	905220	Maybe it's through any cast, maybe through circular hashing.
905220	908180	There's a couple of different computer science algorithms that will give you that information.
908420	916680	Then if I don't have that done consistently, I will lose that algorithm of I saw that traffic once, I'm incrementing a counter.
916680	918500	I now know if I can go back and rate limit.
918660	923460	So as you start globalizing, and again, this is a Reddit scale problem for sure.
924000	928160	You have to figure out how do you deal with that inconsistency that might exist?
928160	930300	Am I going to try to replicate those caches everywhere?
930300	931560	That's expensive.
931760	933320	Fastly does do that for us.
933320	935320	They abstract a lot of that away.
935380	939260	Cloudflare will also do that with KV store, or the KV workers product.
939260	941400	That's fine, but it's something that you then have to consider.
941400	950580	You have a time of call, time of use problem now, where if somebody's throwing a million requests a second, and it's distributing it globally, you now have a problem.
954100	960740	Okay, and then finally, making some smart architectural principle decisions will help you in your defenses.
960740	964320	So for Reddit, we have historically always split out.
964320	966420	We've got one site that serves all of our server rendering.
966420	968740	We've got one site that serves media assets.
968740	973680	There's one domain that serves chat traffic.
973680	977280	That makes it very easy for us to understand, okay, this is this traffic.
977280	978200	This is the rate limits.
978200	980340	This is how expensive those calls are.
980680	991780	Doing that and being very, I have reasonable on the slides, being reasonable about that architecture helps you in your defense to figure out, okay, where do I want to put in those guardrails?
992400	994160	Cache where you can.
994160	995600	This is a computer science problem.
995600	997980	You always want to cache it because then it's going to be cheaper.
998620	1000160	Caching Reddit is hard, though.
1000400	1006840	When you load your feed, you are not getting, like, it's not the same cache or the same feed that Pratik is going to have.
1006840	1007820	It's going to be different.
1007820	1010720	So I can't cache that, but I can cache media assets.
1010820	1011220	So great.
1011220	1014060	Figuring out where you can and cannot is extremely important.
1014060	1015480	It means you have to know your traffic.
1016200	1019620	And then finally, this isolating workloads for a specific purpose.
1019620	1023760	We'll talk about some of our resource pools as another resiliency technique in a second.
1023760	1033800	But being able to say, like, this is exactly the pool of traffic where I can fan out, like, we, for example, our server-side rendering, we call it Shred It, that we have multiple pods.
1033940	1036640	And we're on vanilla Kubernetes.
1036640	1047060	We have multiple deployments of those pods, one that might do the login page, one that might do our post details page, one that might do chat iframe rendering.
1047300	1056220	Doing that makes it very easy for us to kind of swap in and out either with the rate limits themselves or to understand the behavior of that traffic that's hitting those backend services.
1057420	1061700	So on the next slide, I have a very fancy diagram that I'm not going to go into super detail.
1061700	1063800	It's there from like a reference architecture standpoint.
1063840	1071220	This is how we talk about the network ingress from clients all the way to backend requests and the return trip.
1071220	1074400	I'll reference this as we talk about edge and application rate limiting in a second.
1075340	1078040	Okay, so edge rate limiting, I kind of already talked about this a little bit.
1078040	1081500	Fastly, we use their paid product, Fastly Edge Rate Limiter.
1081500	1082300	It's pretty good.
1082300	1086860	They give us essentially two KVs, a penalty box and a rate counter.
1086860	1100040	So think of the penalty box as essentially that's the TTL for if this IP looks bad or this IP plus TLS or this whatever the combination is, it's literally a function that they provide, then we can add that value into their KV store.
1100040	1106600	And it'll have a TTL that we can configure and then it'll drop out a cache whenever it's supposed to drop out.
1106600	1110060	The rate counter is literally, it's the abacus of the entire thing.
1110060	1113560	As we see those things happen, we're adding one to those counters.
1113680	1115940	And that's the other half of that magic.
1116140	1118020	There's documentation on how Fastly does it.
1118020	1120820	We did not have an option to do this.
1120820	1123520	We use Fastly's VCL implementation.
1123520	1127260	It's not the compute product because computed edge can get a little spendy.
1127260	1132020	Again, we're thinking about like cost optimization of the sheer volume of traffic that we have.
1132020	1136320	And so we are doing this outside of VCL, which is our normal flow.
1136320	1136880	It's fine.
1136880	1139880	We're actually changing this, as we talk about the next slide.
1140820	1141800	Oh, sorry.
1141800	1147060	I included a very fancy picture of, okay, this is how you might do this rate limiting call in Fastly.
1147180	1148720	Documentation is actually pretty good.
1148720	1151120	So do go check that out if you are using Fastly.
1151240	1153540	Otherwise, on the Cloudflare side, you got two options.
1153540	1160700	You can be an enterprise customer and pay a boatload of money, which we weren't super interested in, or you can build it yourself in workers.
1160700	1165900	So between workers and KV workers, we've essentially replicated what we have in Fastly into Cloudflare.
1165900	1167740	Again, this is our like multi-CDN approach.
1167740	1172320	We want to have the ability to swap in and out and do commercials and do all this jazz.
1173040	1177820	Business aside, engineering principles, it's essentially we're going to replicate that functionality.
1178540	1182180	And so relatively straightforward with what Cloudflare provides you.
1182880	1188080	One thing that I will say is that we are extremely, extremely obsessive about the logs that come out of that.
1188080	1197320	Now, if you've ever looked at a CDN log provider, the logs that come out are really terrible in terms of like the verbosity of what is going on, right?
1197320	1200140	It'll give you like HP status codes and then maybe some other stuff.
1200140	1206040	And that's a super, super lacking of detail for you to figure out what exactly is happening.
1206040	1211320	So for us, we have customized all of our logging to say, okay, this is exactly what we want to have.
1211320	1213920	We have these synthetic code and synthetic reason values.
1213920	1216180	We can track why is something being rate limited?
1216180	1220380	Oh, it's being rate limited on TLS fingerprint or it's being rate limited on IP plus TLS.
1220380	1226600	We can see what that failure mode is rather than just here's a whole slew of 429s, go figure it out.
1226600	1229380	That does not work from an engineering standpoint.
1230380	1236080	So in terms of how I'm piecing all of these things together, think of it as just a series of band pass filters.
1236080	1240020	I'm gonna have something extremely coarse grained at the very top that might be like IP address.
1240440	1244700	If you haven't already exhausted that rate limit, then we'll bump down to the next one.
1244700	1246560	Maybe it's IP plus TLS fingerprint.
1246660	1250960	Maybe the next one is IP plus TLS fingerprint plus this pools word that I have here.
1250960	1255180	So think about like logged out traffic, logged in traffic, third-party clients.
1255180	1260260	If it's OAuth, you can group your traffic and extend the groupings that you're having there.
1260260	1261500	And then finally, reCAPTCHA.
1261500	1268840	So I might pay somebody else to give me some additional signal that maybe I include that as part of my rate limit.
1269000	1275620	Again, as I'm moving down that stack, I am getting more narrow in the terms of how many times you can do a thing.
1275640	1278900	But I'm also, the permutations are becoming more and more and more, right?
1278900	1280420	So that is the trade-off.
1280900	1283680	Obviously, this has super bad weaknesses.
1283680	1287600	We have CGNATs, people have shared IP addresses.
1287940	1289220	This is a problem.
1289740	1290980	You will block people.
1291160	1291800	It happens.
1291800	1295840	But that's why the importance of being able to tune and understand like what are the exemptions?
1295840	1299840	We have plenty of edge dictionaries that say, all right, we know that this is a Google crawler.
1299980	1301700	Obviously, we don't want to block Google.
1301700	1302980	So Google, you go on through.
1302980	1309460	We're going to add some fingerprinting and some secret sauce to make sure that that's actually Google and not somebody impersonating.
1309660	1311860	But if that's actually you, Google, then sure, go on through.
1311860	1312900	We won't rate limit you.
1312900	1316060	Again, all that is controlled via these edge dictionaries that are in Fastly.
1316060	1318300	Or again, a KV store on the Cloudflare side.
1320000	1327200	And so if I look at the edge rate limiting application, you can see some locks that I'm doing that at the edge.
1327200	1330520	Those are the cheaper, but those are, again, very, very coarse grained.
1331120	1333320	All right, let's talk about application rate limiting.
1333700	1335720	Ooh, and we're going to go move really fast.
1335840	1338420	So in terms of application rate limiting, we have a library.
1338420	1339820	This is the easiest way for your devs.
1339820	1342980	Don't make them think about what algorithm, how should I go and implement this?
1343000	1344180	We have a baseplate library.
1344180	1346100	Every single dev can use this.
1346100	1348860	We have essentially one click for standing up Redis.
1348960	1353380	If you need rate limiting is essentially a handful of lines of code to get something.
1353380	1354620	You have a KV store.
1354620	1355480	You have Redis.
1355480	1356820	You now have rate limiting your app.
1356820	1359960	The hardest part here is to figure out, well, what should the values be?
1359960	1365640	And the general guidance is that you will always do how fast a human should be able to do this, given an order of magnitude, right?
1365640	1366360	Is it 2x?
1366360	1367320	Is it 10x?
1367320	1369620	Pick something, but devs just need to hear that.
1369620	1370340	And then they're like, all right, cool.
1370340	1371200	I can dial this in.
1371200	1376340	And now that it is less of a security problem and it is more of a developer experience problem, which is great.
1377960	1382480	So this is the best for if I have per user or per endpoint logic.
1382480	1386820	So how many times can you post in an hour or in a minute?
1386820	1389800	Those are great rate limits for this because I need the context.
1389800	1391580	I need to know, okay, what post are you looking at?
1391580	1392520	Who are you?
1392520	1395880	I need this information that only the app might actually have.
1395880	1397500	Same thing for OAuth clients.
1397500	1404820	We have a whole slew of OAuth clients, third party and first party that we want to say, okay, you have this quality of service through.
1405260	1405420	Great.
1405420	1406800	You have a thousand requests a second.
1406800	1408280	Or, you know, you're not paying.
1408280	1410160	So you only get 10 requests a second.
1410280	1411860	All that data has to come from somewhere.
1411860	1414660	I'm coming, that's coming from the application itself.
1416380	1418160	The rest, I'm going to skip.
1418160	1420180	So I'm on resiliency techniques.
1420820	1425520	So I threw an example of like what our logging looks like from a Cloudflare or from a Fastly perspective.
1425600	1426620	It's gnarly.
1426620	1430800	We did a Terraform module that actually generates all this for us.
1430800	1434580	You have to do JSON escaping, like it's kind of gross.
1434620	1437020	But we're extracting that all to BigQuery, right?
1437020	1443740	And for us, the network traffic logs are by far not even the drop in the bucket when it comes to our analytic events.
1443760	1448900	So for us, this makes a lot of sense stored in BigQuery because it's cheap and we're not burning a lot of cash.
1449080	1452660	And we can now do SQL queries against it to understand what's actually going on.
1452660	1455680	But it requires a lot of setup for us to actually be able to use it.
1455680	1458060	So you have to have observability.
1458060	1461060	You have to get those custom web logs with additional enrichment.
1461240	1466820	Add a UUID for each request so you understand if people are having problems, they're getting rate limited, track that back.
1466820	1467800	That's pretty commonplace.
1467800	1471660	Like this is a Cloudflare unique ID, the Ray ID that's on every request.
1471660	1472360	Great.
1473120	1476180	You might have to do that yourself, which we did in Fastly.
1476180	1477760	And then we have to invest in tooling.
1477760	1487340	So we literally have a Go binary that will query BigQuery using application default credentials that a user, you know, gcloud off logon.
1488080	1489920	That actually will go and then query BigQuery.
1489920	1493520	So it takes out that whole, like, you got to go to the console, put in some SQL, do some stuff.
1493520	1497320	It's literally one CLI command to see, okay, is this request being rate limited?
1497320	1498960	Why is it being rate limited, et cetera.
1499440	1504300	So in terms of resiliency techniques, and we're going to speed real quick because we got two.
1504800	1505440	Yeah.
1505440	1509900	So the thing I will call out here, the slow lane versus well lane.
1509900	1517120	This is probably the most interesting thing that I had, I saw when I came on as a security engineer, that you can have pools that can be degraded and you don't care about it.
1517120	1526100	So if you can identify, oh, hey, this is from a Tor exit node, or this is from an IP that has a bad reputation, throw it to a pool that's extremely constrained and just let it die.
1526100	1527520	And if it dies, no big deal.
1527520	1531540	And write your SLOs that aren't going to hit against that thing dying.
1531540	1534820	But they can all go and fight to see who dies fastest in that pool.
1535260	1536500	I had not seen that before.
1536620	1538040	We don't talk about that a whole lot.
1538040	1542400	It's a great resiliency technique to say, I see you're a bad request, you go to timeout.
1544380	1546420	Tar pitting and response bloat, you can check that out.
1546420	1552860	We actually use badger, badger, badger as the response bloat within our VCL, which is a very Reddit-y thing, so I had to include that.
1553260	1555380	But again, the idea here is to make it very easy.
1555380	1562560	So if a request comes to us, it used to be like, you just hit the front page, like send a request to get the front page of Reddit, and that would cascade.
1562620	1566980	So obviously, it is a bad ratio of bytes sent to me versus bytes I'm sending back.
1566980	1572780	I want to make it expensive for the attacker so they have to go out wide, or they have to go out through multiple machines.
1572780	1576480	Like, I want to make it the most expensive for them to come at us.
1577900	1579060	All right, we're gonna wrap there.
1579160	1580280	The rest of the slides are online.
1580280	1581900	We'll be over here if you guys want to talk.
1581900	1582480	Thanks, y'all.
