Introduction
In a digital world where milliseconds determine user experience and infrastructure costs determine a company’s profitability, efficiency must become more than a performance metric — it must become a survival strategy. TikTok is currently a leader in high-volume, high-performance computing among global platforms. TikTok serves billions of videos each day to hundreds of millions of users, leading to one of the highest computational loads of any system in the world. Every swipe generates network requests, data lookups, machine learning inferences, and a variety of multimedia processing — all of which need to happen in less than a second.
Over the years, TikTok was built on a heterogeneous stack involving Go, C++, and Python, prioritizing developer speed and scale. However, as TikTok started to grow globally, even the tiniest of microservices-level inefficiencies compounded to huge cost and performance overhead. TikTok's cloud bills grew to tens of millions of dollars per month, while its engineers were forced to deal with issues like latency spikes, memory spikes, and scalability issues.
TikTok, facing these challenges, overcame them and, as a bold and purposeful act, chose a systems programming language, Rust, that could produce speeds comparable to C++, but with memory safety, concurrency guarantees, and no runtime cost. This not only represented a technical change, it was a foundational change in financial architecture. Less than a year into migrating some of their critical services, TikTok was already experiencing infrastructure cost savings in excess of 35%, and huge strides in stability, reliability and throughput.
In this article we will discuss, with more detail, the engineering aspects of the TikTok backend, before and after migration to Rust and what engineering challenges were overcome, what cost savings were achieved, and the significance for the broader realm of software. We will also describe some other companies making similar moves, Discord, Dropbox, Cloudflare and Amazon, creating observations and predictions for building efficient systems, especially financial/payment systems.
1. The Pre-Rust Era — When Scale Became a Cost Problem
Prior to the migration to Rust, TikTok's server-side infrastructure was heavily reliant on Go, C++, and Python. Go was chosen because it is simple, has a concurrency model, and is a better fit for distributed Microservices; C++ was the best option for the most performance-heavy workloads such as video encoding and live-streaming delivery; and Python was chosen for machine learning and analytics pipelines.
Using multiple languages for the backend provides a great developer experience for rapid feature building, however it became unaffordable to run and maintain when scale became apparent with user growth. Go provides a developer-friendly experience, however as part of the language framework there is also a garbage collector (GC) for automated memory management. As load grows, the GC would occasionally pause activity to clear memory that had not been used; GC was contributing to overall latency and simply would not scale in real-time scenarios. Specifically, when considering the video serve and recommendation service within TikTok, there was no way to remove the GC stalls from the model; engineers within TikTok found themselves often over-provisioning compute instances as a plan to ease the heavier polycentric latencies that resulted, which led to higher cloud costs.
When it comes to performance, it was comparable to C++, though entailed a much greater responsibility for managing memory. C++ was prone to memory-related defects, buffer overflow, or race conditions that can all go undetected until a failure occurs and the consequences of that crash and/or some performance hit are felt. There is some blame to distribute along with failures occurring; the cost of iterations - also called cost of reliability - would increase with the costs of related investigation. To maintain C++ code in a Organization of TikTok's size, there would need to be an immense amount of job-specific talent which would further infer the human cost part of equation.
Even with python's flexibility and library access, single thread execution at scale due to GIL and use of heavier run-times are clear draw backs of python for all things real-time and high concurrency execution. If the overall capacity challenges of TikTok were solved, then we could quickly devolve to just using python to do some infrastructure build-out capability cheaper and faster, though unpredictably and unsustainable in almost all cases.
2. The Strategic Pivot — Why Rust Was the Perfect Fit
In 2021, TikTok's engineering leadership was in search of a long-term fix that could close the gap between performance and predictability. Rust stood out as the best choice. Originally created at Mozilla, Rust is meant to allow developers low-level control of memory and concurrency, all without sacrificing safety. Rust's ownership and borrowing model create strong compile-time rules that prevent data races and invalid memory access by code that uses shared data structures or multiple threads of execution.
The primary benefit of Rust is that it provides C++-level performance without garbage collection. Memory is managed deterministically based on scope-based ownership instead of collection at runtime. This ability permits engineers exact control over when and how resources are allocated or released, providing not just fast, but also consistent performance, a valuable quality when building systems with strict low-latency requirements, like TikTok's video feed delivery pipeline.
Additionally, Rust's async/await framework, which runs on the Tokio runtime, can maintain millions of concurrent lightweight tasks running efficiently in a single process. This came in handy for TikTok's systems that required the ability to manage millions of concurrent requests of operations -- everything from fetching content to recommending video clips -- all needing to respond quickly.
TikTok's engineers also liked the modern tooling Rust provides, like Cargo (for dependency management) and Clippy (for linting), to speed up their building process. Finally, Rust's expressiveness gave developers the ability to write low-level systems code that was both performant and maintainable, something neither Go nor C++ could quite get right at the same time.
3. Quantifying the Impact — How Rust Cut Costs at Scale
The results of TikTok's transition were impressive. Every time the engineering team had re-implemented a few high-traffic microservices in Rust, they were experiencing consistent double-digit improvements in memory efficiency, CPU utilization, and stability of the service and microservice.
Simply put, pre-transition in Go, an average microservice at TikTok was using around 2.5 GB of memory and was running an average of 70% CPU utilization. What they saw was that post-transition in Rust was effectively 1.6 GB per instance in memory and an average of 45% CPU load — a 36% improvement in memory and 35% in CPU utilization — allowing TikTok to effectively run the same workload with 35% fewer servers.
TikTok's cloud compute costs decreased from around $10 million each month to about $6.5 million each month in concrete storage terms, in other words, a savings of about $3.5 million each month, or just over $42 million per year. These estimates do not account for any indirect benefits resulting from reducing maintenance time or avoiding outages altogether, and a faster recoveries from outages resulting in improved operational return on investment (ROI).
Another area of clear improvement from adopting Rust was the reliability of the system. Before using Rust, services were typically in the middle on some kind of major incident every 25 days of using the service (major incidents included memory corruption or stalls as a result of (GC), garbage collection). After the transition to Rust, the MTBF or Mean Time Between Failures increased to about 60 days, which doubled the reliability of service. This resulted in improved uptime, and better experiences for users of a platform with billions of simple daily active users.
4. Evolution of TikTok’s Architecture with Rust
The transition to TikTok was incremental and guided by data, beginning with high-value components that were particularly sensitive to performance. The engineering team prioritized elements such as API gateways, rate limiters, recommendation engines, and real-time media delivery layers, all of which had ultra-low thresholds for latency and expected high degrees of concurrency.
Instead of rewriting the entire architecture from scratch, TikTok employed hybrid integration. Rust components were added in a Foreign Function Interface (FFI)-based way alongside existing services implemented in Go and Python. This enabled Rust modules to mitigate the most serious performance bottlenecks while the remaining architecture continued to run on Go and Python, which ensured compatibility and reduced risks associated with replacing components.
As confidence in Rust grew within TikTok over time (and in the spirit of continuous improvement and iteration), so too did its adoption into additional areas. Rust was then applied to internal frameworks for streaming pipelines, data serialization, and edge networking. Eventually, it became an important part of TikTok's core architecture, forming a foundational layer where predictability, safety, and speed were especially critical.
5. Comparing Rust Against Go, Java (Micronaut & Jakarta EE), C++, Python, and Node.js
TikTok's experience exemplifies a larger trend across the industry. Organizations are recognizing that efficiency in programming languages translates to efficiency in cost. While Go and Java remain popular programming languages for microservices, they rely heavily on garbage collection, making latencies and resource use unpredictable.
In Go, garbage collection pauses at high load can freeze processing threads for new, predictable latencies in services with time-sensitive transaction management such as payment gateways and recommendation engines. Meanwhile, Java has recently moved towards adoption of a new Java Virtual Machine (JVM) architecture that alleviates only some of its heavy memory usage and slow startup. Typical microservices running Java through the Micronaut or Jakarta EE frameworks can sustain loads, though with idle cold starts that push 300 - 800 MB of memory use. Cold start times run 1 - 5 seconds long for these services. In contrast, Rust cold starts under 100 milliseconds and 50 - 150 MB of memory usage, or an order of magnitude less utilization.
When apply benchmark testing of the performance, the disparity between Java and Rust becomes perceptible. To navigate the value metrics, a payment microservice running on Micronaut, backed by Java 21, sustained roughly 15,000 TPS sustained (.7 CPU utilization), costing around $15,000 per month justin infrastructure. Rewriting the same microservice in Rust and Actix-Web increased our throughput utilization from approx 15,000 TPS to > 40,000 TPS and dropped our monthly infrastructure costs from $15,000 to thru $9,000, a drop from high yield performance with correspoding cost savings of 40% and performance more than doubled at 2.6.
Compared to C++, Rust is equally performant and, at the same time, has deleted all the pitfalls of memory management. Indeed, it is not far-fetched to proclaim that compile-time safety checks obliterate memory leaks and race conditions, thus saving development time for debugging and increasing reliability manifold. Compared to Python or Node.js, the difference is still greater: Rust-based services can handle 5-10 times more concurrent connections while having a lesser memory footprint and zero garbage collection or runtime costs.
6. Industry-Wide Ripple Effect — Rust’s Cost Revolution
TikTok is not unique. A growing roster of worldwide technology leaders are moving, or have already moved, to Rust in order to capitalize on its performance, reliability, and cost advantages.
For instance, Discord transitioned the real-time voice and messaging backend of its application from Go to Rust. According to Discord, the service achieved nearly a tenfold increase in throughput and lowered the cost of infrastructure as a result of cutting CPU usage down 90 percent and improving the voice audio latency.
Dropbox recently integrated Rust for its file synchronization engine, creating safer operations across all parallel implementations and helping the energy consumption of its sprawling file storage services.
Cloudflare began rewriting some parts of its edge infrastructure, which are performance-critical, in Rust, allowing greater throughput and removing entire categories of security vulnerabilities from one taste of unsafe C.
Even AWS built Firecracker, the micro-virtualization technology that runs services like AWS Lambda and Fargate, in Rust. Firecracker's microVMs are written in Rust and allow AWS to run thousands of isolated workloads with minimal CPU and memory overhead — a key element of the cloud's cost-effectiveness.
In all of these examples there is a common idea, which is Rust's performance equates to real savings, operational and financial, because companies can accomplish more with fewer servers, have more reliability, and have more stronger security guarantees, which together translate into a better total cost of operation (TCO).
7. Designing Cost-Efficient Payment and Fintech Architectures with Rust
The principles of Rust carry over naturally to industries where precision, dependability, and cost controls are crucial to the success and viability of the industry—most notably in the financial technology (fintech) and payment systems industries. A typical payment architecture consists of a variety of components, including a gateway, processor, ledger service, fraud engine, and reconciliation modules. These components process thousands of transactions per second with at most a few milliseconds of latency and must achieve atomic level processor accuracy.
Rust's zero-cost abstractions make it ideal for a payment processing system. A payment processor written in Rust can handle massive concurrent loads without the overhead of a garbage collector, which slows performance and makes response times less predictable. While the processor continues operating with multiple concurrent transactions, Rust's type safety and error handling eliminates the possibility of corrupting the data being processed. Each component's ledger updates happen in a thread safe manner which eliminates private or shared race conditions.
These features make payment systems operate with less servers and more transactions in production — lower operational cost and reduced transaction latency. Additionally, Rust’s use of secure cryptographic libraries allows applications to be compliant with standards like PCI DSS in financial applications that require security practices.
As a result, a payment system is achieved that is faster, cheaper, and safer, which was previously thought not possible to have all in one stack.
8. Sustainability Through Efficiency — Rust’s Green Advantage
Rust not only impacts performance and cost but also has implications when considered for sustainability. Each CPU cycle takes energy, and any idle gigabyte of memory is consuming energy in your data center, less memory and cycles mean less energy usage in the data center. Having a smaller data center footprint with a Rust app means you are doing the same with fewer servers that would be running at lower utilization to run the app.
Depending on the scale of global usage of TikTok - and hence the thousands of servers running 24/7 - it becomes even more clear how to leverage fewer resources per server and therefore have less cooling needs, to save up that energy. There have been studies that average Rust systems, compared to Java or Go based services, consume something like 50-70% less energy doing the same motor tasks.
As sustainability becomes the primary metric for technology companies, then Rust is beginning to carve out a place for saving costs as well as being a computing option that would help climate change.
9. Lessons from TikTok’s Rust Adoption
The transition to Rust at TikTok was not a result of instantaneous change but an evolution, following a well-planned approach. The engineering team commenced with identifying the high-impact targets where the inefficiency was the strongest, and they started the implementation of Rust in an incremental fashion, beginning with small-scale microservices which they could define a benchmark against the production implementation.
They developed the process with a strong internal culture of measurement and validation - each line deployed into Rust was measured against an actual production traffic pattern, ensuring that any claim of improvement was measurable and verifiable. The developer education was equally important, encouraging engineers to deeply understand the ownership model and the concurrency semantics of Rust, prompting them to write idiomatic and maintainable code.
The hybrid model, where Rust services adjusted with Go, Python and other C++ components, verified safe, gradual adoption of Rust. Over time, as their confidence grew and results behind performance began to become undeniable, Rust became the default implementation and language of choice in TikTok systems architecture for all new systems requiring a performance-critical implementation.
10. The Future of Cost-Efficient Engineering
Rust signifies a shift in the lens of software engineering through a new understanding of scale and cost. For decades, developer productivity has been the focus of software engineering - abstract languages, faster iteration, frameworks that do more with less etc. However, with an escalation in the cost of the cloud, and a growing emphasis on sustainability, efficiency is emerging as scale's metric.
For example, Tik Tok has shown a paramount developer experience and efficiency can be achieved without too much difficulty. Rust gave engineers the ability to build efficient systems, not just from a speed perspective but also from a cost and environmental efficiency perspective. Rust has changed the economic model of the cloud computing service - more efficient code has saved million of dollars, year after year.
For new developers, Rust offers a unique opportunity. Learning Rust is about more than learning it's syntax, it teaches you about the properties of, why code is fast, performant, concurrent safe, and memory safe. As systems become increasingly concurrent; decentralized applications; and real-time compute become common place, Rust will prepare a generation of backend/systems engineers with the knowledge for the content requirements of future hardware compute principles.
Conclusion
TikTok's experience with Rust clearly shows proof of a well-executed focus on efficient engineering. When TikTok replaced their core software infrastructure with future-facing systems focused on improved efficiency, they achieved a remarkable balance of performance, savings, and reliability - including a nearly 30% cost savings in infrastructure, greater than double the stability, and even a foundation for future scalability.
But more importantly, TikTok's story is indicative of a broader industry trend, where the future of software is built efficiently; more engineering organizations recognize higher cloud costs and sustainability as priorities - and Rust is the sustainable option for achieving more out of less.
Rust has morphed from a systems language, into a financial, operational and environmental strategy. Companies adopting Rust today, are not only optimizing their code, they are investing in sustainable and efficient engineering for the world it's builds for.