Conf42 Rustlang 2025 - Online

- premiere 5PM GMT

Building Real-Time AI Fraud Prevention Systems for Gig Platforms in Rust

Video size:

Abstract

Rust shields billion-dollar gig platforms from fraud attacks processing thousands of AI decisions per minute. Discover battle-tested architectures where memory safety meets machine learning. Learn patterns that eliminate costly bugs in mission-critical systems.

Summary

Transcript

This transcript was autogenerated. To make changes, submit a PR.
Hello everyone. I am PR Singh, a senior software in Unit Meta. Today we are going to talk about something that's both a technical challenge and a real world business necessity building real time AI powered fraud prevention systems for gate platforms in Rust. And his exciting part, this is not just a theory. I will share some systems that are already in production, blocking millions in frauds every month, processing tens of thousands of transactions per hour, and doing it within millisecond decision times. So let's deep dive into it. So here is our roadmap for today. We'll start with fraud challenge in the gig economy. What makes it so much harder than fraud in traditional banking or e-commerce? Then we'll see why Rust, specifically rust is a perfect fit for solving it. I will walk you through a multi-layer architecture that's battle tested, we'll type div into real world results from food delivery and ride sharing platforms. And finally, I will share some emerging applications where Rust can push the fraud prevention even further. By the end, I hope you'll see why the next generation of fraud prevention could be written in rust. So let's look into what's the gig economy fraud challenge. Fraud prevention in gig platforms is a game of millisecond. Imagine you are ordering food on DoorDash or booking a ride on Uber. If our system takes even one 50 millisecond longer than expected to approve your transaction, you might abandon the order, or the driver assignment might time out. That's a revenue lost instantly. On top of that, Gigi is hyper distributed, meaning workers and customers are scattered across cities, countries, even continents. Meaning fraud patterns are geographically different and constantly evolving. Payments are instant. Once the money is sent to a driver or courier, it's gone. There is no hold period to investigate suspicious activity like in banking and the throughput requirements. We're talking about AI models analyzing thousands of transactions every minute without even choking. Where is the problem? The Python, Java, node js, they can work. These are popular framework, but under these constraints, they often force painful trade offs between a speed and accuracy. We need both, and that's where the rust changes the game. Let's look at the common fraud pat fraud patterns we have seen. So fraud frauds are very creative. And relentless. Let's look at a few common attack patterns that we have seen in gig platforms. So one commonly is known as account takeover, where attackers buy leaked credentials and brute force their way into legitimate systems or accounts. Synthetic identity is another type. Think of it as a Frank Tine accounts, it stitch together from real and fake details. Another one is work worker customer collusion. A driver and a customer work together to fake trips or deliveries, another one called GPSS spoofing or geo spoofing, where they fake their location to get better jobs or to trick the payout system. And finally, another type is payment method fraud, where stolen credit cards are used for instant payouts. And here is the scary part. Fraud tactics evolve weekly, sometimes daily. A fraud ring can exploit your platform, make hundreds of fraudulent transactions and vanish before your old detection rules even notice something is wrong. That's why our system have to be fast, adaptive, and accurate all at once. So why rust for fraud prevention? So there are three big regions for that first memory, safety without garbage collection. Fraud prevention systems are security critical. A buffer overflow, or use after free bug is not just a crash. It could be an exploit. Rust eliminates those classes of bug at compile time without runtime. GC pauses. Second c plus labor performance. As we know, c plus is very popular programming language. So Rust has geo cost abstraction. It has multiple L-L-M-V-M optimization. You can hit near c plus speed while writing safer and more expressive code. Third, fearless concurrency. The ownership and the borrowing model prevents data races by design. That means we can confidently run fraud checks on many concurrent transactions without corrupting the shared estate in sort the rust gives us a speed, safety and scalability. The trifecta for prevention. Let's look at the performance results. In production benchmarks from a major food delivery company, rust reached 93% of c plus raw performance. It was 6.2 times faster than Java and 2.4 times faster than Python with TensorFlow. What is the P 90 latency Under 35 millisecond consistently. And these are not just a synthetic test. Even CPU ation was dropped by 90% compared to Python. These are real world numbers from a live fraud perform fraud prevention pipeline. And why and when you multiply tho that efficiency across thousands of request per second, the cost savings are huge. Let's look at a multilayered rust architecture. So our rust based architecture uses five layers mainly. One real time stream processing where Tokyo ingest transaction streams and process them asynchronously cutting latency dramatically. Second rule-based detection. Simple if else rules and fr on pattern matching for known fraud signals are sufficient. Think if same card used in three countries in one hour. Flag it. Third statistical OMA detection time series models to spot unusual spikes or dips in user behavior. ML classification candle deep learning models used with code exhalation for GP inference, graph analysis pet graph algorithm to detect sources, clusters of users working together. Each layer acts as a safety net. Catching what others might miss. Let's look at Rust Power in innovations. Two things made a huge difference here. Async Stream processing with Tokyo, which lets us handle thousands of events per second with almost no idle time. And the second zero copy digitalization with ade, which passes J or proto above straight from bytes without extra memory allocations on their own. These are nice to haves, but in real time fraud pipeline, they are the difference between hitting your SLA or missing it by 30 millisecond and losing money. You can look at the some code snippet here that have attached in this slide. That you can use directly in your code to use these frameworks. Let's look at ML inference with candle. If you have used PyTorch candle will feel very familiar very familiar. It's a pure rushed ML framework. Supports ONNX, imports from PyTorch or TensorFlow, and runs on cuda and metal For GP insurance, the best part, no python in production. That means the whole fraud detection pipeline is memory safe from end to end. No language boundaries, no GIL. No extra process overhead. Isn't that amazing? Let's look into graph analysis with pet graph. So as we know, fraud does not always happen in isolation. It's often coordinated. Pet graph lets us map out. Transaction graphs and run algorithms to find what one connected components, two centrality scores. Three. Structural similarities over time, one real case. 32 drivers and 18 customers ran a fake order scam for weeks where a standard ML models missed it. The graph analysis from PET Graph caught it. Isn't that amazing? I have linked a code snippet here again for you, for your reference. Let's move on. Privacy preserving techniques. We can't fight fraud at the expense of privacy. In rust, we have implemented homomorphic encryption, computational encrypted data t learning, which is like training across devices without centralizing sensitive data. Differential privacy, which is adding control noise to protect identities. Secure incls, which is running code in hardware isolated environments. And thanks to Rust performance, these are not just slow, they're production ready. Let's look at the guide sharing case study here. A right sharing platform was losing around $3.2 million per month to Jupe spoofing or GPS spoofing and fake identities. We replaced their Python fraud stack with rusted microservices, for example, used Tokyo for Async, STTP, custom device fingerprinting and rust, WASM modules for distributed rules. And we used candle for ML inference. What's the result? 87% less fraud loss, 65% fewer false positives enforcements. And 99.98% uptime of services over 12 months. Isn't that unbelievable? Let's look next at emerging applications. So what's next? So these are the four use cases that we can use for us, and I think the way rust can shape the industry. So one is behavioral bi biometrics typing, swiping motion patterns as continuous authentication are possible. Now with rust explainable AI pipelines, which are under 12 to six to 12 months of pipeline. In the roadmap, you can have sap lime in rust for transparent fraud decision, advanced fully homomorphic encryption, also known as advanced FHE, which is like 12 to 24 months in the roadmap which for making a privacy preserving fraud detection practical. A NA native GPU acceleration, which is around two plus years in the roadmap where rust, GP, U, and candle can be used for even faster inference. So what are the key takeaways? There are three main key takeaways from this. So one, performance matters. So Rust gives us C plus label speed and developer productivity. Second, safety is non-negotiable. Memory, safety and race free concurrency reduces risks. And third, the ecosystem is ready. Tokyo Candle, pet Craft are production proven ready today. So thank you. Let's build a safer gig platforms together. Thank you for listening.
...

Prabhakar Singh

Software Engineer @ Meta

Prabhakar Singh's LinkedIn account



Join the community!

Learn for free, join the best tech learning community for a price of a pumpkin latte.

Annual
Monthly
Newsletter
$ 0 /mo

Event notifications, weekly newsletter

Delayed access to all content

Immediate access to Keynotes & Panels

Community
$ 8.34 /mo

Immediate access to all content

Courses, quizes & certificates

Community chats

Join the community (7 day free trial)