Talk

Rewrite everything in Rust? What we learned from introducing Rust in Strawberry-GraphQL

Thursday, May 23

14:45 - 15:15
RoomSpaghetti
LanguageEnglish
Audience levelAdvanced
Elevator pitch

Discover how we turbocharged Strawberry’s Python-based GraphQL engine using Rust. Learn about performance improvements, our takeaways, and how to harness Rust’s power in your next Python project!

Abstract

Rewriting libraries in Rust is a hot topic in the Python community. But how do you maximize performance gains, and what’s the best way to shift parts of your Python codebase to Rust? We tackled these questions while working on Strawberry-GraphQL, one of the largest Python-based GraphQL frameworks, and performance is key for the large companies that rely on us.

We saw parsing and validation performance increase by up to seven times with our implementation. Plus, we’ve got more work planned to further enhance performance and share our tools with other language frameworks.

However, it wasn’t straightforward. One main challenge was integrating Rust with our existing code in the execution engine. Rust’s complexities initially made it seem unwise to move parts of our codebase into Rust, but we developed effective strategies for successful integration.

In our session, we’ll share what we learned. We found that frequently switching between Rust and Python was inefficient, and focusing on CPU-heavy tasks like parsing and validation was crucial to performance. Additionally, we’ll discuss how we used PyO3 wisely to bridge Python and Rust code for smooth interactions. We’ll also showcase code examples to explain how we integrated Rust into Strawberry and navigated the challenges. We’ll highlight our design decisions and how they impacted performance.

This session is great for you if you’re interested in gaining performance with Rust or exploring the internals of a GraphQL execution engine. Prior GraphQL knowledge isn’t necessary, but a basic understanding will help.

Join Erik to learn more about improving Python performance with Rust, and how you can implement Rust-based modules in your projects!

TagsGraphQL, Performance, Rust
Participant

Erik Wrede

Erik is a Software Engineer and GraphQL expert that enjoys building full-stack GraphQL solutions. As a member of the GraphQL-Python Maintainer Team and Core Dev at Strawberry-GraphQL, he’s passionate about improving the developer experience and creating exciting new GraphQL tooling. Erik is passionate about building performant and scalable solutions and is always eager to chat about new features, developments and the latest advancements in tech.