So let's get started. I'm Spencer Koch. I'm a principal security engineer at Reddit. And I'm joined by Prateek. He's a senior security engineer at Reddit as well. And we're on the security team. And so thank you to the DDoS village for having us be up here. And we sponsored them too. So we're great to see that advance. And I know we've got some moral support in the back as well. So thanks for coming out. And we're going to be talking about DDoS stuff. 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. So what are you going to get from this talk? So hopefully we should be able to go through an architecture. How do we think about rate limiting? And so the way that we kind of construct that mental model at Reddit so that we can do defense against it. We'll talk about signals and why they are so darn important. We're going to talk about where do we do rate limiting? When should we do that rate limiting? And why do we want to do that rate limiting? 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. 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. And there were only two of us when we started doing DDoS preventions a long time ago. 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. 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. We do a lot of traffic. So 1.3 trillion requests every week. We do 175 petabytes every week. That's a lot of stuff. And so we do this in conjunction with some of our CDNs. We are fastly and looking at Cloudflare right now. We are also AWS based for the most part for our serving side of the platform. And so that's a lot of stuff to flow through cloud providers. In terms of services, just to give you another sense of scale, like our GraphQL endpoints, that's mostly all of our new APIs. 275,000 requests a second. And you can see some of the other metrics that are there. We do a lot of traffic. And so doing things at scale becomes really important. 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. 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. In 2021, we started getting more serious. So this is right around the time of our API riots. And we changed the way that we wanted to do how people interact with the platform. Don't yell at me about that. I just work here. 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. So that's when we first started staffing our transport team. 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. And they're focused on DDoS mitigations. 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. The first one that we'll talk about is the foundational ones. These are the things that you basically get out of the box with any CDN. Literally, you could be running an NGINX proxy somewhere. It's the stuff you get basically for free. GUIP is super easy. It's not super useful. 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. I have GUIP+, because there's often an enrichment. We're in Fastly right now. We have a company called Digital Elements, who supplements data into Fastly. 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. That's why I say GUIP+. User agent is a fantastic one. Again, we're talking about 300,000 requests a second. We can model a lot of things, interestingly, with user agent. 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? Or do we have a random iOS app that's now hitting something that it definitely shouldn't? That's our web platform. Okay, there's something fishy there. Again, that signal helps us out. And path and query, those things come for free. So sure, these are all like the fundamental, bare minimum, things that you can do from a very raw, coarse-grained type modeling perspective. Now we're going to start moving up the stack. The first one is TLS fingerprints. We're still very much focused on where that traffic originated, or how that traffic initially got out the door. So at TLS fingerprint, if you aren't aware, I left a couple of links around Jaw 3 and Jaw 4. I did not come up with them, but they are super great tools for how you think about fingerprinting. What is the actual OS? What is the client? What are the libraries that are loaded behind the scenes? That is how you can focus on the type of machine or the platform that is making that request. And again, as we're going through here, we're stacking up a whole bunch of things. We're actually starting low-level and starting to move up the OSI stack. This is a great mechanism to figure out what is going on behind the scenes. Definitely based on, again, if you're not familiar with it, go check it out. It should be, by default, available for all of your CDN providers. And there's Nginx plugins that you can add to add that in. So pretty well solved. There's some fun things like Grease, which was meant to help with determining the interoperability of cipher suites. It's bad for us because that means there's a whole bunch of random garbage that shows up in those fingerprints. And so that means we need something like a Jaw 3 or Jaw 4 to exclude that noise. Same thing with protocol sprawl, right? So if you have HTTP 3, you have QUIC coming along, you're seeing a modification of how those handshakes are happening. That's just adding more complexity from a fingerprinting perspective. But that's okay. You just have to remember that it exists. And the next slide, I included an overview of Jaw 4. Again, you should totally go look it up. 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. Okay. So now we're into the interming. So we were fingerprints before. We're now kind of sort of retina scanning. The first thing we'll talk about is the request header fingerprints. Now, this one's not super well publicized. There are a couple. I dropped a link that talks about what it is in theory. I have not found a whole lot of documentation or examples out in the wild of this is exactly how it's done. I'm hoping that we should be able to open source our implementation from a Reddit standpoint relatively soon. It's actually, I mentioned Fastly on here, this Fastly info OH fingerprints. Fastly built that using our algorithm. And so now we have a header, this request header fingerprint that's available because we made Fastly do it. We pay them enough, it's the least they could do. Same thing with Cloudflare, right? We got the exposure of what are the raw request header names. And now we can start doing maths against that. So what actually is the request header fingerprint? So we talked about like the TLS fingerprint, right? Like the way that the client is configured, the Cypher suites that it's going to have, et cetera. Okay, well now bump it up into HTTP land. The way that an HTTP request is constructed is very dependent upon what client you're using. Is it a Golang request client? Is it a Python request client? Is it some, is it curl? 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. So we're moving up the stack from OS to libraries perspective. We're now in the land of what is the actual client that is making those calls. 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. Nothing juicy there, but it is essentially an example of, here's a request that might have come through from our proxy perspective. We do some maths. And I'm not a maths, I'm an engineer. So you get maths and you get down at the bottom, which is essentially a glorified fingerprint, right? 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. 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. It's a great another example of a fingerprint. And so finally, we have advanced signals. So the first thing to think about is the network request timings. 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. Network request timings are great examples of that. 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. And you can glean information from that. 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. New Reddit, we have, it's a single page app. You load that, it loads a whole bunch of JavaScript bullshit, and then you're basically done until you scroll down. 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. Is the user still there? What experiments did we expose? Et cetera. There's a rough pattern that exists there. And that's assuming that you're using a browser or Chrome or whatever. 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. 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. I can get that distinction then. Same thing with analytic events. 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. I can get some information about the absence of that data there. Same thing with cookies and JOTs. We'll talk about a resiliency technique that happens when we don't have a JOT or a cookie on the request. 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. 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. 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. If that doesn't exist, then I can pretty much tell that, yeah, you just sent out a curl request. You're not an actual human that's surfing Reddit. 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. We know exactly how our login flow works. It is literally essentially three API calls. If those happen out of order, well, okay, great. Now I can tell that you're trying to brute force passwords or I can tell that you're doing something nefarious. You're not a real human. Again, this is additional signal, but it's much higher level of complexity. I have to do some asynchronous processing to understand is it good or is it bad? All right. So now I'm going to talk about where do we rate limit. So I have all this signals and these exist between an edge and an application. And I'm completely discarding layer three and four. There are, you know, I'm paying a CDN or I'm paying a cloud provider to make that problem go away. So like the HTTP 1.1 desyncs that we had in the news the other week, I don't care. Fastly can send me a postmortem and it's fine. I do care from a HTTP perspective. So now I get to make a decision of do I do that at the edge? So if I'm in my CDN or do I do that at my application? And so the way that I'm thinking about this are twofold. I can think about cost. So doing at the edge always makes it cheaper from my perspective because that means it doesn't have to hit my app. I don't have to load data. 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. I can make that decision early on and save me a bunch of money. Or I can do it at the application layer. Maybe I need it to be more expensive. Maybe I need to have that additional app context. And that's where it makes sense. Essentially, you always have to use both. But thinking, being able to have that architectural pattern of, okay, here's how I'm doing this at the edge. Here's how I'm doing at the app. Extremely important so that you understand how good your defenses are. Again, like defense in depth. This is just defense in depth. Okay, so we said we're going to do both. We need to store essentially that data in some sort of KV. Now, an edge and an app both have pros and cons around that KV structure. So, you know, you might make a decision that, okay, I want to store that data. But Fastly only gives you... So Fastly has a product called Edge Rate Limiter. We'll talk about it in a second. It gives you very, very coarse-grained access to... It actually doesn't even give you access to the KV. If you wanted to go and look to see, like, what's in there, you can't. Which is okay if you don't need that information. Reddit is really weird and we want to be able to control and have observability for everything. So we really want that. 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. Otherwise, sure, I'll stick it up in Fastly and call it a day. This also extends to, like, the ability to flush or reset that. You know, if you accidentally ban all of a particular TLS fingerprint, and we've never done this. Oh, no, we have. We do this much too often because it's hard. But you want to be able to revert that very quickly, right? 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. Because inevitably, you will block somebody that you did not mean to. And then lastly is programmatic interactions, right? Again, along the same lines, how often do you need to interact with your KV store? Last one is a very interesting one. We're going through a process right now of what we're calling worldwide Reddit. 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. Not super great if you are literally anywhere else but on the East Coast. So if you're in India, it's going to take a long ass time for your site to load. Obviously, not a good user experience. So we want to fix that. That means we now are going to be deploying essentially serving stacks across the globe in different points of presence. But what happens about rate limiting? 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. Maybe it's through any cast, maybe through circular hashing. There's a couple of different computer science algorithms that will give you that information. 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. I now know if I can go back and rate limit. So as you start globalizing, and again, this is a Reddit scale problem for sure. You have to figure out how do you deal with that inconsistency that might exist? Am I going to try to replicate those caches everywhere? That's expensive. Fastly does do that for us. They abstract a lot of that away. Cloudflare will also do that with KV store, or the KV workers product. That's fine, but it's something that you then have to consider. 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. Okay, and then finally, making some smart architectural principle decisions will help you in your defenses. So for Reddit, we have historically always split out. We've got one site that serves all of our server rendering. We've got one site that serves media assets. There's one domain that serves chat traffic. That makes it very easy for us to understand, okay, this is this traffic. This is the rate limits. This is how expensive those calls are. 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? Cache where you can. This is a computer science problem. You always want to cache it because then it's going to be cheaper. Caching Reddit is hard, though. 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. It's going to be different. So I can't cache that, but I can cache media assets. So great. Figuring out where you can and cannot is extremely important. It means you have to know your traffic. And then finally, this isolating workloads for a specific purpose. We'll talk about some of our resource pools as another resiliency technique in a second. 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. And we're on vanilla Kubernetes. 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. 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. So on the next slide, I have a very fancy diagram that I'm not going to go into super detail. It's there from like a reference architecture standpoint. This is how we talk about the network ingress from clients all the way to backend requests and the return trip. I'll reference this as we talk about edge and application rate limiting in a second. Okay, so edge rate limiting, I kind of already talked about this a little bit. Fastly, we use their paid product, Fastly Edge Rate Limiter. It's pretty good. They give us essentially two KVs, a penalty box and a rate counter. 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. 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. The rate counter is literally, it's the abacus of the entire thing. As we see those things happen, we're adding one to those counters. And that's the other half of that magic. There's documentation on how Fastly does it. We did not have an option to do this. We use Fastly's VCL implementation. It's not the compute product because computed edge can get a little spendy. Again, we're thinking about like cost optimization of the sheer volume of traffic that we have. And so we are doing this outside of VCL, which is our normal flow. It's fine. We're actually changing this, as we talk about the next slide. Oh, sorry. I included a very fancy picture of, okay, this is how you might do this rate limiting call in Fastly. Documentation is actually pretty good. So do go check that out if you are using Fastly. Otherwise, on the Cloudflare side, you got two options. 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. So between workers and KV workers, we've essentially replicated what we have in Fastly into Cloudflare. Again, this is our like multi-CDN approach. We want to have the ability to swap in and out and do commercials and do all this jazz. Business aside, engineering principles, it's essentially we're going to replicate that functionality. And so relatively straightforward with what Cloudflare provides you. One thing that I will say is that we are extremely, extremely obsessive about the logs that come out of that. 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? It'll give you like HP status codes and then maybe some other stuff. And that's a super, super lacking of detail for you to figure out what exactly is happening. So for us, we have customized all of our logging to say, okay, this is exactly what we want to have. We have these synthetic code and synthetic reason values. We can track why is something being rate limited? Oh, it's being rate limited on TLS fingerprint or it's being rate limited on IP plus TLS. We can see what that failure mode is rather than just here's a whole slew of 429s, go figure it out. That does not work from an engineering standpoint. So in terms of how I'm piecing all of these things together, think of it as just a series of band pass filters. I'm gonna have something extremely coarse grained at the very top that might be like IP address. If you haven't already exhausted that rate limit, then we'll bump down to the next one. Maybe it's IP plus TLS fingerprint. Maybe the next one is IP plus TLS fingerprint plus this pools word that I have here. So think about like logged out traffic, logged in traffic, third-party clients. If it's OAuth, you can group your traffic and extend the groupings that you're having there. And then finally, reCAPTCHA. So I might pay somebody else to give me some additional signal that maybe I include that as part of my rate limit. 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. But I'm also, the permutations are becoming more and more and more, right? So that is the trade-off. Obviously, this has super bad weaknesses. We have CGNATs, people have shared IP addresses. This is a problem. You will block people. It happens. But that's why the importance of being able to tune and understand like what are the exemptions? We have plenty of edge dictionaries that say, all right, we know that this is a Google crawler. Obviously, we don't want to block Google. So Google, you go on through. We're going to add some fingerprinting and some secret sauce to make sure that that's actually Google and not somebody impersonating. But if that's actually you, Google, then sure, go on through. We won't rate limit you. Again, all that is controlled via these edge dictionaries that are in Fastly. Or again, a KV store on the Cloudflare side. And so if I look at the edge rate limiting application, you can see some locks that I'm doing that at the edge. Those are the cheaper, but those are, again, very, very coarse grained. All right, let's talk about application rate limiting. Ooh, and we're going to go move really fast. So in terms of application rate limiting, we have a library. This is the easiest way for your devs. Don't make them think about what algorithm, how should I go and implement this? We have a baseplate library. Every single dev can use this. We have essentially one click for standing up Redis. If you need rate limiting is essentially a handful of lines of code to get something. You have a KV store. You have Redis. You now have rate limiting your app. The hardest part here is to figure out, well, what should the values be? 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? Is it 2x? Is it 10x? Pick something, but devs just need to hear that. And then they're like, all right, cool. I can dial this in. And now that it is less of a security problem and it is more of a developer experience problem, which is great. So this is the best for if I have per user or per endpoint logic. So how many times can you post in an hour or in a minute? Those are great rate limits for this because I need the context. I need to know, okay, what post are you looking at? Who are you? I need this information that only the app might actually have. Same thing for OAuth clients. 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. Great. You have a thousand requests a second. Or, you know, you're not paying. So you only get 10 requests a second. All that data has to come from somewhere. I'm coming, that's coming from the application itself. The rest, I'm going to skip. So I'm on resiliency techniques. So I threw an example of like what our logging looks like from a Cloudflare or from a Fastly perspective. It's gnarly. We did a Terraform module that actually generates all this for us. You have to do JSON escaping, like it's kind of gross. But we're extracting that all to BigQuery, right? And for us, the network traffic logs are by far not even the drop in the bucket when it comes to our analytic events. 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. And we can now do SQL queries against it to understand what's actually going on. But it requires a lot of setup for us to actually be able to use it. So you have to have observability. You have to get those custom web logs with additional enrichment. Add a UUID for each request so you understand if people are having problems, they're getting rate limited, track that back. That's pretty commonplace. Like this is a Cloudflare unique ID, the Ray ID that's on every request. Great. You might have to do that yourself, which we did in Fastly. And then we have to invest in tooling. So we literally have a Go binary that will query BigQuery using application default credentials that a user, you know, gcloud off logon. That actually will go and then query BigQuery. So it takes out that whole, like, you got to go to the console, put in some SQL, do some stuff. It's literally one CLI command to see, okay, is this request being rate limited? Why is it being rate limited, et cetera. So in terms of resiliency techniques, and we're going to speed real quick because we got two. Yeah. So the thing I will call out here, the slow lane versus well lane. 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. 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. And if it dies, no big deal. And write your SLOs that aren't going to hit against that thing dying. But they can all go and fight to see who dies fastest in that pool. I had not seen that before. We don't talk about that a whole lot. It's a great resiliency technique to say, I see you're a bad request, you go to timeout. Tar pitting and response bloat, you can check that out. 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. But again, the idea here is to make it very easy. 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. So obviously, it is a bad ratio of bytes sent to me versus bytes I'm sending back. 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. Like, I want to make it the most expensive for them to come at us. All right, we're gonna wrap there. The rest of the slides are online. We'll be over here if you guys want to talk. Thanks, y'all.