Surviving Black Friday: 329 billion requests with Falcon
Comments
Transcript
Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.
[applause]
>> I'm Samuel and I built Falcon. And BFCM 2025 was the moment we found out what it was actually worth. I'm joined by Mark and Josh and together we're going to tell you about the biggest bet we've ever made on Ruby. Five parts, the bet we made, the things that broke, the darkest week of the project, BFCM itself and the lessons we took away. Mark will take us through then.
>> All right, so here's the bet. Here's the bet we made ship Falcon to 100% of storefront traffic before BFCM and that ended up being 329 billion requests.
That's billion with a B in one single weekend, our biggest weekend of the year. We call it BFCM for Black Friday Summer Monday. And the app that we ran is called storefront renderer. It's a rack application, a Ruby rack application. It powers every online store on the platform. So if you've ever visited a Shopify store, uh this is the code that renders the page. Uh some of the biggest online store online are hosted on storefront renderer, Mattel, Allbirds, Glossier, Ruggable just to name a few. So and once a year all the traffic we normally get doubles during that weekend. This is the biggest shopping weekend on the internet.
So this is what it looks like. We get four four bumps. The biggest one is uh Black Friday, that's the most popular, then we get the weekends and then Cyber Monday is pretty big too. So the dips you see is when people go to sleep and when they wake up it goes back up and they start shopping again. So, it peaks at 1.42 million requests per second and all of those go through storefront renderer, the rack application. And for the longest time we've run all of this on unicorn, which we most of us know, it uses one process per request, it's simple and it was very reliable, but the problem we had was that it blocked on IO.
So, when a request waits on IO, calling to an external service, for example, the old worker just sits there doing nothing, right? So, here's a picture. We got worker one is blocked waiting on IO, it cannot take another request, so the requests gets queued up waiting for a worker to be ready. So, worker two is the one doing actual CPU work here because it's not blocked on IO. But, we got Falcon, which is a fiber-based async Ruby web server built by Samuel. It can handle multiple requests in one single process at a time. So, in Falcon, each worker handles multiple requests concurrently in the same process using fibers. When a fiber is waiting on IO, another fiber picks up the next request. Now, I'll hand it back to Samuel to walk us through how Falcon works.
>> So, how does Falcon actually work? Let me walk you through the engine we are building on. Falcon is a layered system. Async container manages the Falcon worker processes and is responsible for restarting them if they fail. Each worker runs the Falcon service using Async to multiplex requests. Each fiber handles one request. When a fiber is waiting on IO, Async suspends it and runs the next one. This is what lets a single worker handle multiple requests concurrently. In addition to that, Falcon can have a supervisor, which monitors memory usage, process status, and server utilization. These ensure the Falcon server remains healthy and operational. Now, let's look at how request scheduling actually works. How async decides which fiber to run next and what happens when a request is waiting on IO.
Here is a trivialized example showing two requests. Request A, a card fetch from core. When the fiber hits a network wait, it doesn't block, it yields. Async picks up the next ready fiber. That is request B, a catalog query from Spanner. Same pattern. While this one waits on the database, request A can continue. The two requests execute concurrently. Finally, we wait for both requests to complete. But here's the key, they haven't been sitting idle. While request A was waiting on core, request B was running. And while request B was waiting on Spanner, request A was running. Two requests interleaved. At its heart, async uses the IO event gem, which provides platform-specific backends for multiplexing blocking operations.
IO Uring and epoll on Linux and kqueue on macOS. Let's take a look at how the fiber scheduler integrates with the IO event selector. When an IO operation would otherwise block, Ruby invokes the IO wait hook.
The implementation registers the fiber with the IO event selector, then calls transfer, which yields control back to the event loop. The fiber is suspended. The initial event loop runs on the main fiber. It keeps selecting ready fibers and transferring to them. And when they need to wait, they come back to this loop.
Now, let's talk about how the supervisor works. The supervisor is a separate process inside the container. It runs monitors that keep the workers healthy, tracking memory usage, process metrics, and server utilization. Every worker has a bi-directional connection to the supervisor via the async bus jam, a transparent Ruby RPC mechanism that lets monitors execute operations directly in the context of the worker process. The memory monitor is policy-driven. When a worker's memory usage crosses a threshold, it terminates the process. It supports both a maximum size limit and a minimum free size. The process monitor emits system metrics for each worker, including CPU usage, private and shared memory usage, memory map counts, and so on. Useful for diagnostics and debugging purposes.
The utilization monitor reads worker utilization information from shared memory, including things like the number of active connections and the number of active requests. This information can be used for controlling, scaling, and load balancing. So, in summary, Falcon workers, along with the supervisor, run inside the container. The container restarts processes if they fail, and the supervisor monitors the state of the workers to ensure they're healthy and behaving correctly. But, here's the thing. We didn't turn on all of this concurrency on day one. Let me tell you about long tasks, the feature that gave us control over winter unlock concurrency. Handling multiple concurrent CPU-bound requests can make overall latency worse.
So, we wanted a way to control this carefully while still enabling IO concurrency. We introduced a semaphore, a permit a worker must acquire to accept a request. Before the request is accepted, it acquires the permit, and when it is finished, it releases it. Falcon is now a drop-in replacement for Unicorn with all the same behavioral characteristics, same performance benefits, uh operational profile, and safe starting point. Long tasks is an opt-in concurrency. Wrapping an IO-bound block in a long task releases that semaphore, admitting the next request, then reacquiring it when the IO is done. CPU-bound requests never release the semaphore. They run without competition.
Here is an example. Two requests arrive. Neither can proceed until it acquires the semaphore. The semaphore is free. Request A acquires the semaphore and starts processing. Request B must wait.
Request A enters the long task, IO-bound work. It releases the semaphore. Request B acquires it immediately. Request A runs its IO. Request B runs on
the CPU. Two requests in flight. One doing IO and one doing CPU work. The long task completes. Request A waits at the gate. Request B finishes and releases the semaphore. Two requests, one worker, zero CPU contention. That's long tasks.
But this only works if your code is fiber-safe. We had a massive Ruby code base with native C extensions that was never built for this kind of concurrency. This is a key danger. A C extension that makes a blocking system call without yielding doesn't stall just one request. It stalls every concurrent request on that worker, every fiber. The entire point of Falcon disappears. These aren't obscure libraries. RD Kafka wraps lib RD Kafka in C. GRPC has its
own threading model. They were written for a world where the thread and the execution context were the same thing. Some would break. We just didn't know which ones yet. Let me pass over to Josh, who will tell us what happened next.
>> We had a plan, a phased rollout, and for a while it seemed like it was going to work. We didn't flip the switch right away. You don't go from zero to 100 on a new web server overnight just before Black Friday. We built a careful, methodical rollout designed to catch problems before they would hit merchants. Our confidence was high. We're running We've been running Falcon on lower stakes workloads for some time. The fiber scheduler was solid. Samuel's code was battle-tested. We just hadn't put it under the full weight of server rendering BFCM. The rollout was sequential, manually targeted with canary phases one through N, and the final phase being production.
Once canary was fully on Falcon, we'd start targeting phase one, then phase two, and so on. At any moment, only one cohort was moving, and only a fraction of that fractional traffic was moving. We didn't advance until we were sure that the current step was stable. And when something does go wrong, we see a box turns red, we determine whether we need to roll back, and if it does, we go straight back to unicorn with minimal impact.
There were two phases, two separate deployments, each with its own rollout. We worked through any issues with our GraphQL deployment first. The The surface area was much smaller and stood to benefit the most from moving to Falcon. Once GraphQL was deployed at 100% and stable, we started the process over from scratch for liquid template rendering, which is the bulk of traffic and has much higher stakes.
Company-wide scale tests are a way of simulating high traffic loads like Black Friday before the real thing. This is where we find out if Falcon can actually handle the load before it's showtime. The first scale test, low traffic, Falcon wasn't carrying much yet. >> [clears throat] >> We had a cautious optimism. Everything worked as expected. Mark posted it to our team channel, low numbers so far, but it's working. >> [snorts] >> The first signal that Falcon could run in production under heavy load at our scale without falling apart. This is the first scale test. Traffic ramps up, plateaus, ramps back down. Car- Unicorn is carrying the majority of the load at this point. Falcon's the green line at the bottom. Falcon shares is tiny by contrast, but it holds steady and nothing broke, which is key.
The second scale test here with more long tasks in April. I posted in the channel afterwards, nothing really exciting happened. >> [snorts] >> The second scale test, as you can see here, long task did jump from the baseline, plateaued during the test window, and then fall back down. No more traffic, [clears throat] more long tasks, still nothing broke.
Third test. Unicorn's utilization's climbing. The headron shrinking under load, Falcon is steady. Scale test three, Falcon's utilization stays around 10% the whole test. Unicorn's spikes to 26% on the first load window, and then over 30% on the second. Same traffic, same cluster. Falcon's doing the work more efficiently. Scale test four is set to run. Three tests in, nothing catastrophic happened. We have no reason to expect this will be any different. We watch the same dashboards we've been watching all year. We expect the same result. We were wrong. Falcon pods don't degrade. They don't slow down gracefully. They lock up. Utilization spikes to the ceiling. Load shedding kicks in. We're dropping in real requests in production.
It's only the Falcon pods. Unicorn pods are fine. We dig in. We find not one problem, but three. Each one would have been bad enough on its own. Together, they nearly killed the project. Crisis one, already Kafka side faults.
The Kafka client we use wraps a C library called RD Kafka. It handles all of event streaming. It was never designed for fibers. The C code doesn't have a concept of cooperative scheduling. This led to a very difficult investigation. Heaps were nearly useless. It was basically impossible to reproduce locally. We eventually did find out what was wrong. Under high load, we would see seg faults. Our system protection would kick in causing hard timeouts, which would exit the process. A 1 GB default buffer was silently eat memory until we saw things corrupt. And then we would get OOM killed by Kubernetes resulting in useless heat. So we shipped a flurry of fixes. Fire and forget messages, cap buffers, bump gem versions.
Each fix peeled back another layer. There always seemed to be another problem underneath. Now I'll pass to Mark.
>> All right. Crisis number two, Spanner deadlocks. >> [clears throat] >> Spanner is a Google distributed database that we use for storing session data. And under load, Falcon workers were freezing inside a C call and the event loop was blocked. So the L checks were timing out, the controller was sending sig int and sig term signals, but the process were staying alive. So completely unresponsive, right? So it was stuck waiting for some Spanner partitions that were taking more time to come back. So here's the sync event loop, the run method you see here. It deliberately deliberately defers the signal handling until it's safe to do so.
And here's the GRPC blocking operation that's inside that's what's used inside Spanner for communicating with the the servers. The loop only exits if the operation completes successfully or times out explicitly, right? So if an interrupt occurs, it tries again. So normally RB thread call without GVL checks the Ruby internal interrupts and can raise an exception on sig int or sig term, but in our case a sync has deferred exception handling. So no user space user space signal can exit the loop. So the process did not respond. So the fix we applied is we updated a sync on air to use the kill as a last resort, right? We still still send the other signals before if it does not respond timely fashion, we kill it and the operating system terminates the process immediately regardless of what code is running. We spun a new worker and the hung process is gone. And separately, of course, we fixed the root cause which was the Spanner queries were not were not good.
Uh now I'll hand it back to Samuel to walk us through the final crisis.
>> Crisis three, the silent death.
The most insidious bug because you can't see it happening. Workers get killed for exceeding memory limits. That's normal. The supervisor kills them and async container controller spawns new ones. But in this case, the controller process hangs and is unable to spawn new workers. So the pods slowly bleed. Five workers becomes four, then three, then two.
Each one that dies is never replaced. And no alerts fire. There's no alarm, just a slow silent degradation until the pods can't handle any more traffic and every request starts failing. We found the root cause. A write wasn't atomic. Sig end could land between the data and the new line. The new line never arrives. The controller hangs forever. Let me show you the code.
Workers communicate with the controller through a notification pipe. It's how they signal readiness, health, and status. Let's look at the channel implementation. We create a pipe for communication. The child process inherits this pipe and the container controller reads from it. The receive method calls gets, which reads until it sees a new line. On the other side, the worker, it writes status messages to the pipe using puts and puts is not always one right. It can be two. The data then the new line as a separate system call. Between any two Ruby system calls a pending signal can fire. Sigint fires between the two rights. The JSON data arrives, the new line doesn't.
The controller process hangs waiting for the data that will never arrive.
Fix one, add a timeout. If a complete line hasn't arrived within a second, gets gives up and returns nil. The controller moves on. It can restart workers, it can do its job. Fix two, make the right atomic. Append the new line to the data string before writing. So, it goes out in a single system call. There is no gap for the Sigint to land in. Either the whole message arrives or nothing does. I shipped the fix and deployed it. Watched the pods. Workers that died were replaced. The silent death stopped.
>> All right. So, three crisis. We fixed the ship, but then on October 14th, I meet with the infra leads and we make the call to roll back all regions back to unicorn. As we fix Falcon, right? So, we BFCM at this point is only six weeks away and we set a deadline to fix Falcon by next Monday or else we'll have to stay on unicorn during BFCM. So, one week, two blockers left. Uh but we there's one we have a fix, but the other one we have no solutions yet. The first one is the workers are not restarting due to the silent death that's similar to what I just talked about. We do have the fix, but it's still unproven at the scale that we need to be for BFCM, right?
The second one is Kafka cardinality issues so we discovered what during one of the load test there were too many Kafka connection. Now, I'm going to hand it to Justin to dive into this one.
We had one week, one blocker, and with a with a fix that might work for one thing and nothing and one with nothing. >> [snorts] >> This is the story of how we found the nothing. Not the seg faults, we fixed those. This was a different problem, one that was more structural, and if we didn't solve, Falcon couldn't ship. Under Unicorn, each process has one Kafka connection. Only connects on the first message, one process per connection. >> [snorts] >> You have 20 workers per pod, you have 20 connections. In our experience with Unicorn, low PIDs tend to handle more traffic, meaning 20 workers, really only the first few handle the majority of the traffic, and staying very warm. We had depended on this Unicorn behavior for years and planned with that.
From our experience with Falcon, we more evenly distribute the traffic. This is good because it means there's more warm workers at any given time.
The catch is now, when we connect more quickly on all workers, we have more connections. We're running thousands of pods, each pod has hundreds of workers. Each worker has its own Kafka connection. The connection count explodes, and it grows linearly with every pod we add.
We ran the numbers with Kafka with the Kafka infrastructure team, and at BFCM scale, with the traffic we were expecting, we would overwhelm our brokers. They were to direct, "This wouldn't work. You can't ship Falcon like this." So, Ilya had suggested something simple. What if one process per pod talks to Kafka? All the other workers send their messages to that process, one process talks to Kafka, the broker only ever sees one connection per pod. So, Mark and I pair on prototyping. Mark gets it ready enough to talk about. It's rough, but it works. >> [snorts] >> I take the build into something that we can actually ship into production, proper error handling, retry logic, low test, etc.
We call it outbox. And we have 4 weeks to test, scale test, and roll it out everywhere before BFCM.
This is what it looks like. Each Falcon worker sends Kafka messages to a single outbox process in that same pod over [snorts] HTTP. Outbox buffers them, then forwards one batch connection to Kafka. From the book broker's perspective, it's one connection per pod, not hundreds. This dramatically reduces our load on Kafka. Every worker's messages flow through one process per pod instead of hundreds of connections hitting the brokers, they see almost nothing.
We tested on a small cluster first. The numbers are exactly what we expect. Here's a view of what that looked like. >> [snorts] >> You can see the connection count drop the moment outbox goes out. Before a wall of connections, after almost nothing. The go no go meeting arrives. We walk in with two things, Samuel's fix for the silent death, deployed and holding, and outbox running on a small cluster with numbers that we can actually show. We put them on the screen and walk through our changes. We show the numbers, fixes are holding, outbox works, we get the green light to go ahead. 4 weeks, that's what we have between the green light and BFCM.
We roll outbox out cluster by cluster, carefully watching the connection counts after each deploy. Every roll out confirms the same thing. It works, connection counts drop. The Kafka team signs off on each cluster as we roll. Mid sprint, we run scale test five and a Kafka regional failover at that full scale. Traffic more than doubles, outbox handled it. Message drop rate was basically zero. The Kafka team confirmed it works and the moment the last moment of doubt had gone away. By November 14th, outbox was live on every cluster in the in every region, 2 weeks before BFCM, the first time since October that we feel like we're actually going to make it.
The Kafka team sends us the real numbers. In one North American region, we get 1.5 times fewer connections, and another North American region get we get 1.9 times fewer connections. That's not just Outbox works, but it's Outbox making our whole fleet leaner and more efficient. Everything we built, everything we fixed, everything we shipped, it was all for this. Scale tests, three crises, a rollback, Outbox, four week sprint, and now we're here. It's BFCM. November 28th, 2025, it's Black Friday.
Traffic ramps up, the dashboards light up, and we watch.
85 million requests per minute at peak. The dashboards are lit up. We're watching every number. 100 and 20,000 long tasks per minute. Fibers are picking up work where other requests wait. Everything's working as designed. 110 million Kafka connections per minute. Every single one flowing through Outbox. Six weeks ago, this would have crushed our brokers. Today, brokers barely notice. All with fewer connections than Unicorn had ever used. Outbox was working exactly as designed. And response times were flat, which is exactly what we expected. We did see some P99 bumps on GraphQL when upstream services slowed down. That's expected. That's not us, that's our upstream. That's what long tasks were designed for.
Memory terminations were stable and consistent. Silent death bugs was fit bug was fixed. Workers die and are replaced. Life goes on. Saturday, Sunday, Cyber Monday, the graphs stay flat. On December 3rd, I post in our channel, "Congrats, folks, on making it through Black Friday and Cyber Monday on Falcon. We wouldn't have been able to do it with every without everyone here. Now pass to Mark to continue going through the numbers. >> So a couple more numbers. We've got 9.7 better throughput per core versus unicorn. Uh 14 more requests per minutes per core. 14% better P99 latency. That means the tails got shorter. Kafka connections reduced by 35% fleet wide. So what that means we're more efficient. And again, 329 billion
requests over the BFCM weekend. So we're on a server that we've never run at this scale before, right? So five lessons that we've learned from all this. The first one is uh native code that doesn't know about cooperative scheduling. So fibers you will catch you off guard. So you need to audit your dependencies before you go anywhere near production when uh fibers. The second one is scale tests can save you. They do. So we ran five of them and each one uncovered a different class of failure. Without them we'd have discovered like three big bugs on BFCM day. And if you have high stakes even coming uh like test early and make sure that each test it tests harder than the previous one so you uncover new types of bugs.
Uh the third one, third lesson is roll back without ego, right? We reverted to using unicorn to give us time to fix Falcon. Or else we'd have been spending our time putting out fires in production instead. Fourth lesson, pre-pressure creates invention, right? That's how we created the outbox. Uh it was created out of a deadline, a crisis. From prototype to production in four weeks. So sometimes the best solution they come from there's when there's no time for a perfect solution. So fifth one, what's contribute upstream? We currently contributed all the fixes that we've shown you today uh to back to the Ruby open source ecosystem. It got better because we pushed Falcon this hard and uh scale tested and put it to production.
So now everybody can use it. So what's next for us? We didn't stop We didn't stop after BFCM. There's a couple things that Falcon also unlocked for us. The first one is we've been stuck on rack two with unicorn. If you don't know unicorn only supports rack two, so we've been waiting for this to migrate to rack three. Another thing is that we have been running like different deployments depending on workloads and now with Falcon we can mix them all inside the same process. So, liquid template rendering, GraphQL, long IO operation. This gives us better utilization, lower cost, and it also simplifies our infrastructure. And now Falcon is prove it is proven at Shopify scale. So, that opens the door for about people more people inside Shopify, but also everyone in the Ruby community to use this server for a bigger scale of serving web applications.
If you want to go deeper on Falcon async outbox fiber scheduler, or anything else we talked about today, come talk to us, come find us. We're more than happy to talk about this. >> Um this whole talk, the live reloading and animation, the diagrams, it's all running on presently, uh which is built on top of async and lively. It's the same stack, uh different application. Um and so, if you'd like to go deeper on Falcon async or building real-time web applications with Ruby, please come to the async cafe workshop. It's on Saturday. You can scan the QR code or visit the Ruby Kaigi event page for more information. Looking forward to hanging out.
>> Thank you. >> [applause] >> Thank you. Want to thank you I think you're going to





