45% faster APIs on Bentley iTwin
Query tuning and Redis caching made the iTwin .NET Core APIs 45% faster, with test coverage above 90%.
- Role
- Software engineer on the iTwin services and web platform
- Core tools
- C# · .NET Core · SQL · Redis · Azure Functions · Cosmos DB · React · xUnit
Slow APIs → Tune the queries → Cache what repeats → Test everything → 45% faster
In this post
I started my career at Bentley Systems on iTwin, its digital-twin platform, first as an Associate Software Engineer and then, from May 2020, as Software Engineer I. Over about three and a half years I worked across its C# and .NET Core services and its React front end. The work I'm proudest of from that time made the platform's APIs 45% faster.
The problem
iTwin's C# and .NET Core services sat behind the platform's web modules, and their response times shaped how fast every screen felt. Too much of each request went into data access: queries doing more work than the screen needed, and the same data fetched again and again.
The task was to make the APIs fast without changing what they returned, and to keep them correct while doing it.
The approach: fix the data path first
Rather than tuning code at random, I went after the two places where time actually went. First the SQL: optimizing the queries so each request did only the work its answer needed. Then caching: putting Redis in front of data that was read far more often than it changed, so repeat requests stopped going to the database at all.
Engineering decisions
- Queries before caches. A cache in front of a slow query hides the problem and makes it harder to see later. Tuning the queries first meant the cache only had to carry the load that was truly repeated.
- Cache what is read often and changes rarely. Redis held the data that many requests shared, which is where caching pays off most.
- Tests as the safety net. Faster must not mean different. I championed testing with Jest, React Testing Library and xUnit, and took coverage above 90%, so every performance change ran against a suite that would catch a wrong answer.
- Cloud-native where it fits. Alongside the API work I built microservices on Azure Functions, Service Bus and Cosmos DB, and full-stack features connecting React modules to .NET Core services.
- Components built once. On the front end I built interactive React modules and a shared React/MUI library of accessible, reusable components used across the iTwin web platform.
The outcome
The iTwin .NET Core APIs became 45% faster, with test coverage above 90% guarding the change, and the shared component library gave teams across the web platform one accessible set of building blocks.
It set habits I still work by: measure where the time goes before changing anything, fix the data path before tuning code, and never ship a performance change without tests that would catch it being wrong.